Update runc to use device structs from updated spec

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2015-08-11 14:24:00 -07:00
parent 0f99c20fd0
commit b5eed4a246
1 changed files with 72 additions and 13 deletions

85
spec.go
View File

@ -15,7 +15,6 @@ import (
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/specs" "github.com/opencontainers/specs"
) )
@ -114,13 +113,67 @@ var specCommand = cli.Command{
"KILL", "KILL",
"NET_BIND_SERVICE", "NET_BIND_SERVICE",
}, },
Devices: []string{ Devices: []specs.Device{
"null", {
"random", Type: 'c',
"full", Path: "/dev/null",
"tty", Major: 1,
"zero", Minor: 3,
"urandom", Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
{
Type: 'c',
Path: "/dev/random",
Major: 1,
Minor: 8,
Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
{
Type: 'c',
Path: "/dev/full",
Major: 1,
Minor: 7,
Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
{
Type: 'c',
Path: "/dev/tty",
Major: 5,
Minor: 0,
Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
{
Type: 'c',
Path: "/dev/zero",
Major: 1,
Minor: 5,
Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
{
Type: 'c',
Path: "/dev/urandom",
Major: 1,
Minor: 9,
Permissions: "rwm",
FileMode: 0666,
UID: 0,
GID: 0,
},
}, },
Resources: specs.Resources{ Resources: specs.Resources{
Memory: specs.Memory{ Memory: specs.Memory{
@ -297,12 +350,18 @@ func createCgroupConfig(name string, spec *specs.LinuxSpec, devices []*configs.D
} }
func createDevices(spec *specs.LinuxSpec, config *configs.Config) error { func createDevices(spec *specs.LinuxSpec, config *configs.Config) error {
for _, name := range spec.Linux.Devices { for _, d := range spec.Linux.Devices {
d, err := devices.DeviceFromPath(filepath.Join("/dev", name), "rwm") device := &configs.Device{
if err != nil { Type: d.Type,
return err Path: d.Path,
Major: d.Major,
Minor: d.Minor,
Permissions: d.Permissions,
FileMode: d.FileMode,
Uid: d.UID,
Gid: d.GID,
} }
config.Devices = append(config.Devices, d) config.Devices = append(config.Devices, device)
} }
return nil return nil
} }