[09/10] ext2fs: Don't check s_inodes_count with EXT2_FLAG_IGNORE_SB_ERRORS

Message ID 20180612095328.5215-10-jack@suse.cz
State Accepted, archived
Headers show
Series
  • e2fsprogs: Handle s_inodes_count overflow better
Related show

Commit Message

Jan Kara June 12, 2018, 9:53 a.m.
Don't verify s_inodes_count is correct with EXT2_FLAG_IGNORE_SB_ERRORS
flag set. This allows e2fsck and debugfs to fix this value.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 lib/ext2fs/openfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Theodore Y. Ts'o June 19, 2018, 3:33 p.m. | #1
On Tue, Jun 12, 2018 at 11:53:27AM +0200, Jan Kara wrote:
> Don't verify s_inodes_count is correct with EXT2_FLAG_IGNORE_SB_ERRORS
> flag set. This allows e2fsck and debugfs to fix this value.
> 
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> Signed-off-by: Jan Kara <jack@suse.cz>

Applied, thanks.

				- Ted

Patch

diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index e9ad0cd1a2c6..d046b2517505 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -386,7 +386,8 @@  errcode_t ext2fs_open2(const char *name, const char *io_options,
 		goto cleanup;
 	}
 	fs->group_desc_count = 	groups_cnt;
-	if ((__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
+	if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
+	    (__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
 	    fs->super->s_inodes_count) {
 		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
 		goto cleanup;