mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
Kernel/FATFS: Read the FAT32 FSInfo structure
This structure contains information about free clusters which is going to be useful when allocating clusters.
This commit is contained in:
@@ -239,6 +239,24 @@ ErrorOr<void> FATFS::initialize_while_locked()
|
||||
root_entry.attributes = FATAttributes::Directory;
|
||||
m_root_inode = TRY(FATInode::create(*this, root_entry, { 0, 1 }));
|
||||
|
||||
if (m_fat_version == FATVersion::FAT32) {
|
||||
auto fs_info_buffer = UserOrKernelBuffer::for_kernel_buffer(bit_cast<u8*>(&m_fs_info));
|
||||
// We know that there is a DOS7 BPB, because if it wasn't present
|
||||
// we would have returned EINVAL above.
|
||||
TRY(read_block(ebpb.dos7_bpb()->fs_info_sector, &fs_info_buffer, sizeof(m_fs_info)));
|
||||
|
||||
if (m_fs_info.lead_signature != fs_info_signature_1 || m_fs_info.struct_signature != fs_info_signature_2 || m_fs_info.trailing_signature != fs_info_signature_3) {
|
||||
dbgln("FATFS: Invalid FSInfo struct signature");
|
||||
dbgln_if(FAT_DEBUG, "FATFS: FSInfo signature1: {:#x}, expected: {:#x}", m_fs_info.lead_signature, fs_info_signature_1);
|
||||
dbgln_if(FAT_DEBUG, "FATFS: FSInfo signature2: {:#x}, expected: {:#x}", m_fs_info.struct_signature, fs_info_signature_2);
|
||||
dbgln_if(FAT_DEBUG, "FATFS: FSInfo signature3: {:#x}, expected: {:#x}", m_fs_info.trailing_signature, fs_info_signature_3);
|
||||
return Error::from_errno(EINVAL);
|
||||
}
|
||||
|
||||
dbgln_if(FAT_DEBUG, "FATFS: fs_info.last_known_free_cluster_count: {}", m_fs_info.last_known_free_cluster_count);
|
||||
dbgln_if(FAT_DEBUG, "FATFS: fs_info.next_free_cluster_hint: {}", m_fs_info.next_free_cluster_hint);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user