diff options
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 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; } |