-
Notifications
You must be signed in to change notification settings - Fork 9
/
ns.h
68 lines (57 loc) · 1.37 KB
/
ns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Copyright © 2020 Arista Networks, Inc. All rights reserved.
*
* Use of this source code is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef NS_H_
# define NS_H_
struct cloneflag {
int flag;
const char *proc_ns_name;
};
enum {
/* To ensure backward and forward compatibility for the ability of
unsharing the maximum of namespaces, we re-define these constants. */
BST_CLONE_NEWNET = 0x40000000,
BST_CLONE_NEWUTS = 0x04000000,
BST_CLONE_NEWCGROUP = 0x02000000,
BST_CLONE_NEWNS = 0x00020000,
BST_CLONE_NEWPID = 0x20000000,
BST_CLONE_NEWUSER = 0x10000000,
BST_CLONE_NEWIPC = 0x08000000,
BST_CLONE_NEWTIME = 0x00000080,
ALL_NAMESPACES = 0
| BST_CLONE_NEWCGROUP
| BST_CLONE_NEWIPC
| BST_CLONE_NEWNS
| BST_CLONE_NEWNET
| BST_CLONE_NEWPID
| BST_CLONE_NEWUSER
| BST_CLONE_NEWUTS
| BST_CLONE_NEWTIME
};
enum nstype {
NS_CGROUP = 0,
NS_IPC,
NS_MNT,
NS_NET,
NS_PID,
NS_TIME,
NS_USER,
NS_UTS,
MAX_NS
};
enum nsaction {
NSACTION_SHARE_WITH_PARENT = -1,
NSACTION_UNSHARE = -2,
};
struct nsid {
int ns;
enum nsaction action;
};
const char *ns_name(enum nstype);
int ns_cloneflag(enum nstype);
void opts_to_nsactions(const char *shares[], enum nsaction *nsactions);
void ns_enter_prefork(struct nsid *namespaces, size_t *len);
void ns_enter_postfork(struct nsid *namespaces, size_t len);
#endif /* !NS_H_ */