xref: /minix3/minix/usr.sbin/mkfs.mfs/v1/const.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #ifndef _MKFS_MFS_CONST_H__
2*433d6423SLionel Sambuc #define _MKFS_MFS_CONST_H__
3*433d6423SLionel Sambuc 
4*433d6423SLionel Sambuc /* Tables sizes */
5*433d6423SLionel Sambuc #define NR_DZONES       7	/* # direct zone numbers in a V1 inode */
6*433d6423SLionel Sambuc #define NR_TZONES       9	/* total # zone numbers in a V1 inode */
7*433d6423SLionel Sambuc 
8*433d6423SLionel Sambuc /* V1 file systems are special in that zone numbers are only 16-bit */
9*433d6423SLionel Sambuc #define zone_t		uint16_t
10*433d6423SLionel Sambuc 
11*433d6423SLionel Sambuc /* Blocks are of a fixed size */
12*433d6423SLionel Sambuc #define MFS_STATIC_BLOCK_SIZE	1024
13*433d6423SLionel Sambuc 
14*433d6423SLionel Sambuc #define SUPER_BLOCK_BYTES  MFS_STATIC_BLOCK_SIZE	/* 1 block */
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc /* The type of sizeof may be (unsigned) long.  Use the following macro for
17*433d6423SLionel Sambuc  * taking the sizes of small objects so that there are no surprises like
18*433d6423SLionel Sambuc  * (small) long constants being passed to routines expecting an int.
19*433d6423SLionel Sambuc  */
20*433d6423SLionel Sambuc #define usizeof(t) ((unsigned) sizeof(t))
21*433d6423SLionel Sambuc 
22*433d6423SLionel Sambuc /* File system types: magic number contained in super-block. */
23*433d6423SLionel Sambuc #define SUPER_V1	0x137F	/* magic # for V1 file systems */
24*433d6423SLionel Sambuc #define SUPER_MAGIC	SUPER_V1
25*433d6423SLionel Sambuc 
26*433d6423SLionel Sambuc /* Miscellaneous constants */
27*433d6423SLionel Sambuc #define SU_UID		((uid_t) 0)	/* super_user's uid_t */
28*433d6423SLionel Sambuc #define SECTOR_SIZE	512
29*433d6423SLionel Sambuc 
30*433d6423SLionel Sambuc #define BOOT_BLOCK	((block_t) 0)	/* block number of boot block */
31*433d6423SLionel Sambuc #define SUPER_BLOCK	((block_t) 1)	/* block number of super block */
32*433d6423SLionel Sambuc #define START_BLOCK	((block_t) 2)	/* first block of FS (not counting SB) */
33*433d6423SLionel Sambuc 
34*433d6423SLionel Sambuc #define ROOT_INODE	((ino_t) 1)	/* inode number for root directory */
35*433d6423SLionel Sambuc 
36*433d6423SLionel Sambuc /* Derived sizes pertaining to the file system. */
37*433d6423SLionel Sambuc #define FS_BITMAP_CHUNKS(b)	((b)/usizeof(bitchunk_t)) /*# map chunks/blk*/
38*433d6423SLionel Sambuc #define FS_BITCHUNK_BITS	(usizeof(bitchunk_t) * CHAR_BIT)
39*433d6423SLionel Sambuc #define FS_BITS_PER_BLOCK(b)	(FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
40*433d6423SLionel Sambuc 
41*433d6423SLionel Sambuc #define ZONE_NUM_SIZE		usizeof (zone_t)  /* # bytes in zone */
42*433d6423SLionel Sambuc #define INODE_SIZE		usizeof (struct inode)  /* bytes in dsk ino */
43*433d6423SLionel Sambuc #define INODES_PER_BLOCK(b)	((b)/INODE_SIZE)  /* # V2 dsk inodes/blk */
44*433d6423SLionel Sambuc #define INDIRECTS(b)		((b)/ZONE_NUM_SIZE)  /* # zones/indir block */
45*433d6423SLionel Sambuc 
46*433d6423SLionel Sambuc #define DIR_ENTRY_SIZE		usizeof(struct direct) /* # bytes/dir entry */
47*433d6423SLionel Sambuc #define NR_DIR_ENTRIES(b)	((b)/DIR_ENTRY_SIZE)  /* # dir entries/blk  */
48*433d6423SLionel Sambuc 
49*433d6423SLionel Sambuc #endif
50