aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2008-10-20 12:03:16 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2008-10-20 12:03:16 +0000
commitbe44229cfe5a40eb29205deb404316fb5db9dde9 (patch)
treed69517eae18c8832d73845bed11a8848e72294db /sshfs.c
parentc7dbdc1f77949506ddce5448bf844e6bf4c948fc (diff)
downloadsshfs-be44229cfe5a40eb29205deb404316fb5db9dde9.tar
sshfs-be44229cfe5a40eb29205deb404316fb5db9dde9.tar.gz
sshfs-be44229cfe5a40eb29205deb404316fb5db9dde9.tar.bz2
sshfs-be44229cfe5a40eb29205deb404316fb5db9dde9.zip
Escape commas in fsname option if libfuse supports it
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/sshfs.c b/sshfs.c
index 1a79b77..07c3cf9 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -3121,6 +3121,42 @@ static char *find_base_path(void)
return s;
}
+/*
+ * Remove commas from fsname, as it confuses the fuse option parser.
+ */
+static void fsname_remove_commas(char *fsname)
+{
+ if (strchr(fsname, ',') != NULL) {
+ char *s = fsname;
+ char *d = s;
+
+ for (; *s; s++) {
+ if (*s != ',')
+ *d++ = *s;
+ }
+ *d = *s;
+ }
+}
+
+#if FUSE_VERSION >= 27
+static char *fsname_escape_commas(char *fsnameold)
+{
+ char *fsname = g_malloc(strlen(fsnameold) * 2 + 1);
+ char *d = fsname;
+ char *s;
+
+ for (s = fsnameold; *s; s++) {
+ if (*s == '\\' || *s == ',')
+ *d++ = '\\';
+ *d++ = *s;
+ }
+ *d = '\0';
+ g_free(fsnameold);
+
+ return fsname;
+}
+#endif
+
int main(int argc, char *argv[])
{
int res;
@@ -3237,27 +3273,16 @@ int main(int argc, char *argv[])
tmp = g_strdup_printf("-omax_write=%u", sshfs.max_write);
fuse_opt_insert_arg(&args, 1, tmp);
g_free(tmp);
- /*
- * Remove commas from fsname, as it confuses the fuse option
- * parser.
- *
- * FIXME: escape commas instead. Needs support in libfuse.
- */
- if (strchr(fsname, ',') != NULL) {
- char *s = fsname;
- char *d = s;
-
- for (; *s; s++) {
- if (*s != ',')
- *d++ = *s;
- }
- *d = *s;
- }
#if FUSE_VERSION >= 27
libver = fuse_version();
assert(libver >= 27);
+ if (libver >= 28)
+ fsname = fsname_escape_commas(fsname);
+ else
+ fsname_remove_commas(fsname);
tmp = g_strdup_printf("-osubtype=sshfs,fsname=%s", fsname);
#else
+ fsname_remove_commas(fsname);
tmp = g_strdup_printf("-ofsname=sshfs#%s", fsname);
#endif
fuse_opt_insert_arg(&args, 1, tmp);