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:
parent
a0b16564ee
commit
e83a88f6ea
@ -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)
|
||||
|
||||
@ -108,6 +108,9 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var,
|
||||
const grub_guid_t *guid,
|
||||
void *data,
|
||||
grub_size_t datasize);
|
||||
grub_err_t
|
||||
EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_guid_t *guid,
|
||||
const char *value, grub_efi_uint32_t attributes);
|
||||
int
|
||||
EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
|
||||
const grub_efi_device_path_t *dp2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user