#ifndef FILE_SYSTEM_H #define FILE_SYSTEM_H #include <hardDrive.h> #include <task.h> enum FileSystemEntryTypes { FS_FOLDER, FS_FILE }; typedef struct { uint8_t type; char *name; uint32_t cluster; } FileSystemTreeNode; typedef struct { FileSystemTreeNode; uint8_t subType; uint32_t size; } FileSystemFile; typedef struct { FileSystemTreeNode; ListElement *children; } FileSystemFolder; typedef struct { FileSystemFile *file; char *path, *absolutePath; Task *task; void *data; } File; extern File *readFile(char *path); typedef struct { uint8_t jmp[3]; char oemName[8]; uint16_t sectorSize; // this is on an odd offset, that's why the packed // attribute is needed here. uint8_t sectorsPerCluster; uint16_t reservedSectorCount; uint8_t FATCount; uint16_t rootEntryCount, totalSectorCount16Bit; uint8_t mediaType; uint16_t fatSize16Bit, sectorsPerTrack, numberOfHeads; uint32_t hiddenSectorCount, totalSectorCount32Bit; } __attribute__((packed)) FatBootSector; typedef struct { FatBootSector; // todo } __attribute__((packed)) Fat32BootSector; typedef struct { FatBootSector; uint8_t driveNumber, reserved, bootSignature; uint32_t serialNumber; char volumeLabel[11], fileSystemType[8]; } __attribute__((packed)) Fat16BootSector; typedef struct { FatBootSector *bootSector; uint8_t version; uint32_t fatSize, totalSectorCount, rootDirectorySize, firstDataSector, firstFatSector, firstRootSector, clusterSize; char *volumeID; HardDrive *hardDrive; void *fat; ListElement ***knownFolders; } FatInfo; typedef struct { char name[11]; uint8_t attributes, reserved, creationTimeTenthsOfSecond; uint16_t creationTime, creationDate, lastAccessDate; uint16_t fistDataClusterUpper, lastModifiedTime, lastModifiedDate, firstDataClusterLower; uint32_t size; } __attribute__((packed)) FatDirectoryEntry; typedef struct { uint8_t index; char name1[10]; uint8_t attributes, reserved, checksum; char name2[12]; uint16_t reserved_; char name3[4]; } __attribute__((packed)) LongNameEntry; enum FAT_ATTRIBUTES { FAT_ATTRIBUTE_READ_ONLY = 0x01, FAT_ATTRIBUTE_HIDDEN = 0x02, FAT_ATTRIBUTE_SYSTEM_FILE = 0x04, FAT_ATTRIBUTE_VOLUME_ID = 0x08, FAT_ATTRIBUTE_DIRECTORY = 0x10, FAT_ATTRIBUTE_ARCHIVE = 0x20, FAT_ATTRIBUTE_LONG_NAME = 0x0F, }; extern void mountDisk(HardDrive *drive); extern void printFileSystemTree(); #endif