stpdfs.inc | |
Stupid Filesystem | |
Constants and Enumerations | |
STPDFS_SB_MAGIC | Superblock magic number, MUST BE `0x44505453` (STPD) |
STPDFS_SB_REV | StupidFS revision, currently `0x1` |
STPDFS_BSIZE | StupidFS block size (512) |
STPDFS_BADINO | StupidFS bad inode |
STPDFS_ROOTINO | StupidFS root inode number |
STPDFS_NDIRECT | Number of direct block (7) |
STPDFS_INDIRECT_PER_BLOCK | |
STPDFS_NAME_MAX | Max file name length (28) |
StupidFS State | |
StupidFS i-node flags | |
STPDFS_INODE_PER_BLOCK | I-node per block |
STPDFS_DIRENT_PER_BLOCK | Directory entry per block |
Structs | |
StpdFS_FreeList | |
StpdFS_Sb | |
StpdFS_Inode | StupidFS on disk i-node |
StpdFS_Dirent | StupidFS directory entry |
Implementation |
┌──────────┬───────────┬──────┬───┬──────┬────┬───┬────┐ │Boot block│Super block│Inodes│...│Inodes│Data│...│Data│ └──────────┴───────────┴──────┴───┴──────┴────┴───┴────┘
Constants and Enumerations | |
STPDFS_SB_MAGIC | Superblock magic number, MUST BE `0x44505453` (STPD) |
STPDFS_SB_REV | StupidFS revision, currently `0x1` |
STPDFS_BSIZE | StupidFS block size (512) |
STPDFS_BADINO | StupidFS bad inode |
STPDFS_ROOTINO | StupidFS root inode number |
STPDFS_NDIRECT | Number of direct block (7) |
STPDFS_INDIRECT_PER_BLOCK | |
STPDFS_NAME_MAX | Max file name length (28) |
StupidFS State | |
StupidFS i-node flags | |
STPDFS_INODE_PER_BLOCK | I-node per block |
STPDFS_DIRENT_PER_BLOCK | Directory entry per block |
Structs | |
StpdFS_FreeList | |
StpdFS_Sb | |
StpdFS_Inode | StupidFS on disk i-node |
StpdFS_Dirent | StupidFS directory entry |
STPDFS_INO_FLAG_ALOC | I-node is allocated |
STPDFS_INO_FLAG_LZP | I-node data is compressed using LZP algorithm (see lzp.asm) |
STPDFS_INO_FLAG_ENC | I-node data is encrypted with XChaCha12 (see xchacha.asm) |
.free | List of free block (0-99), index 0 point to next freelist |
.nfree | Index |
┌──────────┐ │ block 99 │ ├──────────┤ │ block 98 │ ├──────────┤ │ ... │ ├──────────┤ │ block 2 │ ├──────────┤ │ block 1 │ ├──────────┤ ┌──────────┐ │ block 0 ├───►│ block 99 │ └──────────┘ ├──────────┤ │ ... │ ├──────────┤ ┌──────────┐ │ block 0 ├───►│ block 99 │ └──────────┘ ├──────────┤ │ ... │ ├──────────┤ │ block 0 │ └──────────┘
.magic | See STPDFS_SB_MAGIC |
.isize | Size in block of the i-node list |
.fsize | Size in block of the entire volume |
.freelist | See StpdFS_FreeList |
.rev | See STPDFS_SB_REV |
.state | See StupidFS State |
.time | Last mod time (64bit UNIX timestamp) |
StupidFS on disk i-node
.mode | File mode |
.nlink | Links count |
.uid | Owner Uid |
.gid | Group Id |
.flags | File flags, see StupidFS i-node flags |
.size | Data size in byte |
.zone | See bellow |
.actime | Access time (64-bit UNIX timestamp) |
.modtime | Modification time (64-bit UNIX timestamp) |
Zone 0-6 are direct, zone 7 indirect, zone 8 double indirect, zone 9 triple indirect
┌────────┐ │ │ ┌───────►│Data │ │ │ │ ┌──────┐ Direct│ └────────┘ │zone 0├───────┘ ├──────┤ │... │ ├──────┤ ┌────────┐ ┌────────┐ │zone 6│ │ ├─────►│ │ ├──────┤ Indirect │ │ │ Data │ │zone 7├─────────►│ │ │ │ ├──────┤ └────────┘ └────────┘ │zone 8├───────┐ ├──────┤ │Double indirect┌────────┐ ┌────────┐ ┌────────┐ │zone 9│ └──────────────►│ ├───►│ ├───►│ │ └──┬───┘ │ │ │ │ │ Data │ │ │ │ │ │ │ │ │ └────────┘ └────────┘ └────────┘ │ Triple indirect ┌────────┐ └────────────────►│ │ ┌────────┐ ┌────────┐ ┌────────┐ │ ├───►│ │ │ │ │ │ │ │ │ ├─────►│ ├─────►│ Data │ └────────┘ │ │ │ │ │ │ └────────┘ └────────┘ └────────┘
StupidFS directory entry
.inode | address of i-node |
.name | null terminated file name (see STPDFS_NAME_MAX) |