diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-13 16:39:18 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-13 16:39:18 +0200 |
| commit | 0b2b0f31a38d77ebfb2a6416011562687ef58191 (patch) | |
| tree | 7d51260fefeefd04bab934817a24e200f4297ae9 /include | |
| parent | caf5768154301697430f0a3718838967d0f55f95 (diff) | |
| download | busybox-w32-0b2b0f31a38d77ebfb2a6416011562687ef58191.tar.gz busybox-w32-0b2b0f31a38d77ebfb2a6416011562687ef58191.tar.bz2 busybox-w32-0b2b0f31a38d77ebfb2a6416011562687ef58191.zip | |
Create and use our own copy of linux/ext2_fs.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/bb_linux_ext2_fs.h | 547 |
1 files changed, 547 insertions, 0 deletions
diff --git a/include/bb_linux_ext2_fs.h b/include/bb_linux_ext2_fs.h new file mode 100644 index 000000000..fdc470bc2 --- /dev/null +++ b/include/bb_linux_ext2_fs.h | |||
| @@ -0,0 +1,547 @@ | |||
| 1 | /* | ||
| 2 | * Work around linux/ext2_fs.h breakage. | ||
| 3 | * linux/ext2_fs.h might be removed from future kernel header distribution. | ||
| 4 | * See https://bugzilla.kernel.org/show_bug.cgi?id=42986 | ||
| 5 | * | ||
| 6 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
| 7 | */ | ||
| 8 | #ifndef BB_LINUX_EXT2_FS_H | ||
| 9 | #define BB_LINUX_EXT2_FS_H | ||
| 10 | |||
| 11 | /* | ||
| 12 | * From linux/magic.h | ||
| 13 | */ | ||
| 14 | |||
| 15 | #define EXT2_SUPER_MAGIC 0xEF53 | ||
| 16 | #define EXT3_SUPER_MAGIC 0xEF53 | ||
| 17 | #define EXT4_SUPER_MAGIC 0xEF53 | ||
| 18 | |||
| 19 | /* | ||
| 20 | * From linux/ext2_fs.h, with minor changes. | ||
| 21 | */ | ||
| 22 | |||
| 23 | /* | ||
| 24 | * Copyright (C) 1992, 1993, 1994, 1995 | ||
| 25 | * Remy Card (card@masi.ibp.fr) | ||
| 26 | * Laboratoire MASI - Institut Blaise Pascal | ||
| 27 | * Universite Pierre et Marie Curie (Paris VI) | ||
| 28 | * | ||
| 29 | * from | ||
| 30 | * | ||
| 31 | * linux/include/linux/minix_fs.h | ||
| 32 | * | ||
| 33 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
| 34 | */ | ||
| 35 | |||
| 36 | /* | ||
| 37 | * The second extended filesystem constants/structures | ||
| 38 | */ | ||
| 39 | |||
| 40 | /* | ||
| 41 | * Define EXT2_RESERVATION to reserve data blocks for expanding files | ||
| 42 | */ | ||
| 43 | #define EXT2_DEFAULT_RESERVE_BLOCKS 8 | ||
| 44 | /*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ | ||
| 45 | #define EXT2_MAX_RESERVE_BLOCKS 1027 | ||
| 46 | #define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0 | ||
| 47 | |||
| 48 | /* | ||
| 49 | * Special inode numbers | ||
| 50 | */ | ||
| 51 | #define EXT2_BAD_INO 1 /* Bad blocks inode */ | ||
| 52 | #define EXT2_ROOT_INO 2 /* Root inode */ | ||
| 53 | #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ | ||
| 54 | #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ | ||
| 55 | |||
| 56 | /* First non-reserved inode for old ext2 filesystems */ | ||
| 57 | #define EXT2_GOOD_OLD_FIRST_INO 11 | ||
| 58 | |||
| 59 | /* Assume that user mode programs are passing in an ext2fs superblock, not | ||
| 60 | * a kernel struct super_block. This will allow us to call the feature-test | ||
| 61 | * macros from user land. */ | ||
| 62 | #define EXT2_SB(sb) (sb) | ||
| 63 | |||
| 64 | /* | ||
| 65 | * Maximal count of links to a file | ||
| 66 | */ | ||
| 67 | #define EXT2_LINK_MAX 32000 | ||
| 68 | |||
| 69 | /* | ||
| 70 | * Macro-instructions used to manage several block sizes | ||
| 71 | */ | ||
| 72 | #define EXT2_MIN_BLOCK_SIZE 1024 | ||
| 73 | #define EXT2_MAX_BLOCK_SIZE 4096 | ||
| 74 | #define EXT2_MIN_BLOCK_LOG_SIZE 10 | ||
| 75 | # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) | ||
| 76 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (uint32_t)) | ||
| 77 | # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) | ||
| 78 | #define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ | ||
| 79 | EXT2_GOOD_OLD_INODE_SIZE : \ | ||
| 80 | (s)->s_inode_size) | ||
| 81 | #define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ | ||
| 82 | EXT2_GOOD_OLD_FIRST_INO : \ | ||
| 83 | (s)->s_first_ino) | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Macro-instructions used to manage fragments | ||
| 87 | */ | ||
| 88 | #define EXT2_MIN_FRAG_SIZE 1024 | ||
| 89 | #define EXT2_MAX_FRAG_SIZE 4096 | ||
| 90 | #define EXT2_MIN_FRAG_LOG_SIZE 10 | ||
| 91 | # define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) | ||
| 92 | # define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) | ||
| 93 | |||
| 94 | /* | ||
| 95 | * Structure of a blocks group descriptor | ||
| 96 | */ | ||
| 97 | struct ext2_group_desc | ||
| 98 | { | ||
| 99 | uint32_t bg_block_bitmap; /* Blocks bitmap block */ | ||
| 100 | uint32_t bg_inode_bitmap; /* Inodes bitmap block */ | ||
| 101 | uint32_t bg_inode_table; /* Inodes table block */ | ||
| 102 | uint16_t bg_free_blocks_count; /* Free blocks count */ | ||
| 103 | uint16_t bg_free_inodes_count; /* Free inodes count */ | ||
| 104 | uint16_t bg_used_dirs_count; /* Directories count */ | ||
| 105 | uint16_t bg_pad; | ||
| 106 | uint32_t bg_reserved[3]; | ||
| 107 | }; | ||
| 108 | |||
| 109 | /* | ||
| 110 | * Macro-instructions used to manage group descriptors | ||
| 111 | */ | ||
| 112 | # define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) | ||
| 113 | # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) | ||
| 114 | # define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Constants relative to the data blocks | ||
| 118 | */ | ||
| 119 | #define EXT2_NDIR_BLOCKS 12 | ||
| 120 | #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS | ||
| 121 | #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) | ||
| 122 | #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) | ||
| 123 | #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) | ||
| 124 | |||
| 125 | /* | ||
| 126 | * Inode flags (GETFLAGS/SETFLAGS) | ||
| 127 | */ | ||
| 128 | #define EXT2_SECRM_FL FS_SECRM_FL /* Secure deletion */ | ||
| 129 | #define EXT2_UNRM_FL FS_UNRM_FL /* Undelete */ | ||
| 130 | #define EXT2_COMPR_FL FS_COMPR_FL /* Compress file */ | ||
| 131 | #define EXT2_SYNC_FL FS_SYNC_FL /* Synchronous updates */ | ||
| 132 | #define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */ | ||
| 133 | #define EXT2_APPEND_FL FS_APPEND_FL /* writes to file may only append */ | ||
| 134 | #define EXT2_NODUMP_FL FS_NODUMP_FL /* do not dump file */ | ||
| 135 | #define EXT2_NOATIME_FL FS_NOATIME_FL /* do not update atime */ | ||
| 136 | /* Reserved for compression usage... */ | ||
| 137 | #define EXT2_DIRTY_FL FS_DIRTY_FL | ||
| 138 | #define EXT2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */ | ||
| 139 | #define EXT2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */ | ||
| 140 | #define EXT2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */ | ||
| 141 | /* End compression flags --- maybe not all used */ | ||
| 142 | #define EXT2_BTREE_FL FS_BTREE_FL /* btree format dir */ | ||
| 143 | #define EXT2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */ | ||
| 144 | #define EXT2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */ | ||
| 145 | #define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */ | ||
| 146 | #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */ | ||
| 147 | #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */ | ||
| 148 | #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/ | ||
| 149 | #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */ | ||
| 150 | |||
| 151 | #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */ | ||
| 152 | #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */ | ||
| 153 | |||
| 154 | /* Flags that should be inherited by new inodes from their parent. */ | ||
| 155 | #define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\ | ||
| 156 | EXT2_SYNC_FL | EXT2_IMMUTABLE_FL | EXT2_APPEND_FL |\ | ||
| 157 | EXT2_NODUMP_FL | EXT2_NOATIME_FL | EXT2_COMPRBLK_FL|\ | ||
| 158 | EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\ | ||
| 159 | EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL) | ||
| 160 | |||
| 161 | /* Flags that are appropriate for regular files (all but dir-specific ones). */ | ||
| 162 | #define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL)) | ||
| 163 | |||
| 164 | /* Flags that are appropriate for non-directories/regular files. */ | ||
| 165 | #define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL) | ||
| 166 | |||
| 167 | /* Mask out flags that are inappropriate for the given type of inode. */ | ||
| 168 | static inline uint32_t ext2_mask_flags(mode_t mode, uint32_t flags) | ||
| 169 | { | ||
| 170 | if (S_ISDIR(mode)) | ||
| 171 | return flags; | ||
| 172 | else if (S_ISREG(mode)) | ||
| 173 | return flags & EXT2_REG_FLMASK; | ||
| 174 | else | ||
| 175 | return flags & EXT2_OTHER_FLMASK; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* | ||
| 179 | * ioctl commands | ||
| 180 | */ | ||
| 181 | #define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS | ||
| 182 | #define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS | ||
| 183 | #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION | ||
| 184 | #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION | ||
| 185 | #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) | ||
| 186 | #define EXT2_IOC_SETRSVSZ _IOW('f', 6, long) | ||
| 187 | |||
| 188 | /* | ||
| 189 | * ioctl commands in 32 bit emulation | ||
| 190 | */ | ||
| 191 | #define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS | ||
| 192 | #define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS | ||
| 193 | #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION | ||
| 194 | #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION | ||
| 195 | |||
| 196 | /* | ||
| 197 | * Structure of an inode on the disk | ||
| 198 | */ | ||
| 199 | struct ext2_inode { | ||
| 200 | uint16_t i_mode; /* File mode */ | ||
| 201 | uint16_t i_uid; /* Low 16 bits of Owner Uid */ | ||
| 202 | uint32_t i_size; /* Size in bytes */ | ||
| 203 | uint32_t i_atime; /* Access time */ | ||
| 204 | uint32_t i_ctime; /* Creation time */ | ||
| 205 | uint32_t i_mtime; /* Modification time */ | ||
| 206 | uint32_t i_dtime; /* Deletion Time */ | ||
| 207 | uint16_t i_gid; /* Low 16 bits of Group Id */ | ||
| 208 | uint16_t i_links_count; /* Links count */ | ||
| 209 | uint32_t i_blocks; /* Blocks count */ | ||
| 210 | uint32_t i_flags; /* File flags */ | ||
| 211 | union { | ||
| 212 | struct { | ||
| 213 | uint32_t l_i_reserved1; | ||
| 214 | } linux1; | ||
| 215 | struct { | ||
| 216 | uint32_t h_i_translator; | ||
| 217 | } hurd1; | ||
| 218 | struct { | ||
| 219 | uint32_t m_i_reserved1; | ||
| 220 | } masix1; | ||
| 221 | } osd1; /* OS dependent 1 */ | ||
| 222 | uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ | ||
| 223 | uint32_t i_generation; /* File version (for NFS) */ | ||
| 224 | uint32_t i_file_acl; /* File ACL */ | ||
| 225 | uint32_t i_dir_acl; /* Directory ACL */ | ||
| 226 | uint32_t i_faddr; /* Fragment address */ | ||
| 227 | union { | ||
| 228 | struct { | ||
| 229 | uint8_t l_i_frag; /* Fragment number */ | ||
| 230 | uint8_t l_i_fsize; /* Fragment size */ | ||
| 231 | uint16_t i_pad1; | ||
| 232 | uint16_t l_i_uid_high; /* these 2 fields */ | ||
| 233 | uint16_t l_i_gid_high; /* were reserved2[0] */ | ||
| 234 | uint32_t l_i_reserved2; | ||
| 235 | } linux2; | ||
| 236 | struct { | ||
| 237 | uint8_t h_i_frag; /* Fragment number */ | ||
| 238 | uint8_t h_i_fsize; /* Fragment size */ | ||
| 239 | uint16_t h_i_mode_high; | ||
| 240 | uint16_t h_i_uid_high; | ||
| 241 | uint16_t h_i_gid_high; | ||
| 242 | uint32_t h_i_author; | ||
| 243 | } hurd2; | ||
| 244 | struct { | ||
| 245 | uint8_t m_i_frag; /* Fragment number */ | ||
| 246 | uint8_t m_i_fsize; /* Fragment size */ | ||
| 247 | uint16_t m_pad1; | ||
| 248 | uint32_t m_i_reserved2[2]; | ||
| 249 | } masix2; | ||
| 250 | } osd2; /* OS dependent 2 */ | ||
| 251 | }; | ||
| 252 | |||
| 253 | #define i_size_high i_dir_acl | ||
| 254 | |||
| 255 | #if defined(__KERNEL__) || defined(__linux__) | ||
| 256 | #define i_reserved1 osd1.linux1.l_i_reserved1 | ||
| 257 | #define i_frag osd2.linux2.l_i_frag | ||
| 258 | #define i_fsize osd2.linux2.l_i_fsize | ||
| 259 | #define i_uid_low i_uid | ||
| 260 | #define i_gid_low i_gid | ||
| 261 | #define i_uid_high osd2.linux2.l_i_uid_high | ||
| 262 | #define i_gid_high osd2.linux2.l_i_gid_high | ||
| 263 | #define i_reserved2 osd2.linux2.l_i_reserved2 | ||
| 264 | #endif | ||
| 265 | |||
| 266 | #ifdef __hurd__ | ||
| 267 | #define i_translator osd1.hurd1.h_i_translator | ||
| 268 | #define i_frag osd2.hurd2.h_i_frag | ||
| 269 | #define i_fsize osd2.hurd2.h_i_fsize | ||
| 270 | #define i_uid_high osd2.hurd2.h_i_uid_high | ||
| 271 | #define i_gid_high osd2.hurd2.h_i_gid_high | ||
| 272 | #define i_author osd2.hurd2.h_i_author | ||
| 273 | #endif | ||
| 274 | |||
| 275 | #ifdef __masix__ | ||
| 276 | #define i_reserved1 osd1.masix1.m_i_reserved1 | ||
| 277 | #define i_frag osd2.masix2.m_i_frag | ||
| 278 | #define i_fsize osd2.masix2.m_i_fsize | ||
| 279 | #define i_reserved2 osd2.masix2.m_i_reserved2 | ||
| 280 | #endif | ||
| 281 | |||
| 282 | /* | ||
| 283 | * File system states | ||
| 284 | */ | ||
| 285 | #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ | ||
| 286 | #define EXT2_ERROR_FS 0x0002 /* Errors detected */ | ||
| 287 | |||
| 288 | /* | ||
| 289 | * Mount flags | ||
| 290 | */ | ||
| 291 | #define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */ | ||
| 292 | #define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */ | ||
| 293 | #define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */ | ||
| 294 | #define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */ | ||
| 295 | #define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ | ||
| 296 | #define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ | ||
| 297 | #define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ | ||
| 298 | #define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ | ||
| 299 | #define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ | ||
| 300 | #define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */ | ||
| 301 | #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */ | ||
| 302 | #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */ | ||
| 303 | #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */ | ||
| 304 | #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */ | ||
| 305 | #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */ | ||
| 306 | #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */ | ||
| 307 | |||
| 308 | |||
| 309 | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt | ||
| 310 | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt | ||
| 311 | #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ | ||
| 312 | EXT2_MOUNT_##opt) | ||
| 313 | /* | ||
| 314 | * Maximal mount counts between two filesystem checks | ||
| 315 | */ | ||
| 316 | #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ | ||
| 317 | #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ | ||
| 318 | |||
| 319 | /* | ||
| 320 | * Behaviour when detecting errors | ||
| 321 | */ | ||
| 322 | #define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ | ||
| 323 | #define EXT2_ERRORS_RO 2 /* Remount fs read-only */ | ||
| 324 | #define EXT2_ERRORS_PANIC 3 /* Panic */ | ||
| 325 | #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE | ||
| 326 | |||
| 327 | /* | ||
| 328 | * Structure of the super block | ||
| 329 | */ | ||
| 330 | struct ext2_super_block { | ||
| 331 | uint32_t s_inodes_count; /* Inodes count */ | ||
| 332 | uint32_t s_blocks_count; /* Blocks count */ | ||
| 333 | uint32_t s_r_blocks_count; /* Reserved blocks count */ | ||
| 334 | uint32_t s_free_blocks_count; /* Free blocks count */ | ||
| 335 | uint32_t s_free_inodes_count; /* Free inodes count */ | ||
| 336 | uint32_t s_first_data_block; /* First Data Block */ | ||
| 337 | uint32_t s_log_block_size; /* Block size */ | ||
| 338 | uint32_t s_log_frag_size; /* Fragment size */ | ||
| 339 | uint32_t s_blocks_per_group; /* # Blocks per group */ | ||
| 340 | uint32_t s_frags_per_group; /* # Fragments per group */ | ||
| 341 | uint32_t s_inodes_per_group; /* # Inodes per group */ | ||
| 342 | uint32_t s_mtime; /* Mount time */ | ||
| 343 | uint32_t s_wtime; /* Write time */ | ||
| 344 | uint16_t s_mnt_count; /* Mount count */ | ||
| 345 | uint16_t s_max_mnt_count; /* Maximal mount count */ | ||
| 346 | uint16_t s_magic; /* Magic signature */ | ||
| 347 | uint16_t s_state; /* File system state */ | ||
| 348 | uint16_t s_errors; /* Behaviour when detecting errors */ | ||
| 349 | uint16_t s_minor_rev_level; /* minor revision level */ | ||
| 350 | uint32_t s_lastcheck; /* time of last check */ | ||
| 351 | uint32_t s_checkinterval; /* max. time between checks */ | ||
| 352 | uint32_t s_creator_os; /* OS */ | ||
| 353 | uint32_t s_rev_level; /* Revision level */ | ||
| 354 | uint16_t s_def_resuid; /* Default uid for reserved blocks */ | ||
| 355 | uint16_t s_def_resgid; /* Default gid for reserved blocks */ | ||
| 356 | /* | ||
| 357 | * These fields are for EXT2_DYNAMIC_REV superblocks only. | ||
| 358 | * | ||
| 359 | * Note: the difference between the compatible feature set and | ||
| 360 | * the incompatible feature set is that if there is a bit set | ||
| 361 | * in the incompatible feature set that the kernel doesn't | ||
| 362 | * know about, it should refuse to mount the filesystem. | ||
| 363 | * | ||
| 364 | * e2fsck's requirements are more strict; if it doesn't know | ||
| 365 | * about a feature in either the compatible or incompatible | ||
| 366 | * feature set, it must abort and not try to meddle with | ||
| 367 | * things it doesn't understand... | ||
| 368 | */ | ||
| 369 | uint32_t s_first_ino; /* First non-reserved inode */ | ||
| 370 | uint16_t s_inode_size; /* size of inode structure */ | ||
| 371 | uint16_t s_block_group_nr; /* block group # of this superblock */ | ||
| 372 | uint32_t s_feature_compat; /* compatible feature set */ | ||
| 373 | uint32_t s_feature_incompat; /* incompatible feature set */ | ||
| 374 | uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ | ||
| 375 | uint8_t s_uuid[16]; /* 128-bit uuid for volume */ | ||
| 376 | char s_volume_name[16]; /* volume name */ | ||
| 377 | char s_last_mounted[64]; /* directory where last mounted */ | ||
| 378 | uint32_t s_algorithm_usage_bitmap; /* For compression */ | ||
| 379 | /* | ||
| 380 | * Performance hints. Directory preallocation should only | ||
| 381 | * happen if the EXT2_COMPAT_PREALLOC flag is on. | ||
| 382 | */ | ||
| 383 | uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ | ||
| 384 | uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ | ||
| 385 | uint16_t s_padding1; | ||
| 386 | /* | ||
| 387 | * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. | ||
| 388 | */ | ||
| 389 | uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ | ||
| 390 | uint32_t s_journal_inum; /* inode number of journal file */ | ||
| 391 | uint32_t s_journal_dev; /* device number of journal file */ | ||
| 392 | uint32_t s_last_orphan; /* start of list of inodes to delete */ | ||
| 393 | uint32_t s_hash_seed[4]; /* HTREE hash seed */ | ||
| 394 | uint8_t s_def_hash_version; /* Default hash version to use */ | ||
| 395 | uint8_t s_reserved_char_pad; | ||
| 396 | uint16_t s_reserved_word_pad; | ||
| 397 | uint32_t s_default_mount_opts; | ||
| 398 | uint32_t s_first_meta_bg; /* First metablock block group */ | ||
| 399 | uint32_t s_reserved[190]; /* Padding to the end of the block */ | ||
| 400 | }; | ||
| 401 | |||
| 402 | /* | ||
| 403 | * Codes for operating systems | ||
| 404 | */ | ||
| 405 | #define EXT2_OS_LINUX 0 | ||
| 406 | #define EXT2_OS_HURD 1 | ||
| 407 | #define EXT2_OS_MASIX 2 | ||
| 408 | #define EXT2_OS_FREEBSD 3 | ||
| 409 | #define EXT2_OS_LITES 4 | ||
| 410 | |||
| 411 | /* | ||
| 412 | * Revision levels | ||
| 413 | */ | ||
| 414 | #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ | ||
| 415 | #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ | ||
| 416 | |||
| 417 | #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV | ||
| 418 | #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV | ||
| 419 | |||
| 420 | #define EXT2_GOOD_OLD_INODE_SIZE 128 | ||
| 421 | |||
| 422 | /* | ||
| 423 | * Feature set definitions | ||
| 424 | */ | ||
| 425 | |||
| 426 | #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ | ||
| 427 | ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) ) | ||
| 428 | #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ | ||
| 429 | ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) ) | ||
| 430 | #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ | ||
| 431 | ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) ) | ||
| 432 | #define EXT2_SET_COMPAT_FEATURE(sb,mask) \ | ||
| 433 | EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask) | ||
| 434 | #define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \ | ||
| 435 | EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask) | ||
| 436 | #define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \ | ||
| 437 | EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask) | ||
| 438 | #define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \ | ||
| 439 | EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask) | ||
| 440 | #define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ | ||
| 441 | EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask) | ||
| 442 | #define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ | ||
| 443 | EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask) | ||
| 444 | |||
| 445 | #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 | ||
| 446 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 | ||
| 447 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 | ||
| 448 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 | ||
| 449 | #define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 | ||
| 450 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 | ||
| 451 | #define EXT2_FEATURE_COMPAT_ANY 0xffffffff | ||
| 452 | |||
| 453 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 | ||
| 454 | #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 | ||
| 455 | #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 | ||
| 456 | #define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff | ||
| 457 | |||
| 458 | #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 | ||
| 459 | #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 | ||
| 460 | #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 | ||
| 461 | #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 | ||
| 462 | #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 | ||
| 463 | #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff | ||
| 464 | |||
| 465 | #define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR | ||
| 466 | #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ | ||
| 467 | EXT2_FEATURE_INCOMPAT_META_BG) | ||
| 468 | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ | ||
| 469 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ | ||
| 470 | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) | ||
| 471 | #define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP | ||
| 472 | #define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP | ||
| 473 | |||
| 474 | /* | ||
| 475 | * Default values for user and/or group using reserved blocks | ||
| 476 | */ | ||
| 477 | #define EXT2_DEF_RESUID 0 | ||
| 478 | #define EXT2_DEF_RESGID 0 | ||
| 479 | |||
| 480 | /* | ||
| 481 | * Default mount options | ||
| 482 | */ | ||
| 483 | #define EXT2_DEFM_DEBUG 0x0001 | ||
| 484 | #define EXT2_DEFM_BSDGROUPS 0x0002 | ||
| 485 | #define EXT2_DEFM_XATTR_USER 0x0004 | ||
| 486 | #define EXT2_DEFM_ACL 0x0008 | ||
| 487 | #define EXT2_DEFM_UID16 0x0010 | ||
| 488 | /* Not used by ext2, but reserved for use by ext3 */ | ||
| 489 | #define EXT3_DEFM_JMODE 0x0060 | ||
| 490 | #define EXT3_DEFM_JMODE_DATA 0x0020 | ||
| 491 | #define EXT3_DEFM_JMODE_ORDERED 0x0040 | ||
| 492 | #define EXT3_DEFM_JMODE_WBACK 0x0060 | ||
| 493 | |||
| 494 | /* | ||
| 495 | * Structure of a directory entry | ||
| 496 | */ | ||
| 497 | #define EXT2_NAME_LEN 255 | ||
| 498 | |||
| 499 | struct ext2_dir_entry { | ||
| 500 | uint32_t inode; /* Inode number */ | ||
| 501 | uint16_t rec_len; /* Directory entry length */ | ||
| 502 | uint16_t name_len; /* Name length */ | ||
| 503 | char name[EXT2_NAME_LEN]; /* File name */ | ||
| 504 | }; | ||
| 505 | |||
| 506 | /* | ||
| 507 | * The new version of the directory entry. Since EXT2 structures are | ||
| 508 | * stored in intel byte order, and the name_len field could never be | ||
| 509 | * bigger than 255 chars, it's safe to reclaim the extra byte for the | ||
| 510 | * file_type field. | ||
| 511 | */ | ||
| 512 | struct ext2_dir_entry_2 { | ||
| 513 | uint32_t inode; /* Inode number */ | ||
| 514 | uint16_t rec_len; /* Directory entry length */ | ||
| 515 | uint8_t name_len; /* Name length */ | ||
| 516 | uint8_t file_type; | ||
| 517 | char name[EXT2_NAME_LEN]; /* File name */ | ||
| 518 | }; | ||
| 519 | |||
| 520 | /* | ||
| 521 | * Ext2 directory file types. Only the low 3 bits are used. The | ||
| 522 | * other bits are reserved for now. | ||
| 523 | */ | ||
| 524 | enum { | ||
| 525 | EXT2_FT_UNKNOWN = 0, | ||
| 526 | EXT2_FT_REG_FILE = 1, | ||
| 527 | EXT2_FT_DIR = 2, | ||
| 528 | EXT2_FT_CHRDEV = 3, | ||
| 529 | EXT2_FT_BLKDEV = 4, | ||
| 530 | EXT2_FT_FIFO = 5, | ||
| 531 | EXT2_FT_SOCK = 6, | ||
| 532 | EXT2_FT_SYMLINK = 7, | ||
| 533 | EXT2_FT_MAX | ||
| 534 | }; | ||
| 535 | |||
| 536 | /* | ||
| 537 | * EXT2_DIR_PAD defines the directory entries boundaries | ||
| 538 | * | ||
| 539 | * NOTE: It must be a multiple of 4 | ||
| 540 | */ | ||
| 541 | #define EXT2_DIR_PAD 4 | ||
| 542 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) | ||
| 543 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ | ||
| 544 | ~EXT2_DIR_ROUND) | ||
| 545 | #define EXT2_MAX_REC_LEN ((1<<16)-1) | ||
| 546 | |||
| 547 | #endif | ||
