MCPcopy Create free account
hub / github.com/containerd/cgroups / readUint

Function readUint

cgroup1/utils.go:135–155  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

133}
134
135func readUint(path string) (uint64, error) {
136 f, err := os.Open(path)
137 if err != nil {
138 return 0, err
139 }
140 defer f.Close()
141
142 // We should only need 20 bytes for the max uint64, but for a nice power of 2
143 // lets use 32.
144 b := make([]byte, 32)
145 n, err := f.Read(b)
146 if err != nil {
147 return 0, err
148 }
149 s := string(bytes.TrimSpace(b[:n]))
150 if s == "max" {
151 // Return 0 for the max value to maintain backward compatibility.
152 return 0, nil
153 }
154 return parseUint(s, 10, 64)
155}
156
157func parseUint(s string, base, bitSize int) (uint64, error) {
158 v, err := strconv.ParseUint(s, base, bitSize)

Callers 7

BenchmarkReaduint64Function · 0.85
TestReadUintFunction · 0.85
readSizeStatMethod · 0.85
StatMethod · 0.85
UpdateMethod · 0.85
StatMethod · 0.85
StatMethod · 0.85

Calls 1

parseUintFunction · 0.70

Tested by 2

BenchmarkReaduint64Function · 0.68
TestReadUintFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…