5606d83
From 6ae61e265d8becff0960c0911e8bd37b0df42386 Mon Sep 17 00:00:00 2001
5606d83
From: Fedora systemd team <systemd-maint@redhat.com>
5606d83
Date: Thu, 18 Dec 2014 15:21:22 +0100
5606d83
Subject: [PATCH] nspawn: fix invocation of the raw clone() system call on s390
5606d83
 and cris
5606d83
5606d83
Since the order of the first and second arguments of the raw clone() system
5606d83
call is reversed on s390 and cris it needs to be invoked differently.
5606d83
5606d83
(cherry-picked from 60e1651a31c9c0ed1caef1a63f5e3a87156b0b1e)
5606d83
---
5606d83
 src/nspawn/nspawn.c  |  6 +++---
5606d83
 src/shared/missing.h | 10 ++++++++++
5606d83
 2 files changed, 13 insertions(+), 3 deletions(-)
5606d83
5606d83
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
5606d83
index 0466ddb..2f57e65 100644
5606d83
--- a/src/nspawn/nspawn.c
5606d83
+++ b/src/nspawn/nspawn.c
5606d83
@@ -2982,9 +2982,9 @@ int main(int argc, char *argv[]) {
5606d83
                         goto finish;
5606d83
                 }
5606d83
 
5606d83
-                pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWNS|
5606d83
-                                          (arg_share_system ? 0 : CLONE_NEWIPC|CLONE_NEWPID|CLONE_NEWUTS)|
5606d83
-                                          (arg_private_network ? CLONE_NEWNET : 0), NULL);
5606d83
+                pid = raw_clone(SIGCHLD|CLONE_NEWNS|
5606d83
+                                (arg_share_system ? 0 : CLONE_NEWIPC|CLONE_NEWPID|CLONE_NEWUTS)|
5606d83
+                                (arg_private_network ? CLONE_NEWNET : 0), NULL);
5606d83
                 if (pid < 0) {
5606d83
                         if (errno == EINVAL)
5606d83
                                 log_error_errno(errno, "clone() failed, do you have namespace support enabled in your kernel? (You need UTS, IPC, PID and NET namespacing built in): %m");
5606d83
diff --git a/src/shared/missing.h b/src/shared/missing.h
5606d83
index 478988c..8ea3807 100644
5606d83
--- a/src/shared/missing.h
5606d83
+++ b/src/shared/missing.h
5606d83
@@ -631,3 +631,13 @@ static inline int setns(int fd, int nstype) {
5606d83
 #ifndef CAP_AUDIT_READ
5606d83
 #define CAP_AUDIT_READ 37
5606d83
 #endif
5606d83
+
5606d83
+static inline long raw_clone(unsigned long flags, void *child_stack) {
5606d83
+#if defined(__s390__) || defined(__CRIS__)
5606d83
+        /* On s390 and cris the order of the first and second arguments
5606d83
+         * of the raw clone() system call is reversed. */
5606d83
+        return syscall(__NR_clone, child_stack, flags);
5606d83
+#else
5606d83
+        return syscall(__NR_clone, flags, child_stack);
5606d83
+#endif
5606d83
+}
5606d83
-- 
5606d83
2.2.0
5606d83