fb4b8522223c94a7aabecebc4f19850d4462aead
[oom/registrator.git] /
1 // +build linux
2
3 package configs
4
5 import "syscall"
6
7 func (n *Namespace) Syscall() int {
8         return namespaceInfo[n.Type]
9 }
10
11 var namespaceInfo = map[NamespaceType]int{
12         NEWNET:  syscall.CLONE_NEWNET,
13         NEWNS:   syscall.CLONE_NEWNS,
14         NEWUSER: syscall.CLONE_NEWUSER,
15         NEWIPC:  syscall.CLONE_NEWIPC,
16         NEWUTS:  syscall.CLONE_NEWUTS,
17         NEWPID:  syscall.CLONE_NEWPID,
18 }
19
20 // CloneFlags parses the container's Namespaces options to set the correct
21 // flags on clone, unshare. This function returns flags only for new namespaces.
22 func (n *Namespaces) CloneFlags() uintptr {
23         var flag int
24         for _, v := range *n {
25                 if v.Path != "" {
26                         continue
27                 }
28                 flag |= namespaceInfo[v.Type]
29         }
30         return uintptr(flag)
31 }