Blame SOURCES/e2fsprogs-1.42.9-14-libext2fs-fix-ext2fs_open2-error-for-meta_bg-image-f.patch

98901c
From fc9ed72f64b0e6689eaed1faa33e3a333b995bf7 Mon Sep 17 00:00:00 2001
98901c
From: Kazuya Mio <k-mio@sx.jp.nec.com>
98901c
Date: Sat, 17 Mar 2018 14:56:15 -0400
98901c
Subject: [PATCH 05/16] libext2fs: fix ext2fs_open2() error for meta_bg image
98901c
 file
98901c
98901c
commit 8b061a641dff1a0becf645f8e6002de79b997b95
98901c
98901c
dumpe2fs/debugfs can examine the image file by using the -i option.
98901c
However, if meta_bg feature is enabled, dumpe2fs/debugfs cannot open
98901c
the image file.
98901c
98901c
$ dumpe2fs -i test.img
98901c
dumpe2fs: Attempt to read block from filesystem resulted in short read while trying to open test.img
98901c
Couldn't find valid filesystem superblock.
98901c
98901c
In case of specifying an image file, the location of block group descriptors
98901c
is the same as the case of default filesystem regardless of meta_bg feature.
98901c
So if EXT2_FLAG_IMAGE_FILE flag is set in ext2fs_open2(),
98901c
don't use the meta_bg handling.
98901c
98901c
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
98901c
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
98901c
---
98901c
 lib/ext2fs/openfs.c | 3 ++-
98901c
 1 file changed, 2 insertions(+), 1 deletion(-)
98901c
98901c
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
98901c
index ba501e6a..200f7815 100644
98901c
--- a/lib/ext2fs/openfs.c
98901c
+++ b/lib/ext2fs/openfs.c
98901c
@@ -378,7 +378,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
98901c
 #ifdef WORDS_BIGENDIAN
98901c
 	groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
98901c
 #endif
98901c
-	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
98901c
+	if ((fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
98901c
+	    !(flags & EXT2_FLAG_IMAGE_FILE)) {
98901c
 		first_meta_bg = fs->super->s_first_meta_bg;
98901c
 		if (first_meta_bg > fs->desc_blocks)
98901c
 			first_meta_bg = fs->desc_blocks;
98901c
-- 
98901c
2.20.1
98901c