fsck.f2fs: allow --dry-run to check readonly mounted fs
authorChao Yu <yuchao0@huawei.com>
Mon, 24 Feb 2020 11:31:15 +0000 (19:31 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 24 Feb 2020 22:01:53 +0000 (14:01 -0800)
commit64750e90d63792ab457d7000b71aac62d6b9f6dd
tree4ed65aebc144d4dcd1330d7958cdb7890a65ad4a
parentdaa0f8b9e9b1eea6c85e5c169b809254d9d7074e
fsck.f2fs: allow --dry-run to check readonly mounted fs

As Ondřej Jirman <megi@xff.cz> 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.

Reported-by: Ondřej Jirman <megi@xff.cz>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
lib/libf2fs.c