Do a configure check to see whether UNIX_PATH_MAX is defined; if it is
not defined, provide it with the size of sun_path in the struct
sockaddr_un, thus with the proper size for any libc.
---
configure.ac | 24 ++++++++++++++++++++++++
src/guestfs-internal-all.h | 6 ------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5de624e..dd7a70b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -328,6 +328,30 @@ AC_CHECK_FUNCS([\
statvfs \
sync])
+dnl Check for UNIX_PATH_MAX, creating a custom one if not available.
+AC_MSG_CHECKING([for UNIX_PATH_MAX])
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+#include <sys/un.h>
+ ]], [[
+#ifndef UNIX_PATH_MAX
+#error UNIX_PATH_MAX not defined
+#endif
+ ]])], [
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ AC_MSG_CHECKING([for size of sockaddr_un.sun_path])
+ AC_COMPUTE_INT(unix_path_max, [sizeof (myaddr.sun_path)], [
+#include <sys/un.h>
+struct sockaddr_un myaddr;
+ ], [
+ AC_MSG_ERROR([cannot get it])
+ ])
+ AC_MSG_RESULT([$unix_path_max])
+ AC_DEFINE_UNQUOTED([UNIX_PATH_MAX], $unix_path_max, [Custom value for
UNIX_PATH_MAX])
+ ])
+
dnl tgetent, tputs and UP [sic] are all required. They come from libtinfo
dnl which is pulled in as a dependency of libncurses.
old_LIBS="$LIBS"
diff --git a/src/guestfs-internal-all.h b/src/guestfs-internal-all.h
index 23c3490..84b8fd6 100644
--- a/src/guestfs-internal-all.h
+++ b/src/guestfs-internal-all.h
@@ -53,12 +53,6 @@
#define SOCK_CLOEXEC 0
#endif
-#ifdef __APPLE__
-#define UNIX_PATH_MAX 104
-#else
-#define UNIX_PATH_MAX 108
-#endif
-
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
--
1.9.3