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