Skip to contentSkip to conversation

fsck.f2fs: allow to fsck readonly image w/ -f option

PATCH New Chao Yu 1 participant 1 message Nov 26, 2018 Library code

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 fsck.f2fs: allow to fsck readonly image w/ -f option

To keep line with e2fsprogs, let's allow to fsck mounted image as readonly w/ -f option.

---
 fsck/main.c       | 1 +
 include/f2fs_fs.h | 1 +
 lib/libf2fs.c     | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)
fsck/main.c +1 -0
index 675c603b1a76..bb79f6e9fc89 100644
@@ -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':
include/f2fs_fs.h +1 -0
index 65cc8fdb3c22..6eebb3ac44e1 100644
@@ -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;
lib/libf2fs.c +1 -1
index cc335dbb48ee..498f6c0968d8 100644
@@ -821,7 +821,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);
Signature · 1 line
2.18.0.rc1