• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2014 Red Hat, Inc.
4  * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
5  */
6 
7 #ifndef COMMON_H
8 #define COMMON_H
9 
10 #include "tst_test.h"
11 #include "lapi/sched.h"
12 
13 #define DIRA "LTP_DIR_A"
14 #define DIRB "LTP_DIR_B"
15 
dummy_child(void * v)16 static int dummy_child(void *v)
17 {
18 	(void)v;
19 	return 0;
20 }
21 
check_newns(void)22 static void check_newns(void)
23 {
24 	int pid, status;
25 
26 	pid = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, dummy_child, NULL);
27 	if (pid < 0)
28 		tst_brk(TCONF, "CLONE_NEWNS not supported");
29 
30 	SAFE_WAIT(&status);
31 }
32 
umount_folders(void)33 static void umount_folders(void)
34 {
35 	if (tst_is_mounted(DIRA))
36 		SAFE_UMOUNT(DIRA);
37 
38 	if (tst_is_mounted(DIRB))
39 		SAFE_UMOUNT(DIRB);
40 }
41 
create_folders(void)42 static void create_folders(void)
43 {
44 	SAFE_MKDIR(DIRA, 0777);
45 	SAFE_MKDIR(DIRB, 0777);
46 	SAFE_TOUCH(DIRA "/A", 0, NULL);
47 	SAFE_TOUCH(DIRB "/B", 0, NULL);
48 }
49 
50 #endif
51