#include #include #include #include #define DFS_MAGIC 0xDF1984CC #define DFS_BLOCK_SIZE 512 #define DFS_VERSION_0 "DuckFS, wheresDax?" #define DFS_VERSION_1 "DuckFS, Terminator" #define DFS_VERSION_2 "DuckFS-Terminator2" #define DFS_VERSION_3 "DuckFS,StarWarsEIV" #define DFS_VERSION_4 "DuckFS QUACK,QUACK" #define DFS_FILE_ERROR -8 #define DFS_FILE_UNUSED -1 #define DFS_FILE_USED 0 #define DFS_FILE_TEXT 0 #define DFS_FILE_BINARY 1 #define DFS_FILE_DIRECTORY 2 /* encryption algorithms */ #define DFS_CAESAR_5 88 #define DFS_CAESAR_8 84 #define DFS_CAESAR_2 09 #define DFS_QUACK_32 99 #define DFS_MAX_FILENAME_LEN 64 #define DFS_MAX_FILES 256 typedef struct duckfs_file_header { char filename[DFS_MAX_FILENAME_LEN + 1]; /* + 1 for the \0 */ char permissions[3]; /* Same thing here */ /* 512 Bytes per sector, meaning a 2 sector file is 1024 bytes, or 1 KiB. Only valid if this file is not a directory. */ int32_t num_sectors; int16_t type; /* Indicates the file type. -1 for null file, 0 for a text file, 1 for a binary file, and 2 for a directory. */ uint16_t _reserved0; /* (align to 4) */ struct duckfs_file_header* next; /* Next file in the directory this file is in. */ struct duckfs_file_header* contents; /* contains the first file in the directory. only valid if this file is a directory. */ struct duckfs_file_header* parent; /* The directory this file is in. */ uint64_t next_lba; /* The LBA of the next file's file header on the disk. */ uint64_t contents_lba; uint64_t parent_lba; uint64_t lba_start; /* only is valid if this file is not a directory. */ uint64_t lba_end; /* only is valid if this file is not a directory. */ uint8_t _reserved1[126]; /* padding to 256 bytes total */ } duckfs_file_header_t; typedef struct duckfs_superblock { int32_t duckfs_magic; /* must be DFS_MAGIC. */ char duckfs_version_string[19]; char volume_label[19]; /* 18 characters and a null zero. */ int16_t encryption; uint64_t duckfs_root; /* LBA of the root directory's file header */ uint32_t _padding[115]; /* padding to 512 bytes total */ } duckfs_superblock_t; static uint16_t duckfs_initialized = 0; static duckfs_file_header_t duckfs_root; const char* duckfs_versions[18] = { DFS_VERSION_0, DFS_VERSION_1, DFS_VERSION_2, DFS_VERSION_3, DFS_VERSION_4 }; void duckfs_init(void) { printf("\t%i\n", (sizeof(duckfs_file_header_t))); printf("\t\t%i\n", (sizeof(duckfs_superblock_t))); /* int32_t ide_read48(uint8_t drive, uint64_t lba, uint8_t sector_count, void* buffer) */ /* int32_t ide_write48(uint8_t drive, uint64_t lba, uint8_t sector_count, const void* buffer) */ /*uint8_t superblock_sector[512] = { 0 }; ide_read*/ }