sysfs

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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"
)

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

func NewSysFsDeviceFromDevPath(devPath string) (*Device, error)

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

func (s Device) GetCapacityInBytes() (int64, error)

GetCapacityInBytes gets the capacity of the device in bytes

func (Device) GetDependents

func (s Device) GetDependents() (blockdevice.DependentBlockDevices, error)

GetDependents gets all the dependent devices for a given Device

func (Device) GetDeviceType

func (s Device) GetDeviceType(devType string) (string, error)

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

func (s Device) GetDriveType() (string, error)

GetDriveType gets the drive type of the device based on the rotational value. Can be HDD or SSD

func (Device) GetHardwareSectorSize

func (s Device) GetHardwareSectorSize() (int64, error)

GetHardwareSectorSize gets the hardware sector size of the device

func (Device) GetLogicalBlockSize

func (s Device) GetLogicalBlockSize() (int64, error)

GetLogicalBlockSize gets the logical block size, the caller should handle if 0 LB size is returned

func (Device) GetPhysicalBlockSize

func (s Device) GetPhysicalBlockSize() (int64, error)

GetPhysicalBlockSize gets the physical block size of the device

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL