2014-05-15 06:21:44 +08:00
|
|
|
package fs
|
|
|
|
|
2014-05-28 08:01:08 +08:00
|
|
|
import "github.com/dotcloud/docker/pkg/libcontainer/cgroups"
|
|
|
|
|
2014-05-15 06:21:44 +08:00
|
|
|
type devicesGroup struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *devicesGroup) Set(d *data) error {
|
|
|
|
dir, err := d.join("devices")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:14:30 +08:00
|
|
|
if !d.c.AllowAllDevices {
|
2014-05-15 06:21:44 +08:00
|
|
|
if err := writeFile(dir, "devices.deny", "a"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:14:30 +08:00
|
|
|
for _, dev := range d.c.AllowedDevices {
|
|
|
|
if err := writeFile(dir, "devices.allow", dev.GetCgroupAllowString()); err != nil {
|
2014-05-15 06:21:44 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *devicesGroup) Remove(d *data) error {
|
|
|
|
return removePath(d.path("devices"))
|
|
|
|
}
|
|
|
|
|
2014-05-28 08:01:08 +08:00
|
|
|
func (s *devicesGroup) GetStats(d *data, stats *cgroups.Stats) error {
|
|
|
|
return nil
|
2014-05-15 06:21:44 +08:00
|
|
|
}
|