chiark / gitweb /
missing: define name_to_handle_at on our own if it is missing
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Sep 2012 22:20:04 +0000 (15:20 -0700)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Sep 2012 22:30:24 +0000 (15:30 -0700)
configure.ac
src/readahead/readahead-collect.c
src/shared/missing.h
src/shared/path-util.c

index 4bafbfb2eae30b47854f8a9c558c72d11739e129..f1b88384f1730e5a3a9a0cfa0cd5f4aa8fc65a3c 100644 (file)
@@ -154,6 +154,11 @@ CAP_LIBS="$LIBS"
 LIBS="$save_LIBS"
 AC_SUBST(CAP_LIBS)
 
+AC_CHECK_FUNCS([fanotify_init fanotify_mark name_to_handle_at])
+AC_CHECK_DECLS([gettid, pivot_root], [], [], [[#include <sys/types.h>
+#include <unistd.h>
+#include <sys/mount.h>]])
+
 # This makes sure pkg.m4 is available.
 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
 
index 4fcf64c24d766833b70f01c1d7104d45079979c6..a3f7df5f6ae6ac91ffdc0a4e061890e429151c8e 100644 (file)
 #include <getopt.h>
 #include <sys/inotify.h>
 
+#ifdef HAVE_FANOTIFY_INIT
+#include <sys/fanotify.h>
+#endif
+
 #include <systemd/sd-daemon.h>
 
 #include "missing.h"
index df3fd0e839d59ef47882041e638bce112f7809f1..7fbb9259ebae8151746058c8444f88a66f32480c 100644 (file)
 #define IP_TRANSPARENT 19
 #endif
 
+#if !HAVE_DECL_PIVOT_ROOT
 static inline int pivot_root(const char *new_root, const char *put_old) {
         return syscall(SYS_pivot_root, new_root, put_old);
 }
+#endif
 
 #ifdef __x86_64__
 #  ifndef __NR_fanotify_init
@@ -126,10 +128,13 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
 #  endif
 #endif
 
+#ifndef HAVE_FANOTIFY_INIT
 static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags) {
         return syscall(__NR_fanotify_init, flags, event_f_flags);
 }
+#endif
 
+#ifndef HAVE_FANOTIFY_MARK
 static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask,
                                 int dfd, const char *pathname) {
 #if defined _MIPS_SIM && _MIPS_SIM == _MIPS_SIM_ABI32 || defined __powerpc__ && !defined __powerpc64__
@@ -145,6 +150,7 @@ static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t ma
         return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
 #endif
 }
+#endif
 
 #ifndef BTRFS_IOCTL_MAGIC
 #define BTRFS_IOCTL_MAGIC 0x94
@@ -175,9 +181,11 @@ struct btrfs_ioctl_vol_args {
 #define MS_PRIVATE  (1 << 18)
 #endif
 
+#if !HAVE_DECL_GETTID
 static inline pid_t gettid(void) {
         return (pid_t) syscall(SYS_gettid);
 }
+#endif
 
 #ifndef SCM_SECURITY
 #define SCM_SECURITY 0x03
@@ -194,3 +202,30 @@ static inline pid_t gettid(void) {
 #ifndef PR_SET_CHILD_SUBREAPER
 #define PR_SET_CHILD_SUBREAPER 36
 #endif
+
+#ifndef MAX_HANDLE_SZ
+#define MAX_HANDLE_SZ 128
+#endif
+
+#ifdef __x86_64__
+#  ifndef __NR_name_to_handle
+#    define __NR_name_to_handle 303
+#  endif
+#else
+#  ifndef __NR_name_to_handle
+#    define __NR_name_to_handle 341
+#  endif
+#endif
+
+#ifndef HAVE_NAME_TO_HANDLE_AT
+
+struct file_handle {
+        unsigned int handle_bytes;
+        int handle_type;
+        unsigned char f_handle[0];
+};
+
+static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
+        return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags);
+}
+#endif
index 2bdbd22dc71becce8484dec92fb81dc8326e68ef..4cb0b03c5a55c8d0af3b36c078788cfb89d14286 100644 (file)
@@ -35,6 +35,7 @@
 #include "log.h"
 #include "strv.h"
 #include "path-util.h"
+#include "missing.h"
 
 bool path_is_absolute(const char *p) {
         return p[0] == '/';