]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mmp: fix 64-bit handling of s_mmp_block
authorAndreas Dilger <adilger@dilger.ca>
Wed, 4 Dec 2013 01:02:12 +0000 (20:02 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 4 Dec 2013 01:22:16 +0000 (20:22 -0500)
Fix the checking of s_mmp_block in e2fsck_pass1() and
ext2fs_mmp_read() to handle the high 32 bits of s_blocks_count.
Remove redundant check of s_mmp_block in do_dump_mmp() right before
ext2fs_mmp_read() is called.

Also fix s_blocks_count_hi in check_backup_super_block(), since it
cannot use the ext2fs_blocks_count() helper easily.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/debugfs.c
e2fsck/pass1.c
e2fsck/super.c
lib/ext2fs/mmp.c

index 55902951ba30994c0f9a8ef74bb6a8ac0953cf55..b2406c74d6b0f90880980f2f113046f323ab3fd9 100644 (file)
@@ -2312,11 +2312,6 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
                return;
 
        sb  = current_fs->super;
-       if (sb->s_mmp_block <= sb->s_first_data_block ||
-           sb->s_mmp_block >= ext2fs_blocks_count(sb)) {
-               com_err(argv[0], EXT2_ET_MMP_BAD_BLOCK, "while dumping it.\n");
-               return;
-       }
 
        if (current_fs->mmp_buf == NULL) {
                retval = ext2fs_get_mem(current_fs->blocksize,
index a8534134644f64c98b458173b36a04eec7640abd..20157fa07ad6b4b42dacd0b741b344abb34211d3 100644 (file)
@@ -716,8 +716,8 @@ void e2fsck_pass1(e2fsck_t ctx)
                busted_fs_time = 1;
 
        if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
-           !(fs->super->s_mmp_block <= fs->super->s_first_data_block ||
-             fs->super->s_mmp_block >= fs->super->s_blocks_count))
+           fs->super->s_mmp_block > fs->super->s_first_data_block &&
+           fs->super->s_mmp_block < ext2fs_blocks_count(fs->super))
                ext2fs_mark_block_bitmap2(ctx->block_found_map,
                                          fs->super->s_mmp_block);
 
index ce824f4640cbb6aea3a6992957a138b524f578b9..56a338144b44f393d379d9c814122773c480cf89 100644 (file)
@@ -956,6 +956,7 @@ int check_backup_super_block(e2fsck_t ctx)
                    SUPER_INCOMPAT_DIFFERENT(s_feature_incompat) ||
                    SUPER_RO_COMPAT_DIFFERENT(s_feature_ro_compat) ||
                    SUPER_DIFFERENT(s_blocks_count) ||
+                   SUPER_DIFFERENT(s_blocks_count_hi) ||
                    SUPER_DIFFERENT(s_inodes_count) ||
                    memcmp(fs->super->s_uuid, backup_sb->s_uuid,
                           sizeof(fs->super->s_uuid)))
index 98562e789ea327bf2c6821febc6c8571c19db475..fb266d1df9d021a3f2e8e90e57f1914d016577f1 100644 (file)
@@ -37,7 +37,7 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
        errcode_t retval = 0;
 
        if ((mmp_blk <= fs->super->s_first_data_block) ||
-           (mmp_blk >= fs->super->s_blocks_count))
+           (mmp_blk >= ext2fs_blocks_count(fs->super)))
                return EXT2_ET_MMP_BAD_BLOCK;
 
        /* ext2fs_open() reserves fd0,1,2 to avoid stdio collision, so checking