summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-25 18:19:09 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-16 16:44:34 +0200
commit0e2bc7327428b410feb0e7d7a23ca07f0e810222 (patch)
tree00b8eaf6f14aa6b22356821821956bba6c343c5d /src/boot
parentf82ecab0a9c4c1ef5f43bdee98f128c3a0ee611c (diff)
downloadsystemd-0e2bc7327428b410feb0e7d7a23ca07f0e810222.tar.gz
sd-boot: write the IDs of all discovered entries to an EFI variable
This is primarily useful for debugging, but can be useful for other purposes too. For example userspace could check whether "auto-windows" is included in the list, before triggering a boot-into-windows operation.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/boot.c25
-rw-r--r--src/boot/efi/util.c2
-rw-r--r--src/boot/efi/util.h2
3 files changed, 28 insertions, 1 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index 02c46c44c2..7fff880414 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -2028,6 +2028,29 @@ static VOID config_free(Config *config) {
FreePool(config->entry_oneshot);
}
+static VOID config_write_entries_to_variable(Config *config) {
+ _cleanup_freepool_ CHAR16 *buffer = NULL;
+ UINTN i, sz = 0;
+ CHAR16 *p;
+
+ for (i = 0; i < config->entry_count; i++)
+ sz += StrLen(config->entries[i]->id) + 1;
+
+ p = buffer = AllocatePool(sz * sizeof(CHAR16));
+
+ for (i = 0; i < config->entry_count; i++) {
+ UINTN l;
+
+ l = StrLen(config->entries[i]->id) + 1;
+ CopyMem(p, config->entries[i]->id, l * sizeof(CHAR16));
+
+ p += l;
+ }
+
+ /* Store the full list of discovered entries. */
+ (void) efivar_set_raw(&loader_guid, L"LoaderEntries", buffer, (UINT8*) p - (UINT8*) buffer, FALSE);
+}
+
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
_cleanup_freepool_ CHAR16 *infostr = NULL, *typestr = NULL;
CHAR8 *b;
@@ -2119,6 +2142,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
goto out;
}
+ config_write_entries_to_variable(&config);
+
config_title_generate(&config);
/* select entry by configured pattern or EFI LoaderDefaultEntry= variable */
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index e286b14bcc..fd4be681a5 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -10,7 +10,7 @@
* the (ESP)\loader\entries\<vendor>-<revision>.conf convention and the
* associated EFI variables.
*/
-static const EFI_GUID loader_guid = { 0x4a67b082, 0x0a4c, 0x41cf, {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f} };
+const EFI_GUID loader_guid = { 0x4a67b082, 0x0a4c, 0x41cf, {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f} };
#ifdef __x86_64__
UINT64 ticks_read(VOID) {
diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h
index ae06444014..40ede66d4a 100644
--- a/src/boot/efi/util.h
+++ b/src/boot/efi/util.h
@@ -50,3 +50,5 @@ static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) {
uefi_call_wrapper((*handle)->Close, 1, *handle);
}
+
+const EFI_GUID loader_guid;