FileSystem/FATFS: Convert internal FAT inode attributes to dirent types

This commit is contained in:
Taj Morton 2023-07-08 23:00:54 -07:00 committed by Andrew Kaster
parent a961447dbd
commit 1d2f1abf97
Notes: sideshowbarker 2024-07-16 22:54:10 +09:00
2 changed files with 15 additions and 0 deletions

View File

@ -91,4 +91,18 @@ BlockBasedFileSystem::BlockIndex FATFS::first_block_of_cluster(u32 cluster) cons
return ((cluster - first_data_cluster) * boot_record()->sectors_per_cluster) + m_first_data_sector;
}
u8 FATFS::internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const
{
FATAttributes attrib = static_cast<FATAttributes>(entry.file_type);
if (has_flag(attrib, FATAttributes::Directory)) {
return DT_DIR;
} else if (has_flag(attrib, FATAttributes::VolumeID)) {
return DT_UNKNOWN;
} else {
// ReadOnly, Hidden, System, Archive, LongFileName.
return DT_REG;
}
return DT_UNKNOWN;
}
}

View File

@ -26,6 +26,7 @@ public:
virtual ~FATFS() override = default;
virtual StringView class_name() const override { return "FATFS"sv; }
virtual Inode& root_inode() override;
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
private:
virtual ErrorOr<void> initialize_while_locked() override;