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