efivarfs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Overview

Package efivarfs allows interaction with efivarfs of the linux kernel.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFsNotMounted is caused if no vailed efivarfs magic is found
	ErrFsNotMounted = errors.New("no efivarfs magic found, is it mounted?")

	// ErrVarsUnavailable is caused by not having a valid backend
	ErrVarsUnavailable = errors.New("no variable backend is available")

	// ErrVarNotExist is caused by accessing a non-existing variable
	ErrVarNotExist = errors.New("variable does not exist")

	// ErrVarPermission is caused by not haven the right permissions either
	// because of not being root or xattrs not allowing changes
	ErrVarPermission = errors.New("permission denied")
)
View Source
var EfiVarFs = "/sys/firmware/efi/efivars/"

EfiVarFs is the path to the efivarfs mount point

Note: This has to be a var instead of const because of our unit tests.

Functions

func RemoveVariable

func RemoveVariable(desc VariableDescriptor) error

RemoveVariable calls remove() on the current efivarfs backend.

func SimpleListVariables

func SimpleListVariables() ([]string, error)

SimpleListVariables is like ListVariables but returns a []string instead of a []VariableDescriptor.

func SimpleRemoveVariable

func SimpleRemoveVariable(v string) error

SimpleRemoveVariable is like RemoveVariable but takes the combined name and guid string of the form name-guid.

func SimpleWriteVariable

func SimpleWriteVariable(v string, attrs VariableAttributes, data *bytes.Buffer) error

SimpleWriteVariable is like WriteVariables but takes the combined name and guid string of the form name-guid and returns a bytes.Buffer instead of a []byte.

func WriteVariable

func WriteVariable(desc VariableDescriptor, attrs VariableAttributes, data []byte) error

WriteVariable calls set() on the current efivarfs backend.

Types

type VariableAttributes

type VariableAttributes uint32

VariableAttributes is an uint32 identifying the variables attributes.

const (
	// AttributeNonVolatile indicates a variable is non volatile.
	AttributeNonVolatile VariableAttributes = 0x00000001
	// AttributeBootserviceAccess indicates a variable is accessible during boot service.
	AttributeBootserviceAccess VariableAttributes = 0x00000002
	// AttributeRuntimeAccess indicates a variable is accessible during runtime.
	AttributeRuntimeAccess VariableAttributes = 0x00000004
	// AttributeHardwareErrorRecord indicates a variable holds hardware error records.
	AttributeHardwareErrorRecord VariableAttributes = 0x00000008
	// AttributeAuthenticatedWriteAccess indicates a variable needs authentication before write access.
	AttributeAuthenticatedWriteAccess VariableAttributes = 0x00000010
	// AttributeTimeBasedAuthenticatedWriteAccess indicates a variable needs time based authentication before write access.
	AttributeTimeBasedAuthenticatedWriteAccess VariableAttributes = 0x00000020
	// AttributeAppendWrite indicates data written to this variable is appended.
	AttributeAppendWrite VariableAttributes = 0x00000040
	// AttributeEnhancedAuthenticatedAccess indicate a variable uses the new authentication format.
	AttributeEnhancedAuthenticatedAccess VariableAttributes = 0x00000080
)

func ReadVariable

func ReadVariable(desc VariableDescriptor) (VariableAttributes, []byte, error)

ReadVariable calls get() on the current efivarfs backend.

func SimpleReadVariable

func SimpleReadVariable(v string) (VariableAttributes, *bytes.Reader, error)

SimpleReadVariable is like ReadVariables but takes the combined name and guid string of the form name-guid and returns a bytes.Reader instead of a []byte.

type VariableDescriptor

type VariableDescriptor struct {
	Name string
	GUID *guid.UUID
}

VariableDescriptor contains the name and GUID identifying a variable

func ListVariables

func ListVariables() ([]VariableDescriptor, error)

ListVariables calls list() on the current efivarfs backend.

Jump to

Keyboard shortcuts

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