EFI_GET_VARIABLE(3)
π EFI_GET_VARIABLE π
okay bestie, so this is the EFI_GET_VARIABLE(3) page from the Library Functions Manual β it's all about manipulating UEFI variables and it's genuinely iconic. grab a boba, we're doing this π§β¨
β¨ NAME β¨
efi_variables_supported, efi_del_variable, efi_get_variable, efi_get_variable_attributes, efi_get_variable_size, efi_set_variable β manipulate UEFI variables π¦
πΈ SYNOPSIS πΈ
#include <efivar.h>
int efi_variables_supported(void);
int efi_del_variable(efi_guid_t guid, const char *name);
int efi_get_variable(efi_guid_t guid, const char *name,
void **data, ssize_t *data_size,
uint32_t *attributes);
int efi_get_variable_attributes(efi_guid_t guid, const char *name,
uint32_t *attributes);
int efi_get_variable_exists(efi_guid_t guid, const char *name);
int efi_get_variable_size(efi_guid_t guid, const char *name,
size_t *size);
int efi_append_variable(efi_guid_t guid, const char *name,
void *data, size_t data_size,
uint32_t attributes);
int efi_set_variable(efi_guid_t guid, const char *name,
void *data, size_t data_size,
uint32_t attributes, mode_t mode);
int efi_get_next_variable_name(efi_guid_t **guid, char **name);
int efi_str_to_guid(const char *s, efi_guid_t *guid);
int efi_guid_to_str(const efi_guid_t *guid, char **sp);
int efi_name_to_guid(const char *name, efi_guid_t *guid);
int efi_id_guid_to_guid(const char *id_guid, efi_guid_t *guid);
int efi_guid_to_name(efi_guid_t *guid, char **name);
int efi_guid_to_id_guid(efi_guid_t *guid, char **id_guid);
int efi_guid_to_symbol(efi_guid_t *guid, char **symbol);
int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid);
π DESCRIPTION π
okay so here's the whole cast, one by one, no skips π
efi_variables_supported() β tests if the UEFI variable facility is supported on the current machine. vibe check for your hardware, basically.
efi_del_variable() β deletes the variable specified by guid and name. gone. bye. π
efi_get_variable() β gets the variable specified by guid and name. the value lands in data, its size in data_size, and its attributes are stored in attributes. the whole package deal π¦
efi_get_variable_attributes() β gets attributes for the variable specified by guid and name. just the attributes, nothing else, she's focused.
efi_get_variable_exists() β gets if the variable specified by guid and name exists. yes/no moment fr.
efi_get_variable_size() β gets the size of the data for the variable specified by guid and name.
efi_append_variable() β appends data of size size to the variable specified by guid and name. adding on, not replacing π
efi_set_variable() β sets the variable specified by guid and name, and sets the file mode to mode, subject to umask. note that the mode will not persist across a reboot, and that the permissions only apply if on systems using efivarfs. so like, don't get attached to those perms π
efi_get_next_variable_name() β iterates across the currently extant variables, passing back a guid and name. it's giving "one at a time, bestie".
efi_str_to_guid() β parses a UEFI GUID from string form to an efi_guid_t the caller provides.
efi_guid_to_str() β creates a string representation of a UEFI GUID. if sp is NULL, it returns how big the string would be. if sp is not NULL but *sp is NULL, it allocates a string and returns it with. it is the caller's responsibility to free this string. if sp is not NULL and *sp is not NULL, efi_guid_to_str() assumes there is an allocation of suitable size and uses it. three modes, main character energy π
efi_name_to_guid() β translates from a well known name to an efi_guid_t the caller provides.
efi_guid_to_name() β translates from an efi_guid_t to a well known name. if the supplied GUID does not have a well known name, this function is equivalent to efi_guid_to_str().
efi_guid_to_id_guid() β translates from an efi_guid_t to an {ID GUID}. if the supplied GUID has a well known name, the {ID GUID} will be of the form "{name_here}". if not, it will be of the form "{66b2af1c-6211-4082-95cb-9f73a4795a7e}". bestie that's a literal UUID in the manpage, keep it forever π
efi_id_guid_to_guid() β translates from an {ID GUID} to an efi_guid_t the caller provides.
efi_guid_to_symbol() β translates from an efi_guid_t to a unique (within libefivar) C-style symbol name. these symbol names are useful for printing as a unique, easily parsed identifier, and are also provide by the library and its header files.
efi_symbol_to_guid() β translates from a libefivar efi_guid_$FOO symbol name to an efi_guid_t the caller provides.
β RETURN VALUE β
efi_variables_supported() returns true if variables are supported on the running hardware, and false if they are not.
efi_get_next_variable_name() returns 0 when iteration has completed, 1 when iteration has not completed, and -1 on error. in the event of an error, errno(3) is set appropriately.
efi_del_variable(), efi_get_variable(), efi_get_variable_attributes(), efi_get_variable_exists(), efi_get_variable_size(), efi_append_variable(), efi_set_variable(), efi_str_to_guid(), efi_guid_to_str(), efi_name_to_guid(), and efi_guid_to_name() return negative on error and zero on success.
π AUTHORS π
Peter Jones <pjones@redhat.com> β shoutout to the author, we love a legend π«Ά
that's the whole page bestie, no notes, you ate that π β¨
okay so the sign-off: this is from EFI_GET_VARIABLE(3) in the Library Functions Manual, dated Thu Aug 20 2012. vintage but still serving. mwah πππ¦
π¦ where this page comes from
- alpine 3.22: efivar-doc 39-r0 Β· LGPL-2.1-only
- alpine 3.23: efivar-doc 39-r1 Β· LGPL-2.1-only
- alpine 3.24: efivar-doc 39-r1 Β· LGPL-2.1-only
- arch rolling: efivar 39-2 Β· LGPL-2.1-or-later
- centos-stream 10: efivar-devel 39-3.el10 Β· LGPL-2.1-only
- centos-stream 9: efivar-devel 38-3.el9 Β· LGPLv2
- centos-stream 9: efivar-devel 38-3.el9 Β· LGPLv2
- debian trixie: libefivar-dev 38-3.1+b1 Β· LGPL-2.0-or-later
- fedora 43: efivar-devel 39-10.fc43 Β· LGPL-2.1-only
- fedora 43: efivar-devel 39-10.fc43 Β· LGPL-2.1-only
- fedora 44: efivar-devel 39-12.fc44 Β· LGPL-2.1-only
- fedora 44: efivar-devel 39-12.fc44 Β· LGPL-2.1-only
- nixpkgs unstable: efivar 39
- opensuse-leap 16.0: efivar-devel 38-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: efivar-devel 38-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: efivar-devel 38-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: efivar-devel 38-160000.2.2 Β· LGPL-2.1-only
- ubuntu noble: libefivar-dev 38-3.1build1 Β· LGPL-2.0-or-later
- ubuntu questing: libefivar-dev 38-3.1build1
- ubuntu resolute: libefivar-dev 39-2 Β· LGPL-2.0-or-later
- ubuntu stonking: libefivar-dev 39-2 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms