From 50aa77b1d3a8ddad8e82a33783b9b9d2e8f32940 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 18 Feb 2016 17:37:14 -0800 Subject: [PATCH] fsck.f2fs: check /proc/mounts first to detect readonly Once f2fs_stop_checkpoint makes f2fs as readonly, only /proc/mounts shows RDONLY whereas /etc/mtab does not. Signed-off-by: Jaegeuk Kim --- lib/libf2fs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/libf2fs.c b/lib/libf2fs.c index d61eb85..5eb5c33 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -530,17 +530,17 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c) struct stat st_buf; int ret = 0; - ret = is_mounted(MOUNTED, c->device_name); + /* + * try with /proc/mounts fist to detect RDONLY. + * f2fs_stop_checkpoint makes RO in /proc/mounts while RW in /etc/mtab. + */ + ret = is_mounted("/proc/mounts", c->device_name); if (ret) { MSG(0, "Info: Mounted device!\n"); return -1; } - /* - * if failed due to /etc/mtab file not present - * try with /proc/mounts. - */ - ret = is_mounted("/proc/mounts", c->device_name); + ret = is_mounted(MOUNTED, c->device_name); if (ret) { MSG(0, "Info: Mounted device!\n"); return -1; -- 2.7.4