aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-02-18 17:37:14 -0800
committerluca020400 <luca.stefani.ge1@gmail.com>2016-04-04 17:17:52 +0200
commitc541f04d8bf12de46eb3c40c9ace4a904db74984 (patch)
treee9f4bc5b5802a210e94a6054f8965859bb313def
parente88571e2c56a6e55fdb34450195b40a1d99467b1 (diff)
downloadandroid_external_f2fs-tools-c541f04d8bf12de46eb3c40c9ace4a904db74984.tar.gz
android_external_f2fs-tools-c541f04d8bf12de46eb3c40c9ace4a904db74984.tar.bz2
android_external_f2fs-tools-c541f04d8bf12de46eb3c40c9ace4a904db74984.zip
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. Change-Id: I389cc1589147fcf4da8822de32cd3313d881e65f Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--lib/libf2fs.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index b1741bc..0eb1477 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -559,23 +559,23 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
struct stat st_buf;
int ret = 0;
-#ifdef __linux__
- 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;
}
-#endif
- /*
- * if failed due to /etc/mtab file not present
- * try with /proc/mounts.
- */
- ret = is_mounted("/proc/mounts", c->device_name);
+#ifdef __linux__
+ ret = is_mounted(MOUNTED, c->device_name);
if (ret) {
MSG(0, "Info: Mounted device!\n");
return -1;
}
+#endif
/*
* If f2fs is umounted with -l, the process can still use