From 88b34b1f87c2d7c3dfc9be7ff6e5d916f06d960a Mon Sep 17 00:00:00 2001 From: "Jose R. Santos" Date: Mon, 13 Aug 2007 23:33:03 -0500 Subject: [PATCH] Relax group descriptor checking for FLEX_BG The FLEX_BG feature allows the inode table, block bitmap, and inode bitmaps to be located anywhere in the filesystem. Update e2fsck and libext2fs's checking code to recognize this. Signed-off-by: Jose R. Santos Signed-off-by: "Theodore Ts'o" -- e2fsck/super.c | 14 ++++++++++++-- lib/ext2fs/check_desc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) --- e2fsck/super.c | 10 +++++++--- lib/ext2fs/check_desc.c | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/e2fsck/super.c b/e2fsck/super.c index e3943cbe..dbd7b1ac 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -575,13 +575,17 @@ void check_super_block(e2fsck_t ctx) /* * Verify the group descriptors.... */ - first_block = sb->s_first_data_block; + first_block = sb->s_first_data_block; + last_block = sb->s_blocks_count-1; for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) { pctx.group = i; - first_block = ext2fs_group_first_block(fs, i); - last_block = ext2fs_group_last_block(fs, i); + if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super, + EXT4_FEATURE_INCOMPAT_FLEX_BG)) { + first_block = ext2fs_group_first_block(fs, i); + last_block = ext2fs_group_last_block(fs, i); + } if ((gd->bg_block_bitmap < first_block) || (gd->bg_block_bitmap > last_block)) { diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c index 146f9e59..900b1790 100644 --- a/lib/ext2fs/check_desc.c +++ b/lib/ext2fs/check_desc.c @@ -33,13 +33,16 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) { dgrp_t i; blk_t first_block = fs->super->s_first_data_block; - blk_t last_block; + blk_t last_block = fs->super->s_blocks_count-1; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); for (i = 0; i < fs->group_desc_count; i++) { - first_block = ext2fs_group_first_block(fs, i); - last_block = ext2fs_group_last_block(fs, i); + if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super, + EXT4_FEATURE_INCOMPAT_FLEX_BG)) { + first_block = ext2fs_group_first_block(fs, i); + last_block = ext2fs_group_last_block(fs, i); + } /* * Check to make sure block bitmap for group is -- 2.11.0