super.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __MFS_SUPER_H__
  2. #define __MFS_SUPER_H__
  3. /* Super block table. The root file system and every mounted file system
  4. * has an entry here. The entry holds information about the sizes of the bit
  5. * maps and inodes. The s_ninodes field gives the number of inodes available
  6. * for files and directories, including the root directory. Inode 0 is
  7. * on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be
  8. * used in the bit map, bit 0, which is always 1 and not used, and bits 1-4
  9. * for files and directories. The disk layout is:
  10. *
  11. * Item # blocks
  12. * boot block 1
  13. * super block 1 (offset 1kB)
  14. * inode map s_imap_blocks
  15. * zone map s_zmap_blocks
  16. * inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block'
  17. * unused whatever is needed to fill out the current zone
  18. * data zones (s_zones - s_firstdatazone) << s_log_zone_size
  19. *
  20. * A super_block slot is free if s_dev == NO_DEV.
  21. */
  22. EXTERN struct super_block {
  23. u32_t s_ninodes; /* # usable inodes on the minor device */
  24. zone1_t s_nzones; /* total device size, including bit maps etc */
  25. short s_imap_blocks; /* # of blocks used by inode bit map */
  26. short s_zmap_blocks; /* # of blocks used by zone bit map */
  27. zone1_t s_firstdatazone_old; /* number of first data zone (small) */
  28. short s_log_zone_size; /* log2 of blocks/zone */
  29. unsigned short s_flags; /* FS state flags */
  30. i32_t s_max_size; /* maximum file size on this device */
  31. zone_t s_zones; /* number of zones (replaces s_nzones in V2) */
  32. short s_magic; /* magic number to recognize super-blocks */
  33. /* The following items are valid on disk only for V3 and above */
  34. short s_pad2; /* try to avoid compiler-dependent padding */
  35. unsigned short s_block_size; /* block size in bytes. */
  36. char s_disk_version; /* filesystem format sub-version */
  37. /* The following items are only used when the super_block is in memory.
  38. * If this ever changes, i.e. more fields after s_disk_version has to go to
  39. * disk, update LAST_ONDISK_FIELD in super.c as that controls which part of the
  40. * struct is copied to and from disk.
  41. */
  42. /*struct inode *s_isup;*/ /* inode for root dir of mounted file sys */
  43. /*struct inode *s_imount;*/ /* inode mounted on */
  44. unsigned s_inodes_per_block; /* precalculated from magic number */
  45. zone_t s_firstdatazone; /* number of first data zone (big) */
  46. dev_t s_dev; /* whose super block is this? */
  47. int s_rd_only; /* set to 1 iff file sys mounted read only */
  48. int s_native; /* set to 1 iff not byte swapped file system */
  49. int s_version; /* file system version, zero means bad magic */
  50. int s_ndzones; /* # direct zones in an inode */
  51. int s_nindirs; /* # indirect zones per indirect block */
  52. bit_t s_isearch; /* inodes below this bit number are in use */
  53. bit_t s_zsearch; /* all zones below this bit number are in use*/
  54. } superblock;
  55. #define IMAP 0 /* operating on the inode bit map */
  56. #define ZMAP 1 /* operating on the zone bit map */
  57. /* s_flags contents; undefined flags are guaranteed to be zero on disk
  58. * (not counting future versions of mfs setting them!)
  59. */
  60. #define MFSFLAG_CLEAN (1L << 0) /* 0: dirty; 1: FS was unmounted cleanly */
  61. /* Future compatability (or at least, graceful failure):
  62. * if any of these bits are on, and the MFS or fsck
  63. * implementation doesn't understand them, do not mount/fsck
  64. * the FS.
  65. */
  66. #define MFSFLAG_MANDATORY_MASK 0xff00
  67. #endif