...
1
2
3
4 package configs
5
6 import "golang.org/x/sys/unix"
7
8 func (n *Namespace) Syscall() int {
9 return namespaceInfo[n.Type]
10 }
11
12 var namespaceInfo = map[NamespaceType]int{
13 NEWNET: unix.CLONE_NEWNET,
14 NEWNS: unix.CLONE_NEWNS,
15 NEWUSER: unix.CLONE_NEWUSER,
16 NEWIPC: unix.CLONE_NEWIPC,
17 NEWUTS: unix.CLONE_NEWUTS,
18 NEWPID: unix.CLONE_NEWPID,
19 NEWCGROUP: unix.CLONE_NEWCGROUP,
20 }
21
22
23
24 func (n *Namespaces) CloneFlags() uintptr {
25 var flag int
26 for _, v := range *n {
27 if v.Path != "" {
28 continue
29 }
30 flag |= namespaceInfo[v.Type]
31 }
32 return uintptr(flag)
33 }
34
View as plain text