[lxc-devel] [lxd/stable-3.0] Centos 6 build

hackman on Github lxc-bot at linuxcontainers.org
Sat Jul 27 21:07:37 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 349 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190727/3f8d6216/attachment.bin>
-------------- next part --------------
From fc29bacc485467ad5cc18bfc8657ef41cc4d7a0b Mon Sep 17 00:00:00 2001
From: Marian Marinov <mm at yuhu.biz>
Date: Sat, 27 Jul 2019 23:57:12 +0300
Subject: [PATCH 1/2] In order to build LXD on CentOS 6 we need setns() which
 is not provided by CentOS 6.

We create a header namespaces.h which will be included in main_checkfeature.go and main_nsexec.go.
The header defines the setns() function, on distros, that don't export it in their own headers.

Signed-off-by: Marian Marinov <mm at yuhu.biz>
---
 lxd/include/namespaces.h | 17 +++++++++++++++++
 lxd/main_checkfeature.go |  1 +
 lxd/main_nsexec.go       |  1 +
 3 files changed, 19 insertions(+)
 create mode 100644 lxd/include/namespaces.h

diff --git a/lxd/include/namespaces.h b/lxd/include/namespaces.h
new file mode 100644
index 0000000000..64e3bbab53
--- /dev/null
+++ b/lxd/include/namespaces.h
@@ -0,0 +1,17 @@
+#ifndef __NAMESPACES_H
+
+// 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
+
+#endif
diff --git a/lxd/main_checkfeature.go b/lxd/main_checkfeature.go
index e82a157379..8edb64f9e9 100644
--- a/lxd/main_checkfeature.go
+++ b/lxd/main_checkfeature.go
@@ -21,6 +21,7 @@ import (
 
 #include "../shared/netutils/netns_getifaddrs.c"
 #include "include/memory_utils.h"
+#include "include/namespaces.h"
 
 bool netnsid_aware = false;
 char errbuf[4096];
diff --git a/lxd/main_nsexec.go b/lxd/main_nsexec.go
index df338e14da..2ad8a95e3d 100644
--- a/lxd/main_nsexec.go
+++ b/lxd/main_nsexec.go
@@ -34,6 +34,7 @@ package main
 #include <unistd.h>
 
 #include "include/memory_utils.h"
+#include "include/namespaces.h"
 
 // External functions
 extern void checkfeature();

From 532990416631b72c7c0fbc0294331d883509fb83 Mon Sep 17 00:00:00 2001
From: Marian Marinov <mm at yuhu.biz>
Date: Sat, 27 Jul 2019 23:59:26 +0300
Subject: [PATCH 2/2] Again in order to build LXD on CentOS 6 we need the
 O_PATH and AT_EMPTY_PATH definitions. These are borrowed from newer glibc
 headers.

Signed-off-by: Marian Marinov <mm at yuhu.biz>
---
 shared/idmap/shift_linux.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/shared/idmap/shift_linux.go b/shared/idmap/shift_linux.go
index 11a2447955..801cefde0f 100644
--- a/shared/idmap/shift_linux.go
+++ b/shared/idmap/shift_linux.go
@@ -36,6 +36,15 @@ import (
 
 #include "../../lxd/include/memory_utils.h"
 
+#ifndef __O_PATH
+#define __O_PATH 010000000
+#endif
+
+#ifndef O_PATH
+#define O_PATH __O_PATH
+#endif
+#define AT_EMPTY_PATH 0x1000
+
 #ifndef VFS_CAP_REVISION_1
 #define VFS_CAP_REVISION_1 0x01000000
 #endif


More information about the lxc-devel mailing list