1*433d6423SLionel Sambuc #ifndef _MKFS_MFS_SUPER_H__ 2*433d6423SLionel Sambuc #define _MKFS_MFS_SUPER_H__ 3*433d6423SLionel Sambuc 4*433d6423SLionel Sambuc /* Super block table. The entry holds information about the sizes of the bit 5*433d6423SLionel Sambuc * maps and inodes. The s_ninodes field gives the number of inodes available 6*433d6423SLionel Sambuc * for files and directories, including the root directory. Inode 0 is 7*433d6423SLionel Sambuc * on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be 8*433d6423SLionel Sambuc * used in the bit map, bit 0, which is always 1 and not used, and bits 1-4 9*433d6423SLionel Sambuc * for files and directories. The disk layout is: 10*433d6423SLionel Sambuc * 11*433d6423SLionel Sambuc * Item # blocks 12*433d6423SLionel Sambuc * boot block 1 13*433d6423SLionel Sambuc * super block 1 (offset 1kB) 14*433d6423SLionel Sambuc * inode map s_imap_blocks 15*433d6423SLionel Sambuc * zone map s_zmap_blocks 16*433d6423SLionel Sambuc * inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block' 17*433d6423SLionel Sambuc * unused whatever is needed to fill out the current zone 18*433d6423SLionel Sambuc * data zones (s_zones - s_firstdatazone) << s_log_zone_size 19*433d6423SLionel Sambuc */ 20*433d6423SLionel Sambuc 21*433d6423SLionel Sambuc struct super_block { 22*433d6423SLionel Sambuc uint32_t s_ninodes; /* # usable inodes on the minor device */ 23*433d6423SLionel Sambuc uint16_t s_nzones; /* total device size, including bit maps etc */ 24*433d6423SLionel Sambuc int16_t s_imap_blocks; /* # of blocks used by inode bit map */ 25*433d6423SLionel Sambuc int16_t s_zmap_blocks; /* # of blocks used by zone bit map */ 26*433d6423SLionel Sambuc uint16_t s_firstdatazone_old; /* number of first data zone (small) */ 27*433d6423SLionel Sambuc uint16_t s_log_zone_size; /* log2 of blocks/zone */ 28*433d6423SLionel Sambuc uint16_t s_flags; /* FS state flags */ 29*433d6423SLionel Sambuc int32_t s_max_size; /* maximum file size on this device */ 30*433d6423SLionel Sambuc uint32_t s_zones; /* number of zones (replaces s_nzones in V2) */ 31*433d6423SLionel Sambuc int16_t s_magic; /* magic number to recognize super-blocks */ 32*433d6423SLionel Sambuc 33*433d6423SLionel Sambuc /* The following items are valid on disk only for V3 and above */ 34*433d6423SLionel Sambuc 35*433d6423SLionel Sambuc int16_t s_pad2; /* try to avoid compiler-dependent padding */ 36*433d6423SLionel Sambuc /* The block size in bytes. Minimum MIN_BLOCK SIZE. SECTOR_SIZE multiple.*/ 37*433d6423SLionel Sambuc uint16_t s_block_size; /* block size in bytes. */ 38*433d6423SLionel Sambuc int8_t s_disk_version; /* filesystem format sub-version */ 39*433d6423SLionel Sambuc 40*433d6423SLionel Sambuc /* The following items are only used when the super_block is in memory. 41*433d6423SLionel Sambuc * If this ever changes, i.e. more fields after s_disk_version has to go to 42*433d6423SLionel Sambuc * disk, update LAST_ONDISK_FIELD in servers/mfs/super.c as that controls 43*433d6423SLionel Sambuc * which part of the struct is copied to and from disk. 44*433d6423SLionel Sambuc */ 45*433d6423SLionel Sambuc /* XXX padding inserted here... */ 46*433d6423SLionel Sambuc 47*433d6423SLionel Sambuc unsigned s_inodes_per_block; /* precalculated from magic number */ 48*433d6423SLionel Sambuc uint32_t s_firstdatazone; /* number of first data zone (big) */ 49*433d6423SLionel Sambuc } superblock; 50*433d6423SLionel Sambuc 51*433d6423SLionel Sambuc /* s_flags contents; undefined flags are guaranteed to be zero on disk 52*433d6423SLionel Sambuc * (not counting future versions of mfs setting them!) 53*433d6423SLionel Sambuc */ 54*433d6423SLionel Sambuc #define MFSFLAG_CLEAN (1L << 0) /* 0: dirty; 1: FS was unmounted cleanly */ 55*433d6423SLionel Sambuc 56*433d6423SLionel Sambuc /* Future compatability (or at least, graceful failure): 57*433d6423SLionel Sambuc * if any of these bits are on, and the MFS or fsck 58*433d6423SLionel Sambuc * implementation doesn't understand them, do not mount/fsck 59*433d6423SLionel Sambuc * the FS. 60*433d6423SLionel Sambuc */ 61*433d6423SLionel Sambuc #define MFSFLAG_MANDATORY_MASK 0xff00 62*433d6423SLionel Sambuc 63*433d6423SLionel Sambuc /* The block size should be registered on disk, even 64*433d6423SLionel Sambuc * multiple. If V1 or V2 filesystem, this should be 65*433d6423SLionel Sambuc * initialised to STATIC_BLOCK_SIZE. 66*433d6423SLionel Sambuc */ 67*433d6423SLionel Sambuc #define MFS_SUPER_BLOCK_SIZE s_block_size 68*433d6423SLionel Sambuc 69*433d6423SLionel Sambuc /* To keep the super block on disk clean, the MFS server only read/write up to 70*433d6423SLionel Sambuc * and including this field: 71*433d6423SLionel Sambuc */ 72*433d6423SLionel Sambuc #define LAST_ONDISK_FIELD s_disk_version 73*433d6423SLionel Sambuc 74*433d6423SLionel Sambuc #endif 75