grub-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]