namespace: remove stack allocations

Switch to a static stack instead of allocating a new one. There's really no point in doing all of the dance to get the current pagesize. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 54b43e8f
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#endif #endif
#include <alloca.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sched.h> #include <sched.h>
...@@ -37,6 +36,7 @@ ...@@ -37,6 +36,7 @@
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "memory_utils.h"
#include "namespace.h" #include "namespace.h"
#include "utils.h" #include "utils.h"
...@@ -53,16 +53,17 @@ static int do_clone(void *arg) ...@@ -53,16 +53,17 @@ static int do_clone(void *arg)
return clone_arg->fn(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) pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
{ {
size_t stack_size;
pid_t ret;
struct clone_arg clone_arg = { struct clone_arg clone_arg = {
.fn = fn, .fn = fn,
.arg = arg, .arg = arg,
}; };
char *stack[__LXC_STACK_SIZE] = {0};
size_t stack_size = lxc_getpagesize(); stack_size = __LXC_STACK_SIZE;
void *stack = alloca(stack_size);
pid_t ret;
#ifdef __ia64__ #ifdef __ia64__
ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg); ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg);
......
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