xref: /aosp_15_r20/external/ltp/testcases/lib/tst_ns_common.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright (c) 2015 Red Hat, Inc.
3  * Copyright (c) Linux Test Project, 2015-2023
4  */
5 
6 #ifndef TST_NS_COMMON_H__
7 #define TST_NS_COMMON_H__
8 #include <sched.h>
9 #include "lapi/sched.h"
10 
11 #define PROC_PATH "/proc"
12 
13 struct param {
14 	const char *name;
15 	int flag;
16 };
17 
18 static struct param params[] = {
19 	{"ipc",  CLONE_NEWIPC},
20 	{"mnt",  CLONE_NEWNS},
21 	{"net",  CLONE_NEWNET},
22 	{"pid",  CLONE_NEWPID},
23 	{"user", CLONE_NEWUSER},
24 	{"uts",  CLONE_NEWUTS},
25 	{NULL,   0}
26 };
27 
28 #define NS_TOTAL (ARRAY_SIZE(params) - 1)
29 
get_param(const char * name)30 static struct param *get_param(const char *name)
31 {
32 	int i;
33 
34 	for (i = 0; params[i].name; i++) {
35 		if (!strcasecmp(params[i].name, name))
36 			return params + i;
37 	}
38 
39 	return NULL;
40 }
41 
42 #endif /* TST_NS_COMMON_H__ */
43