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

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