xref: /xv6-public/fs.h (revision ea2909b6)
111a9947fSrtm // on-disk file system format
211a9947fSrtm 
324111398Skaashoek #define BSIZE 512  // block size
424111398Skaashoek 
524111398Skaashoek // sector 1 (2nd sector)
611a9947fSrtm struct superblock{
724111398Skaashoek   uint size;
824111398Skaashoek   uint nblocks;
924111398Skaashoek   uint ninodes;
1011a9947fSrtm };
1111a9947fSrtm 
12*ea2909b6Skaashoek #define NADDRS NDIRECT+1
13*ea2909b6Skaashoek #define NDIRECT 12
14*ea2909b6Skaashoek #define INDIRECT 12
15*ea2909b6Skaashoek #define NINDIRECT (BSIZE / sizeof(uint))
16*ea2909b6Skaashoek #define MAXFILE (NDIRECT  + NINDIRECT)
1711a9947fSrtm 
1811a9947fSrtm struct dinode {
1911a9947fSrtm   short type;
20e8d11c2eSkaashoek   short major;
21e8d11c2eSkaashoek   short minor;
2211a9947fSrtm   short nlink;
2311a9947fSrtm   uint size;
24*ea2909b6Skaashoek   uint addrs[NADDRS];
2511a9947fSrtm };
26e8d11c2eSkaashoek 
2711a9947fSrtm #define T_DIR 1
2811a9947fSrtm #define T_FILE 2
29e8d11c2eSkaashoek #define T_DEV 3
3011a9947fSrtm 
3124111398Skaashoek // sector 0 is unused, sector 1 is superblock, inodes start at sector 2
3224111398Skaashoek #define IPB (BSIZE / sizeof(struct dinode))
3324111398Skaashoek #define IBLOCK(inum) (inum / IPB + 2)   // start of inode
3424111398Skaashoek #define BPB (BSIZE*8)
3524111398Skaashoek #define BBLOCK(b,ninodes) (b/BPB + (ninodes/IPB) + 3)  // start of bitmap
3611a9947fSrtm 
379d3fb671Srtm #define DIRSIZ 14
389d3fb671Srtm 
3911a9947fSrtm struct dirent {
4011a9947fSrtm   ushort inum;
419d3fb671Srtm   char name[DIRSIZ];
4211a9947fSrtm };
43e958c538Skaashoek 
44e958c538Skaashoek 
45