dmMultipathPaths reads the slaves/ directory of a dm device and returns the path devices with their states.
(dmDevice string)
| 116 | // dmMultipathPaths reads the slaves/ directory of a dm device and returns |
| 117 | // the path devices with their states. |
| 118 | func (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 | } |
no test coverage detected