Control: tags -1 +pending

On Wed, Oct 18, 2017 at 10:31:31AM -0400, Theodore Ts'o wrote:
> On Tue, Oct 17, 2017 at 01:56:32PM -0400, Michael Stone wrote:
> > I'd like the fuse2fs package to gain the norecovery option so that read-only
> > sources with dirty journals can be mounted via fuse. This seems fairly
> > straightforward, and I could prepare a patch if desired, but was curious if 
> > not
> > having that option was a conscious decision.

This will be in the next feature release of e2fsprogs (1.46).

                                         - Ted

commit 75e3a9ef4c7a638b91b26dfbfcfc43e5770e9aa2
Author: Theodore Ts'o <ty...@mit.edu>
Date:   Sun Aug 18 20:25:53 2019 -0400

    fuse2fs: add a norecovery option which suppresses journal replay
    
    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 <ty...@mit.edu>

diff --git a/misc/fuse2fs.1.in b/misc/fuse2fs.1.in
index 3bc7ada3..1a0c9d54 100644
--- a/misc/fuse2fs.1.in
+++ b/misc/fuse2fs.1.in
@@ -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:"
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index be2cd1db..dc7a0392 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -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) {

Reply via email to