in cgroup/util.go [121:168]
func SupportedSubsystems(rootfsMountpoint string) (map[string]struct{}, error) {
if rootfsMountpoint == "" {
rootfsMountpoint = "/"
}
cgroups, err := os.Open(filepath.Join(rootfsMountpoint, "proc", "cgroups"))
if err != nil {
if os.IsNotExist(err) {
return nil, ErrCgroupsMissing
}
return nil, err
}
defer cgroups.Close()
subsystemSet := map[string]struct{}{}
sc := bufio.NewScanner(cgroups)
for sc.Scan() {
line := sc.Text()
// Ignore the header.
if len(line) > 0 && line[0] == '#' {
continue
}
// Parse the cgroup subsystems.
// Format: subsys_name hierarchy num_cgroups enabled
// Example: cpuset 4 1 1
fields := strings.Fields(line)
if len(fields) == 0 {
continue
}
// Check the enabled flag.
if len(fields) > 3 {
enabled := fields[3]
if enabled == "0" {
// Ignore cgroup subsystems that are disabled (via the
// cgroup_disable kernel command-line boot parameter).
continue
}
}
subsystem := fields[0]
subsystemSet[subsystem] = struct{}{}
}
return subsystemSet, sc.Err()
}