[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 01/11] efi: Add grub_efi_set_variable_with_attributes()
From: |
Oliver Steffen |
Subject: |
[PATCH v9 01/11] efi: Add grub_efi_set_variable_with_attributes() |
Date: |
Fri, 26 May 2023 13:35:42 +0200 |
Add a function to the EFI module that allows setting EFI variables
with specific attributes.
This is useful for marking variables as volatile, for example.
Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/kern/efi/efi.c | 20 +++++++++++++-------
include/grub/efi/efi.h | 6 ++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index c84d5d280..4a1df6fb2 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -203,8 +203,8 @@ grub_efi_set_virtual_address_map (grub_efi_uintn_t
memory_map_size,
}
grub_err_t
-grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
- void *data, grub_size_t datasize)
+grub_efi_set_variable_with_attributes (const char *var, const grub_efi_guid_t
*guid,
+ void *data, grub_size_t datasize, grub_efi_uint32_t
attributes)
{
grub_efi_status_t status;
grub_efi_runtime_services_t *r;
@@ -221,11 +221,7 @@ grub_efi_set_variable(const char *var, const
grub_efi_guid_t *guid,
r = grub_efi_system_table->runtime_services;
- status = r->set_variable (var16, guid,
- (GRUB_EFI_VARIABLE_NON_VOLATILE
- | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
- | GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
- datasize, data);
+ status = r->set_variable (var16, guid, attributes, datasize, data);
grub_free (var16);
if (status == GRUB_EFI_SUCCESS)
return GRUB_ERR_NONE;
@@ -233,6 +229,16 @@ grub_efi_set_variable(const char *var, const
grub_efi_guid_t *guid,
return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var);
}
+grub_err_t
+grub_efi_set_variable (const char *var, const grub_efi_guid_t *guid,
+ void *data, grub_size_t datasize)
+{
+ return grub_efi_set_variable_with_attributes (var, guid, data, datasize,
+ GRUB_EFI_VARIABLE_NON_VOLATILE
+ | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
+ | GRUB_EFI_VARIABLE_RUNTIME_ACCESS);
+}
+
grub_efi_status_t
grub_efi_get_variable_with_attributes (const char *var,
const grub_efi_guid_t *guid,
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index d3b967619..26f33433b 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -98,6 +98,12 @@ grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const
char *variable,
grub_size_t
*datasize_out,
void **data_out);
grub_err_t
+EXPORT_FUNC (grub_efi_set_variable_with_attributes) (const char *var,
+ const grub_efi_guid_t *guid,
+ void *data,
+ grub_size_t datasize,
+ grub_efi_uint32_t attributes);
+grub_err_t
EXPORT_FUNC (grub_efi_set_variable) (const char *var,
const grub_efi_guid_t *guid,
void *data,
--
2.40.1
- [PATCH v9 00/11] Add basic Boot Loader Interface support, Oliver Steffen, 2023/05/26
- [PATCH v9 07/11] efi: Add grub_efi_set_variable_to_string(), Oliver Steffen, 2023/05/26
- [PATCH v9 05/11] types.h: Add GRUB_SSIZE_MAX, Oliver Steffen, 2023/05/26
- [PATCH v9 04/11] grub-core: Make use of guid printf format specifier, Oliver Steffen, 2023/05/26
- [PATCH v9 02/11] Unify GUID types, Oliver Steffen, 2023/05/26
- [PATCH v9 06/11] kern/misc, kern/efi: Extract UTF-8 to UTF-16 code, Oliver Steffen, 2023/05/26
- [PATCH v9 01/11] efi: Add grub_efi_set_variable_with_attributes(),
Oliver Steffen <=
- [PATCH v9 03/11] kern/misc: Add a format specifier GUIDs, Oliver Steffen, 2023/05/26
- [PATCH v9 08/11] docs: Reword section headings, Oliver Steffen, 2023/05/26
- [PATCH v9 10/11] Add a module for the Boot Loader Interface, Oliver Steffen, 2023/05/26
- [PATCH v9 09/11] kern: check for NULL when closing devices and disks, Oliver Steffen, 2023/05/26
- [PATCH v9 11/11] util/grub.d: Activate bli module on EFI, Oliver Steffen, 2023/05/26
- Re: [PATCH v9 00/11] Add basic Boot Loader Interface support, Daniel Kiper, 2023/05/30