1 // on-disk file system format 2 3 #define BSIZE 512 // block size 4 5 // sector 1 (2nd sector) 6 struct superblock{ 7 uint size; 8 uint nblocks; 9 uint ninodes; 10 }; 11 12 #define NDIRECT 13 13 14 struct dinode { 15 short type; 16 short major; 17 short minor; 18 short nlink; 19 uint size; 20 uint addrs[NDIRECT]; 21 }; 22 23 #define T_DIR 1 24 #define T_FILE 2 25 #define T_DEV 3 26 27 // sector 0 is unused, sector 1 is superblock, inodes start at sector 2 28 #define IPB (BSIZE / sizeof(struct dinode)) 29 #define IBLOCK(inum) (inum / IPB + 2) // start of inode 30 #define BPB (BSIZE*8) 31 #define BBLOCK(b,ninodes) (b/BPB + (ninodes/IPB) + 3) // start of bitmap 32 33 #define DIRSIZ 14 34 35 struct dirent { 36 ushort inum; 37 char name[DIRSIZ]; 38 }; 39 40 41