2014-05-15 06:21:44 +08:00
|
|
|
package fs
|
|
|
|
|
2014-06-10 23:14:16 +08:00
|
|
|
import "github.com/docker/libcontainer/cgroups"
|
2014-05-28 08:01:08 +08:00
|
|
|
|
2014-06-20 21:13:56 +08:00
|
|
|
type DevicesGroup struct {
|
2014-05-15 06:21:44 +08:00
|
|
|
}
|
|
|
|
|
2014-06-20 21:13:56 +08:00
|
|
|
func (s *DevicesGroup) Set(d *data) error {
|
2014-05-15 06:21:44 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2014-06-20 21:13:56 +08:00
|
|
|
func (s *DevicesGroup) Remove(d *data) error {
|
2014-05-15 06:21:44 +08:00
|
|
|
return removePath(d.path("devices"))
|
|
|
|
}
|
|
|
|
|
2014-06-20 21:13:56 +08:00
|
|
|
func (s *DevicesGroup) GetStats(path string, stats *cgroups.Stats) error {
|
2014-05-28 08:01:08 +08:00
|
|
|
return nil
|
2014-05-15 06:21:44 +08:00
|
|
|
}
|
2014-08-06 06:12:28 +08:00
|
|
|
|
|
|
|
func (s *DevicesGroup) Active(d *data) (bool, error) {
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DevicesGroup) Enter(path, pid string) error {
|
|
|
|
return writeFile(path, cgroupProcesses, pid)
|
|
|
|
}
|