fsck.f2fs: allow to fsck readonly image w/ -f option
authorChao Yu <yuchao0@huawei.com>
Mon, 26 Nov 2018 10:53:37 +0000 (18:53 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 27 Nov 2018 00:40:39 +0000 (16:40 -0800)
To keep line with e2fsprogs, let's allow to fsck mounted image as
readonly w/ -f option.

Reported-by: Perfect Gentleman <perfect007gentleman@gmail.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/main.c
include/f2fs_fs.h
lib/libf2fs.c

index 675c603..bb79f6e 100644 (file)
@@ -249,6 +249,7 @@ void f2fs_parse_options(int argc, char *argv[])
                        case 'f':
                        case 'y':
                                c.fix_on = 1;
+                               c.force = 1;
                                MSG(0, "Info: Force to fix corruption\n");
                                break;
                        case 'q':
index 65cc8fd..6eebb3a 100644 (file)
@@ -369,6 +369,7 @@ struct f2fs_configuration {
        void *private;
        int dry_run;
        int fix_on;
+       int force;
        int defset;
        int bug_on;
        int alloc_failed;
index a0079ad..c692bf2 100644 (file)
@@ -825,7 +825,7 @@ int get_device_info(int i)
                        return -1;
                }
 
-               if (S_ISBLK(stat_buf->st_mode))
+               if (S_ISBLK(stat_buf->st_mode) && !c.force)
                        fd = open(dev->path, O_RDWR | O_EXCL);
                else
                        fd = open(dev->path, O_RDWR);