Unverified Commit 8a545679 by Tycho Andersen Committed by Christian Brauner

lxc_clone: get rid of some indirection

We have a do_clone(), which just calls a void f(void *) that it gets passed. We build up a struct consisting of two args that are just the actual arg and actual function. Let's just have the syscall do this for us. Signed-off-by: 's avatarTycho Andersen <tycho@tycho.ws>
parent 4f7e281f
......@@ -42,25 +42,10 @@
lxc_log_define(namespace, lxc);
struct clone_arg {
int (*fn)(void *);
void *arg;
};
static int do_clone(void *arg)
{
struct clone_arg *clone_arg = arg;
return clone_arg->fn(clone_arg->arg);
}
#define __LXC_STACK_SIZE 4096
pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd)
{
pid_t ret;
struct clone_arg clone_arg = {
.fn = fn,
.arg = arg,
};
void *stack;
stack = malloc(__LXC_STACK_SIZE);
......@@ -70,9 +55,9 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd)
}
#ifdef __ia64__
ret = __clone2(fn, stack, __LXC_STACK_SIZE, flags | SIGCHLD, &clone_arg, pidfd);
ret = __clone2(fn, stack, __LXC_STACK_SIZE, flags | SIGCHLD, arg, pidfd);
#else
ret = clone(fn, stack + __LXC_STACK_SIZE, flags | SIGCHLD, &clone_arg, pidfd);
ret = clone(fn, stack + __LXC_STACK_SIZE, flags | SIGCHLD, arg, pidfd);
#endif
if (ret < 0)
SYSERROR("Failed to clone (%#x)", flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment