2
* Copyright (C) 2007 Novell/SUSE
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation, version 2 of the
15
#include <sys/types.h>
24
#include <linux/unistd.h>
26
struct option long_options[] =
28
{"newns", 0, 0, 'n'}, /* create a new namespace */
32
static void usage (char * program) {
33
fprintf(stderr, "usage: %s [arguments]\n",
35
fprintf(stderr, "%s\n", "$Id$");
39
static int filedes[2] = {-1, -1};
41
static int do_child(void *arg)
47
rc = write(filedes[1], "PASS\n", strlen("PASS\n"));
49
perror("FAIL: write failed");
56
int main(int argc, char *argv[])
62
int stack_size = PAGE_SIZE << 4;
63
void *child_stack = malloc(stack_size);
64
int clone_flags = SIGCHLD;
66
while ((c = getopt_long (argc, argv, "+hn", long_options, NULL)) != -1) {
69
clone_flags |= CLONE_NEWNS;
85
perror("FAIL: pipe failed");
89
rc = clone(do_child, child_stack + stack_size, clone_flags, argv);
91
perror("FAIL: clone failed");
96
rc = waitpid(-1, (&waitstatus), __WALL);
98
read(filedes[0], &buf, sizeof(buf));
100
fprintf(stderr, "FAIL: wait failed - %s\n",
105
if ((WEXITSTATUS(waitstatus) == 0) && strcmp("PASS\n", buf) == 0) {
109
return WEXITSTATUS(waitstatus);