summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/fuse-lib/mount.c40
-rw-r--r--contrib/fuse-util/fusermount.c20
2 files changed, 55 insertions, 5 deletions
diff --git a/contrib/fuse-lib/mount.c b/contrib/fuse-lib/mount.c
index e88293b38c7..376d0668668 100644
--- a/contrib/fuse-lib/mount.c
+++ b/contrib/fuse-lib/mount.c
@@ -589,11 +589,41 @@ fuse_mount_sys (const char *mountpoint, char *fsname, char *mnt_param)
return fd;
}
+static char *
+escape (char *s)
+{
+ size_t len = 0;
+ char *p = NULL;
+ char *q = NULL;
+ char *e = NULL;
+
+ for (p = s; *p; p++) {
+ if (*p == ',')
+ len++;
+ len++;
+ }
+
+ e = CALLOC (1, len + 1);
+ if (!e)
+ return NULL;
+
+ for (p = s, q = e; *p; p++, q++) {
+ if (*p == ',') {
+ *q = '\\';
+ q++;
+ }
+ *q = *p;
+ }
+
+ return e;
+}
+
int
gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param)
{
int fd = -1, rv = -1;
char *fm_mnt_params = NULL, *p = NULL;
+ char *efsname = NULL;
fd = fuse_mount_sys (mountpoint, fsname, mnt_param);
if (fd == -1) {
@@ -602,10 +632,16 @@ gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param)
"retry to mount via fusermount",
strerror (errno));
+ efsname = escape (fsname);
+ if (!efsname) {
+ GFFUSE_LOGERR ("Out of memory");
+
+ return -1;
+ }
rv = asprintf (&fm_mnt_params,
"%s,fsname=%s,nonempty,subtype=glusterfs",
- mnt_param, fsname);
-
+ mnt_param, efsname);
+ FREE (efsname);
if (rv == -1) {
GFFUSE_LOGERR ("Out of memory");
diff --git a/contrib/fuse-util/fusermount.c b/contrib/fuse-util/fusermount.c
index ae779d3fb21..39da9b6a0b6 100644
--- a/contrib/fuse-util/fusermount.c
+++ b/contrib/fuse-util/fusermount.c
@@ -649,7 +649,9 @@ static int opt_eq(const char *s, unsigned len, const char *opt)
static int get_string_opt(const char *s, unsigned len, const char *opt,
char **val)
{
+ int i;
unsigned opt_len = strlen(opt);
+ char *d;
if (*val)
free(*val);
@@ -659,8 +661,15 @@ static int get_string_opt(const char *s, unsigned len, const char *opt,
return 0;
}
- memcpy(*val, s + opt_len, len - opt_len);
- (*val)[len - opt_len] = '\0';
+ d = *val;
+ s += opt_len;
+ len -= opt_len;
+ for (i = 0; i < len; i++) {
+ if (s[i] == '\\' && i + 1 < len)
+ i++;
+ *d++ = s[i];
+ }
+ *d = '\0';
return 1;
}
@@ -691,7 +700,12 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
unsigned len;
const char *fsname_str = "fsname=";
const char *subtype_str = "subtype=";
- for (len = 0; s[len] && s[len] != ','; len++);
+ for (len = 0; s[len]; len++) {
+ if (s[len] == '\\' && s[len + 1])
+ len++;
+ else if (s[len] == ',')
+ break;
+ }
if (begins_with(s, fsname_str)) {
if (!get_string_opt(s, len, fsname_str, &fsname))
goto err;