1 /* 2 * linux/include/linux/ext3_fs.h 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card (at) 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 #include <linux/magic.h> 21 22 /* 23 * The second extended filesystem constants/structures 24 */ 25 26 /* 27 * Define EXT3FS_DEBUG to produce debug messages 28 */ 29 #undef EXT3FS_DEBUG 30 31 /* 32 * Define EXT3_RESERVATION to reserve data blocks for expanding files 33 */ 34 #define EXT3_DEFAULT_RESERVE_BLOCKS 8 35 /*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ 36 #define EXT3_MAX_RESERVE_BLOCKS 1027 37 #define EXT3_RESERVE_WINDOW_NOT_ALLOCATED 0 38 39 /* 40 * Debug code 41 */ 42 #ifdef EXT3FS_DEBUG 43 #define ext3_debug(f, a...) \ 44 do { \ 45 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \ 46 __FILE__, __LINE__, __FUNCTION__); \ 47 printk (KERN_DEBUG f, ## a); \ 48 } while (0) 49 #else 50 #define ext3_debug(f, a...) do {} while (0) 51 #endif 52 53 /* 54 * Special inodes numbers 55 */ 56 #define EXT3_BAD_INO 1 /* Bad blocks inode */ 57 #define EXT3_ROOT_INO 2 /* Root inode */ 58 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */ 59 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */ 60 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */ 61 #define EXT3_JOURNAL_INO 8 /* Journal inode */ 62 63 /* First non-reserved inode for old ext3 filesystems */ 64 #define EXT3_GOOD_OLD_FIRST_INO 11 65 66 /* 67 * Maximal count of links to a file 68 */ 69 #define EXT3_LINK_MAX 32000 70 71 /* 72 * Macro-instructions used to manage several block sizes 73 */ 74 #define EXT3_MIN_BLOCK_SIZE 1024 75 #define EXT3_MAX_BLOCK_SIZE 65536 76 #define EXT3_MIN_BLOCK_LOG_SIZE 10 77 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) 78 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) 79 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) 80 #define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ 81 EXT3_GOOD_OLD_INODE_SIZE : \ 82 (s)->s_inode_size) 83 #define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ 84 EXT3_GOOD_OLD_FIRST_INO : \ 85 (s)->s_first_ino) 86 87 /* 88 * Macro-instructions used to manage fragments 89 */ 90 #define EXT3_MIN_FRAG_SIZE 1024 91 #define EXT3_MAX_FRAG_SIZE 4096 92 #define EXT3_MIN_FRAG_LOG_SIZE 10 93 # define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size) 94 # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s)) 95 96 /* 97 * Structure of a blocks group descriptor 98 */ 99 struct ext3_group_desc 100 { 101 __le32 bg_block_bitmap; /* Blocks bitmap block */ 102 __le32 bg_inode_bitmap; /* Inodes bitmap block */ 103 __le32 bg_inode_table; /* Inodes table block */ 104 __le16 bg_free_blocks_count; /* Free blocks count */ 105 __le16 bg_free_inodes_count; /* Free inodes count */ 106 __le16 bg_used_dirs_count; /* Directories count */ 107 __u16 bg_pad; 108 __le32 bg_reserved[3]; 109 }; 110 111 /* 112 * Macro-instructions used to manage group descriptors 113 */ 114 # define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) 115 # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) 116 # define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) 117 118 /* 119 * Constants relative to the data blocks 120 */ 121 #define EXT3_NDIR_BLOCKS 12 122 #define EXT3_IND_BLOCK EXT3_NDIR_BLOCKS 123 #define EXT3_DIND_BLOCK (EXT3_IND_BLOCK + 1) 124 #define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1) 125 #define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1) 126 127 /* 128 * Inode flags 129 */ 130 #define EXT3_SECRM_FL 0x00000001 /* Secure deletion */ 131 #define EXT3_UNRM_FL 0x00000002 /* Undelete */ 132 #define EXT3_COMPR_FL 0x00000004 /* Compress file */ 133 #define EXT3_SYNC_FL 0x00000008 /* Synchronous updates */ 134 #define EXT3_IMMUTABLE_FL 0x00000010 /* Immutable file */ 135 #define EXT3_APPEND_FL 0x00000020 /* writes to file may only append */ 136 #define EXT3_NODUMP_FL 0x00000040 /* do not dump file */ 137 #define EXT3_NOATIME_FL 0x00000080 /* do not update atime */ 138 /* Reserved for compression usage... */ 139 #define EXT3_DIRTY_FL 0x00000100 140 #define EXT3_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ 141 #define EXT3_NOCOMPR_FL 0x00000400 /* Don't compress */ 142 #define EXT3_ECOMPR_FL 0x00000800 /* Compression error */ 143 /* End compression flags --- maybe not all used */ 144 #define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */ 145 #define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */ 146 #define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ 147 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */ 148 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ 149 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ 150 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */ 151 152 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ 153 #define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */ 154 155 /* 156 * Inode dynamic state flags 157 */ 158 #define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */ 159 #define EXT3_STATE_NEW 0x00000002 /* inode is newly created */ 160 #define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */ 161 162 /* Used to pass group descriptor data when online resize is done */ 163 struct ext3_new_group_input { 164 __u32 group; /* Group number for this data */ 165 __u32 block_bitmap; /* Absolute block number of block bitmap */ 166 __u32 inode_bitmap; /* Absolute block number of inode bitmap */ 167 __u32 inode_table; /* Absolute block number of inode table start */ 168 __u32 blocks_count; /* Total number of blocks in this group */ 169 __u16 reserved_blocks; /* Number of reserved blocks in this group */ 170 __u16 unused; 171 }; 172 173 /* The struct ext3_new_group_input in kernel space, with free_blocks_count */ 174 struct ext3_new_group_data { 175 __u32 group; 176 __u32 block_bitmap; 177 __u32 inode_bitmap; 178 __u32 inode_table; 179 __u32 blocks_count; 180 __u16 reserved_blocks; 181 __u16 unused; 182 __u32 free_blocks_count; 183 }; 184 185 186 /* 187 * ioctl commands 188 */ 189 #define EXT3_IOC_GETFLAGS FS_IOC_GETFLAGS 190 #define EXT3_IOC_SETFLAGS FS_IOC_SETFLAGS 191 #define EXT3_IOC_GETVERSION _IOR('f', 3, long) 192 #define EXT3_IOC_SETVERSION _IOW('f', 4, long) 193 #define EXT3_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long) 194 #define EXT3_IOC_GROUP_ADD _IOW('f', 8,struct ext3_new_group_input) 195 #define EXT3_IOC_GETVERSION_OLD FS_IOC_GETVERSION 196 #define EXT3_IOC_SETVERSION_OLD FS_IOC_SETVERSION 197 #ifdef CONFIG_JBD_DEBUG 198 #define EXT3_IOC_WAIT_FOR_READONLY _IOR('f', 99, long) 199 #endif 200 #define EXT3_IOC_GETRSVSZ _IOR('f', 5, long) 201 #define EXT3_IOC_SETRSVSZ _IOW('f', 6, long) 202 203 /* 204 * ioctl commands in 32 bit emulation 205 */ 206 #define EXT3_IOC32_GETFLAGS FS_IOC32_GETFLAGS 207 #define EXT3_IOC32_SETFLAGS FS_IOC32_SETFLAGS 208 #define EXT3_IOC32_GETVERSION _IOR('f', 3, int) 209 #define EXT3_IOC32_SETVERSION _IOW('f', 4, int) 210 #define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int) 211 #define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int) 212 #define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int) 213 #ifdef CONFIG_JBD_DEBUG 214 #define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int) 215 #endif 216 #define EXT3_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION 217 #define EXT3_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION 218 219 220 /* 221 * Mount options 222 */ 223 struct ext3_mount_options { 224 unsigned long s_mount_opt; 225 uid_t s_resuid; 226 gid_t s_resgid; 227 unsigned long s_commit_interval; 228 #ifdef CONFIG_QUOTA 229 int s_jquota_fmt; 230 char *s_qf_names[MAXQUOTAS]; 231 #endif 232 }; 233 234 /* 235 * Structure of an inode on the disk 236 */ 237 struct ext3_inode { 238 __le16 i_mode; /* File mode */ 239 __le16 i_uid; /* Low 16 bits of Owner Uid */ 240 __le32 i_size; /* Size in bytes */ 241 __le32 i_atime; /* Access time */ 242 __le32 i_ctime; /* Creation time */ 243 __le32 i_mtime; /* Modification time */ 244 __le32 i_dtime; /* Deletion Time */ 245 __le16 i_gid; /* Low 16 bits of Group Id */ 246 __le16 i_links_count; /* Links count */ 247 __le32 i_blocks; /* Blocks count */ 248 __le32 i_flags; /* File flags */ 249 union { 250 struct { 251 __u32 l_i_reserved1; 252 } linux1; 253 struct { 254 __u32 h_i_translator; 255 } hurd1; 256 struct { 257 __u32 m_i_reserved1; 258 } masix1; 259 } osd1; /* OS dependent 1 */ 260 __le32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */ 261 __le32 i_generation; /* File version (for NFS) */ 262 __le32 i_file_acl; /* File ACL */ 263 __le32 i_dir_acl; /* Directory ACL */ 264 __le32 i_faddr; /* Fragment address */ 265 union { 266 struct { 267 __u8 l_i_frag; /* Fragment number */ 268 __u8 l_i_fsize; /* Fragment size */ 269 __u16 i_pad1; 270 __le16 l_i_uid_high; /* these 2 fields */ 271 __le16 l_i_gid_high; /* were reserved2[0] */ 272 __u32 l_i_reserved2; 273 } linux2; 274 struct { 275 __u8 h_i_frag; /* Fragment number */ 276 __u8 h_i_fsize; /* Fragment size */ 277 __u16 h_i_mode_high; 278 __u16 h_i_uid_high; 279 __u16 h_i_gid_high; 280 __u32 h_i_author; 281 } hurd2; 282 struct { 283 __u8 m_i_frag; /* Fragment number */ 284 __u8 m_i_fsize; /* Fragment size */ 285 __u16 m_pad1; 286 __u32 m_i_reserved2[2]; 287 } masix2; 288 } osd2; /* OS dependent 2 */ 289 __le16 i_extra_isize; 290 __le16 i_pad1; 291 }; 292 293 #define i_size_high i_dir_acl 294 295 #if defined(__KERNEL__) || defined(__linux__) 296 #define i_reserved1 osd1.linux1.l_i_reserved1 297 #define i_frag osd2.linux2.l_i_frag 298 #define i_fsize osd2.linux2.l_i_fsize 299 #define i_uid_low i_uid 300 #define i_gid_low i_gid 301 #define i_uid_high osd2.linux2.l_i_uid_high 302 #define i_gid_high osd2.linux2.l_i_gid_high 303 #define i_reserved2 osd2.linux2.l_i_reserved2 304 305 #elif defined(__GNU__) 306 307 #define i_translator osd1.hurd1.h_i_translator 308 #define i_frag osd2.hurd2.h_i_frag; 309 #define i_fsize osd2.hurd2.h_i_fsize; 310 #define i_uid_high osd2.hurd2.h_i_uid_high 311 #define i_gid_high osd2.hurd2.h_i_gid_high 312 #define i_author osd2.hurd2.h_i_author 313 314 #elif defined(__masix__) 315 316 #define i_reserved1 osd1.masix1.m_i_reserved1 317 #define i_frag osd2.masix2.m_i_frag 318 #define i_fsize osd2.masix2.m_i_fsize 319 #define i_reserved2 osd2.masix2.m_i_reserved2 320 321 #endif /* defined(__KERNEL__) || defined(__linux__) */ 322 323 /* 324 * File system states 325 */ 326 #define EXT3_VALID_FS 0x0001 /* Unmounted cleanly */ 327 #define EXT3_ERROR_FS 0x0002 /* Errors detected */ 328 #define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */ 329 330 /* 331 * Mount flags 332 */ 333 #define EXT3_MOUNT_CHECK 0x00001 /* Do mount-time checks */ 334 #define EXT3_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */ 335 #define EXT3_MOUNT_GRPID 0x00004 /* Create files with directory's group */ 336 #define EXT3_MOUNT_DEBUG 0x00008 /* Some debugging messages */ 337 #define EXT3_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */ 338 #define EXT3_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */ 339 #define EXT3_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */ 340 #define EXT3_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */ 341 #define EXT3_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/ 342 #define EXT3_MOUNT_ABORT 0x00200 /* Fatal error detected */ 343 #define EXT3_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */ 344 #define EXT3_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */ 345 #define EXT3_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */ 346 #define EXT3_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */ 347 #define EXT3_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */ 348 #define EXT3_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */ 349 #define EXT3_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */ 350 #define EXT3_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */ 351 #define EXT3_MOUNT_RESERVATION 0x10000 /* Preallocation */ 352 #define EXT3_MOUNT_BARRIER 0x20000 /* Use block barriers */ 353 #define EXT3_MOUNT_NOBH 0x40000 /* No bufferheads */ 354 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */ 355 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ 356 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ 357 358 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ 359 #ifndef _LINUX_EXT2_FS_H 360 #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt 361 #define set_opt(o, opt) o |= EXT3_MOUNT_##opt 362 #define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \ 363 EXT3_MOUNT_##opt) 364 #else 365 #define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD 366 #define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT 367 #define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS 368 #endif 369 370 #define ext3_set_bit ext2_set_bit 371 #define ext3_set_bit_atomic ext2_set_bit_atomic 372 #define ext3_clear_bit ext2_clear_bit 373 #define ext3_clear_bit_atomic ext2_clear_bit_atomic 374 #define ext3_test_bit ext2_test_bit 375 #define ext3_find_first_zero_bit ext2_find_first_zero_bit 376 #define ext3_find_next_zero_bit ext2_find_next_zero_bit 377 378 /* 379 * Maximal mount counts between two filesystem checks 380 */ 381 #define EXT3_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ 382 #define EXT3_DFL_CHECKINTERVAL 0 /* Don't use interval check */ 383 384 /* 385 * Behaviour when detecting errors 386 */ 387 #define EXT3_ERRORS_CONTINUE 1 /* Continue execution */ 388 #define EXT3_ERRORS_RO 2 /* Remount fs read-only */ 389 #define EXT3_ERRORS_PANIC 3 /* Panic */ 390 #define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE 391 392 /* 393 * Structure of the super block 394 */ 395 struct ext3_super_block { 396 /*00*/ __le32 s_inodes_count; /* Inodes count */ 397 __le32 s_blocks_count; /* Blocks count */ 398 __le32 s_r_blocks_count; /* Reserved blocks count */ 399 __le32 s_free_blocks_count; /* Free blocks count */ 400 /*10*/ __le32 s_free_inodes_count; /* Free inodes count */ 401 __le32 s_first_data_block; /* First Data Block */ 402 __le32 s_log_block_size; /* Block size */ 403 __le32 s_log_frag_size; /* Fragment size */ 404 /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */ 405 __le32 s_frags_per_group; /* # Fragments per group */ 406 __le32 s_inodes_per_group; /* # Inodes per group */ 407 __le32 s_mtime; /* Mount time */ 408 /*30*/ __le32 s_wtime; /* Write time */ 409 __le16 s_mnt_count; /* Mount count */ 410 __le16 s_max_mnt_count; /* Maximal mount count */ 411 __le16 s_magic; /* Magic signature */ 412 __le16 s_state; /* File system state */ 413 __le16 s_errors; /* Behaviour when detecting errors */ 414 __le16 s_minor_rev_level; /* minor revision level */ 415 /*40*/ __le32 s_lastcheck; /* time of last check */ 416 __le32 s_checkinterval; /* max. time between checks */ 417 __le32 s_creator_os; /* OS */ 418 __le32 s_rev_level; /* Revision level */ 419 /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */ 420 __le16 s_def_resgid; /* Default gid for reserved blocks */ 421 /* 422 * These fields are for EXT3_DYNAMIC_REV superblocks only. 423 * 424 * Note: the difference between the compatible feature set and 425 * the incompatible feature set is that if there is a bit set 426 * in the incompatible feature set that the kernel doesn't 427 * know about, it should refuse to mount the filesystem. 428 * 429 * e2fsck's requirements are more strict; if it doesn't know 430 * about a feature in either the compatible or incompatible 431 * feature set, it must abort and not try to meddle with 432 * things it doesn't understand... 433 */ 434 __le32 s_first_ino; /* First non-reserved inode */ 435 __le16 s_inode_size; /* size of inode structure */ 436 __le16 s_block_group_nr; /* block group # of this superblock */ 437 __le32 s_feature_compat; /* compatible feature set */ 438 /*60*/ __le32 s_feature_incompat; /* incompatible feature set */ 439 __le32 s_feature_ro_compat; /* readonly-compatible feature set */ 440 /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */ 441 /*78*/ char s_volume_name[16]; /* volume name */ 442 /*88*/ char s_last_mounted[64]; /* directory where last mounted */ 443 /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */ 444 /* 445 * Performance hints. Directory preallocation should only 446 * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on. 447 */ 448 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ 449 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ 450 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */ 451 /* 452 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. 453 */ 454 /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */ 455 /*E0*/ __le32 s_journal_inum; /* inode number of journal file */ 456 __le32 s_journal_dev; /* device number of journal file */ 457 __le32 s_last_orphan; /* start of list of inodes to delete */ 458 __le32 s_hash_seed[4]; /* HTREE hash seed */ 459 __u8 s_def_hash_version; /* Default hash version to use */ 460 __u8 s_reserved_char_pad; 461 __u16 s_reserved_word_pad; 462 __le32 s_default_mount_opts; 463 __le32 s_first_meta_bg; /* First metablock block group */ 464 __u32 s_reserved[190]; /* Padding to the end of the block */ 465 }; 466 467 /* Assume that user mode programs are passing in an ext3fs superblock, not 468 * a kernel struct super_block. This will allow us to call the feature-test 469 * macros from user land. */ 470 #define EXT3_SB(sb) (sb) 471 472 #define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime 473 474 /* 475 * Codes for operating systems 476 */ 477 #define EXT3_OS_LINUX 0 478 #define EXT3_OS_HURD 1 479 #define EXT3_OS_MASIX 2 480 #define EXT3_OS_FREEBSD 3 481 #define EXT3_OS_LITES 4 482 483 /* 484 * Revision levels 485 */ 486 #define EXT3_GOOD_OLD_REV 0 /* The good old (original) format */ 487 #define EXT3_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ 488 489 #define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV 490 #define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV 491 492 #define EXT3_GOOD_OLD_INODE_SIZE 128 493 494 /* 495 * Feature set definitions 496 */ 497 498 #define EXT3_HAS_COMPAT_FEATURE(sb,mask) \ 499 ( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) ) 500 #define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask) \ 501 ( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) ) 502 #define EXT3_HAS_INCOMPAT_FEATURE(sb,mask) \ 503 ( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) ) 504 #define EXT3_SET_COMPAT_FEATURE(sb,mask) \ 505 EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask) 506 #define EXT3_SET_RO_COMPAT_FEATURE(sb,mask) \ 507 EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask) 508 #define EXT3_SET_INCOMPAT_FEATURE(sb,mask) \ 509 EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask) 510 #define EXT3_CLEAR_COMPAT_FEATURE(sb,mask) \ 511 EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask) 512 #define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ 513 EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask) 514 #define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask) \ 515 EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask) 516 517 #define EXT3_FEATURE_COMPAT_DIR_PREALLOC 0x0001 518 #define EXT3_FEATURE_COMPAT_IMAGIC_INODES 0x0002 519 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 520 #define EXT3_FEATURE_COMPAT_EXT_ATTR 0x0008 521 #define EXT3_FEATURE_COMPAT_RESIZE_INODE 0x0010 522 #define EXT3_FEATURE_COMPAT_DIR_INDEX 0x0020 523 524 #define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 525 #define EXT3_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 526 #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 527 528 #define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001 529 #define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002 530 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ 531 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ 532 #define EXT3_FEATURE_INCOMPAT_META_BG 0x0010 533 534 #define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR 535 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \ 536 EXT3_FEATURE_INCOMPAT_RECOVER| \ 537 EXT3_FEATURE_INCOMPAT_META_BG) 538 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \ 539 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \ 540 EXT3_FEATURE_RO_COMPAT_BTREE_DIR) 541 542 /* 543 * Default values for user and/or group using reserved blocks 544 */ 545 #define EXT3_DEF_RESUID 0 546 #define EXT3_DEF_RESGID 0 547 548 /* 549 * Default mount options 550 */ 551 #define EXT3_DEFM_DEBUG 0x0001 552 #define EXT3_DEFM_BSDGROUPS 0x0002 553 #define EXT3_DEFM_XATTR_USER 0x0004 554 #define EXT3_DEFM_ACL 0x0008 555 #define EXT3_DEFM_UID16 0x0010 556 #define EXT3_DEFM_JMODE 0x0060 557 #define EXT3_DEFM_JMODE_DATA 0x0020 558 #define EXT3_DEFM_JMODE_ORDERED 0x0040 559 #define EXT3_DEFM_JMODE_WBACK 0x0060 560 561 /* 562 * Structure of a directory entry 563 */ 564 #define EXT3_NAME_LEN 255 565 566 struct ext3_dir_entry { 567 __le32 inode; /* Inode number */ 568 __le16 rec_len; /* Directory entry length */ 569 __le16 name_len; /* Name length */ 570 char name[EXT3_NAME_LEN]; /* File name */ 571 }; 572 573 /* 574 * The new version of the directory entry. Since EXT3 structures are 575 * stored in intel byte order, and the name_len field could never be 576 * bigger than 255 chars, it's safe to reclaim the extra byte for the 577 * file_type field. 578 */ 579 struct ext3_dir_entry_2 { 580 __le32 inode; /* Inode number */ 581 __le16 rec_len; /* Directory entry length */ 582 __u8 name_len; /* Name length */ 583 __u8 file_type; 584 char name[EXT3_NAME_LEN]; /* File name */ 585 }; 586 587 /* 588 * Ext3 directory file types. Only the low 3 bits are used. The 589 * other bits are reserved for now. 590 */ 591 #define EXT3_FT_UNKNOWN 0 592 #define EXT3_FT_REG_FILE 1 593 #define EXT3_FT_DIR 2 594 #define EXT3_FT_CHRDEV 3 595 #define EXT3_FT_BLKDEV 4 596 #define EXT3_FT_FIFO 5 597 #define EXT3_FT_SOCK 6 598 #define EXT3_FT_SYMLINK 7 599 600 #define EXT3_FT_MAX 8 601 602 /* 603 * EXT3_DIR_PAD defines the directory entries boundaries 604 * 605 * NOTE: It must be a multiple of 4 606 */ 607 #define EXT3_DIR_PAD 4 608 #define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1) 609 #define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \ 610 ~EXT3_DIR_ROUND) 611 #define EXT3_MAX_REC_LEN ((1<<16)-1) 612 613 static __inline__ unsigned ext3_rec_len_from_disk(__le16 dlen) 614 { 615 unsigned len = le16_to_cpu(dlen); 616 617 if (len == EXT3_MAX_REC_LEN) 618 return 1 << 16; 619 return len; 620 } 621 622 static __inline__ __le16 ext3_rec_len_to_disk(unsigned len) 623 { 624 if (len == (1 << 16)) 625 return cpu_to_le16(EXT3_MAX_REC_LEN); 626 else if (len > (1 << 16)) 627 BUG(); 628 return cpu_to_le16(len); 629 } 630 631 /* 632 * Hash Tree Directory indexing 633 * (c) Daniel Phillips, 2001 634 */ 635 636 #define is_dx(dir) (EXT3_HAS_COMPAT_FEATURE(dir->i_sb, \ 637 EXT3_FEATURE_COMPAT_DIR_INDEX) && \ 638 (EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) 639 #define EXT3_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT3_LINK_MAX) 640 #define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) 641 642 /* Legal values for the dx_root hash_version field: */ 643 644 #define DX_HASH_LEGACY 0 645 #define DX_HASH_HALF_MD4 1 646 #define DX_HASH_TEA 2 647 648 649 #endif /* _LINUX_EXT3_FS_H */ 650