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