linux

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: LGPL-3.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilePathToDevicePath added in v0.4.0

func FilePathToDevicePath(path string, mode FilePathToDevicePathMode) (out efi.DevicePath, err error)

FilePathToDevicePath creates an EFI device path from the supplied filepath.

If mode is FullPath, this will attempt to create a full device path which requires the use of sysfs. If the device in which the file is stored cannot be mapped to a device path, a ErrNoDevicePath error is returned. This could be because the device is not recognized by this package, or because the device genuinely cannot be mapped to a device path (eg, it is a device-mapper or loop device). In this case, one of the ShortForm modes can be used.

If mode is ShortFormPathHD, this will attempt to create a short-form device path beginning with a HD() component. If the file is stored inside an unpartitioned device, a ErrNoDevicePath error will be returned. In this case, ShortFormPathFile can be used.

When mode is ShortFormPathHD or FullPath and the file is stored inside a partitoned device, read access is required on the underlying block device in order to decode the partition table.

If mode is ShortFormPathFile, this will attempt to create a short-form device path consisting only of the file path relative to the device.

In all modes, read access to the file's directory is required.

func NewHardDriveDevicePathNodeFromDevice

func NewHardDriveDevicePathNodeFromDevice(dev string, part int) (*efi.HardDriveDevicePathNode, error)

NewHardDriveDevicePathNodeFromDevice constructs a HardDriveDevicePathNode for the specified partition on the device or file at the supplied path.

func ReadPartitionTable added in v0.4.0

func ReadPartitionTable(path string, role efi.PartitionTableRole, checkCrc bool) (*efi.PartitionTable, error)

ReadPartitionTable reads a complete GUID partition table from the supplied device path.

This function expects the device to have a valid protective MBR.

If role is efi.PrimaryPartitionTable, this will read the primary partition table that is located immediately after the protective MBR. If role is efi.BackupPartitionTable, this will read the backup partition table that is located at the end of the device.

If checkCrc is true and either CRC check fails for the requested table, an error will be returned. Setting checkCrc to false disables the CRC checks.

Note that whilst this function checks the integrity of the header and partition table entries, it does not check the contents of the partition table entries.

If role is efi.BackupPartitionTable and the backup table is not located at the end of the device, this will return efi.ErrInvalidBackupPartitionTableLocation along with the valid table.

Types

type ErrNoDevicePath

type ErrNoDevicePath string

ErrNoDevicePath is returned from FilePathToDevicePath if the device in which a file is stored cannot be mapped to a device path with the specified mode.

func (ErrNoDevicePath) Error added in v0.3.0

func (e ErrNoDevicePath) Error() string

type FilePathToDevicePathMode added in v0.4.0

type FilePathToDevicePathMode int

FilePathToDevicePathMode specifies the mode for FilePathToDevicePath

const (
	// FullPath indicates that only a full device path should be created.
	FullPath FilePathToDevicePathMode = iota

	// ShortFormPathHD indicates that a short-form device path beginning
	// with a HD() node should be created.
	ShortFormPathHD

	// ShortFormPathFile indicates that a short-form device path consisting
	// of only the file path relative to the device should be created.
	ShortFormPathFile
)

Jump to

Keyboard shortcuts

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