summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_bootmgr.c
diff options
context:
space:
mode:
authorRaymond Mao <raymond.mao@linaro.org>2023-06-19 14:23:01 -0700
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-07-15 11:20:41 +0200
commit7aa022c797171e4405b66ee41e5644835ca9c9dd (patch)
tree185ef4fddcb561b6fb271657e9e2ea098401ad00 /lib/efi_loader/efi_bootmgr.c
parent9945bc4f867a9d0dd2c69b86b182265320f37d4b (diff)
Load option with short device path for boot vars
The boot variables automatically generated for removable medias should be with short form of device path without device nodes. This is a requirement for the case that a removable media is plugged into a different port but is still able to work with the existing boot variables. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib/efi_loader/efi_bootmgr.c')
-rw-r--r--lib/efi_loader/efi_bootmgr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 993bb1139cd..a40762c74c8 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -368,6 +368,7 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo
struct efi_load_option lo;
char buf[BOOTMENU_DEVICE_NAME_MAX];
struct efi_device_path *device_path;
+ struct efi_device_path *short_dp;
ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler);
if (ret != EFI_SUCCESS)
@@ -384,6 +385,11 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo
p = dev_name;
utf8_utf16_strncpy(&p, buf, strlen(buf));
+ /* prefer to short form device path */
+ short_dp = efi_dp_shorten(device_path);
+ if (short_dp)
+ device_path = short_dp;
+
lo.label = dev_name;
lo.attributes = LOAD_OPTION_ACTIVE;
lo.file_path = device_path;