I'm back to the OS dev direction again. I'm reworking my entire OS code, loader code and bootup code and ended up with loading files from a filesystem, where I decided to make a simple filesystem design that basically does the same thing as FAT - ie, simple file storage with no complicated structures - but seen from a 2014 perspective.
My current design:
Code: Select all
struct extent {
uint64_t startblock;
uint64_t length;
};
struct inode {
uint256_t filehash;
extent storage;
uint64_t filesize;
time_t creation;
time_t modification;
time_t access;
uint32_t flags;
uint32_t pad[12];
};
enum {
INO_SYSTEM =0x0001,
INO_MODIFIED = 0x0002,
INO_READONLY = 0x0004,
INO_HASHSTALE = 0x0008,
INO_EXTENT_INDIRECTION = 0x0030,
INO_DIRECTORY = 0x0040
};
struct direntry {
uint64_t inodeno;
uint32_t filenamelength;
char[] name; // null-terminated, length includes terminator
};
struct directory {
uint32_t formatid = 1;
uint32_t entrycount;
direntry first;
};
0. Boot block, 8 blocks (32KB) from the exact start (block 0).
1. Partition header (undefined currently), describing the partition where necessary. May be dropped if not useful. 4KB at block 8.
2. Inode table. Contains description for itself, so it is as long as it needs to be. Always contiguous though.
3. Root directory, lists file names.
4. Free block list, contains all extents that are not a part of an existing file.
5. Bad block list, contains all blocks that logically exist, but should not be used for another reason.
To read a file,
1. Read inode table first block.
2. Read root directory fully, find file you want.
3. Read inode for subdir, find file you want (repeat as necessary)
4. Read inode for file, read file.
To boot,
1. Load boot block fully from boot sector (if your platform requires)
2. Load files as desired, load any other things as desired.
Any ideas? Just wanted to reflect on this idea for a bit to see if it could be simplified or if there are major issues for writing.