Port: Add Solaris dirent compat
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 14 Oct 2015 21:05:24 +0000 (17:05 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 19 Oct 2015 18:54:21 +0000 (14:54 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/common/compat/Makefile.am
src/common/compat/dirent.h [new file with mode: 0644]
src/common/utils.c

index c922e3224866aea009ac843b726830e61a6e3a4a..5d286beb0c2103ffef3fb394c58fd54fb03d2a95 100644 (file)
@@ -111,7 +111,7 @@ AC_CHECK_FUNCS([ \
        gethostbyname gethostname getpagesize localtime_r memchr memset \
        mkdir munmap putenv realpath rmdir socket strchr strcspn strdup \
        strncasecmp strndup strnlen strpbrk strrchr strstr strtol strtoul \
-       strtoull \
+       strtoull dirfd \
 ])
 
 # Babeltrace viewer check
index b3973847d2f3535fac07ef55ea226e4a322abbd3..69e2dc590bd54c5a6de3e11a7d6dabca3eaf244d 100644 (file)
@@ -8,6 +8,6 @@ else
 COMPAT=compat-poll.c
 endif
 
-libcompat_la_SOURCES = poll.h fcntl.h endian.h mman.h \
+libcompat_la_SOURCES = poll.h fcntl.h endian.h mman.h dirent.h \
                socket.h compat-fcntl.c uuid.h tid.h \
                getenv.h string.h prctl.h paths.h $(COMPAT)
diff --git a/src/common/compat/dirent.h b/src/common/compat/dirent.h
new file mode 100644 (file)
index 0000000..d3c73a6
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _COMPAT_DIRENT_H
+#define _COMPAT_DIRENT_H
+
+#include <dirent.h>
+
+#ifdef HAVE_DIRFD
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dirfd(dir);
+}
+#else
+# ifndef __XOPEN_OR_POSIX
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dir->dd_fd;
+}
+# else
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dir->d_fd;
+}
+# endif
+#endif
+
+#endif /* _COMPAT_DIRENT_H */
index b9af7b9da4d9c189e204ad7c91c12cb08c67f4b0..e3f1bf7e62ad8109db5cbefd211f81484f02d737 100644 (file)
 #include <grp.h>
 #include <pwd.h>
 #include <sys/file.h>
-#include <dirent.h>
 
 #include <common/common.h>
 #include <common/runas.h>
 #include <common/compat/getenv.h>
 #include <common/compat/string.h>
+#include <common/compat/dirent.h>
 
 #include "utils.h"
 #include "defaults.h"
@@ -1212,9 +1212,9 @@ int utils_recursive_rmdir(const char *path)
                PERROR("Cannot open '%s' path", path);
                return -1;
        }
-       dir_fd = dirfd(dir);
+       dir_fd = lttng_dirfd(dir);
        if (dir_fd < 0) {
-               PERROR("dirfd");
+               PERROR("lttng_dirfd");
                return -1;
        }
 
This page took 0.027828 seconds and 4 git commands to generate.