SysBlockDevices lists the device names from /sys/block/ .
()
| 307 | |
| 308 | // SysBlockDevices lists the device names from /sys/block/<dev>. |
| 309 | func (fs FS) SysBlockDevices() ([]string, error) { |
| 310 | deviceDirs, err := os.ReadDir(fs.sys.Path(sysBlockPath)) |
| 311 | if err != nil { |
| 312 | return nil, err |
| 313 | } |
| 314 | devices := []string{} |
| 315 | for _, deviceDir := range deviceDirs { |
| 316 | devices = append(devices, deviceDir.Name()) |
| 317 | } |
| 318 | return devices, nil |
| 319 | } |
| 320 | |
| 321 | // SysBlockDeviceStat returns stats for the block device read from /sys/block/<device>/stat. |
| 322 | // The number of stats read will be 15 if the discard stats are available (kernel 4.18+) |