2014-02-19 22:55:34 +00:00
|
|
|
package main
|
2014-02-19 00:56:11 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/dotcloud/docker/pkg/libcontainer"
|
2014-02-20 00:40:36 +00:00
|
|
|
"syscall"
|
2014-02-19 00:56:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var namespaceMap = map[libcontainer.Namespace]int{
|
2014-02-20 00:40:36 +00:00
|
|
|
libcontainer.CLONE_NEWNS: syscall.CLONE_NEWNS,
|
|
|
|
libcontainer.CLONE_NEWUTS: syscall.CLONE_NEWUTS,
|
|
|
|
libcontainer.CLONE_NEWIPC: syscall.CLONE_NEWIPC,
|
|
|
|
libcontainer.CLONE_NEWUSER: syscall.CLONE_NEWUSER,
|
|
|
|
libcontainer.CLONE_NEWPID: syscall.CLONE_NEWPID,
|
|
|
|
libcontainer.CLONE_NEWNET: syscall.CLONE_NEWNET,
|
2014-02-19 00:56:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 07:13:36 +00:00
|
|
|
// getNamespaceFlags parses the container's Namespaces options to set the correct
|
|
|
|
// flags on clone, unshare, and setns
|
|
|
|
func getNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) {
|
|
|
|
for _, ns := range namespaces {
|
|
|
|
flag |= namespaceMap[ns]
|
|
|
|
}
|
2014-02-19 22:33:25 +00:00
|
|
|
return flag
|
2014-02-19 07:13:36 +00:00
|
|
|
}
|