File: devices.go

package info (click to toggle)
golang-github-opencontainers-cgroups 0.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 844 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 768 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package fs

import (
	"github.com/opencontainers/cgroups"
)

type DevicesGroup struct{}

func (s *DevicesGroup) Name() string {
	return "devices"
}

func (s *DevicesGroup) Apply(path string, r *cgroups.Resources, pid int) error {
	if r.SkipDevices {
		return nil
	}
	if path == "" {
		// Return error here, since devices cgroup
		// is a hard requirement for container's security.
		return errSubsystemDoesNotExist
	}

	return apply(path, pid)
}

func (s *DevicesGroup) Set(path string, r *cgroups.Resources) error {
	if cgroups.DevicesSetV1 == nil {
		if len(r.Devices) == 0 {
			return nil
		}
		return cgroups.ErrDevicesUnsupported
	}
	return cgroups.DevicesSetV1(path, r)
}

func (s *DevicesGroup) GetStats(path string, stats *cgroups.Stats) error {
	return nil
}