chiark / gitweb /
build-sys: use linux/memfd.h if available
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 5 Oct 2014 22:41:31 +0000 (18:41 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 5 Oct 2014 23:07:28 +0000 (19:07 -0400)
linux/memfd.h was added linux 3.17, so it might not be widely
available for a while.

Also, check if memfd_create is defined, for the HAVE_LINUX_MEMFD_H
check to have a chance of succeeding.

Also, collapse all ifdefs for memfd-related stuff, because they
were all added together so there's no need to check separately.

configure.ac
src/shared/memfd.c
src/shared/missing.h

index e33c8f75accb36139e679805175a8d1cfc65ad9a..caf1f0e54edcb551a038ae76ba561e057e963d54 100644 (file)
@@ -283,6 +283,7 @@ AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
 AC_CHECK_HEADERS([linux/btrfs.h], [], [])
+AC_CHECK_HEADERS([linux/memfd.h], [], [])
 
 # unconditionally pull-in librt with old glibc versions
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
@@ -300,6 +301,7 @@ AC_SUBST(RT_LIBS)
 LIBS="$save_LIBS"
 
 AC_CHECK_FUNCS([fanotify_init fanotify_mark])
+AC_CHECK_FUNCS([memfd_create])
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
 AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, setns, LO_FLAGS_PARTSCAN],
                [], [], [[
index 1feca0c9799c2da43e9937148d2460f2234573e4..162c12f7a77e035e472ca4d2bc470c7852e8551c 100644 (file)
 #include <sys/mman.h>
 #include <sys/prctl.h>
 
+#ifdef HAVE_LINUX_MEMFD_H
+#  include <linux/memfd.h>
+#endif
+
 #include "util.h"
 #include "bus-label.h"
-#include "missing.h"
 #include "memfd.h"
 #include "utf8.h"
+#include "missing.h"
 
 int memfd_new(const char *name) {
         _cleanup_free_ char *g = NULL;
index 031fe2d1ce2fd00fe91ef24731f192d0ddada53d..656921d6871b5a9fc485994318d52f7ac888feee 100644 (file)
 
 #ifndef F_ADD_SEALS
 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
-#endif
-
-#ifndef F_GET_SEALS
 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
-#endif
 
-#ifndef F_SEAL_SEAL
 #define F_SEAL_SEAL     0x0001  /* prevent further seals from being set */
-#endif
-
-#ifndef F_SEAL_SHRINK
 #define F_SEAL_SHRINK   0x0002  /* prevent file from shrinking */
-#endif
-
-#ifndef F_SEAL_GROW
 #define F_SEAL_GROW     0x0004  /* prevent file from growing */
-#endif
-
-#ifndef F_SEAL_WRITE
 #define F_SEAL_WRITE    0x0008  /* prevent writes */
 #endif