Documentation ¶
Overview ¶
Package efivarfs allows interaction with efivarfs of the linux kernel.
Package efivarfs allows interaction with efivarfs of the linux kernel.
Index ¶
- Constants
- Variables
- func RemoveVariable(e EFIVar, desc VariableDescriptor) error
- func SimpleListVariables(e EFIVar) ([]string, error)
- func SimpleRemoveVariable(e EFIVar, v string) error
- func SimpleWriteVariable(e EFIVar, v string, attrs VariableAttributes, data *bytes.Buffer) error
- func WriteVariable(e EFIVar, desc VariableDescriptor, attrs VariableAttributes, data []byte) error
- type EFIVar
- type EFIVarFS
- type VariableAttributes
- type VariableDescriptor
Constants ¶
const DefaultVarFS = "/sys/firmware/efi/efivars/"
DefaultVarFS is the path to the efivarfs mount point
const FS_IMMUTABLE_FL = 0x10
FS_IMMUTABLE_FL is an inode flag to make a file immutable.
Variables ¶
var ( fmt.Errorf("no variable backend is available:%w", os.ErrNotExist) // ErrVarNotExist is caused by accessing a non-existing variable ErrVarNotExist = os.ErrNotExist // ErrVarPermission is caused by not haven the right permissions either // because of not being root or xattrs not allowing changes ErrVarPermission = os.ErrPermission // ErrNoFS is returned when the file system is not available for some // reason. ErrNoFS = errors.New("varfs not available") )ErrVarsUnavailable =
var ( // ErrBadGUID is for any errors parsing GUIDs. ErrBadGUID = errors.New("Bad GUID") )
Functions ¶
func RemoveVariable ¶
func RemoveVariable(e EFIVar, desc VariableDescriptor) error
RemoveVariable calls remove() on the current efivarfs backend.
func SimpleListVariables ¶
SimpleListVariables is like ListVariables but returns a []string instead of a []VariableDescriptor.
func SimpleRemoveVariable ¶
SimpleRemoveVariable is like RemoveVariable but takes the combined name and guid string of the form name-guid.
func SimpleWriteVariable ¶
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(e EFIVar, desc VariableDescriptor, attrs VariableAttributes, data []byte) error
WriteVariable calls set() on the current efivarfs backend.
Types ¶
type EFIVar ¶
type EFIVar interface { Get(desc VariableDescriptor) (VariableAttributes, []byte, error) List() ([]VariableDescriptor, error) Remove(desc VariableDescriptor) error Set(desc VariableDescriptor, attrs VariableAttributes, data []byte) error }
EFIVar is the interface for EFI variables. Note that it need not use a file system, but typically does.
type EFIVarFS ¶
type EFIVarFS struct {
// contains filtered or unexported fields
}
EFIVarFS implements EFIVar
func (*EFIVarFS) Get ¶
func (v *EFIVarFS) Get(desc VariableDescriptor) (VariableAttributes, []byte, error)
Get reads the contents of an efivar if it exists and has the necessary permission
func (*EFIVarFS) List ¶
func (v *EFIVarFS) List() ([]VariableDescriptor, error)
List returns the VariableDescriptor for each efivar in the system TODO: why can't list implement
func (*EFIVarFS) Remove ¶
func (v *EFIVarFS) Remove(desc VariableDescriptor) error
Remove makes the specified EFI var mutable and then deletes it
func (*EFIVarFS) Set ¶
func (v *EFIVarFS) Set(desc VariableDescriptor, attrs VariableAttributes, data []byte) error
Set modifies a given efivar with the provided contents
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(e EFIVar, desc VariableDescriptor) (VariableAttributes, []byte, error)
ReadVariable calls get() on the current efivarfs backend.
func SimpleReadVariable ¶
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 ¶
VariableDescriptor contains the name and GUID identifying a variable
func ListVariables ¶
func ListVariables(e EFIVar) ([]VariableDescriptor, error)
ListVariables calls list() on the current efivarfs backend.