SysBlockDeviceSize returns the size of the block device from /sys/block/ /size in bytes by multiplying the value by the Linux sector length of 512.
(device string)
| 485 | // SysBlockDeviceSize returns the size of the block device from /sys/block/<device>/size |
| 486 | // in bytes by multiplying the value by the Linux sector length of 512. |
| 487 | func (fs FS) SysBlockDeviceSize(device string) (uint64, error) { |
| 488 | size, err := parsers.ReadUintFromFile(fs.sys.Path(sysBlockPath, device, sysBlockSize)) |
| 489 | if err != nil { |
| 490 | return 0, err |
| 491 | } |
| 492 | return procfs.SectorSize * size, nil |
| 493 | } |
| 494 | |
| 495 | // SysBlockDeviceRotational returns the rotational value for the block device |
| 496 | // from /sys/block/<device>/queue/rotational. |