---
name: "efi_get_variable"
section: "3"
platform: "linux"
package: "efivar"
version: "39-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/efi_get_variable"
---

# efi\_get\_variable(3)

manipulate UEFI variables

## 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

**efi\_variables\_supported**() tests if the UEFI variable facility is supported on the current machine.

**efi\_del\_variable**() deletes the variable specified by *guid* and *name*.

**efi\_get\_variable**() gets the variable specified by *guid* and *name*. The value is stored in *data*, its size in *data\_size*, and its attributes are stored in *attributes*.

**efi\_get\_variable\_attributes**() gets attributes for the variable specified by *guid* and *name*.

**efi\_get\_variable\_exists**() gets if the variable specified by *guid* and *name* exists.

**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*.

**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.

**efi\_get\_next\_variable\_name**() iterates across the currently extant variables, passing back a guid and name.

**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.

**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}".

**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)](/errno/3.md) 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>
```
