MCPcopy Create free account
hub / github.com/containers/common / readCgroup2MapPath

Function readCgroup2MapPath

pkg/cgroups/cgroups.go:642–665  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

640}
641
642func readCgroup2MapPath(path string) (map[string][]string, error) {
643 ret := map[string][]string{}
644 f, err := os.Open(path)
645 if err != nil {
646 if os.IsNotExist(err) {
647 return ret, nil
648 }
649 return nil, errors.Wrapf(err, "open file %s", path)
650 }
651 defer f.Close()
652 scanner := bufio.NewScanner(f)
653 for scanner.Scan() {
654 line := scanner.Text()
655 parts := strings.Fields(line)
656 if len(parts) < 2 {
657 continue
658 }
659 ret[parts[0]] = parts[1:]
660 }
661 if err := scanner.Err(); err != nil {
662 return nil, errors.Wrapf(err, "parsing file %s", path)
663 }
664 return ret, nil
665}
666
667func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, error) {
668 p := filepath.Join(cgroupRoot, ctr.path, name)

Callers 2

GetSystemCPUUsageFunction · 0.85
readCgroup2MapFileFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…