aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wallace <greg@gregtwallace.com>2016-01-02 17:01:27 -0500
committerGreg Wallace <greg@gregtwallace.com>2016-01-19 22:02:22 -0500
commit35570b5578f4ba2ce6c380bafe6867c399d0921f (patch)
tree736ad12e269e037dbe53db666abc85dcba129b30
parentad0f267af3be1bac982a9095a7cf8a749d59ffd6 (diff)
downloadandroid_external_f2fs-tools-35570b5578f4ba2ce6c380bafe6867c399d0921f.tar.gz
android_external_f2fs-tools-35570b5578f4ba2ce6c380bafe6867c399d0921f.tar.bz2
android_external_f2fs-tools-35570b5578f4ba2ce6c380bafe6867c399d0921f.zip
Fix readonly for android
The hasmntopt() function doesn't exist in android, so it needs to be defined if we are building for android. Also, MNTOPT_RO isn't defined on android (and maybe others), so we need to manually specify if if it isn't already defined. Change-Id: I55330e37cebc087e138cdf6a0cbbe61df59f55fa
-rw-r--r--lib/libf2fs.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 57de047..b1741bc 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -25,6 +25,25 @@
#include <f2fs_fs.h>
+#ifdef __ANDROID__
+char *hasmntopt (const struct mntent *mnt, const char *opt) {
+ const size_t optlen = strlen (opt);
+ char *rest = mnt->mnt_opts, *p;
+
+ while ((p = strstr (rest, opt)) != NULL) {
+ if ((p == rest || p[-1] == ',')
+ && (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ','))
+ return p;
+
+ rest = strchr (p, ',');
+ if (rest == NULL)
+ break;
+ ++rest;
+ }
+ return NULL;
+}
+#endif
+
/*
* UTF conversion codes are Copied from exfat tools.
*/
@@ -520,8 +539,10 @@ static int is_mounted(const char *mpt, const char *device)
if (!strcmp(device, mnt->mnt_fsname)) {
#ifdef MNTOPT_RO
if (hasmntopt(mnt, MNTOPT_RO))
- config.ro = 1;
+#else
+ if (hasmntopt(mnt, "ro"))
#endif
+ config.ro = 1;
break;
}
}