00001 // On-disk file system format. 00002 // Both the kernel and user programs use this header file. 00003 00004 // Block 0 is unused. 00005 // Block 1 is super block. 00006 // Inodes start at block 2. 00007 00008 #define ROOTINO 1 // root i-number 00009 #define BSIZE 512 // block size 00010 00011 // File system super block 00012 struct superblock { 00013 uint size; // Size of file system image (blocks) 00014 uint nblocks; // Number of data blocks 00015 uint ninodes; // Number of inodes. 00016 }; 00017 00018 #define NDIRECT 12 00019 #define NINDIRECT (BSIZE / sizeof(uint)) 00020 #define MAXFILE (NDIRECT + NINDIRECT) 00021 00022 // On-disk inode structure 00023 struct dinode { 00024 short type; // File type 00025 short major; // Major device number (T_DEV only) 00026 short minor; // Minor device number (T_DEV only) 00027 short nlink; // Number of links to inode in file system 00028 uint size; // Size of file (bytes) 00029 uint addrs[NDIRECT+1]; // Data block addresses 00030 }; 00031 00032 // Inodes per block. 00033 #define IPB (BSIZE / sizeof(struct dinode)) 00034 00035 // Block containing inode i 00036 #define IBLOCK(i) ((i) / IPB + 2) 00037 00038 // Bitmap bits per block 00039 #define BPB (BSIZE*8) 00040 00041 // Block containing bit for block b 00042 #define BBLOCK(b, ninodes) (b/BPB + (ninodes)/IPB + 3) 00043 00044 // Directory is a file containing a sequence of dirent structures. 00045 #define DIRSIZ 14 00046 00047 struct dirent { 00048 ushort inum; 00049 char name[DIRSIZ]; 00050 }; 00051
1.5.6