MCPcopy Create free account
hub / github.com/prometheus/procfs / parseMount

Function parseMount

mountstats.go:324–353  ·  view source on GitHub ↗

parseMount parses an entry in /proc/[pid]/mountstats in the format: device [device] mounted on [mount] with fstype [type]

(ss []string)

Source from the content-addressed store, hash-verified

322//
323// device [device] mounted on [mount] with fstype [type]
324func parseMount(ss []string) (*Mount, error) {
325 if len(ss) < deviceEntryLen {
326 return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
327 }
328
329 // Check for specific words appearing at specific indices to ensure
330 // the format is consistent with what we expect
331 format := []struct {
332 i int
333 s string
334 }{
335 {i: 0, s: "device"},
336 {i: 2, s: "mounted"},
337 {i: 3, s: "on"},
338 {i: 5, s: "with"},
339 {i: 6, s: "fstype"},
340 }
341
342 for _, f := range format {
343 if ss[f.i] != f.s {
344 return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
345 }
346 }
347
348 return &Mount{
349 Device: ss[1],
350 Mount: ss[4],
351 Type: ss[7],
352 }, nil
353}
354
355// parseMountStatsNFS parses a MountStatsNFS by scanning additional information
356// related to NFS statistics.

Callers 1

parseMountStatsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…