# Amene File System Design Specification ## Underlying Constraints This will be used on ilo, a virtual computer with some limits: - 65,536 cells of memory - cells are 32-bit signed integer (int32_t) - cell addressing only - block storage i/o is done in blocks of 1,024 cells only ## Overview The Amene file system is a simple file system for use with the ilo computer. It derives loosely from Unix in structure, but is not intended to be compatible with existing file systems. Strings (e.g., file names) are length prefixed, with one character per 32-bit cell. ## Block Layout ### Block 0: Superblock The superblock holds the overall structure of the file system. ``` Offset | Size | Description -------|------|---------------------------------------------------------- 0 | 1 | Magic number (0x414D4E45 = "AMNE", dec. 1095585349) 1 | 1 | Version (1 = no indirect, 2 = indirect, 3 = dbl indirect) 2 | 1 | Total blocks in filesystem 3 | 1 | Free blocks count 4 | 1 | Root directory inode number (typically 1) 5 | 1 | First data block number 6 | 1 | Blocks per inode table entry 7 | 1 | Maximum filename length (14, excluding length prefix) 8-15 | 8 | Reserved for future use 16-1023| 1008 | Free block bitmap (32,256 blocks max) ``` ### Block 1+: Inode Table Each inode is 16 cells (64 bytes): ``` Offset | Size | Description -------|------|------------------------------------------ 0 | 1 | File type & permissions | Bits 0-15: permissions | Bits 16-31: type (0=free, 1=file, 2=dir) 1 | 1 | Link count 2 | 1 | File size in bytes 3 | 3 | Reserved 6-15 | 10 | Block pointers: | [6-13]: Direct blocks (8 blocks) | [14]: Indirect block [v2 format] | [15]: Double indirect block [v3 format] ``` **Inode calculations:** - 64 inodes per block (1024 * 16 = 64) - Max file size with direct blocks: 8 * 4KB = 32KB - With single indirect: 32KB + (1024 * 4KB) = ~4MB - With double indirect: ~4GB (more than filesystem can hold) ## Directory Structure Directory entries are 16 cells each: ``` Offset | Size | Description -------|------|----------------------------------------- 0 | 1 | Inode number (0 = unused entry) 1-15 | 15 | Filename (length prefixed, max 14 chars) ``` **Directory calculations:** - 64 directory entries per block - Root directory uses inode 1