• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************/
2 /*                                                                            */
3 /* Copyright (c) Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, 2009      */
4 /*                                                                            */
5 /* This program is free software;  you can redistribute it and/or modify      */
6 /* it under the terms of the GNU General Public License as published by       */
7 /* the Free Software Foundation; either version 2 of the License, or          */
8 /* (at your option) any later version.                                        */
9 /*                                                                            */
10 /* This program is distributed in the hope that it will be useful,            */
11 /* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
13 /* the GNU General Public License for more details.                           */
14 /*                                                                            */
15 /* You should have received a copy of the GNU General Public License          */
16 /* along with this program;  if not, write to the Free Software               */
17 /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
18 /*                                                                            */
19 /******************************************************************************/
20 
21 #define _GNU_SOURCE
22 
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <sys/wait.h>
26 #include <sys/mount.h>
27 #include <unistd.h>
28 #include <sched.h>
29 #include <errno.h>
30 #include <stdlib.h>
31 #include "test.h"
32 
child(void * arg)33 static int child(void *arg)
34 {
35 	char **argv = (char **)arg;
36 	argv++;
37 	mount("/tmp/", "/tmp/", "tmpfs", 0, NULL);
38 	execvp(argv[0], argv);
39 	_exit(1);
40 }
41 
main(int argc,char * argv[])42 int main(int argc, char *argv[])
43 {
44 	char c = 0;
45 	const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child, (void *)argv);
46 	while (waitpid(pid, NULL, __WALL) == EOF && errno == EINTR)
47 		c++;		/* Dummy. */
48 	return 0;
49 }
50