diff mbox series

libext2fs: fix ext2fs_open2() error for meta_bg image file

Message ID C26C67884C4B7A48980D57463559486403435BC6@BPXM20GP.gisp.nec.co.jp
State Accepted, archived
Headers show
Series libext2fs: fix ext2fs_open2() error for meta_bg image file | expand

Commit Message

Kazuya Mio March 14, 2018, 5:46 a.m. UTC
dumpe2fs/debugfs can examine the image file by using the -i option.
However, if meta_bg feature is enabled, dumpe2fs/debugfs cannot open
the image file.

$ dumpe2fs -i test.img
dumpe2fs: Attempt to read block from filesystem resulted in short read while trying to open test.img
Couldn't find valid filesystem superblock.

In case of specifying an image file, the location of block group descriptors
is the same as the case of default filesystem regardless of meta_bg feature.
So if EXT2_FLAG_IMAGE_FILE flag is set in ext2fs_open2(),
don't use the meta_bg handling.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
---
 lib/ext2fs/openfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Theodore Ts'o March 17, 2018, 7:14 p.m. UTC | #1
On Wed, Mar 14, 2018 at 05:46:29AM +0000, Kazuya Mio wrote:
> dumpe2fs/debugfs can examine the image file by using the -i option.
> However, if meta_bg feature is enabled, dumpe2fs/debugfs cannot open
> the image file.
> 
> $ dumpe2fs -i test.img
> dumpe2fs: Attempt to read block from filesystem resulted in short read while trying to open test.img
> Couldn't find valid filesystem superblock.
> 
> In case of specifying an image file, the location of block group descriptors
> is the same as the case of default filesystem regardless of meta_bg feature.
> So if EXT2_FLAG_IMAGE_FILE flag is set in ext2fs_open2(),
> don't use the meta_bg handling.
> 
> Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>

Applied, thanks!!

					- Ted
diff mbox series

Patch

diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 506c025..385d6e8 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -416,7 +416,8 @@  errcode_t ext2fs_open2(const char *name, const char *io_options,
 #ifdef WORDS_BIGENDIAN
 	groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
 #endif
-	if (ext2fs_has_feature_meta_bg(fs->super)) {
+	if (ext2fs_has_feature_meta_bg(fs->super) &&
+	    !(flags & EXT2_FLAG_IMAGE_FILE)) {
 		first_meta_bg = fs->super->s_first_meta_bg;
 		if (first_meta_bg > fs->desc_blocks)
 			first_meta_bg = fs->desc_blocks;