]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: add a norecovery option which suppresses journal replay
authorTheodore Ts'o <tytso@mit.edu>
Mon, 19 Aug 2019 00:25:53 +0000 (20:25 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 19 Aug 2019 00:25:53 +0000 (20:25 -0400)
Teach fuse2fs the "-o norecovery" option, which will suppress any
journal replay that might be necessary, and mounts the file system
read-only.

Addresses-Debian-Bug: #878927

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.1.in
misc/fuse2fs.c

index 3bc7ada3b30781daf39e0deb129ea7ea82a3eff0..1a0c9d54f5893a9a71b3a269fba926002e07ce64 100644 (file)
@@ -48,6 +48,9 @@ pretend to be root for permission checks
 \fB-o\fR no_default_opts
 do not include default fuse options
 .TP
+\fB-o\fR norecovery
+do not replay the journal and mount the file system read-only
+.TP
 \fB-o\fR fuse2fs_debug
 enable fuse2fs debugging
 .SS "FUSE options:"
index be2cd1dbd752cebea420ad4882762e01f697c72c..dc7a03920d520e60d386928c1752fc5ee5459310 100644 (file)
@@ -324,6 +324,7 @@ struct fuse2fs {
        int minixdf;
        int fakeroot;
        int alloc_all_blocks;
+       int norecovery;
        FILE *err_fp;
        unsigned int next_generation;
 };
@@ -3662,6 +3663,7 @@ static struct fuse_opt fuse2fs_opts[] = {
        FUSE2FS_OPT("fakeroot",         fakeroot,               1),
        FUSE2FS_OPT("fuse2fs_debug",    debug,                  1),
        FUSE2FS_OPT("no_default_opts",  no_default_opts,        1),
+       FUSE2FS_OPT("norecovery",       norecovery,             1),
 
        FUSE_OPT_KEY("-V",             FUSE2FS_VERSION),
        FUSE_OPT_KEY("--version",      FUSE2FS_VERSION),
@@ -3700,6 +3702,7 @@ static int fuse2fs_opt_proc(void *data, const char *arg,
        "    -o minixdf             minix-style df\n"
        "    -o fakeroot            pretend to be root for permission checks\n"
        "    -o no_default_opts     do not include default fuse options\n"
+       "    -o norecovery          don't replay the journal (implies ro)\n"
        "    -o fuse2fs_debug       enable fuse2fs debugging\n"
        "\n",
                        outargs->argv[0]);
@@ -3741,6 +3744,8 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
+       if (fctx.norecovery)
+               fctx.ro = 1;
        if (fctx.ro)
                printf("%s", _("Mounting read-only.\n"));
 
@@ -3788,7 +3793,11 @@ int main(int argc, char *argv[])
        ret = 3;
 
        if (ext2fs_has_feature_journal_needs_recovery(global_fs->super)) {
-               if (!fctx.ro) {
+               if (fctx.norecovery) {
+                       printf(_("%s: mounting read-only without "
+                                "recovering journal\n"),
+                              fctx.device);
+               } else if (!fctx.ro) {
                        printf(_("%s: recovering journal\n"), fctx.device);
                        err = ext2fs_run_ext3_journal(&global_fs);
                        if (err) {