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

Function parseDevice

proc_maps.go:63–80  ·  view source on GitHub ↗

parseDevice parses the device token of a line and converts it to a dev_t (mkdev) like structure.

(s string)

Source from the content-addressed store, hash-verified

61// parseDevice parses the device token of a line and converts it to a dev_t
62// (mkdev) like structure.
63func parseDevice(s string) (uint64, error) {
64 i := strings.Index(s, ":")
65 if i == -1 {
66 return 0, fmt.Errorf("%w: expected separator `:` in %s", ErrFileParse, s)
67 }
68
69 major, err := strconv.ParseUint(s[0:i], 16, 0)
70 if err != nil {
71 return 0, err
72 }
73
74 minor, err := strconv.ParseUint(s[i+1:], 16, 0)
75 if err != nil {
76 return 0, err
77 }
78
79 return unix.Mkdev(uint32(major), uint32(minor)), nil
80}
81
82// parseAddress converts a hex-string to a uintptr.
83func parseAddress(s string) (uintptr, error) {

Callers 2

BenchmarkParseDeviceFunction · 0.85
parseProcMapFunction · 0.85

Calls

no outgoing calls

Tested by 1

BenchmarkParseDeviceFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…