diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-17 15:06:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-17 15:06:55 +0200 |
commit | 176bc344751dfc41e87976182381ae0560c94f22 (patch) | |
tree | 4fceb4c364f3dbabd43724d9352969a3df36e2a5 | |
parent | 86a03bee1d3d6990c03bf500836b19ec8a1c1f12 (diff) | |
download | busybox-w32-176bc344751dfc41e87976182381ae0560c94f22.tar.gz busybox-w32-176bc344751dfc41e87976182381ae0560c94f22.tar.bz2 busybox-w32-176bc344751dfc41e87976182381ae0560c94f22.zip |
Drop include/bb_linux_ext2_fs.h, use existing e2fsprogs/e2fs_defs.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | e2fsprogs/e2fs_lib.h | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/e2fsck.c | 6 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/e2p/feature.c | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/initialize.c | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/mke2fs.c | 8 | ||||
-rw-r--r-- | e2fsprogs/tune2fs.c | 2 | ||||
-rw-r--r-- | include/bb_e2fs_defs.h (renamed from e2fsprogs/e2fs_defs.h) | 2 | ||||
-rw-r--r-- | include/bb_linux_ext2_fs.h | 547 | ||||
-rw-r--r-- | util-linux/mkfs_ext2.c | 2 |
11 files changed, 15 insertions, 562 deletions
diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h index 3905ee71d..f2ae56f43 100644 --- a/e2fsprogs/e2fs_lib.h +++ b/e2fsprogs/e2fs_lib.h | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* Constants and structures */ | 9 | /* Constants and structures */ |
10 | #include "e2fs_defs.h" | 10 | #include "bb_e2fs_defs.h" |
11 | 11 | ||
12 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | 12 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
13 | 13 | ||
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 8fffa7f20..373e8ce91 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c | |||
@@ -11577,7 +11577,7 @@ static void check_resize_inode(e2fsck_t ctx) | |||
11577 | * s_reserved_gdt_blocks must be zero. | 11577 | * s_reserved_gdt_blocks must be zero. |
11578 | */ | 11578 | */ |
11579 | if (!(fs->super->s_feature_compat & | 11579 | if (!(fs->super->s_feature_compat & |
11580 | EXT2_FEATURE_COMPAT_RESIZE_INODE)) { | 11580 | EXT2_FEATURE_COMPAT_RESIZE_INO)) { |
11581 | if (fs->super->s_reserved_gdt_blocks) { | 11581 | if (fs->super->s_reserved_gdt_blocks) { |
11582 | pctx.num = fs->super->s_reserved_gdt_blocks; | 11582 | pctx.num = fs->super->s_reserved_gdt_blocks; |
11583 | if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS, | 11583 | if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS, |
@@ -11593,7 +11593,7 @@ static void check_resize_inode(e2fsck_t ctx) | |||
11593 | retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); | 11593 | retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); |
11594 | if (retval) { | 11594 | if (retval) { |
11595 | if (fs->super->s_feature_compat & | 11595 | if (fs->super->s_feature_compat & |
11596 | EXT2_FEATURE_COMPAT_RESIZE_INODE) | 11596 | EXT2_FEATURE_COMPAT_RESIZE_INO) |
11597 | ctx->flags |= E2F_FLAG_RESIZE_INODE; | 11597 | ctx->flags |= E2F_FLAG_RESIZE_INODE; |
11598 | return; | 11598 | return; |
11599 | } | 11599 | } |
@@ -11603,7 +11603,7 @@ static void check_resize_inode(e2fsck_t ctx) | |||
11603 | * the resize inode is cleared; then we're done. | 11603 | * the resize inode is cleared; then we're done. |
11604 | */ | 11604 | */ |
11605 | if (!(fs->super->s_feature_compat & | 11605 | if (!(fs->super->s_feature_compat & |
11606 | EXT2_FEATURE_COMPAT_RESIZE_INODE)) { | 11606 | EXT2_FEATURE_COMPAT_RESIZE_INO)) { |
11607 | for (i=0; i < EXT2_N_BLOCKS; i++) { | 11607 | for (i=0; i < EXT2_N_BLOCKS; i++) { |
11608 | if (inode.i_block[i]) | 11608 | if (inode.i_block[i]) |
11609 | break; | 11609 | break; |
diff --git a/e2fsprogs/old_e2fsprogs/e2p/feature.c b/e2fsprogs/old_e2fsprogs/e2p/feature.c index b45754f97..2102ed8e7 100644 --- a/e2fsprogs/old_e2fsprogs/e2p/feature.c +++ b/e2fsprogs/old_e2fsprogs/e2p/feature.c | |||
@@ -34,7 +34,7 @@ static const struct feature feature_list[] = { | |||
34 | "ext_attr" }, | 34 | "ext_attr" }, |
35 | { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX, | 35 | { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX, |
36 | "dir_index" }, | 36 | "dir_index" }, |
37 | { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE, | 37 | { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INO, |
38 | "resize_inode" }, | 38 | "resize_inode" }, |
39 | { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER, | 39 | { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER, |
40 | "sparse_super" }, | 40 | "sparse_super" }, |
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h index 6f4f70862..80ea2cbdd 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h | |||
@@ -475,7 +475,7 @@ struct ext2_super_block { | |||
475 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 | 475 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 |
476 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 | 476 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 |
477 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 | 477 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 |
478 | #define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 | 478 | #define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 |
479 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 | 479 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 |
480 | 480 | ||
481 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 | 481 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h index 9f772016f..39fb11620 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h | |||
@@ -383,7 +383,7 @@ typedef struct ext2_icount *ext2_icount_t; | |||
383 | #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ | 383 | #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ |
384 | EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ | 384 | EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ |
385 | EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ | 385 | EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ |
386 | EXT2_FEATURE_COMPAT_RESIZE_INODE|\ | 386 | EXT2_FEATURE_COMPAT_RESIZE_INO|\ |
387 | EXT2_FEATURE_COMPAT_DIR_INDEX|\ | 387 | EXT2_FEATURE_COMPAT_DIR_INDEX|\ |
388 | EXT2_FEATURE_COMPAT_EXT_ATTR) | 388 | EXT2_FEATURE_COMPAT_EXT_ATTR) |
389 | 389 | ||
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c index ef1d34379..da2d15137 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c +++ b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c | |||
@@ -284,7 +284,7 @@ retry: | |||
284 | /* | 284 | /* |
285 | * check the number of reserved group descriptor table blocks | 285 | * check the number of reserved group descriptor table blocks |
286 | */ | 286 | */ |
287 | if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) | 287 | if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) |
288 | rsv_gdt = calc_reserved_gdt_blocks(fs); | 288 | rsv_gdt = calc_reserved_gdt_blocks(fs); |
289 | else | 289 | else |
290 | rsv_gdt = 0; | 290 | rsv_gdt = 0; |
diff --git a/e2fsprogs/old_e2fsprogs/mke2fs.c b/e2fsprogs/old_e2fsprogs/mke2fs.c index 7555650a2..35d717a55 100644 --- a/e2fsprogs/old_e2fsprogs/mke2fs.c +++ b/e2fsprogs/old_e2fsprogs/mke2fs.c | |||
@@ -757,7 +757,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param, | |||
757 | 757 | ||
758 | if (rsv_gdb > 0) { | 758 | if (rsv_gdb > 0) { |
759 | sb_param->s_feature_compat |= | 759 | sb_param->s_feature_compat |= |
760 | EXT2_FEATURE_COMPAT_RESIZE_INODE; | 760 | EXT2_FEATURE_COMPAT_RESIZE_INO; |
761 | 761 | ||
762 | sb_param->s_reserved_gdt_blocks = rsv_gdb; | 762 | sb_param->s_reserved_gdt_blocks = rsv_gdb; |
763 | } | 763 | } |
@@ -778,7 +778,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param, | |||
778 | 778 | ||
779 | static __u32 ok_features[3] = { | 779 | static __u32 ok_features[3] = { |
780 | EXT3_FEATURE_COMPAT_HAS_JOURNAL | | 780 | EXT3_FEATURE_COMPAT_HAS_JOURNAL | |
781 | EXT2_FEATURE_COMPAT_RESIZE_INODE | | 781 | EXT2_FEATURE_COMPAT_RESIZE_INO | |
782 | EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */ | 782 | EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */ |
783 | EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */ | 783 | EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */ |
784 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV| | 784 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV| |
@@ -1123,7 +1123,7 @@ static int PRS(int argc, char **argv) | |||
1123 | /* Since sparse_super is the default, we would only have a problem | 1123 | /* Since sparse_super is the default, we would only have a problem |
1124 | * here if it was explicitly disabled. | 1124 | * here if it was explicitly disabled. |
1125 | */ | 1125 | */ |
1126 | if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) && | 1126 | if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) && |
1127 | !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) { | 1127 | !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) { |
1128 | bb_error_msg_and_die("reserved online resize blocks not supported " | 1128 | bb_error_msg_and_die("reserved online resize blocks not supported " |
1129 | "on non-sparse filesystem"); | 1129 | "on non-sparse filesystem"); |
@@ -1312,7 +1312,7 @@ int mke2fs_main (int argc, char **argv) | |||
1312 | reserve_inodes(fs); | 1312 | reserve_inodes(fs); |
1313 | create_bad_block_inode(fs, bb_list); | 1313 | create_bad_block_inode(fs, bb_list); |
1314 | if (fs->super->s_feature_compat & | 1314 | if (fs->super->s_feature_compat & |
1315 | EXT2_FEATURE_COMPAT_RESIZE_INODE) { | 1315 | EXT2_FEATURE_COMPAT_RESIZE_INO) { |
1316 | retval = ext2fs_create_resize_inode(fs); | 1316 | retval = ext2fs_create_resize_inode(fs); |
1317 | mke2fs_error_msg_and_die(retval, "reserve blocks for online resize"); | 1317 | mke2fs_error_msg_and_die(retval, "reserve blocks for online resize"); |
1318 | } | 1318 | } |
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 841d58a9c..46a745ee4 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include "bb_linux_ext2_fs.h" | 11 | #include "bb_e2fs_defs.h" |
12 | 12 | ||
13 | // storage helpers | 13 | // storage helpers |
14 | char BUG_wrong_field_size(void); | 14 | char BUG_wrong_field_size(void); |
diff --git a/e2fsprogs/e2fs_defs.h b/include/bb_e2fs_defs.h index 379640eb8..7974497ca 100644 --- a/e2fsprogs/e2fs_defs.h +++ b/include/bb_e2fs_defs.h | |||
@@ -467,7 +467,7 @@ struct ext2_super_block { | |||
467 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 | 467 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 |
468 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 | 468 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 |
469 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 | 469 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 |
470 | #define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 | 470 | #define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 |
471 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 | 471 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 |
472 | 472 | ||
473 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 | 473 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
diff --git a/include/bb_linux_ext2_fs.h b/include/bb_linux_ext2_fs.h deleted file mode 100644 index fdc470bc2..000000000 --- a/include/bb_linux_ext2_fs.h +++ /dev/null | |||
@@ -1,547 +0,0 @@ | |||
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 | ||
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 2d9d72000..69b25c946 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c | |||
@@ -48,7 +48,7 @@ | |||
48 | 48 | ||
49 | #include "libbb.h" | 49 | #include "libbb.h" |
50 | #include <linux/fs.h> | 50 | #include <linux/fs.h> |
51 | #include "bb_linux_ext2_fs.h" | 51 | #include "bb_e2fs_defs.h" |
52 | 52 | ||
53 | #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0 | 53 | #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0 |
54 | #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1 | 54 | #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1 |