6 #define NR_INODES 512 /* # slots in "in core" inode table;
7 * should be more or less the same as
10 #define GETDENTS_BUFSIZ 257
12 #define INODE_HASH_LOG2 7 /* 2 based logarithm of the inode hash size */
13 #define INODE_HASH_SIZE ((unsigned long)1<<INODE_HASH_LOG2)
14 #define INODE_HASH_MASK (((unsigned long)1<<INODE_HASH_LOG2)-1)
17 /* The type of sizeof may be (unsigned) long. Use the following macro for
18 * taking the sizes of small objects so that there are no surprises like
19 * (small) long constants being passed to routines expecting an int.
21 #define usizeof(t) ((unsigned) sizeof(t))
23 #define SUPER_MAGIC 0xEF53 /* magic number contained in super-block */
25 #define EXT2_NAME_MAX 255
27 /* Miscellaneous constants */
28 #define SU_UID ((uid_t) 0) /* super_user's uid_t */
29 #define NORMAL 0 /* forces get_block to do disk read */
30 #define NO_READ 1 /* prevents get_block from doing disk read */
31 #define PREFETCH 2 /* tells get_block not to read or mark dev */
33 #define NO_BIT ((bit_t) 0) /* returned by alloc_bit() to signal failure */
35 #define LOOK_UP 0 /* tells search_dir to lookup string */
36 #define ENTER 1 /* tells search_dir to make dir entry */
37 #define DELETE 2 /* tells search_dir to delete entry */
38 #define IS_EMPTY 3 /* tells search_dir to ret. OK or ENOTEMPTY */
40 /* write_map() args */
41 #define WMAP_FREE (1 << 0)
46 #define IN_CLEAN 0 /* inode disk and memory copies identical */
47 #define IN_DIRTY 1 /* inode disk and memory copies differ */
48 #define ATIME 002 /* set if atime field needs updating */
49 #define CTIME 004 /* set if ctime field needs updating */
50 #define MTIME 010 /* set if mtime field needs updating */
52 #define BYTE_SWAP 0 /* tells conv2/conv4 to swap bytes */
54 #define END_OF_FILE (-104) /* eof detected */
56 #define SUPER_BLOCK_BYTES (1024) /* bytes offset */
58 #define ROOT_INODE ((ino_t) 2) /* inode number for root directory */
59 #define BOOT_BLOCK ((block_t) 0) /* block number of boot block */
60 #define START_BLOCK ((block_t) 2) /* first block of FS (not counting SB) */
61 #define BLOCK_ADDRESS_BYTES 4 /* bytes per address */
63 #define SUPER_SIZE usizeof (struct super_block) /* sb size in RAM */
64 #define SUPER_SIZE_D (1024) /* max size of superblock stored on disk */
66 /* Directories related macroses */
68 #define DIR_ENTRY_ALIGN 4
70 /* ino + rec_len + name_len + file_type, doesn't include name and padding */
71 #define MIN_DIR_ENTRY_SIZE 8
73 #define DIR_ENTRY_CONTENTS_SIZE(d) (MIN_DIR_ENTRY_SIZE + (d)->d_name_len)
75 /* size with padding */
76 #define DIR_ENTRY_ACTUAL_SIZE(d) (DIR_ENTRY_CONTENTS_SIZE(d) + \
77 ((DIR_ENTRY_CONTENTS_SIZE(d) & 0x03) == 0 ? 0 : \
78 DIR_ENTRY_ALIGN - (DIR_ENTRY_CONTENTS_SIZE(d) & 0x03) ))
80 /* How many bytes can be taken from the end of dentry */
81 #define DIR_ENTRY_SHRINK(d) (conv2(le_CPU, (d)->d_rec_len) \
82 - DIR_ENTRY_ACTUAL_SIZE(d))
84 /* Dentry can have padding, which can be used to enlarge namelen */
85 #define DIR_ENTRY_MAX_NAME_LEN(d) (conv2(le_CPU, (d)->d_rec_len) \
88 /* Constants relative to the data blocks */
89 /* When change EXT2_NDIR_BLOCKS, modify ext2_max_size()!!!*/
90 #define EXT2_NDIR_BLOCKS 12
91 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
92 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
93 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
94 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
96 #define FS_BITMAP_CHUNKS(b) ((b)/usizeof (bitchunk_t))/* # map chunks/blk */
97 #define FS_BITCHUNK_BITS (usizeof(bitchunk_t) * CHAR_BIT)
98 #define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
102 /* Next 4 following macroses were taken from linux' ext2_fs.h */
103 #define EXT2_GOOD_OLD_INODE_SIZE 128
104 #define EXT2_GOOD_OLD_FIRST_INO 11
106 #define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
107 EXT2_GOOD_OLD_INODE_SIZE : \
109 #define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
110 EXT2_GOOD_OLD_FIRST_INO : \
113 /* Maximum size of a fast symlink including trailing '\0' */
114 #define MAX_FAST_SYMLINK_LENGTH \
115 ( sizeof(((d_inode *)0)->i_block[0]) * EXT2_N_BLOCKS )
117 #define NUL(str,l,m) mfs_nul_f(__FILE__,__LINE__,(str), (l), (m))
120 #define EXT2_VALID_FS 0x0001 /* Cleanly unmounted */
121 #define EXT2_ERROR_FS 0x0002 /* Errors detected */
123 #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
124 #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
126 /* ext2 features, names shorted (cut EXT2_ prefix) */
127 #define COMPAT_DIR_PREALLOC 0x0001
128 #define COMPAT_IMAGIC_INODES 0x0002
129 #define COMPAT_HAS_JOURNAL 0x0004
130 #define COMPAT_EXT_ATTR 0x0008
131 #define COMPAT_RESIZE_INO 0x0010
132 #define COMPAT_DIR_INDEX 0x0020
133 #define COMPAT_ANY 0xffffffff
135 #define RO_COMPAT_SPARSE_SUPER 0x0001
136 #define RO_COMPAT_LARGE_FILE 0x0002
137 #define RO_COMPAT_BTREE_DIR 0x0004
138 #define RO_COMPAT_ANY 0xffffffff
140 #define INCOMPAT_COMPRESSION 0x0001
141 #define INCOMPAT_FILETYPE 0x0002
142 #define INCOMPAT_RECOVER 0x0004
143 #define INCOMPAT_JOURNAL_DEV 0x0008
144 #define INCOMPAT_META_BG 0x0010
145 #define INCOMPAT_ANY 0xffffffff
147 /* What do we support? */
148 #define SUPPORTED_INCOMPAT_FEATURES (INCOMPAT_FILETYPE)
149 #define SUPPORTED_RO_COMPAT_FEATURES (RO_COMPAT_SPARSE_SUPER | \
150 RO_COMPAT_LARGE_FILE)
152 /* Ext2 directory file types. Only the low 3 bits are used.
153 * The other bits are reserved for now.
155 #define EXT2_FT_UNKNOWN 0
156 #define EXT2_FT_REG_FILE 1
157 #define EXT2_FT_DIR 2
158 #define EXT2_FT_CHRDEV 3
159 #define EXT2_FT_BLKDEV 4
160 #define EXT2_FT_FIFO 5
161 #define EXT2_FT_SOCK 6
162 #define EXT2_FT_SYMLINK 7
164 #define EXT2_FT_MAX 8
166 #define HAS_COMPAT_FEATURE(sp, mask) \
167 ( (sp)->s_feature_compat & (mask) )
168 #define HAS_RO_COMPAT_FEATURE(sp, mask) \
169 ( (sp)->s_feature_ro_compat & (mask) )
170 #define HAS_INCOMPAT_FEATURE(sp, mask) \
171 ( (sp)->s_feature_incompat & (mask) )
174 /* hash-indexed directory */
175 #define EXT2_INDEX_FL 0x00001000
176 /* Top of directory hierarchies*/
177 #define EXT2_TOPDIR_FL 0x00020000
179 #define EXT2_PREALLOC_BLOCKS 8
182 #endif /* EXT2_CONST_H */