1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

boot: Add efivar_get_boolean_u8()

This commit is contained in:
Daan De Meyer 2021-01-31 10:56:21 +00:00
parent 5e1f0e6fca
commit 2a7c16753b
3 changed files with 17 additions and 5 deletions

View File

@ -4,11 +4,10 @@
#include "util.h"
BOOLEAN secure_boot_enabled(void) {
_cleanup_freepool_ CHAR8 *b = NULL;
UINTN size;
BOOLEAN secure;
EFI_STATUS err;
if (efivar_get_raw(EFI_GLOBAL_GUID, L"SecureBoot", &b, &size) == EFI_SUCCESS)
return *b > 0;
err = efivar_get_boolean_u8(EFI_GLOBAL_GUID, L"SecureBoot", &secure);
return FALSE;
return !EFI_ERROR(err) && secure;
}

View File

@ -166,6 +166,18 @@ EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **bu
return err;
}
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret) {
_cleanup_freepool_ CHAR8 *b = NULL;
UINTN size;
EFI_STATUS err;
err = efivar_get_raw(vendor, name, &b, &size);
if (!EFI_ERROR(err))
*ret = *b > 0;
return err;
}
VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) {
CHAR16 str[32];

View File

@ -29,6 +29,7 @@ VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec);
EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value);
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **buffer, UINTN *size);
EFI_STATUS efivar_get_int(const EFI_GUID *vendor, const CHAR16 *name, UINTN *i);
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret);
CHAR8 *strchra(CHAR8 *s, CHAR8 c);
CHAR16 *stra_to_path(CHAR8 *stra);