Skip to contentSkip to conversation

fsck.f2fs: allow --dry-run to check readonly mounted fs

PATCH New Chao Yu 1 participant 1 message Feb 24, 2020 Library code

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 fsck.f2fs: allow --dry-run to check readonly mounted fs

As Ondřej Jirman <[email protected]> reported:

I was trying to run: fsck.f2fs --dry-run /dev/mmcblk0p2 on a RO mounted device, and fsck refuses to run. Strace shows that it tries to open the block device with O_EXCL even in RO mode, which will always fail if the block device is mounted.

fsck.f2fs --dry-run /dev/mmcblk0p2
Info: Dry run
Info: Mounted device!
Info: Check FS only on RO mounted device
Error: Failed to open the device!

I suggest not using O_EXCL for --dry-run check.

Let's change to allow --dry-run to check readonly mounted fs.

---
 lib/libf2fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/libf2fs.c +2 -1
index d527d68..5c064c8 100644
@@ -907,7 +907,8 @@ int get_device_info(int i)
 			return -1;
 		}
 
-		if (S_ISBLK(stat_buf->st_mode) && !c.force && c.func != DUMP) {
+		if (S_ISBLK(stat_buf->st_mode) &&
+				!c.force && c.func != DUMP && !c.dry_run) {
 			fd = open(dev->path, O_RDWR | O_EXCL);
 			if (fd < 0)
 				fd = open_check_fs(dev->path, O_EXCL);
Signature · 8 lines
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel