1 /*
2  *  linux/include/linux/ext3_fs.h
3  *
4  * Copyright (C) 1992, 1993, 1994, 1995
5  * Remy Card (card@masi.ibp.fr)
6  * Laboratoire MASI - Institut Blaise Pascal
7  * Universite Pierre et Marie Curie (Paris VI)
8  *
9  *  from
10  *
11  *  linux/include/linux/minix_fs.h
12  *
13  *  Copyright (C) 1991, 1992  Linus Torvalds
14  */
15 
16 #ifndef _LINUX_EXT3_FS_H
17 #define _LINUX_EXT3_FS_H
18 
19 #include <linux/types.h>
20 
21 /*
22  * The second extended filesystem constants/structures
23  */
24 
25 /*
26  * Define EXT3FS_DEBUG to produce debug messages
27  */
28 #undef EXT3FS_DEBUG
29 
30 /*
31  * Define EXT3_PREALLOCATE to preallocate data blocks for expanding files
32  */
33 #undef  EXT3_PREALLOCATE /* @@@ Fix this! */
34 #define EXT3_DEFAULT_PREALLOC_BLOCKS	8
35 
36 /*
37  * The second extended file system version
38  */
39 #define EXT3FS_DATE		"19 August 2002"
40 #define EXT3FS_VERSION		"2.4-0.9.19"
41 
42 /*
43  * Debug code
44  */
45 #ifdef EXT3FS_DEBUG
46 #define ext3_debug(f, a...)						\
47 	do {								\
48 		printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:",	\
49 			__FILE__, __LINE__, __FUNCTION__);		\
50 		printk (KERN_DEBUG f, ## a);				\
51 	} while (0)
52 #else
53 #define ext3_debug(f, a...)	do {} while (0)
54 #endif
55 
56 /*
57  * Special inodes numbers
58  */
59 #define	EXT3_BAD_INO		 1	/* Bad blocks inode */
60 #define EXT3_ROOT_INO		 2	/* Root inode */
61 #define EXT3_ACL_IDX_INO	 3	/* ACL inode */
62 #define EXT3_ACL_DATA_INO	 4	/* ACL inode */
63 #define EXT3_BOOT_LOADER_INO	 5	/* Boot loader inode */
64 #define EXT3_UNDEL_DIR_INO	 6	/* Undelete directory inode */
65 #define EXT3_RESIZE_INO		 7	/* Reserved group descriptors inode */
66 #define EXT3_JOURNAL_INO	 8	/* Journal inode */
67 
68 /* First non-reserved inode for old ext3 filesystems */
69 #define EXT3_GOOD_OLD_FIRST_INO	11
70 
71 /*
72  * The second extended file system magic number
73  */
74 #define EXT3_SUPER_MAGIC	0xEF53
75 
76 /*
77  * Maximal count of links to a file
78  */
79 #define EXT3_LINK_MAX		32000
80 
81 /*
82  * Macro-instructions used to manage several block sizes
83  */
84 #define EXT3_MIN_BLOCK_SIZE		1024
85 #define	EXT3_MAX_BLOCK_SIZE		4096
86 #define EXT3_MIN_BLOCK_LOG_SIZE		  10
87 #ifdef __KERNEL__
88 # define EXT3_BLOCK_SIZE(s)		((s)->s_blocksize)
89 #else
90 # define EXT3_BLOCK_SIZE(s)		(EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
91 #endif
92 #define EXT3_ACLE_PER_BLOCK(s)		(EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
93 #define	EXT3_ADDR_PER_BLOCK(s)		(EXT3_BLOCK_SIZE(s) / sizeof (__u32))
94 #ifdef __KERNEL__
95 # define EXT3_BLOCK_SIZE_BITS(s)	((s)->s_blocksize_bits)
96 #else
97 # define EXT3_BLOCK_SIZE_BITS(s)	((s)->s_log_block_size + 10)
98 #endif
99 #ifdef __KERNEL__
100 #define	EXT3_ADDR_PER_BLOCK_BITS(s)	((s)->u.ext3_sb.s_addr_per_block_bits)
101 #define EXT3_INODE_SIZE(s)		((s)->u.ext3_sb.s_inode_size)
102 #define EXT3_FIRST_INO(s)		((s)->u.ext3_sb.s_first_ino)
103 #else
104 #define EXT3_INODE_SIZE(s)	(((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
105 				 EXT3_GOOD_OLD_INODE_SIZE : \
106 				 (s)->s_inode_size)
107 #define EXT3_FIRST_INO(s)	(((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
108 				 EXT3_GOOD_OLD_FIRST_INO : \
109 				 (s)->s_first_ino)
110 #endif
111 
112 /*
113  * Macro-instructions used to manage fragments
114  */
115 #define EXT3_MIN_FRAG_SIZE		1024
116 #define	EXT3_MAX_FRAG_SIZE		4096
117 #define EXT3_MIN_FRAG_LOG_SIZE		  10
118 #ifdef __KERNEL__
119 # define EXT3_FRAG_SIZE(s)		((s)->u.ext3_sb.s_frag_size)
120 # define EXT3_FRAGS_PER_BLOCK(s)	((s)->u.ext3_sb.s_frags_per_block)
121 #else
122 # define EXT3_FRAG_SIZE(s)		(EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
123 # define EXT3_FRAGS_PER_BLOCK(s)	(EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
124 #endif
125 
126 /*
127  * ACL structures
128  */
129 struct ext3_acl_header	/* Header of Access Control Lists */
130 {
131 	__u32	aclh_size;
132 	__u32	aclh_file_count;
133 	__u32	aclh_acle_count;
134 	__u32	aclh_first_acle;
135 };
136 
137 struct ext3_acl_entry	/* Access Control List Entry */
138 {
139 	__u32	acle_size;
140 	__u16	acle_perms;	/* Access permissions */
141 	__u16	acle_type;	/* Type of entry */
142 	__u16	acle_tag;	/* User or group identity */
143 	__u16	acle_pad1;
144 	__u32	acle_next;	/* Pointer on next entry for the */
145 					/* same inode or on next free entry */
146 };
147 
148 /*
149  * Structure of a blocks group descriptor
150  */
151 struct ext3_group_desc
152 {
153 	__u32	bg_block_bitmap;		/* Blocks bitmap block */
154 	__u32	bg_inode_bitmap;		/* Inodes bitmap block */
155 	__u32	bg_inode_table;		/* Inodes table block */
156 	__u16	bg_free_blocks_count;	/* Free blocks count */
157 	__u16	bg_free_inodes_count;	/* Free inodes count */
158 	__u16	bg_used_dirs_count;	/* Directories count */
159 	__u16	bg_pad;
160 	__u32	bg_reserved[3];
161 };
162 
163 /*
164  * Macro-instructions used to manage group descriptors
165  */
166 #ifdef __KERNEL__
167 # define EXT3_BLOCKS_PER_GROUP(s)	((s)->u.ext3_sb.s_blocks_per_group)
168 # define EXT3_DESC_PER_BLOCK(s)		((s)->u.ext3_sb.s_desc_per_block)
169 # define EXT3_INODES_PER_GROUP(s)	((s)->u.ext3_sb.s_inodes_per_group)
170 # define EXT3_DESC_PER_BLOCK_BITS(s)	((s)->u.ext3_sb.s_desc_per_block_bits)
171 #else
172 # define EXT3_BLOCKS_PER_GROUP(s)	((s)->s_blocks_per_group)
173 # define EXT3_DESC_PER_BLOCK(s)		(EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
174 # define EXT3_INODES_PER_GROUP(s)	((s)->s_inodes_per_group)
175 #endif
176 
177 /*
178  * Constants relative to the data blocks
179  */
180 #define	EXT3_NDIR_BLOCKS		12
181 #define	EXT3_IND_BLOCK			EXT3_NDIR_BLOCKS
182 #define	EXT3_DIND_BLOCK			(EXT3_IND_BLOCK + 1)
183 #define	EXT3_TIND_BLOCK			(EXT3_DIND_BLOCK + 1)
184 #define	EXT3_N_BLOCKS			(EXT3_TIND_BLOCK + 1)
185 
186 /*
187  * Inode flags
188  */
189 #define	EXT3_SECRM_FL			0x00000001 /* Secure deletion */
190 #define	EXT3_UNRM_FL			0x00000002 /* Undelete */
191 #define	EXT3_COMPR_FL			0x00000004 /* Compress file */
192 #define EXT3_SYNC_FL			0x00000008 /* Synchronous updates */
193 #define EXT3_IMMUTABLE_FL		0x00000010 /* Immutable file */
194 #define EXT3_APPEND_FL			0x00000020 /* writes to file may only append */
195 #define EXT3_NODUMP_FL			0x00000040 /* do not dump file */
196 #define EXT3_NOATIME_FL			0x00000080 /* do not update atime */
197 /* Reserved for compression usage... */
198 #define EXT3_DIRTY_FL			0x00000100
199 #define EXT3_COMPRBLK_FL		0x00000200 /* One or more compressed clusters */
200 #define EXT3_NOCOMPR_FL			0x00000400 /* Don't compress */
201 #define EXT3_ECOMPR_FL			0x00000800 /* Compression error */
202 /* End compression flags --- maybe not all used */
203 #define EXT3_INDEX_FL			0x00001000 /* hash-indexed directory */
204 #define EXT3_IMAGIC_FL			0x00002000 /* AFS directory */
205 #define EXT3_JOURNAL_DATA_FL		0x00004000 /* file data should be journaled */
206 #define EXT3_RESERVED_FL		0x80000000 /* reserved for ext3 lib */
207 
208 #define EXT3_FL_USER_VISIBLE		0x00005FFF /* User visible flags */
209 #define EXT3_FL_USER_MODIFIABLE		0x000000FF /* User modifiable flags */
210 
211 /*
212  * Inode dynamic state flags
213  */
214 #define EXT3_STATE_JDATA		0x00000001 /* journaled data exists */
215 #define EXT3_STATE_NEW			0x00000002 /* inode is newly created */
216 
217 /*
218  * ioctl commands
219  */
220 #define	EXT3_IOC_GETFLAGS		_IOR('f', 1, long)
221 #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
222 #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
223 #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
224 #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
225 #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
226 #ifdef CONFIG_JBD_DEBUG
227 #define EXT3_IOC_WAIT_FOR_READONLY	_IOR('f', 99, long)
228 #endif
229 
230 /*
231  * Structure of an inode on the disk
232  */
233 struct ext3_inode {
234 	__u16	i_mode;		/* File mode */
235 	__u16	i_uid;		/* Low 16 bits of Owner Uid */
236 	__u32	i_size;		/* Size in bytes */
237 	__u32	i_atime;	/* Access time */
238 	__u32	i_ctime;	/* Creation time */
239 	__u32	i_mtime;	/* Modification time */
240 	__u32	i_dtime;	/* Deletion Time */
241 	__u16	i_gid;		/* Low 16 bits of Group Id */
242 	__u16	i_links_count;	/* Links count */
243 	__u32	i_blocks;	/* Blocks count */
244 	__u32	i_flags;	/* File flags */
245 	union {
246 		struct {
247 			__u32  l_i_reserved1;
248 		} linux1;
249 		struct {
250 			__u32  h_i_translator;
251 		} hurd1;
252 		struct {
253 			__u32  m_i_reserved1;
254 		} masix1;
255 	} osd1;				/* OS dependent 1 */
256 	__u32	i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
257 	__u32	i_generation;	/* File version (for NFS) */
258 	__u32	i_file_acl;	/* File ACL */
259 	__u32	i_dir_acl;	/* Directory ACL */
260 	__u32	i_faddr;	/* Fragment address */
261 	union {
262 		struct {
263 			__u8	l_i_frag;	/* Fragment number */
264 			__u8	l_i_fsize;	/* Fragment size */
265 			__u16	i_pad1;
266 			__u16	l_i_uid_high;	/* these 2 fields    */
267 			__u16	l_i_gid_high;	/* were reserved2[0] */
268 			__u32	l_i_reserved2;
269 		} linux2;
270 		struct {
271 			__u8	h_i_frag;	/* Fragment number */
272 			__u8	h_i_fsize;	/* Fragment size */
273 			__u16	h_i_mode_high;
274 			__u16	h_i_uid_high;
275 			__u16	h_i_gid_high;
276 			__u32	h_i_author;
277 		} hurd2;
278 		struct {
279 			__u8	m_i_frag;	/* Fragment number */
280 			__u8	m_i_fsize;	/* Fragment size */
281 			__u16	m_pad1;
282 			__u32	m_i_reserved2[2];
283 		} masix2;
284 	} osd2;				/* OS dependent 2 */
285 };
286 
287 #define i_size_high	i_dir_acl
288 
289 #if defined(__KERNEL__) || defined(__linux__)
290 #define i_reserved1	osd1.linux1.l_i_reserved1
291 #define i_frag		osd2.linux2.l_i_frag
292 #define i_fsize		osd2.linux2.l_i_fsize
293 #define i_uid_low	i_uid
294 #define i_gid_low	i_gid
295 #define i_uid_high	osd2.linux2.l_i_uid_high
296 #define i_gid_high	osd2.linux2.l_i_gid_high
297 #define i_reserved2	osd2.linux2.l_i_reserved2
298 
299 #elif defined(__GNU__)
300 
301 #define i_translator	osd1.hurd1.h_i_translator
302 #define i_frag		osd2.hurd2.h_i_frag;
303 #define i_fsize		osd2.hurd2.h_i_fsize;
304 #define i_uid_high	osd2.hurd2.h_i_uid_high
305 #define i_gid_high	osd2.hurd2.h_i_gid_high
306 #define i_author	osd2.hurd2.h_i_author
307 
308 #elif defined(__masix__)
309 
310 #define i_reserved1	osd1.masix1.m_i_reserved1
311 #define i_frag		osd2.masix2.m_i_frag
312 #define i_fsize		osd2.masix2.m_i_fsize
313 #define i_reserved2	osd2.masix2.m_i_reserved2
314 
315 #endif /* defined(__KERNEL__) || defined(__linux__) */
316 
317 /*
318  * File system states
319  */
320 #define	EXT3_VALID_FS			0x0001	/* Unmounted cleanly */
321 #define	EXT3_ERROR_FS			0x0002	/* Errors detected */
322 #define	EXT3_ORPHAN_FS			0x0004	/* Orphans being recovered */
323 
324 /*
325  * Mount flags
326  */
327 #define EXT3_MOUNT_CHECK		0x0001	/* Do mount-time checks */
328 #define EXT3_MOUNT_GRPID		0x0004	/* Create files with directory's group */
329 #define EXT3_MOUNT_DEBUG		0x0008	/* Some debugging messages */
330 #define EXT3_MOUNT_ERRORS_CONT		0x0010	/* Continue on errors */
331 #define EXT3_MOUNT_ERRORS_RO		0x0020	/* Remount fs ro on errors */
332 #define EXT3_MOUNT_ERRORS_PANIC		0x0040	/* Panic on errors */
333 #define EXT3_MOUNT_MINIX_DF		0x0080	/* Mimics the Minix statfs */
334 #define EXT3_MOUNT_NOLOAD		0x0100	/* Don't use existing journal*/
335 #define EXT3_MOUNT_ABORT		0x0200	/* Fatal error detected */
336 #define EXT3_MOUNT_DATA_FLAGS		0x0C00	/* Mode for data writes: */
337   #define EXT3_MOUNT_JOURNAL_DATA	0x0400	/* Write data to journal */
338   #define EXT3_MOUNT_ORDERED_DATA	0x0800	/* Flush data before commit */
339   #define EXT3_MOUNT_WRITEBACK_DATA	0x0C00	/* No data ordering */
340 #define EXT3_MOUNT_UPDATE_JOURNAL	0x1000	/* Update the journal format */
341 #define EXT3_MOUNT_NO_UID32		0x2000  /* Disable 32-bit UIDs */
342 
343 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
344 #ifndef _LINUX_EXT2_FS_H
345 #define clear_opt(o, opt)		o &= ~EXT3_MOUNT_##opt
346 #define set_opt(o, opt)			o |= EXT3_MOUNT_##opt
347 #define test_opt(sb, opt)		((sb)->u.ext3_sb.s_mount_opt & \
348 					 EXT3_MOUNT_##opt)
349 #else
350 #define EXT2_MOUNT_NOLOAD		EXT3_MOUNT_NOLOAD
351 #define EXT2_MOUNT_ABORT		EXT3_MOUNT_ABORT
352 #define EXT2_MOUNT_DATA_FLAGS		EXT3_MOUNT_DATA_FLAGS
353 #endif
354 
355 #define ext3_set_bit			ext2_set_bit
356 #define ext3_clear_bit			ext2_clear_bit
357 #define ext3_test_bit			ext2_test_bit
358 #define ext3_find_first_zero_bit	ext2_find_first_zero_bit
359 #define ext3_find_next_zero_bit		ext2_find_next_zero_bit
360 
361 /*
362  * Maximal mount counts between two filesystem checks
363  */
364 #define EXT3_DFL_MAX_MNT_COUNT		20	/* Allow 20 mounts */
365 #define EXT3_DFL_CHECKINTERVAL		0	/* Don't use interval check */
366 
367 /*
368  * Behaviour when detecting errors
369  */
370 #define EXT3_ERRORS_CONTINUE		1	/* Continue execution */
371 #define EXT3_ERRORS_RO			2	/* Remount fs read-only */
372 #define EXT3_ERRORS_PANIC		3	/* Panic */
373 #define EXT3_ERRORS_DEFAULT		EXT3_ERRORS_CONTINUE
374 
375 /*
376  * Structure of the super block
377  */
378 struct ext3_super_block {
379 /*00*/	__u32	s_inodes_count;		/* Inodes count */
380 	__u32	s_blocks_count;		/* Blocks count */
381 	__u32	s_r_blocks_count;	/* Reserved blocks count */
382 	__u32	s_free_blocks_count;	/* Free blocks count */
383 /*10*/	__u32	s_free_inodes_count;	/* Free inodes count */
384 	__u32	s_first_data_block;	/* First Data Block */
385 	__u32	s_log_block_size;	/* Block size */
386 	__s32	s_log_frag_size;	/* Fragment size */
387 /*20*/	__u32	s_blocks_per_group;	/* # Blocks per group */
388 	__u32	s_frags_per_group;	/* # Fragments per group */
389 	__u32	s_inodes_per_group;	/* # Inodes per group */
390 	__u32	s_mtime;		/* Mount time */
391 /*30*/	__u32	s_wtime;		/* Write time */
392 	__u16	s_mnt_count;		/* Mount count */
393 	__s16	s_max_mnt_count;	/* Maximal mount count */
394 	__u16	s_magic;		/* Magic signature */
395 	__u16	s_state;		/* File system state */
396 	__u16	s_errors;		/* Behaviour when detecting errors */
397 	__u16	s_minor_rev_level;	/* minor revision level */
398 /*40*/	__u32	s_lastcheck;		/* time of last check */
399 	__u32	s_checkinterval;	/* max. time between checks */
400 	__u32	s_creator_os;		/* OS */
401 	__u32	s_rev_level;		/* Revision level */
402 /*50*/	__u16	s_def_resuid;		/* Default uid for reserved blocks */
403 	__u16	s_def_resgid;		/* Default gid for reserved blocks */
404 	/*
405 	 * These fields are for EXT3_DYNAMIC_REV superblocks only.
406 	 *
407 	 * Note: the difference between the compatible feature set and
408 	 * the incompatible feature set is that if there is a bit set
409 	 * in the incompatible feature set that the kernel doesn't
410 	 * know about, it should refuse to mount the filesystem.
411 	 *
412 	 * e2fsck's requirements are more strict; if it doesn't know
413 	 * about a feature in either the compatible or incompatible
414 	 * feature set, it must abort and not try to meddle with
415 	 * things it doesn't understand...
416 	 */
417 	__u32	s_first_ino;		/* First non-reserved inode */
418 	__u16   s_inode_size;		/* size of inode structure */
419 	__u16	s_block_group_nr;	/* block group # of this superblock */
420 	__u32	s_feature_compat;	/* compatible feature set */
421 /*60*/	__u32	s_feature_incompat;	/* incompatible feature set */
422 	__u32	s_feature_ro_compat;	/* readonly-compatible feature set */
423 /*68*/	__u8	s_uuid[16];		/* 128-bit uuid for volume */
424 /*78*/	char	s_volume_name[16];	/* volume name */
425 /*88*/	char	s_last_mounted[64];	/* directory where last mounted */
426 /*C8*/	__u32	s_algorithm_usage_bitmap; /* For compression */
427 	/*
428 	 * Performance hints.  Directory preallocation should only
429 	 * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
430 	 */
431 	__u8	s_prealloc_blocks;	/* Nr of blocks to try to preallocate*/
432 	__u8	s_prealloc_dir_blocks;	/* Nr to preallocate for dirs */
433 	__u16	s_padding1;
434 	/*
435 	 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
436 	 */
437 /*D0*/	__u8	s_journal_uuid[16];	/* uuid of journal superblock */
438 /*E0*/	__u32	s_journal_inum;		/* inode number of journal file */
439 	__u32	s_journal_dev;		/* device number of journal file */
440 	__u32	s_last_orphan;		/* start of list of inodes to delete */
441 	__u32	s_hash_seed[4];		/* HTREE hash seed */
442 	__u8	s_def_hash_version;	/* Default hash version to use */
443 	__u8	s_reserved_char_pad;
444 	__u16	s_reserved_word_pad;
445 	__u32	s_default_mount_opts;
446 	__u32	s_first_meta_bg; 	/* First metablock block group */
447 	__u32	s_reserved[190];	/* Padding to the end of the block */
448 };
449 
450 #ifdef __KERNEL__
451 #define EXT3_SB(sb)	(&((sb)->u.ext3_sb))
452 #define EXT3_I(inode)	(&((inode)->u.ext3_i))
453 #else
454 /* Assume that user mode programs are passing in an ext3fs superblock, not
455  * a kernel struct super_block.  This will allow us to call the feature-test
456  * macros from user land. */
457 #define EXT3_SB(sb)	(sb)
458 #endif
459 
460 #define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime
461 
462 /*
463  * Codes for operating systems
464  */
465 #define EXT3_OS_LINUX		0
466 #define EXT3_OS_HURD		1
467 #define EXT3_OS_MASIX		2
468 #define EXT3_OS_FREEBSD		3
469 #define EXT3_OS_LITES		4
470 
471 /*
472  * Revision levels
473  */
474 #define EXT3_GOOD_OLD_REV	0	/* The good old (original) format */
475 #define EXT3_DYNAMIC_REV	1	/* V2 format w/ dynamic inode sizes */
476 
477 #define EXT3_CURRENT_REV	EXT3_GOOD_OLD_REV
478 #define EXT3_MAX_SUPP_REV	EXT3_DYNAMIC_REV
479 
480 #define EXT3_GOOD_OLD_INODE_SIZE 128
481 
482 /*
483  * Feature set definitions
484  */
485 
486 #define EXT3_HAS_COMPAT_FEATURE(sb,mask)			\
487 	( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
488 #define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask)			\
489 	( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
490 #define EXT3_HAS_INCOMPAT_FEATURE(sb,mask)			\
491 	( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
492 #define EXT3_SET_COMPAT_FEATURE(sb,mask)			\
493 	EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
494 #define EXT3_SET_RO_COMPAT_FEATURE(sb,mask)			\
495 	EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
496 #define EXT3_SET_INCOMPAT_FEATURE(sb,mask)			\
497 	EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
498 #define EXT3_CLEAR_COMPAT_FEATURE(sb,mask)			\
499 	EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
500 #define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask)			\
501 	EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
502 #define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask)			\
503 	EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
504 
505 #define EXT3_FEATURE_COMPAT_DIR_PREALLOC	0x0001
506 #define EXT3_FEATURE_COMPAT_IMAGIC_INODES	0x0002
507 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL		0x0004
508 #define EXT3_FEATURE_COMPAT_EXT_ATTR		0x0008
509 #define EXT3_FEATURE_COMPAT_RESIZE_INODE	0x0010
510 #define EXT3_FEATURE_COMPAT_DIR_INDEX		0x0020
511 
512 #define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
513 #define EXT3_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
514 #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
515 
516 #define EXT3_FEATURE_INCOMPAT_COMPRESSION	0x0001
517 #define EXT3_FEATURE_INCOMPAT_FILETYPE		0x0002
518 #define EXT3_FEATURE_INCOMPAT_RECOVER		0x0004 /* Needs recovery */
519 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008 /* Journal device */
520 #define EXT3_FEATURE_INCOMPAT_META_BG		0x0010
521 
522 #define EXT3_FEATURE_COMPAT_SUPP	0
523 #define EXT3_FEATURE_INCOMPAT_SUPP	(EXT3_FEATURE_INCOMPAT_FILETYPE| \
524 					 EXT3_FEATURE_INCOMPAT_RECOVER| \
525 					 EXT3_FEATURE_INCOMPAT_META_BG)
526 #define EXT3_FEATURE_RO_COMPAT_SUPP	(EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
527 					 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
528 					 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
529 
530 /*
531  * Default mount options
532  */
533 #define EXT3_DEFM_DEBUG		0x0001
534 #define EXT3_DEFM_BSDGROUPS	0x0002
535 #define EXT3_DEFM_XATTR_USER	0x0004
536 #define EXT3_DEFM_ACL		0x0008
537 #define EXT3_DEFM_UID16		0x0010
538 #define EXT3_DEFM_JMODE		0x0060
539 #define EXT3_DEFM_JMODE_DATA	0x0020
540 #define EXT3_DEFM_JMODE_ORDERED	0x0040
541 #define EXT3_DEFM_JMODE_WBACK	0x0060
542 
543 #define        EXT3_DEF_RESUID         0
544 #define        EXT3_DEF_RESGID         0
545 
546 /*
547  * Structure of a directory entry
548  */
549 #define EXT3_NAME_LEN 255
550 
551 struct ext3_dir_entry {
552 	__u32	inode;			/* Inode number */
553 	__u16	rec_len;		/* Directory entry length */
554 	__u16	name_len;		/* Name length */
555 	char	name[EXT3_NAME_LEN];	/* File name */
556 };
557 
558 /*
559  * The new version of the directory entry.  Since EXT3 structures are
560  * stored in intel byte order, and the name_len field could never be
561  * bigger than 255 chars, it's safe to reclaim the extra byte for the
562  * file_type field.
563  */
564 struct ext3_dir_entry_2 {
565 	__u32	inode;			/* Inode number */
566 	__u16	rec_len;		/* Directory entry length */
567 	__u8	name_len;		/* Name length */
568 	__u8	file_type;
569 	char	name[EXT3_NAME_LEN];	/* File name */
570 };
571 
572 /*
573  * Ext3 directory file types.  Only the low 3 bits are used.  The
574  * other bits are reserved for now.
575  */
576 #define EXT3_FT_UNKNOWN		0
577 #define EXT3_FT_REG_FILE	1
578 #define EXT3_FT_DIR		2
579 #define EXT3_FT_CHRDEV		3
580 #define EXT3_FT_BLKDEV		4
581 #define EXT3_FT_FIFO		5
582 #define EXT3_FT_SOCK		6
583 #define EXT3_FT_SYMLINK		7
584 
585 #define EXT3_FT_MAX		8
586 
587 /*
588  * EXT3_DIR_PAD defines the directory entries boundaries
589  *
590  * NOTE: It must be a multiple of 4
591  */
592 #define EXT3_DIR_PAD			4
593 #define EXT3_DIR_ROUND			(EXT3_DIR_PAD - 1)
594 #define EXT3_DIR_REC_LEN(name_len)	(((name_len) + 8 + EXT3_DIR_ROUND) & \
595 					 ~EXT3_DIR_ROUND)
596 
597 #ifdef __KERNEL__
598 /*
599  * Describe an inode's exact location on disk and in memory
600  */
601 struct ext3_iloc
602 {
603 	struct buffer_head *bh;
604 	struct ext3_inode *raw_inode;
605 	unsigned long block_group;
606 };
607 
608 /*
609  * Function prototypes
610  */
611 
612 /*
613  * Ok, these declarations are also in <linux/kernel.h> but none of the
614  * ext3 source programs needs to include it so they are duplicated here.
615  */
616 # define NORET_TYPE    /**/
617 # define ATTRIB_NORET  __attribute__((noreturn))
618 # define NORET_AND     noreturn,
619 
620 /* balloc.c */
621 extern int ext3_bg_has_super(struct super_block *sb, int group);
622 extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
623 extern int ext3_new_block (handle_t *, struct inode *, unsigned long,
624 					    __u32 *, __u32 *, int *);
625 extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
626 			      unsigned long);
627 extern unsigned long ext3_count_free_blocks (struct super_block *);
628 extern void ext3_check_blocks_bitmap (struct super_block *);
629 extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
630 						    unsigned int block_group,
631 						    struct buffer_head ** bh);
632 
633 /* dir.c */
634 extern int ext3_check_dir_entry(const char *, struct inode *,
635 				struct ext3_dir_entry_2 *, struct buffer_head *,
636 				unsigned long);
637 /* fsync.c */
638 extern int ext3_sync_file (struct file *, struct dentry *, int);
639 
640 /* ialloc.c */
641 extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int);
642 extern void ext3_free_inode (handle_t *, struct inode *);
643 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
644 extern unsigned long ext3_count_free_inodes (struct super_block *);
645 extern void ext3_check_inodes_bitmap (struct super_block *);
646 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
647 
648 /* inode.c */
649 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
650 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
651 
652 extern int  ext3_get_inode_loc (struct inode *, struct ext3_iloc *);
653 extern void ext3_read_inode (struct inode *);
654 extern void ext3_write_inode (struct inode *, int);
655 extern int  ext3_setattr (struct dentry *, struct iattr *);
656 extern void ext3_put_inode (struct inode *);
657 extern void ext3_delete_inode (struct inode *);
658 extern int  ext3_sync_inode (handle_t *, struct inode *);
659 extern void ext3_discard_prealloc (struct inode *);
660 extern void ext3_dirty_inode(struct inode *);
661 extern int ext3_change_inode_journal_flag(struct inode *, int);
662 extern void ext3_truncate (struct inode *);
663 extern void ext3_set_inode_flags(struct inode *);
664 
665 /* ioctl.c */
666 extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
667 		       unsigned long);
668 
669 /* namei.c */
670 extern int ext3_orphan_add(handle_t *, struct inode *);
671 extern int ext3_orphan_del(handle_t *, struct inode *);
672 
673 /* super.c */
674 extern void ext3_error (struct super_block *, const char *, const char *, ...)
675 	__attribute__ ((format (printf, 3, 4)));
676 extern void __ext3_std_error (struct super_block *, const char *, int);
677 extern void ext3_abort (struct super_block *, const char *, const char *, ...)
678 	__attribute__ ((format (printf, 3, 4)));
679 extern NORET_TYPE void ext3_panic (struct super_block *, const char *,
680 				   const char *, ...)
681 	__attribute__ ((NORET_AND format (printf, 3, 4)));
682 extern void ext3_warning (struct super_block *, const char *, const char *, ...)
683 	__attribute__ ((format (printf, 3, 4)));
684 extern void ext3_update_dynamic_rev (struct super_block *sb);
685 extern void ext3_put_super (struct super_block *);
686 extern void ext3_write_super (struct super_block *);
687 extern void ext3_write_super_lockfs (struct super_block *);
688 extern void ext3_unlockfs (struct super_block *);
689 extern int ext3_remount (struct super_block *, int *, char *);
690 extern struct super_block * ext3_read_super (struct super_block *,void *,int);
691 extern int ext3_statfs (struct super_block *, struct statfs *);
692 
693 #define ext3_std_error(sb, errno)				\
694 do {								\
695 	if ((errno))						\
696 		__ext3_std_error((sb), __FUNCTION__, (errno));	\
697 } while (0)
698 extern const char *ext3_decode_error(struct super_block *sb, int errno, char nbuf[16]);
699 
700 /*
701  * Inodes and files operations
702  */
703 
704 /* dir.c */
705 extern struct file_operations ext3_dir_operations;
706 
707 /* file.c */
708 extern struct inode_operations ext3_file_inode_operations;
709 extern struct file_operations ext3_file_operations;
710 
711 /* inode.c */
712 extern struct address_space_operations ext3_aops;
713 
714 /* namei.c */
715 extern struct inode_operations ext3_dir_inode_operations;
716 
717 /* symlink.c */
718 extern struct inode_operations ext3_fast_symlink_inode_operations;
719 
720 
721 #endif	/* __KERNEL__ */
722 
723 #endif	/* _LINUX_EXT3_FS_H */
724