[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH nbdkit 05/10] freebsd: Provide alternative for glibc get_current_dir_name function.



---
 configure.ac |  4 ++++
 src/utils.c  | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/configure.ac b/configure.ac
index 3381955..0b0f233 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,10 @@ AC_CHECK_HEADERS([\
 	sys/prctl.h \
 	sys/procctl.h])
 
+dnl Check for functions in libc, all optional.
+AC_CHECK_FUNCS([\
+	get_current_dir_name])
+
 dnl Check support for setsockcreatecon_raw (part of SELinux).
 AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:])
 
diff --git a/src/utils.c b/src/utils.c
index 636e483..0e48d52 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -40,11 +40,24 @@
 #include <inttypes.h>
 #include <string.h>
 #include <unistd.h>
+#include <limits.h>
 #include <termios.h>
 #include <errno.h>
 
 #include "internal.h"
 
+#ifndef HAVE_GET_CURRENT_DIR_NAME
+static char *
+get_current_dir_name (void)
+{
+  char *ret = malloc (PATH_MAX);
+
+  ret = getcwd (ret, PATH_MAX);
+  ret = realloc (ret, strlen (ret) + 1);
+  return ret;
+}
+#endif
+
 char *
 nbdkit_absolute_path (const char *path)
 {
-- 
2.18.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]