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

Method dmMultipathPaths

blockdevice/dm_multipath.go:118–142  ·  view source on GitHub ↗

dmMultipathPaths reads the slaves/ directory of a dm device and returns the path devices with their states.

(dmDevice string)

Source from the content-addressed store, hash-verified

116// dmMultipathPaths reads the slaves/ directory of a dm device and returns
117// the path devices with their states.
118func (fs FS) dmMultipathPaths(dmDevice string) ([]DMMultipathPath, error) {
119 slavesDir := fs.sys.Path(sysBlockPath, dmDevice, sysUnderlyingDev)
120
121 entries, err := os.ReadDir(slavesDir)
122 if err != nil {
123 if os.IsNotExist(err) {
124 return nil, nil
125 }
126 return nil, err
127 }
128
129 paths := make([]DMMultipathPath, 0, len(entries))
130 for _, entry := range entries {
131 state, err := util.SysReadFile(fs.sys.Path(sysBlockPath, entry.Name(), sysDevicePath, "state"))
132 if err != nil {
133 return nil, fmt.Errorf("failed to read device/state for %s: %w", entry.Name(), err)
134 }
135 paths = append(paths, DMMultipathPath{
136 Device: entry.Name(),
137 State: state,
138 })
139 }
140
141 return paths, nil
142}

Callers 1

DMMultipathDevicesMethod · 0.95

Calls 3

SysReadFileFunction · 0.92
NameMethod · 0.80
PathMethod · 0.45

Tested by

no test coverage detected