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

Function getStatFileContentUint64

cgroup2/utils.go:267–294  ·  view source on GitHub ↗

Gets uint64 parsed content of single value cgroup stat file

(filePath string)

Source from the content-addressed store, hash-verified

265
266// Gets uint64 parsed content of single value cgroup stat file
267func getStatFileContentUint64(filePath string) uint64 {
268 f, err := os.Open(filePath)
269 if err != nil {
270 return 0
271 }
272 defer f.Close()
273
274 // We expect an unsigned 64 bit integer, or a "max" string
275 // in some cases.
276 buf := make([]byte, 32)
277 n, err := f.Read(buf)
278 if err != nil {
279 return 0
280 }
281
282 trimmed := strings.TrimSpace(string(buf[:n]))
283 if trimmed == "max" {
284 return math.MaxUint64
285 }
286
287 res, err := parseUint(trimmed, 10, 64)
288 if err != nil {
289 log.L.Errorf("unable to parse %q as a uint from Cgroup file %q", trimmed, filePath)
290 return res
291 }
292
293 return res
294}
295
296// getKVStatsFileContentUint64 gets uint64 parsed content of key-value cgroup stat file
297func getKVStatsFileContentUint64(filePath string, propertyName string) uint64 {

Callers 4

readHugeTlbStatsFunction · 0.85
StatFilteredMethod · 0.85
readMemoryStatsFunction · 0.85

Calls 1

parseUintFunction · 0.70

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…