[prev in list] [next in list] [prev in thread] [next in thread]
List: lxc-devel
Subject: [lxc-devel] [lxc/master] Fix build when HAVE_SETNS is unset
From: pkun on Github <lxc-bot () linuxcontainers ! org>
Date: 2018-04-26 12:55:32
Message-ID: 20180426125532.D59C155423 () mailman01 ! srv ! dcmtl ! stgraber ! net
[Download RAW message or body]
[Attachment #2 (text/x-mailbox)]
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2292
This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.
=== Description (from pull-request) ===
Add inline setns() function to tool_utils.h. Without it tool_utils.c can't be build \
when HAVE_SETNS is unset.
jenkins: test this please
[Attachment #3 (text/plain)]
From 636063bc832bc9ffd7020c73d1ff5da95c8c7140 Mon Sep 17 00:00:00 2001
From: Serj Kalichev <serj.kalichev@gmail.com>
Date: Thu, 26 Apr 2018 15:49:44 +0300
Subject: [PATCH] Add inline setns() function to tool_utils.h. Without it
tool_utils.c can't be build when HAVE_SETNS is unset.
Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com>
---
src/lxc/tools/tool_utils.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/lxc/tools/tool_utils.h b/src/lxc/tools/tool_utils.h
index 25f2dfd61..51c8854e1 100644
--- a/src/lxc/tools/tool_utils.h
+++ b/src/lxc/tools/tool_utils.h
@@ -109,6 +109,37 @@ extern signed long lxc_config_parse_arch(const char *arch);
extern int lxc_namespace_2_cloneflag(const char *namespace);
extern int lxc_fill_namespace_flags(char *flaglist, int *flags);
+#if !defined(__NR_setns) && !defined(__NR_set_ns)
+ #if defined(__x86_64__)
+ #define __NR_setns 308
+ #elif defined(__i386__)
+ #define __NR_setns 346
+ #elif defined(__arm__)
+ #define __NR_setns 375
+ #elif defined(__aarch64__)
+ #define __NR_setns 375
+ #elif defined(__powerpc__)
+ #define __NR_setns 350
+ #elif defined(__s390__)
+ #define __NR_setns 339
+ #endif
+#endif
+
+/* Define setns() if missing from the C library */
+#ifndef HAVE_SETNS
+static inline int setns(int fd, int nstype)
+{
+#ifdef __NR_setns
+ return syscall(__NR_setns, fd, nstype);
+#elif defined(__NR_set_ns)
+ return syscall(__NR_set_ns, fd, nstype);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+#endif
+
#if HAVE_LIBCAP
#include <sys/capability.h>
[Attachment #4 (text/plain)]
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic