root/fs.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 // On-disk file system format. 
   2 // Both the kernel and user programs use this header file.
   3 
   4 
   5 #define ROOTINO 1  // root i-number
   6 #define BSIZE 512  // block size
   7 
   8 // Disk layout:
   9 // [ boot block | super block | log | inode blocks | free bit map | data blocks ]
  10 //
  11 // mkfs computes the super block and builds an initial file system. The super describes
  12 // the disk layout:
  13 struct superblock {
  14   uint size;         // Size of file system image (blocks)
  15   uint nblocks;      // Number of data blocks
  16   uint ninodes;      // Number of inodes.
  17   uint nlog;         // Number of log blocks
  18   uint logstart;     // Block number of first log block
  19   uint inodestart;   // Block number of first inode block
  20   uint bmapstart;    // Block number of first free map block
  21 };
  22 
  23 #define NDIRECT 12
  24 #define NINDIRECT (BSIZE / sizeof(uint))
  25 #define MAXFILE (NDIRECT + NINDIRECT)
  26 
  27 // On-disk inode structure
  28 struct dinode {
  29   short type;           // File type
  30   short major;          // Major device number (T_DEV only)
  31   short minor;          // Minor device number (T_DEV only)
  32   short nlink;          // Number of links to inode in file system
  33   uint size;            // Size of file (bytes)
  34   uint addrs[NDIRECT+1];   // Data block addresses
  35 };
  36 
  37 // Inodes per block.
  38 #define IPB           (BSIZE / sizeof(struct dinode))
  39 
  40 // Block containing inode i
  41 #define IBLOCK(i, sb)     ((i) / IPB + sb.inodestart)
  42 
  43 // Bitmap bits per block
  44 #define BPB           (BSIZE*8)
  45 
  46 // Block of free map containing bit for block b
  47 #define BBLOCK(b, sb) (b/BPB + sb.bmapstart)
  48 
  49 // Directory is a file containing a sequence of dirent structures.
  50 #define DIRSIZ 14
  51 
  52 struct dirent {
  53   ushort inum;
  54   char name[DIRSIZ];
  55 };
  56 

/* [<][>][^][v][top][bottom][index][help] */