1 // On-disk file system format.
2 // Both the kernel and user programs use this header file.
5 // Block 1 is super block.
6 // Inodes start at block 2.
8 #define ROOTINO 1 // root i-number
9 #define BSIZE 512 // block size
11 // File system super block
13 uint size
; // Size of file system image (blocks)
14 uint nblocks
; // Number of data blocks
15 uint ninodes
; // Number of inodes.
19 #define NINDIRECT (BSIZE / sizeof(uint))
20 #define MAXFILE (NDIRECT + NINDIRECT)
22 // On-disk inode structure
24 short type
; // File type
25 short major
; // Major device number (T_DEV only)
26 short minor
; // Minor device number (T_DEV only)
27 short nlink
; // Number of links to inode in file system
28 uint size
; // Size of file (bytes)
29 uint addrs
[NDIRECT
+1]; // Data block addresses
33 #define IPB (BSIZE / sizeof(struct dinode))
35 // Block containing inode i
36 #define IBLOCK(i) ((i) / IPB + 2)
38 // Bitmap bits per block
41 // Block containing bit for block b
42 #define BBLOCK(b, ninodes) (b/BPB + (ninodes)/IPB + 3)
44 // Directory is a file containing a sequence of dirent structures.