]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: recheck support after replaying journal
authorDarrick J. Wong <djwong@kernel.org>
Thu, 28 Aug 2025 17:30:43 +0000 (10:30 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 17 Oct 2025 23:34:22 +0000 (16:34 -0700)
The journal could have contained a new primary superblock, so we need to
recheck feature support after recovering it, because otherwise fuse2fs
could blow up on an unsupported feature that was enabled by a journal
transaction.

We also don't need to clear needsrecovery or dirty the superblock after
recovering the journal because ext2fs_run_ext3_journal does that for us.
Remove those lines.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
misc/fuse2fs.c

index e33b09de08a11fcee975e5ec7d00076d2d09cc1e..931e60f61e85b6c03ce0543065c1373b09177279 100644 (file)
@@ -744,6 +744,36 @@ static int check_inum_access(struct fuse2fs *ff, ext2_ino_t ino, int mask)
        return -EACCES;
 }
 
+static errcode_t fuse2fs_check_support(struct fuse2fs *ff)
+{
+       ext2_filsys fs = ff->fs;
+
+       if (ext2fs_has_feature_quota(fs->super)) {
+               err_printf(ff, "%s\n", _("quotas not supported."));
+               return EXT2_ET_UNSUPP_FEATURE;
+       }
+       if (ext2fs_has_feature_verity(fs->super)) {
+               err_printf(ff, "%s\n", _("verity not supported."));
+               return EXT2_ET_UNSUPP_FEATURE;
+       }
+       if (ext2fs_has_feature_encrypt(fs->super)) {
+               err_printf(ff, "%s\n", _("encryption not supported."));
+               return EXT2_ET_UNSUPP_FEATURE;
+       }
+       if (ext2fs_has_feature_casefold(fs->super)) {
+               err_printf(ff, "%s\n", _("casefolding not supported."));
+               return EXT2_ET_UNSUPP_FEATURE;
+       }
+
+       if (fs->super->s_state & EXT2_ERROR_FS) {
+               err_printf(ff, "%s\n",
+ _("Errors detected; running e2fsck is required."));
+               return EXT2_ET_FILESYSTEM_CORRUPTED;
+       }
+
+       return 0;
+}
+
 static void op_destroy(void *p EXT2FS_ATTR((unused)))
 {
        struct fuse_context *ctxt = fuse_get_context();
@@ -4771,29 +4801,9 @@ int main(int argc, char *argv[])
        }
 
        ret = 3;
-
-       if (ext2fs_has_feature_quota(global_fs->super)) {
-               err_printf(&fctx, "%s", _("quotas not supported."));
-               goto out;
-       }
-       if (ext2fs_has_feature_verity(global_fs->super)) {
-               err_printf(&fctx, "%s", _("verity not supported."));
-               goto out;
-       }
-       if (ext2fs_has_feature_encrypt(global_fs->super)) {
-               err_printf(&fctx, "%s", _("encryption not supported."));
-               goto out;
-       }
-       if (ext2fs_has_feature_casefold(global_fs->super)) {
-               err_printf(&fctx, "%s", _("casefolding not supported."));
-               goto out;
-       }
-
-       if (global_fs->super->s_state & EXT2_ERROR_FS) {
-               err_printf(&fctx, "%s\n",
- _("Errors detected; running e2fsck is required."));
+       err = fuse2fs_check_support(&fctx);
+       if (err)
                goto out;
-       }
 
        /*
         * ext4 can't do COW of shared blocks, so if the feature is enabled,
@@ -4817,8 +4827,10 @@ int main(int argc, char *argv[])
                                                _("Please run e2fsck -fy."));
                                goto out;
                        }
-                       ext2fs_clear_feature_journal_needs_recovery(global_fs->super);
-                       ext2fs_mark_super_dirty(global_fs);
+
+                       err = fuse2fs_check_support(&fctx);
+                       if (err)
+                               goto out;
                }
        } else if (ext2fs_has_feature_journal(global_fs->super)) {
                err = ext2fs_check_ext3_journal(global_fs);