efi

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package efi contains a boot management library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVariableNames

func GetVariableNames(efiVars Variables, filterGUID efi.GUID) (names []string, err error)

GetVariableNames returns the names of every variable with the specified GUID.

func VariablesSupported

func VariablesSupported(efiVars Variables) bool

VariablesSupported indicates whether variables can be accessed.

Types

type BootEntry

type BootEntry struct {
	Filename    string
	Label       string
	Options     string
	Description string
}

BootEntry is a boot entry.

type BootEntryVariable

type BootEntryVariable struct {
	BootNumber int                    // number of the Boot variable, for example, for Boot0004 this is 4
	Data       []byte                 // the data of the variable
	Attributes efi.VariableAttributes // any attributes set on the variable
	LoadOption *efi.LoadOption        // the data of the variable parsed as a load option, if it is a valid load option
}

BootEntryVariable defines a boot entry variable

type BootManager

type BootManager struct {
	// contains filtered or unexported fields
}

BootManager manages the boot device selection menu entries (Boot0000...BootFFFF).

func NewBootManagerForVariables

func NewBootManagerForVariables(efivars Variables) (BootManager, error)

NewBootManagerForVariables returns a boot manager for the given EFIVariables manager

func (*BootManager) FindOrCreateEntry

func (bm *BootManager) FindOrCreateEntry(entry BootEntry, relativeTo string) (int, error)

FindOrCreateEntry finds a matching entry in the boot device selection menu, or creates one if it is missing.

It returns the number of the entry created, or -1 on failure, with error set.

The argument relativeTo specifies the directory entry.Filename is in.

func (*BootManager) NextFreeEntry

func (bm *BootManager) NextFreeEntry() (int, error)

NextFreeEntry returns the number of the next free Boot variable.

func (*BootManager) PrependAndSetBootOrder

func (bm *BootManager) PrependAndSetBootOrder(head []int) error

PrependAndSetBootOrder commits a new boot order or returns an error.

The boot order specified is prepended to the existing one, and the order is deduplicated before committing.

type MockEFIVariables

type MockEFIVariables struct {
	// contains filtered or unexported fields
}

MockEFIVariables implements an in-memory variable store.

func (MockEFIVariables) DelVariable

func (m MockEFIVariables) DelVariable(_ efi.GUID, _ string) error

func (MockEFIVariables) GetVariable

func (m MockEFIVariables) GetVariable(guid efi.GUID, name string) (data []byte, attrs efi.VariableAttributes, err error)

GetVariable implements EFIVariables

func (MockEFIVariables) JSON

func (m MockEFIVariables) JSON() ([]byte, error)

JSON renders the MockEFIVariables as an Azure JSON config

func (MockEFIVariables) ListVariables

func (m MockEFIVariables) ListVariables() (out []efi.VariableDescriptor, err error)

ListVariables implements EFIVariables

func (MockEFIVariables) NewFileDevicePath

func (*MockEFIVariables) SetVariable

func (m *MockEFIVariables) SetVariable(guid efi.GUID, name string, data []byte, attrs efi.VariableAttributes) error

SetVariable implements EFIVariables

type RealEFIVariables

type RealEFIVariables struct{}

RealEFIVariables provides the real implementation of efivars

func (RealEFIVariables) DelVariable

func (v RealEFIVariables) DelVariable(guid efi.GUID, name string) error

func (RealEFIVariables) GetVariable

func (RealEFIVariables) GetVariable(guid efi.GUID, name string) (data []byte, attrs efi.VariableAttributes, err error)

GetVariable proxy

func (RealEFIVariables) ListVariables

func (RealEFIVariables) ListVariables() ([]efi.VariableDescriptor, error)

ListVariables proxy

func (RealEFIVariables) NewFileDevicePath

func (v RealEFIVariables) NewFileDevicePath(filepath string, mode efi_linux.FilePathToDevicePathMode) (efi.DevicePath, error)

func (RealEFIVariables) SetVariable

func (RealEFIVariables) SetVariable(guid efi.GUID, name string, data []byte, attrs efi.VariableAttributes) error

SetVariable proxy

type Variables

type Variables interface {
	ListVariables() ([]efi.VariableDescriptor, error)
	GetVariable(guid efi.GUID, name string) (data []byte, attrs efi.VariableAttributes, err error)
	SetVariable(guid efi.GUID, name string, data []byte, attrs efi.VariableAttributes) error
	NewFileDevicePath(filepath string, mode efi_linux.FilePathToDevicePathMode) (efi.DevicePath, error)
	DelVariable(guid efi.GUID, name string) error
}

Variables abstracts away the host-specific bits of the efivars module

Jump to

Keyboard shortcuts

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