rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * linux/include/linux/ext2_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_EXT2_FS_H |
| 17 | #define _LINUX_EXT2_FS_H |
| 18 | |
| 19 | #include <sys/types.h> |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | //#include <linux/types.h> |
| 23 | //#include <linux/magic.h> |
| 24 | |
| 25 | /* |
| 26 | * The second extended filesystem constants/structures |
| 27 | */ |
| 28 | |
| 29 | /* |
| 30 | * Special inode numbers |
| 31 | */ |
| 32 | #define EXT2_BAD_INO 1 /* Bad blocks inode */ |
| 33 | #define EXT2_ROOT_INO 2 /* Root inode */ |
| 34 | #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ |
| 35 | #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ |
| 36 | |
| 37 | /* First non-reserved inode for old ext2 filesystems */ |
| 38 | #define EXT2_GOOD_OLD_FIRST_INO 11 |
| 39 | |
| 40 | /* |
| 41 | * Maximal count of links to a file |
| 42 | */ |
| 43 | #define EXT2_LINK_MAX 32000 |
| 44 | |
| 45 | /* |
| 46 | * Macro-instructions used to manage several block sizes |
| 47 | */ |
| 48 | #define EXT2_MIN_BLOCK_SIZE 1024 |
| 49 | #define EXT2_MAX_BLOCK_SIZE 4096 |
| 50 | #define EXT2_MIN_BLOCK_LOG_SIZE 10 |
| 51 | #define EXT2_BLOCK_SIZE(s) ((uint32_t)EXT2_MIN_BLOCK_SIZE << (s).s_log_block_size) |
| 52 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (uint32_t)) |
| 53 | #define EXT2_BLOCK_SIZE_BITS(s) ((s).s_log_block_size + 10) |
| 54 | #define EXT2_INODE_SIZE(s) (((s).s_rev_level == EXT2_GOOD_OLD_REV) ? \ |
| 55 | EXT2_GOOD_OLD_INODE_SIZE : \ |
| 56 | (s).s_inode_size) |
| 57 | #define EXT2_FIRST_INO(s) (((s).s_rev_level == EXT2_GOOD_OLD_REV) ? \ |
| 58 | EXT2_GOOD_OLD_FIRST_INO : \ |
| 59 | (s).s_first_ino) |
| 60 | |
| 61 | /* |
| 62 | * Macro-instructions used to manage fragments |
| 63 | */ |
| 64 | #define EXT2_MIN_FRAG_SIZE 1024 |
| 65 | #define EXT2_MAX_FRAG_SIZE 4096 |
| 66 | #define EXT2_MIN_FRAG_LOG_SIZE 10 |
| 67 | #define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s).s_log_frag_size) |
| 68 | #define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) |
| 69 | |
| 70 | /* |
| 71 | * Structure of a blocks group descriptor |
| 72 | */ |
| 73 | struct ext2_group_desc { |
| 74 | uint32_t bg_block_bitmap; /* Blocks bitmap block */ |
| 75 | uint32_t bg_inode_bitmap; /* Inodes bitmap block */ |
| 76 | uint32_t bg_inode_table; /* Inodes table block */ |
| 77 | uint16_t bg_free_blocks_count; /* Free blocks count */ |
| 78 | uint16_t bg_free_inodes_count; /* Free inodes count */ |
| 79 | uint16_t bg_used_dirs_count; /* Directories count */ |
| 80 | uint16_t bg_pad; |
| 81 | uint32_t bg_reserved[3]; |
| 82 | }; |
| 83 | |
| 84 | /* |
| 85 | * Macro-instructions used to manage group descriptors |
| 86 | */ |
| 87 | #define EXT2_BLOCKS_PER_GROUP(s) ((s).s_blocks_per_group) |
| 88 | #define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) |
| 89 | #define EXT2_INODES_PER_GROUP(s) ((s).s_inodes_per_group) |
| 90 | |
| 91 | /* |
| 92 | * Constants relative to the data blocks |
| 93 | */ |
| 94 | #define EXT2_NDIR_BLOCKS 12 |
| 95 | #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS |
| 96 | #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) |
| 97 | #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) |
| 98 | #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) |
| 99 | |
| 100 | /* |
| 101 | * Structure of an inode on the disk |
| 102 | */ |
| 103 | struct ext2_inode { |
| 104 | uint16_t i_mode; /* File mode */ |
| 105 | uint16_t i_uid; /* Low 16 bits of Owner Uid */ |
| 106 | uint32_t i_size; /* Size in bytes */ |
| 107 | uint32_t i_atime; /* Access time */ |
| 108 | uint32_t i_ctime; /* Creation time */ |
| 109 | uint32_t i_mtime; /* Modification time */ |
| 110 | uint32_t i_dtime; /* Deletion Time */ |
| 111 | uint16_t i_gid; /* Low 16 bits of Group Id */ |
| 112 | uint16_t i_links_count; /* Links count */ |
| 113 | uint32_t i_blocks; /* Blocks count */ |
| 114 | uint32_t i_flags; /* File flags */ |
| 115 | union { |
| 116 | struct { |
| 117 | uint32_t l_i_reserved1; |
| 118 | } linux1; |
| 119 | struct { |
| 120 | uint32_t h_i_translator; |
| 121 | } hurd1; |
| 122 | struct { |
| 123 | uint32_t m_i_reserved1; |
| 124 | } masix1; |
| 125 | } osd1; /* OS dependent 1 */ |
| 126 | uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ |
| 127 | uint32_t i_generation; /* File version (for NFS) */ |
| 128 | uint32_t i_file_acl; /* File ACL */ |
| 129 | uint32_t i_dir_acl; /* Directory ACL */ |
| 130 | uint32_t i_faddr; /* Fragment address */ |
| 131 | union { |
| 132 | struct { |
| 133 | uint8_t l_i_frag; /* Fragment number */ |
| 134 | uint8_t l_i_fsize; /* Fragment size */ |
| 135 | uint16_t i_pad1; |
| 136 | uint16_t l_i_uid_high; /* these 2 fields */ |
| 137 | uint16_t l_i_gid_high; /* were reserved2[0] */ |
| 138 | uint32_t l_i_reserved2; |
| 139 | } linux2; |
| 140 | struct { |
| 141 | uint8_t h_i_frag; /* Fragment number */ |
| 142 | uint8_t h_i_fsize; /* Fragment size */ |
| 143 | uint16_t h_i_mode_high; |
| 144 | uint16_t h_i_uid_high; |
| 145 | uint16_t h_i_gid_high; |
| 146 | uint32_t h_i_author; |
| 147 | } hurd2; |
| 148 | struct { |
| 149 | uint8_t m_i_frag; /* Fragment number */ |
| 150 | uint8_t m_i_fsize; /* Fragment size */ |
| 151 | uint16_t m_pad1; |
| 152 | uint32_t m_i_reserved2[2]; |
| 153 | } masix2; |
| 154 | } osd2; /* OS dependent 2 */ |
| 155 | }; |
| 156 | |
| 157 | #define i_size_high i_dir_acl |
| 158 | |
| 159 | #define i_reserved1 osd1.linux1.l_i_reserved1 |
| 160 | #define i_frag osd2.linux2.l_i_frag |
| 161 | #define i_fsize osd2.linux2.l_i_fsize |
| 162 | #define i_uid_low i_uid |
| 163 | #define i_gid_low i_gid |
| 164 | #define i_uid_high osd2.linux2.l_i_uid_high |
| 165 | #define i_gid_high osd2.linux2.l_i_gid_high |
| 166 | #define i_reserved2 osd2.linux2.l_i_reserved2 |
| 167 | |
| 168 | /* |
| 169 | * File system states |
| 170 | */ |
| 171 | #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ |
| 172 | #define EXT2_ERROR_FS 0x0002 /* Errors detected */ |
| 173 | |
| 174 | /* |
| 175 | * Mount flags |
| 176 | */ |
| 177 | #define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */ |
| 178 | #define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */ |
| 179 | #define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */ |
| 180 | #define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */ |
| 181 | #define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ |
| 182 | #define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ |
| 183 | #define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ |
| 184 | #define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ |
| 185 | #define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ |
| 186 | #define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */ |
| 187 | #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */ |
| 188 | #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */ |
| 189 | #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */ |
| 190 | #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */ |
| 191 | #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */ |
| 192 | |
| 193 | |
| 194 | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt |
| 195 | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt |
| 196 | #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ |
| 197 | EXT2_MOUNT_##opt) |
| 198 | /* |
| 199 | * Maximal mount counts between two filesystem checks |
| 200 | */ |
| 201 | #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ |
| 202 | #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ |
| 203 | |
| 204 | /* |
| 205 | * Behaviour when detecting errors |
| 206 | */ |
| 207 | #define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ |
| 208 | #define EXT2_ERRORS_RO 2 /* Remount fs read-only */ |
| 209 | #define EXT2_ERRORS_PANIC 3 /* Panic */ |
| 210 | #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE |
| 211 | |
| 212 | #define EXT2_SUPER_MAGIC 0xEF53 |
| 213 | #define EXT3_SUPER_MAGIC 0xEF53 |
| 214 | #define EXT4_SUPER_MAGIC 0xEF53 |
| 215 | |
| 216 | /* |
| 217 | * Structure of the super block |
| 218 | */ |
| 219 | struct ext2_super_block { |
| 220 | uint32_t s_inodes_count; /* Inodes count */ |
| 221 | uint32_t s_blocks_count; /* Blocks count */ |
| 222 | uint32_t s_r_blocks_count; /* Reserved blocks count */ |
| 223 | uint32_t s_free_blocks_count; /* Free blocks count */ |
| 224 | uint32_t s_free_inodes_count; /* Free inodes count */ |
| 225 | uint32_t s_first_data_block; /* First Data Block */ |
| 226 | uint32_t s_log_block_size; /* Block size */ |
| 227 | uint32_t s_log_frag_size; /* Fragment size */ |
| 228 | uint32_t s_blocks_per_group; /* # Blocks per group */ |
| 229 | uint32_t s_frags_per_group; /* # Fragments per group */ |
| 230 | uint32_t s_inodes_per_group; /* # Inodes per group */ |
| 231 | uint32_t s_mtime; /* Mount time */ |
| 232 | uint32_t s_wtime; /* Write time */ |
| 233 | uint16_t s_mnt_count; /* Mount count */ |
| 234 | uint16_t s_max_mnt_count; /* Maximal mount count */ |
| 235 | uint16_t s_magic; /* Magic signature */ |
| 236 | uint16_t s_state; /* File system state */ |
| 237 | uint16_t s_errors; /* Behaviour when detecting errors */ |
| 238 | uint16_t s_minor_rev_level; /* minor revision level */ |
| 239 | uint32_t s_lastcheck; /* time of last check */ |
| 240 | uint32_t s_checkinterval; /* max. time between checks */ |
| 241 | uint32_t s_creator_os; /* OS */ |
| 242 | uint32_t s_rev_level; /* Revision level */ |
| 243 | uint16_t s_def_resuid; /* Default uid for reserved blocks */ |
| 244 | uint16_t s_def_resgid; /* Default gid for reserved blocks */ |
| 245 | /* |
| 246 | * These fields are for EXT2_DYNAMIC_REV superblocks only. |
| 247 | * |
| 248 | * Note: the difference between the compatible feature set and |
| 249 | * the incompatible feature set is that if there is a bit set |
| 250 | * in the incompatible feature set that the kernel doesn't |
| 251 | * know about, it should refuse to mount the filesystem. |
| 252 | * |
| 253 | * e2fsck's requirements are more strict; if it doesn't know |
| 254 | * about a feature in either the compatible or incompatible |
| 255 | * feature set, it must abort and not try to meddle with |
| 256 | * things it doesn't understand... |
| 257 | */ |
| 258 | uint32_t s_first_ino; /* First non-reserved inode */ |
| 259 | uint16_t s_inode_size; /* size of inode structure */ |
| 260 | uint16_t s_block_group_nr; /* block group # of this superblock */ |
| 261 | uint32_t s_feature_compat; /* compatible feature set */ |
| 262 | uint32_t s_feature_incompat; /* incompatible feature set */ |
| 263 | uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ |
| 264 | uint8_t s_uuid[16]; /* 128-bit uuid for volume */ |
| 265 | char s_volume_name[16]; /* volume name */ |
| 266 | char s_last_mounted[64]; /* directory where last mounted */ |
| 267 | uint32_t s_algorithm_usage_bitmap; /* For compression */ |
| 268 | /* |
| 269 | * Performance hints. Directory preallocation should only |
| 270 | * happen if the EXT2_COMPAT_PREALLOC flag is on. |
| 271 | */ |
| 272 | uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ |
| 273 | uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ |
| 274 | uint16_t s_padding1; |
| 275 | /* |
| 276 | * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. |
| 277 | */ |
| 278 | uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ |
| 279 | uint32_t s_journal_inum; /* inode number of journal file */ |
| 280 | uint32_t s_journal_dev; /* device number of journal file */ |
| 281 | uint32_t s_last_orphan; /* start of list of inodes to delete */ |
| 282 | uint32_t s_hash_seed[4]; /* HTREE hash seed */ |
| 283 | uint8_t s_def_hash_version; /* Default hash version to use */ |
| 284 | uint8_t s_reserved_char_pad; |
| 285 | uint16_t s_reserved_word_pad; |
| 286 | uint32_t s_default_mount_opts; |
| 287 | uint32_t s_first_meta_bg; /* First metablock block group */ |
| 288 | uint32_t s_reserved[190]; /* Padding to the end of the block */ |
| 289 | }; |
| 290 | |
| 291 | /* |
| 292 | * Codes for operating systems |
| 293 | */ |
| 294 | #define EXT2_OS_LINUX 0 |
| 295 | #define EXT2_OS_HURD 1 |
| 296 | #define EXT2_OS_MASIX 2 |
| 297 | #define EXT2_OS_FREEBSD 3 |
| 298 | #define EXT2_OS_LITES 4 |
| 299 | |
| 300 | /* |
| 301 | * Revision levels |
| 302 | */ |
| 303 | #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ |
| 304 | #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ |
| 305 | |
| 306 | #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV |
| 307 | #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV |
| 308 | |
| 309 | #define EXT2_GOOD_OLD_INODE_SIZE 128 |
| 310 | |
| 311 | /* |
| 312 | * Feature set definitions |
| 313 | */ |
| 314 | |
| 315 | #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ |
| 316 | ( (sb).s_feature_compat & cpu_to_le32(mask) ) |
| 317 | #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ |
| 318 | ( (sb).s_feature_ro_compat & cpu_to_le32(mask) ) |
| 319 | #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ |
| 320 | ( (sb).s_feature_incompat & cpu_to_le32(mask) ) |
| 321 | #define EXT2_SET_COMPAT_FEATURE(sb,mask) \ |
| 322 | (sb).s_feature_compat |= cpu_to_le32(mask) |
| 323 | #define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \ |
| 324 | (sb).s_feature_ro_compat |= cpu_to_le32(mask) |
| 325 | #define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \ |
| 326 | (sb).s_feature_incompat |= cpu_to_le32(mask) |
| 327 | #define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \ |
| 328 | (sb).s_feature_compat &= ~cpu_to_le32(mask) |
| 329 | #define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ |
| 330 | (sb).s_feature_ro_compat &= ~cpu_to_le32(mask) |
| 331 | #define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ |
| 332 | (sb).s_feature_incompat &= ~cpu_to_le32(mask) |
| 333 | |
| 334 | #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 |
| 335 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 |
| 336 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 |
| 337 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 |
| 338 | #define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 |
| 339 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 |
| 340 | #define EXT2_FEATURE_COMPAT_ANY 0xffffffff |
| 341 | |
| 342 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
| 343 | #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 |
| 344 | #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 |
| 345 | #define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff |
| 346 | |
| 347 | #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 |
| 348 | #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 |
| 349 | #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 |
| 350 | #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 |
| 351 | #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 |
| 352 | #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff |
| 353 | |
| 354 | #define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR |
| 355 | #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ |
| 356 | EXT2_FEATURE_INCOMPAT_META_BG) |
| 357 | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ |
| 358 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ |
| 359 | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) |
| 360 | #define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP |
| 361 | #define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP |
| 362 | |
| 363 | /* |
| 364 | * Default values for user and/or group using reserved blocks |
| 365 | */ |
| 366 | #define EXT2_DEF_RESUID 0 |
| 367 | #define EXT2_DEF_RESGID 0 |
| 368 | |
| 369 | /* |
| 370 | * Default mount options |
| 371 | */ |
| 372 | #define EXT2_DEFM_DEBUG 0x0001 |
| 373 | #define EXT2_DEFM_BSDGROUPS 0x0002 |
| 374 | #define EXT2_DEFM_XATTR_USER 0x0004 |
| 375 | #define EXT2_DEFM_ACL 0x0008 |
| 376 | #define EXT2_DEFM_UID16 0x0010 |
| 377 | /* Not used by ext2, but reserved for use by ext3 */ |
| 378 | #define EXT3_DEFM_JMODE 0x0060 |
| 379 | #define EXT3_DEFM_JMODE_DATA 0x0020 |
| 380 | #define EXT3_DEFM_JMODE_ORDERED 0x0040 |
| 381 | #define EXT3_DEFM_JMODE_WBACK 0x0060 |
| 382 | |
| 383 | /* |
| 384 | * Structure of a directory entry |
| 385 | */ |
| 386 | #define EXT2_NAME_LEN 255 |
| 387 | |
| 388 | struct ext2_dir_entry { |
| 389 | uint32_t inode; /* Inode number */ |
| 390 | uint16_t rec_len; /* Directory entry length */ |
| 391 | uint16_t name_len; /* Name length */ |
| 392 | char name[EXT2_NAME_LEN]; /* File name */ |
| 393 | }; |
| 394 | |
| 395 | /* |
| 396 | * The new version of the directory entry. Since EXT2 structures are |
| 397 | * stored in intel byte order, and the name_len field could never be |
| 398 | * bigger than 255 chars, it's safe to reclaim the extra byte for the |
| 399 | * file_type field. |
| 400 | */ |
| 401 | struct ext2_dir_entry_2 { |
| 402 | uint32_t inode; /* Inode number */ |
| 403 | uint16_t rec_len; /* Directory entry length */ |
| 404 | uint8_t name_len; /* Name length */ |
| 405 | uint8_t file_type; |
| 406 | char name[EXT2_NAME_LEN]; /* File name */ |
| 407 | }; |
| 408 | |
| 409 | /* |
| 410 | * Ext2 directory file types. Only the low 3 bits are used. The |
| 411 | * other bits are reserved for now. |
| 412 | */ |
| 413 | enum { |
| 414 | EXT2_FT_UNKNOWN, |
| 415 | EXT2_FT_REG_FILE, |
| 416 | EXT2_FT_DIR, |
| 417 | EXT2_FT_CHRDEV, |
| 418 | EXT2_FT_BLKDEV, |
| 419 | EXT2_FT_FIFO, |
| 420 | EXT2_FT_SOCK, |
| 421 | EXT2_FT_SYMLINK, |
| 422 | EXT2_FT_MAX |
| 423 | }; |
| 424 | |
| 425 | /* |
| 426 | * EXT2_DIR_PAD defines the directory entries boundaries |
| 427 | * |
| 428 | * NOTE: It must be a multiple of 4 |
| 429 | */ |
| 430 | #define EXT2_DIR_PAD 4 |
| 431 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) |
| 432 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ |
| 433 | ~EXT2_DIR_ROUND) |
| 434 | |
| 435 | #endif /* _LINUX_EXT2_FS_H */ |