On Tue, Nov 15, 2022 at 02:23:46AM +0100, Stefano Brivio wrote:On ia64, clone(2) is not available: the glibc wrapper is named __clone2() and it takes, additionally, the size of the stack area passed by the caller. Spotted in Debian's buildd logs. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>Urgh, I'd really prefer to make our own wrapper to reduce two ifdefs to one.--- pasta.c | 9 +++++++++ util.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/pasta.c b/pasta.c index db86317..1f3afa1 100644 --- a/pasta.c +++ b/pasta.c @@ -226,11 +226,20 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, arg.argv = sh_argv; } +#ifdef __ia64__ + pasta_child_pid = __clone2(pasta_spawn_cmd, + ns_fn_stack + sizeof(ns_fn_stack) / 2, + sizeof(ns_fn_stack) / 2, + CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | + CLONE_NEWUTS, + (void *)&arg); +#else pasta_child_pid = clone(pasta_spawn_cmd, ns_fn_stack + sizeof(ns_fn_stack) / 2, CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWUTS, (void *)&arg); +#endif if (pasta_child_pid == -1) { perror("clone"); diff --git a/util.h b/util.h index 2d4e1ff..3c48992 100644 --- a/util.h +++ b/util.h @@ -81,6 +81,17 @@ (((struct in_addr *)(a))->s_addr == ((struct in_addr *)b)->s_addr) #define NS_FN_STACK_SIZE (RLIMIT_STACK_VAL * 1024 / 8) +#ifdef __ia64__ +#define NS_CALL(fn, arg) \ + do { \ + char ns_fn_stack[NS_FN_STACK_SIZE]; \ + \ + __clone2((fn), ns_fn_stack + sizeof(ns_fn_stack) / 2, \ + sizeof(ns_fn_stack) / 2, \ + CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD,\ + (void *)(arg)); \ + } while (0) +#else #define NS_CALL(fn, arg) \ do { \ char ns_fn_stack[NS_FN_STACK_SIZE]; \ @@ -89,6 +100,7 @@ CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD, \ (void *)(arg)); \ } while (0) +#endif #if __BYTE_ORDER == __BIG_ENDIAN #define L2_BUF_ETH_IP4_INIT \-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson