diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-01-04 14:12:24 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-01-04 14:12:24 +0800 |
| commit | a64d25c07b31d57f8706073e11cd774d0880d6dd (patch) | |
| tree | a4bbae6cff94fa69eea30db865267b211eb4c86b /include/fs/fat32.h | |
| parent | 210025560c80b48af4875af199f183ad709e3bf0 (diff) | |
| parent | d3cf3f08d1343d6b265516d5a79ce2d197b59d26 (diff) | |
| download | lume-a64d25c07b31d57f8706073e11cd774d0880d6dd.tar.gz lume-a64d25c07b31d57f8706073e11cd774d0880d6dd.tar.xz | |
Merge pull request #5 from Richard-Qin-001/dev/file-system
feat(file-system): implement read and write FAT32 File System and basic shell
Diffstat (limited to 'include/fs/fat32.h')
| -rw-r--r-- | include/fs/fat32.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/fs/fat32.h b/include/fs/fat32.h index c794bd7..1bd60ef 100644 --- a/include/fs/fat32.h +++ b/include/fs/fat32.h @@ -74,6 +74,8 @@ public: uint32 first_clus; // The starting cluster number of the file uint32 parent_clus; // Starting cluster number of the parent directory uint32 dir_offset; // The byte offset of this directory entry in the parent directory + uint32 ent_sec; // Sector number of the directory entry + uint32 ent_off; // Offset of the directory entry within the sector FAT32Inode() : fs(nullptr), first_clus(0) {} // Implement VFS Interface @@ -83,6 +85,7 @@ public: Inode *lookup(const char *name) override; Inode *create(const char *name, short type, short major, short minor) override; void truncate() override; + int unlink(const char *name) override; }; class FAT32FileSystem : public FileSystem @@ -93,17 +96,20 @@ public: uint32 root_cluster; uint32 sectors_per_cluster; uint32 bytes_per_cluster; + uint32 fat_sz; // Size of the FAT table (number of sectors) void init() override; Inode* root() override; // Helper functions - uint32 next_cluster(uint32 cluster); // Check the FAT table for the next cluster - uint32 alloc_cluster(); // Assign a new cluster + uint32 next_cluster(uint32 cluster); // Check the FAT table for the next cluster + uint32 alloc_cluster(); // Assign a new cluster uint32 cluster_to_sector(uint32 cluster); // directory entry parsing void read_dir_ent(struct FAT32_DirEnt *de, char *filename); + // Release the entire cluster chain starting from the cluster + void free_cluster_chain(uint32 cluster); }; extern FAT32FileSystem fat32_fs; |
