From: Theodore Ts'o Date: Thu, 16 Jan 2020 23:56:49 +0000 (-0500) Subject: libext2fs: teach ext2fs_flush() to check if group descriptors are loaded X-Git-Tag: v1.46.0~80 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=c8651b4bf6b31c975d92c4c056b8a1bc25a41f9e;p=tools%2Fe2fsprogs.git libext2fs: teach ext2fs_flush() to check if group descriptors are loaded If the EXT2_FLAG_SUPER_ONLY is not set, and the group descriptors are not loaded, ext2fs_flush[2]() will return EXT2_ET_NO_GDESC. Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 1d4d5b7..6814cdc 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -293,6 +293,11 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags) EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if ((fs->flags & EXT2_FLAG_SUPER_ONLY) == 0 && + !ext2fs_has_feature_journal_dev(fs->super) && + fs->group_desc == NULL) + return EXT2_ET_NO_GDESC; + fs_state = fs->super->s_state; feature_incompat = fs->super->s_feature_incompat;