Whamcloud - gitweb
libext2fs: teach ext2fs_flush() to check if group descriptors are loaded
authorTheodore Ts'o <tytso@mit.edu>
Thu, 16 Jan 2020 23:56:49 +0000 (18:56 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Jan 2020 00:47:54 +0000 (19:47 -0500)
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 <tytso@mit.edu>
lib/ext2fs/closefs.c

index 1d4d5b7..6814cdc 100644 (file)
@@ -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;