• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) International Business Machines Corp., 2007
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 * the GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 ***************************************************************************/
17 #ifndef __LIBCLONE_H
18 #define __LIBCLONE_H
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <errno.h>
25 #include <libgen.h>
26 #include <sys/syscall.h>
27 #include <signal.h>
28 #include "lapi/syscalls.h"
29 #include "test.h"
30 #include "lapi/sched.h"
31 
32 #define T_UNSHARE 0
33 #define T_CLONE 1
34 #define T_NONE 2
35 
36 #ifndef SYS_unshare
37 #ifdef __NR_unshare
38 #define SYS_unshare __NR_unshare
39 #elif __i386__
40 #define SYS_unshare 310
41 #elif __ia64__
42 #define SYS_unshare 1296
43 #elif __x86_64__
44 #define SYS_unshare 272
45 #elif __s390x__ || __s390__
46 #define SYS_unshare 303
47 #elif __powerpc__
48 #define SYS_unshare 282
49 #else
50 #error "unshare not supported on this architecure."
51 #endif
52 #endif
53 
54 #ifndef __NR_unshare
55 #define __NR_unshare SYS_unshare
56 #endif
57 
58 /*
59  * Run fn1 in a unshared environmnent, and fn2 in the original context
60  * Fn2 may be NULL.
61  */
62 
63 int do_clone_tests(unsigned long clone_flags,
64 			int(*fn1)(void *arg), void *arg1,
65 			int(*fn2)(void *arg), void *arg2);
66 
67 int do_unshare_tests(unsigned long clone_flags,
68 			int (*fn1)(void *arg), void *arg1,
69 			int (*fn2)(void *arg), void *arg2);
70 
71 int do_fork_tests(int (*fn1)(void *arg), void *arg1,
72 			int (*fn2)(void *arg), void *arg2);
73 
74 int do_clone_unshare_test(int use_clone, unsigned long clone_flags,
75 			int (*fn1)(void *arg), void *arg1);
76 
77 int do_clone_unshare_tests(int use_clone, unsigned long clone_flags,
78 			int (*fn1)(void *arg), void *arg1,
79 			int (*fn2)(void *arg), void *arg2);
80 
81 #endif
82