Documentation ¶
Index ¶
- Constants
- type Device
- func (s Device) GetCapacityInBytes() (int64, error)
- func (s Device) GetDeviceType(devType string) (string, error)
- func (s Device) GetDriveType() (string, error)
- func (s Device) GetHardwareSectorSize() (int64, error)
- func (s Device) GetLogicalBlockSize() (int64, error)
- func (s Device) GetPartitions() ([]string, bool)
- func (s Device) GetPhysicalBlockSize() (int64, error)
Constants ¶
const ( // DriveTypeHDD represents a rotating hard disk drive DriveTypeHDD = "HDD" // DriveTypeSSD represents a solid state drive DriveTypeSSD = "SSD" DriverTypeNVMe = "NVMe" // DriveTypeUnknown is used when the drive type of the disk could not be determined. DriveTypeUnknown = "Unknown" )
const ( // BlockSubSystem is the key used to represent block subsystem in sysfs BlockSubSystem = "block" // NVMeSubSystem is the key used to represent nvme subsystem in sysfs NVMeSubSystem = "nvme" )
const ( // SparseBlockDeviceType is the sparse blockdevice type SparseBlockDeviceType = "sparse" // BlockDeviceType is the type for blockdevice. BlockDeviceType = "blockdevice" // BlockDevicePrefix is the prefix used in UUIDs BlockDevicePrefix = BlockDeviceType + "-" // The following blockdevice types correspond to the types as seen by the host system // BlockDeviceTypeDisk represents a disk type BlockDeviceTypeDisk = "disk" // BlockDeviceTypePartition represents a partition BlockDeviceTypePartition = "partition" // BlockDeviceTypeLoop represents a loop device BlockDeviceTypeLoop = "loop" // BlockDeviceTypeDMDevice is a dm device BlockDeviceTypeDMDevice = "dm" // BlockDeviceTypeLVM is an lvm device type BlockDeviceTypeLVM = "lvm" // BlockDeviceTypeCrypt is a LUKS volume BlockDeviceTypeCrypt = "crypt" // BlockDeviceTypeMultiPath is a multipath device BlockDeviceTypeMultiPath = "mpath" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents a blockdevice using its sysfs path.
func NewSysFsDeviceFromDevPath ¶
NewSysFsDeviceFromDevPath is used to get sysfs device struct from the device devpath The sysfs device struct contains the device name along with the syspath
func (Device) GetCapacityInBytes ¶
GetCapacityInBytes gets the capacity of the device in bytes
func (Device) GetDeviceType ¶
GetDeviceType gets the device type, as shown in lsblk devtype should be prefilled by udev probe (DEVTYPE) as disk/part for this to work
Ported from https://github.com/karelzak/util-linux/blob/master/misc-utils/lsblk.c
func (Device) GetDriveType ¶
GetDriveType gets the drive type of the device based on the rotational value. Can be HDD or SSD
func (Device) GetHardwareSectorSize ¶
GetHardwareSectorSize gets the hardware sector size of the device
func (Device) GetLogicalBlockSize ¶
GetLogicalBlockSize gets the logical block size, the caller should handle if 0 LB size is returned
func (Device) GetPartitions ¶
getPartitions gets the partitions of this device if it has any
func (Device) GetPhysicalBlockSize ¶
GetPhysicalBlockSize gets the physical block size of the device