Documentation ¶
Index ¶
- Variables
- func GetGPTTable(device BlockDev) (*gpt.Table, error)
- func GetMountpointByDevice(devicePath string) (*string, error)
- type BlockDev
- func FilterEFISystemPartitions(devices []BlockDev) ([]BlockDev, error)
- func GetBlockStats() ([]BlockDev, error)
- func PartitionsByFsUUID(devices []BlockDev, fsuuid string) []BlockDev
- func PartitionsByGUID(devices []BlockDev, guid string) ([]BlockDev, error)
- func PartitionsByName(devices []BlockDev, name string) []BlockDev
- type BlockStat
Constants ¶
This section is empty.
Variables ¶
var (
// LinuxMountsPath is the standard mountpoint list path
LinuxMountsPath = "/proc/mounts"
)
var SystemPartitionGUID = gpt.Guid([...]byte{
0x28, 0x73, 0x2a, 0xc1,
0x1f, 0xf8,
0xd2, 0x11,
0xba, 0x4b,
0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b,
})
SystemPartitionGUID is the GUID of EFI system partitions EFI System partitions have GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B
Functions ¶
func GetGPTTable ¶
GetGPTTable tries to read a GPT table from the block device described by the passed BlockDev object, and returns a gpt.Table object, or an error if any
func GetMountpointByDevice ¶
GetMountpointByDevice gets the mountpoint by given device name. Returns on first match
Types ¶
type BlockDev ¶
BlockDev maps a device name to a BlockStat structure for a given block device
func FilterEFISystemPartitions ¶
FilterEFISystemPartitions returns a list of BlockDev objects whose underlying block device is a valid EFI system partition, or an error if any
func GetBlockStats ¶
GetBlockStats iterates over /sys/class/block entries and returns a list of BlockDev objects, or an error if any
func PartitionsByFsUUID ¶
PartitionsByFsUUID returns a list of BlockDev objects whose underlying block device has a filesystem with the given UUID
func PartitionsByGUID ¶
PartitionsByGUID returns a list of BlockDev objects whose underlying block device has the given GUID
func PartitionsByName ¶
PartitionsByName returns a list of BlockDev objects whose underlying block device has a Name with the given Name
func (BlockDev) Summary ¶
Summary prints a multiline summary of the BlockDev object https://www.kernel.org/doc/Documentation/block/stat.txt
type BlockStat ¶
type BlockStat struct { ReadIOs uint64 ReadMerges uint64 ReadSectors uint64 ReadTicks uint64 WriteIOs uint64 WriteMerges uint64 WriteSectors uint64 WriteTicks uint64 InFlight uint64 IOTicks uint64 TimeInQueue uint64 // Kernel 4.18 added four fields for discard tracking, see // https://github.com/torvalds/linux/commit/bdca3c87fb7ad1cc61d231d37eb0d8f90d001e0c DiscardIOs uint64 DiscardMerges uint64 DiscardSectors uint64 DiscardTicks uint64 }
BlockStat provides block device information as contained in /sys/class/block/<device_name>/stat
func BlockStatFromBytes ¶
BlockStatFromBytes parses a block stat file and returns a BlockStat object. The format of the block stat file is the one defined by Linux for /sys/class/block/<device_name>/stat