mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
efi: Add grub_efi_set_variable_to_string()
Add a function that sets an EFI variable to a string value. The string is converted from UTF-8 to UTF-16. Signed-off-by: Oliver Steffen <osteffen@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
a0b16564ee
commit
e83a88f6ea
2 files changed
+25
No files matched your search
@@ -286,6 +286,28 @@ grub_efi_get_variable_with_attributes (const char *var,
|
||||
return status;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_efi_set_variable_to_string (const char *name, const grub_guid_t *guid,
|
||||
const char *value, grub_efi_uint32_t attributes)
|
||||
{
|
||||
grub_efi_char16_t *value_16;
|
||||
grub_ssize_t len16;
|
||||
grub_err_t status;
|
||||
|
||||
len16 = grub_utf8_to_utf16_alloc (value, &value_16, NULL);
|
||||
|
||||
if (len16 < 0)
|
||||
return grub_errno;
|
||||
|
||||
status = grub_efi_set_variable_with_attributes (name, guid,
|
||||
(void *) value_16, (len16 + 1) * sizeof (value_16[0]),
|
||||
attributes);
|
||||
|
||||
grub_free (value_16);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
grub_efi_status_t
|
||||
grub_efi_get_variable (const char *var, const grub_guid_t *guid,
|
||||
grub_size_t *datasize_out, void **data_out)
|
||||
|
||||
Reference in new issue
Block a user