chiark / gitweb /
build-sys: Add setns() functions if not in the C library.
[elogind.git] / src / shared / missing.h
index 939f81d9c4c02f875f545c48f453f35035f140f2..3142306e35c2375382c2539ea81787cb674d4ad9 100644 (file)
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <errno.h>
 #include <linux/oom.h>
 #include <linux/input.h>
+#include <linux/if_link.h>
 
 #ifdef HAVE_AUDIT
 #include <libaudit.h>
 #define IP_TRANSPARENT 19
 #endif
 
+#ifndef IFLA_CARRIER
+  #define IFLA_CARRIER 33
+  #ifndef IFLA_NUM_RX_QUEUES
+    #define IFLA_NUM_RX_QUEUES 32
+    #ifndef IFLA_NUM_TX_QUEUES
+      #define IFLA_NUM_TX_QUEUES 31
+      #ifndef IFLA_PROMISCUITY
+        #define IFLA_PROMISCUITY 30
+      #endif
+    #endif
+  #endif
+#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);
@@ -324,10 +339,6 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle
 #  define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
 #endif
 
-#ifndef TMP_MAX
-# define TMP_MAX 238328
-#endif
-
 #if defined(__i386__) || defined(__x86_64__)
 
 /* The precise definition of __O_TMPFILE is arch specific, so let's
@@ -343,3 +354,19 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle
 #endif
 
 #endif
+
+#ifndef __NR_setns
+#  if defined(__x86_64__)
+#    define __NR_setns 308
+#  elif defined(__i386__)
+#    define __NR_setns 346
+#  else
+#    error "__NR_setns is not defined"
+#  endif
+#endif
+
+#if !HAVE_DECL_SETNS
+static inline int setns(int fd, int nstype) {
+        return syscall(__NR_setns, fd, nstype);
+}
+#endif