summaryrefslogtreecommitdiff
path: root/lib/variables.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-02-25 23:18:24 -0500
committerJavier Martinez Canillas <javier@dowhile0.org>2021-03-09 09:15:27 +0100
commit58cf755d5fd5b3d1f87a5936107a70705ccbb57b (patch)
tree98a08fec8bdc5a598fe9146927b17f0390088f7a /lib/variables.c
parent74d26654d55a4f32e58b76757efca50ceedefef4 (diff)
downloadefi-boot-shim-58cf755d5fd5b3d1f87a5936107a70705ccbb57b.tar.gz
efi-boot-shim-58cf755d5fd5b3d1f87a5936107a70705ccbb57b.zip
Add get_variable_size()/set_variable()del_variable() wrappers.
This get_variable_size() implementation success in either of two cases: - EFI_SUCCESS with *lenp == 0 if the variable isn't found - EFI_SUCCESS with *lenp > 0 on success In the event of other errors, it returns them to you. There's nothing particularly interesting about the set_variable() or del_variable() implementation here. Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'lib/variables.c')
-rw-r--r--lib/variables.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/variables.c b/lib/variables.c
index 0431d4a2..6db069ef 100644
--- a/lib/variables.c
+++ b/lib/variables.c
@@ -260,6 +260,43 @@ get_variable(const CHAR16 * const var, UINT8 **data, UINTN *len, EFI_GUID owner)
}
EFI_STATUS
+get_variable_size(const CHAR16 * const var, EFI_GUID owner, UINTN *lenp)
+{
+ UINTN len = 0;
+ EFI_STATUS efi_status;
+
+ efi_status = get_variable_attr(var, NULL, &len, owner, NULL);
+ if (EFI_ERROR(efi_status)) {
+ if (efi_status == EFI_BUFFER_TOO_SMALL) {
+ *lenp = len;
+ return EFI_SUCCESS;
+ } else if (efi_status == EFI_NOT_FOUND) {
+ *lenp = 0;
+ return EFI_SUCCESS;
+ }
+ return efi_status;
+ }
+ /*
+ * who knows what this means, but...
+ */
+ *lenp = len;
+ return efi_status;
+}
+
+EFI_STATUS
+set_variable(CHAR16 *var, EFI_GUID owner, UINT32 attributes,
+ UINTN datasize, void *data)
+{
+ return gRT->SetVariable(var, &owner, attributes, datasize, data);
+}
+
+EFI_STATUS
+del_variable(CHAR16 *var, EFI_GUID owner)
+{
+ return set_variable(var, owner, 0, 0, "");
+}
+
+EFI_STATUS
find_in_esl(UINT8 *Data, UINTN DataSize, UINT8 *key, UINTN keylen)
{
EFI_SIGNATURE_LIST *CertList;