chiark / gitweb /
nspawn: fix invocation of the raw clone() system call on s390 and cris
authorKen Werner <ken@linux.vnet.ibm.com>
Tue, 16 Dec 2014 17:06:41 +0000 (18:06 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Dec 2014 05:20:56 +0000 (00:20 -0500)
Since the order of the first and second arguments of the raw clone() system
call is reversed on s390 and cris it needs to be invoked differently.

src/nspawn/nspawn.c
src/shared/missing.h

index 9ca53cd1b40b485fc4d05aa996a2fe8972584f82..a13c1fcd246dad7ba3f141d6f3069fd3154618bd 100644 (file)
@@ -3133,9 +3133,9 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWNS|
-                                          (arg_share_system ? 0 : CLONE_NEWIPC|CLONE_NEWPID|CLONE_NEWUTS)|
-                                          (arg_private_network ? CLONE_NEWNET : 0), NULL);
+                pid = raw_clone(SIGCHLD|CLONE_NEWNS|
+                                (arg_share_system ? 0 : CLONE_NEWIPC|CLONE_NEWPID|CLONE_NEWUTS)|
+                                (arg_private_network ? CLONE_NEWNET : 0), NULL);
                 if (pid < 0) {
                         if (errno == EINVAL)
                                 r = 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");
index c547479ad277651058a96d117742b153f572ba67..bea1254369ab3362ce7c5b867a6932ee90a04bb5 100644 (file)
@@ -635,3 +635,13 @@ static inline int setns(int fd, int nstype) {
 #ifndef CAP_AUDIT_READ
 #define CAP_AUDIT_READ 37
 #endif
+
+static inline long raw_clone(unsigned long flags, void *child_stack) {
+#if defined(__s390__) || defined(__CRIS__)
+        /* On s390 and cris the order of the first and second arguments
+         * of the raw clone() system call is reversed. */
+        return syscall(__NR_clone, child_stack, flags);
+#else
+        return syscall(__NR_clone, flags, child_stack);
+#endif
+}