diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-06-18 10:11:19 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-06-21 13:16:09 +0100 |
commit | 305991b79230fb61cd28e21a9b3d14c1a5177437 (patch) | |
tree | ef6e161cb22760638dbd2088d8dcdce9cf86dde0 | |
parent | 3d48d4cd81a3cf4e54d2e3de63555707a4dbd3c3 (diff) | |
download | libguestfs-305991b79230fb61cd28e21a9b3d14c1a5177437.tar.gz libguestfs-305991b79230fb61cd28e21a9b3d14c1a5177437.tar.xz libguestfs-305991b79230fb61cd28e21a9b3d14c1a5177437.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.
Cherry picked from commit 4846b84476015874d569c14c2c30fcd71aa4d54c
and backported to libguestfs 1.16. This includes more of the
development 'configure.ac' than is strictly necessary, but on the
other hand it brings the code closer to that development branch.
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | fuse/guestmount.c | 31 |
2 files changed, 44 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 199e9ccd..116bab6f 100644 --- a/configure.ac +++ b/configure.ac @@ -718,9 +718,19 @@ AC_ARG_ENABLE([fuse], [], [enable_fuse=yes]) AS_IF([test "x$enable_fuse" != "xno"], - [PKG_CHECK_MODULES([FUSE],[fuse],,[ - enable_fuse=no - AC_MSG_WARN([FUSE library and headers are missing, so optional FUSE module won't be built])])]) + [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]) + 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]) + ]) + ]) AM_CONDITIONAL([HAVE_FUSE],[test "x$enable_fuse" != "xno"]) dnl If valgrind is present (it's not required), check whether or not diff --git a/fuse/guestmount.c b/fuse/guestmount.c index a9bf4e33..304d1ae8 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -58,6 +58,37 @@ #define ENOATTR ENODATA #endif +#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; |