diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-11-22 10:53:07 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-11-22 11:26:52 +0800 |
commit | 67de42f76ac67a941cacb689cbd2e0d750ad67a9 (patch) | |
tree | 9950615393e72bf84b033eceaa90e23173d6aa7f /lib | |
parent | ee48fd2ced9bee686a51062d9d53f329a396a4e3 (diff) | |
download | android_external_f2fs-tools-67de42f76ac67a941cacb689cbd2e0d750ad67a9.tar.gz android_external_f2fs-tools-67de42f76ac67a941cacb689cbd2e0d750ad67a9.tar.bz2 android_external_f2fs-tools-67de42f76ac67a941cacb689cbd2e0d750ad67a9.zip |
fsck.f2fs: support a readonly filesystem
If f2fs is mounted as ro, we can do fsck.f2fs.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libf2fs.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 83d1296..32e0651 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -362,9 +362,11 @@ void f2fs_init_configuration(struct f2fs_configuration *c) c->vol_label = ""; c->device_name = NULL; c->trim = 1; + 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) { FILE *file = NULL; struct mntent *mnt = NULL; @@ -374,8 +376,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; @@ -386,9 +391,9 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c) struct stat st_buf; int ret = 0; - 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; } @@ -396,9 +401,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; } |