diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-06-21 16:50:46 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-06-21 16:50:46 +0200 |
commit | c9a13116a4497f4597ad5db6eb3cac9680fd6fc4 (patch) | |
tree | 7089fec95d805ae2678efa875aaf35608e7f9b8f | |
parent | 9ee426649006c4a0db7b4784f2ebb96865d4c705 (diff) | |
download | busybox-w32-c9a13116a4497f4597ad5db6eb3cac9680fd6fc4.tar.gz busybox-w32-c9a13116a4497f4597ad5db6eb3cac9680fd6fc4.tar.bz2 busybox-w32-c9a13116a4497f4597ad5db6eb3cac9680fd6fc4.zip |
mount: fix the wrongly stored fs creation time
This bug made our ext2 images non-mountable by ext4 driver.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/bb_e2fs_defs.h | 30 | ||||
-rwxr-xr-x | testsuite/mount.tests | 27 | ||||
-rw-r--r-- | util-linux/mkfs_ext2.c | 11 |
3 files changed, 54 insertions, 14 deletions
diff --git a/include/bb_e2fs_defs.h b/include/bb_e2fs_defs.h index 071c660c5..b400f8c11 100644 --- a/include/bb_e2fs_defs.h +++ b/include/bb_e2fs_defs.h | |||
@@ -406,25 +406,43 @@ struct ext2_super_block { | |||
406 | * Performance hints. Directory preallocation should only | 406 | * Performance hints. Directory preallocation should only |
407 | * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. | 407 | * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. |
408 | */ | 408 | */ |
409 | uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ | 409 | uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ |
410 | uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ | 410 | uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ |
411 | uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */ | 411 | uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */ |
412 | /* | 412 | /* |
413 | * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. | 413 | * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. |
414 | */ | 414 | */ |
415 | uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ | 415 | /*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ |
416 | uint32_t s_journal_inum; /* inode number of journal file */ | 416 | /*E0*/ uint32_t s_journal_inum; /* inode number of journal file */ |
417 | uint32_t s_journal_dev; /* device number of journal file */ | 417 | uint32_t s_journal_dev; /* device number of journal file */ |
418 | uint32_t s_last_orphan; /* start of list of inodes to delete */ | 418 | uint32_t s_last_orphan; /* start of list of inodes to delete */ |
419 | uint32_t s_hash_seed[4]; /* HTREE hash seed */ | 419 | uint32_t s_hash_seed[4]; /* HTREE hash seed */ |
420 | uint8_t s_def_hash_version; /* Default hash version to use */ | 420 | uint8_t s_def_hash_version; /* Default hash version to use */ |
421 | uint8_t s_jnl_backup_type; /* Default type of journal backup */ | 421 | uint8_t s_jnl_backup_type; /* Default type of journal backup */ |
422 | uint16_t s_reserved_word_pad; | 422 | uint16_t s_reserved_word_pad; |
423 | uint32_t s_default_mount_opts; | 423 | /*100*/ uint32_t s_default_mount_opts; |
424 | uint32_t s_first_meta_bg; /* First metablock group */ | 424 | uint32_t s_first_meta_bg; /* First metablock group */ |
425 | /* ext3 additions */ | ||
425 | uint32_t s_mkfs_time; /* When the filesystem was created */ | 426 | uint32_t s_mkfs_time; /* When the filesystem was created */ |
426 | uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */ | 427 | uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */ |
427 | uint32_t s_reserved[172]; /* Padding to the end of the block */ | 428 | /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */ |
429 | /*150*/ uint32_t s_blocks_count_hi; /* Blocks count */ | ||
430 | uint32_t s_r_blocks_count_hi; /* Reserved blocks count */ | ||
431 | uint32_t s_free_blocks_count_hi; /* Free blocks count */ | ||
432 | uint16_t s_min_extra_isize; /* All inodes have at least # bytes */ | ||
433 | uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */ | ||
434 | uint32_t s_flags; /* Miscellaneous flags */ | ||
435 | uint16_t s_raid_stride; /* RAID stride */ | ||
436 | uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */ | ||
437 | uint64_t s_mmp_block; /* Block for multi-mount protection */ | ||
438 | uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ | ||
439 | uint8_t s_log_groups_per_flex; /* FLEX_BG group size */ | ||
440 | uint8_t s_reserved_char_pad2; | ||
441 | uint16_t s_reserved_pad; | ||
442 | uint32_t s_reserved[162]; /* Padding to the end of the block */ | ||
443 | }; | ||
444 | struct BUG_ext2_super_block { | ||
445 | char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1]; | ||
428 | }; | 446 | }; |
429 | 447 | ||
430 | /* | 448 | /* |
diff --git a/testsuite/mount.tests b/testsuite/mount.tests index c5891be83..a0bc50888 100755 --- a/testsuite/mount.tests +++ b/testsuite/mount.tests | |||
@@ -36,7 +36,8 @@ testing "mount -o remount,mand" \ | |||
36 | "mount -o loop mount.image1m $testdir "\ | 36 | "mount -o loop mount.image1m $testdir "\ |
37 | "&& grep -Fc $testdir </proc/mounts "\ | 37 | "&& grep -Fc $testdir </proc/mounts "\ |
38 | "&& mount -o remount,mand $testdir "\ | 38 | "&& mount -o remount,mand $testdir "\ |
39 | "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \ | 39 | "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\ |
40 | "|| grep -F $testdir </proc/mounts" \ | ||
40 | "1\n""1\n" \ | 41 | "1\n""1\n" \ |
41 | "" "" | 42 | "" "" |
42 | 43 | ||
@@ -83,4 +84,28 @@ b | |||
83 | "" "" | 84 | "" "" |
84 | SKIP= | 85 | SKIP= |
85 | 86 | ||
87 | |||
88 | testing "mount RO loop" "\ | ||
89 | exec 2>&1 | ||
90 | umount -d mount.dir 2>/dev/null | ||
91 | rmdir mount.dir 2>/dev/null | ||
92 | mkdir -p mount.dir | ||
93 | ( | ||
94 | cd mount.dir || { echo 'cd error'; exit 1; } | ||
95 | mkdir z1 z2 || { echo 'mkdir error'; exit 1; } | ||
96 | mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; } | ||
97 | dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; } | ||
98 | mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; } | ||
99 | mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; } | ||
100 | mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; } | ||
101 | ) | ||
102 | umount -d mount.dir/z2 | ||
103 | ##losetup -d /dev/loop* | ||
104 | umount -d mount.dir/z1 | ||
105 | rm -rf mount.dir | ||
106 | echo DONE | ||
107 | " \ | ||
108 | "DONE\n" "" "" | ||
109 | |||
110 | |||
86 | exit $FAILCOUNT | 111 | exit $FAILCOUNT |
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 69b25c946..3258d7eee 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c | |||
@@ -53,11 +53,6 @@ | |||
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 |
55 | 55 | ||
56 | // from e2fsprogs | ||
57 | #define s_reserved_gdt_blocks s_padding1 | ||
58 | #define s_mkfs_time s_reserved[0] | ||
59 | #define s_flags s_reserved[22] | ||
60 | |||
61 | #define EXT2_HASH_HALF_MD4 1 | 56 | #define EXT2_HASH_HALF_MD4 1 |
62 | #define EXT2_FLAGS_SIGNED_HASH 0x0001 | 57 | #define EXT2_FLAGS_SIGNED_HASH 0x0001 |
63 | #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 | 58 | #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 |
@@ -482,8 +477,10 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) | |||
482 | STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC); | 477 | STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC); |
483 | STORE_LE(sb->s_inode_size, inodesize); | 478 | STORE_LE(sb->s_inode_size, inodesize); |
484 | // set "Required extra isize" and "Desired extra isize" fields to 28 | 479 | // set "Required extra isize" and "Desired extra isize" fields to 28 |
485 | if (inodesize != sizeof(*inode)) | 480 | if (inodesize != sizeof(*inode)) { |
486 | STORE_LE(sb->s_reserved[21], 0x001C001C); | 481 | STORE_LE(sb->s_min_extra_isize, 0x001c); |
482 | STORE_LE(sb->s_want_extra_isize, 0x001c); | ||
483 | } | ||
487 | STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO); | 484 | STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO); |
488 | STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); | 485 | STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); |
489 | STORE_LE(sb->s_log_frag_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); | 486 | STORE_LE(sb->s_log_frag_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); |