aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2015-11-22 10:53:07 +0800
committerSteve Kondik <steve@cyngn.com>2016-08-24 11:43:29 -0700
commit378a83549f9e9e5d1123c7a5101d23fb106144b1 (patch)
tree2366072c97165e9e0f9e6573d72c42dd5d8e1776 /lib
parent04477dec80e810a0e51aa9d0a8733e3c11225db2 (diff)
downloadandroid_external_f2fs-tools-378a83549f9e9e5d1123c7a5101d23fb106144b1.tar.gz
android_external_f2fs-tools-378a83549f9e9e5d1123c7a5101d23fb106144b1.tar.bz2
android_external_f2fs-tools-378a83549f9e9e5d1123c7a5101d23fb106144b1.zip
fsck.f2fs: support a readonly filesystem
If f2fs is mounted as ro, we can do fsck.f2fs. Change-Id: If20a055242824fd94110bcde12988ddc019a4011 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libf2fs.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index c42620b..f0a8861 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -365,9 +365,11 @@ void f2fs_init_configuration(struct f2fs_configuration *c)
c->device_name = NULL;
c->trim = 1;
c->bytes_reserved = 0;
+ c->ro = 0;
}
-static int is_mounted(const char *mpt, const char *device)
+static int is_mounted(struct f2fs_configuration *c,
+ const char *mpt, const char *device)
{
#ifdef __linux__
FILE *file = NULL;
@@ -378,8 +380,11 @@ static int is_mounted(const char *mpt, const char *device)
return 0;
while ((mnt = getmntent(file)) != NULL) {
- if (!strcmp(device, mnt->mnt_fsname))
+ if (!strcmp(device, mnt->mnt_fsname)) {
+ if (hasmntopt(mnt, MNTOPT_RO))
+ config.ro = 1;
break;
+ }
}
endmntent(file);
return mnt ? 1 : 0;
@@ -395,9 +400,9 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
int ret = 0;
#ifdef __linux__
- ret = is_mounted(MOUNTED, c->device_name);
+ ret = is_mounted(c, MOUNTED, c->device_name);
if (ret) {
- MSG(0, "\tError: Not available on mounted device!\n");
+ MSG(0, "Info: Mounted device!\n");
return -1;
}
#endif
@@ -406,9 +411,9 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
* if failed due to /etc/mtab file not present
* try with /proc/mounts.
*/
- ret = is_mounted("/proc/mounts", c->device_name);
+ ret = is_mounted(c, "/proc/mounts", c->device_name);
if (ret) {
- MSG(0, "\tError: Not available on mounted device!\n");
+ MSG(0, "Info: Mounted device!\n");
return -1;
}