summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-06-18 10:11:19 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-06-18 15:32:52 +0100
commit4846b84476015874d569c14c2c30fcd71aa4d54c (patch)
treea9a5edcd66556f5703c8bbf25f268c25db80e6d9
parent50aa9533e4a505e1c64dbedddb30491bfbb755d6 (diff)
downloadlibguestfs-4846b84476015874d569c14c2c30fcd71aa4d54c.tar.gz
libguestfs-4846b84476015874d569c14c2c30fcd71aa4d54c.tar.xz
libguestfs-4846b84476015874d569c14c2c30fcd71aa4d54c.zip
fuse: Add replacement for fuse_opt_add_opt_escaped.
RHEL 5-era FUSE didn't have this function. I copied the function out of upstream FUSE, since the license is compatible.
-rw-r--r--configure.ac7
-rw-r--r--fuse/guestmount.c31
2 files changed, 37 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 3e84e11d..b30b9f9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,7 +718,12 @@ AS_IF([test "x$enable_fuse" != "xno"],
[PKG_CHECK_MODULES([FUSE],[fuse],
[AC_SUBST([FUSE_CFLAGS])
AC_SUBST([FUSE_LIBS])
- AC_DEFINE([HAVE_FUSE],[1],[Define to 1 if you have FUSE])],
+ AC_DEFINE([HAVE_FUSE],[1],[Define to 1 if you have FUSE])
+ old_LIBS="$LIBS"
+ LIBS="$FUSE_LIBS $LIBS"
+ AC_CHECK_FUNCS([fuse_opt_add_opt_escaped])
+ LIBS="$old_LIBS"
+ ],
[enable_fuse=no
AC_MSG_WARN([FUSE library and headers are missing, so optional FUSE module won't be built])
])
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index 2fe56ca4..b6c64671 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -42,6 +42,37 @@
#include "guestmount.h"
#include "options.h"
+#ifndef HAVE_FUSE_OPT_ADD_OPT_ESCAPED
+/* Copied from lib/fuse_opt.c and modified.
+ * Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
+ * This [function] can be distributed under the terms of the GNU LGPLv2.
+ */
+static int
+fuse_opt_add_opt_escaped (char **opts, const char *opt)
+{
+ unsigned oldlen = *opts ? strlen(*opts) : 0;
+ char *d = realloc (*opts, oldlen + 1 + strlen(opt) * 2 + 1);
+
+ if (!d) {
+ perror ("realloc");
+ exit (EXIT_FAILURE);
+ }
+
+ *opts = d;
+ if (oldlen) {
+ d += oldlen;
+ *d++ = ',';
+ }
+
+ for (; *opt; opt++) {
+ if (*opt == ',' || *opt == '\\')
+ *d++ = '\\';
+ *d++ = *opt;
+ }
+ *d = '\0';
+}
+#endif
+
guestfs_h *g = NULL;
int read_only = 0;
int live = 0;