MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / cgroupList

Function cgroupList

pkg/init/cmd/rc.init/main.go:82–107  ·  view source on GitHub ↗

list of all enabled cgroups

()

Source from the content-addressed store, hash-verified

80
81// list of all enabled cgroups
82func cgroupList() []string {
83 var list []string
84 f, err := os.Open("/proc/cgroups")
85 if err != nil {
86 log.Printf("cannot open /proc/cgroups: %v", err)
87 return list
88 }
89 defer f.Close()
90 reader := csv.NewReader(f)
91 // tab delimited
92 reader.Comma = '\t'
93 // four fields
94 reader.FieldsPerRecord = 4
95 cgroups, err := reader.ReadAll()
96 if err != nil {
97 log.Printf("cannot parse /proc/cgroups: %v", err)
98 return list
99 }
100 for _, cg := range cgroups {
101 // see if enabled
102 if cg[3] == "1" {
103 list = append(list, cg[0])
104 }
105 }
106 return list
107}
108
109// write a file, eg sysfs
110func write(path string, value string) {

Callers 1

doMountsFunction · 0.85

Calls 2

OpenMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected