mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-12 09:46:25 +08:00
7f1bcd5ebf
libcontainer/configs is used by the docker user namespace proposed patchset to use IDMap for uid/gid maps across the codebase. Given the client uses some of this code, it needs to build on non-Linux. This separates out the Linux-only syscalls using build tags. Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
32 lines
693 B
Go
32 lines
693 B
Go
// +build linux
|
|
|
|
package configs
|
|
|
|
import "syscall"
|
|
|
|
func (n *Namespace) Syscall() int {
|
|
return namespaceInfo[n.Type]
|
|
}
|
|
|
|
var namespaceInfo = map[NamespaceType]int{
|
|
NEWNET: syscall.CLONE_NEWNET,
|
|
NEWNS: syscall.CLONE_NEWNS,
|
|
NEWUSER: syscall.CLONE_NEWUSER,
|
|
NEWIPC: syscall.CLONE_NEWIPC,
|
|
NEWUTS: syscall.CLONE_NEWUTS,
|
|
NEWPID: syscall.CLONE_NEWPID,
|
|
}
|
|
|
|
// CloneFlags parses the container's Namespaces options to set the correct
|
|
// flags on clone, unshare. This functions returns flags only for new namespaces.
|
|
func (n *Namespaces) CloneFlags() uintptr {
|
|
var flag int
|
|
for _, v := range *n {
|
|
if v.Path != "" {
|
|
continue
|
|
}
|
|
flag |= namespaceInfo[v.Type]
|
|
}
|
|
return uintptr(flag)
|
|
}
|