summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-08-25 18:32:58 -0400
committerColin Walters <walters@verbum.org>2015-08-25 18:32:58 -0400
commit99a02e4114b06edf6c03fcc01e09c137f1fc67dd (patch)
tree3158e6c28f8a8a87ca71e4a59a6ccc198aa468fd
parent123f234aa42e3d57bb13de7206d25108c739e059 (diff)
downloadlinux-user-chroot-99a02e4114b06edf6c03fcc01e09c137f1fc67dd.tar.gz
Import S390/CRIS raw_clone syscall ordering fix
I took this from xdg-app.
-rw-r--r--src/linux-user-chroot.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/linux-user-chroot.c b/src/linux-user-chroot.c
index 42bbae2..ccab6f4 100644
--- a/src/linux-user-chroot.c
+++ b/src/linux-user-chroot.c
@@ -137,6 +137,18 @@ fsuid_chdir (uid_t uid,
return ret;
}
+static inline int
+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 (int) syscall(__NR_clone, child_stack, flags);
+#else
+ return (int) syscall(__NR_clone, flags, child_stack);
+#endif
+}
+
int
main (int argc,
char **argv)
@@ -301,7 +313,7 @@ main (int argc,
if (unshare_net)
clone_flags |= CLONE_NEWNET;
- if ((child = syscall (__NR_clone, clone_flags, NULL)) < 0)
+ if ((child = raw_clone (clone_flags, NULL)) < 0)
fatal_errno ("clone");
if (child == 0)