Message ID | 20230526213650.990816-4-raymond.mao@linaro.org |
---|---|
State | Superseded |
Delegated to: | Heinrich Schuchardt |
Headers | show |
Series | Boot variables management for removable media | expand |
On 5/26/23 23:36, Raymond Mao wrote: > 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> > --- > Changes in v2 > - Ignore EFI_NOT_FOUND returned from > efi_bootmgr_update_media_device_boot_option which means no boot > options scanned. > Changes in v3 > - Split the patch into moving and renaming functions and > individual patches for each changed functionality > Changes in v4 > - Revert v2 change of introducing a bool parameter when updating > the boot option. Use short-form of device path by default > Changes in v5 > - Add warning log when a short-form device path doesn't exist > Changes in v6 > - Revert v5 change and use original device path if short-form does > not exist > > lib/efi_loader/efi_bootmgr.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c > index 48cd5f0636..7d0b4f3f90 100644 > --- a/lib/efi_loader/efi_bootmgr.c > +++ b/lib/efi_loader/efi_bootmgr.c > @@ -371,6 +371,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) > @@ -387,6 +388,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;
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 48cd5f0636..7d0b4f3f90 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -371,6 +371,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) @@ -387,6 +388,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;
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> --- Changes in v2 - Ignore EFI_NOT_FOUND returned from efi_bootmgr_update_media_device_boot_option which means no boot options scanned. Changes in v3 - Split the patch into moving and renaming functions and individual patches for each changed functionality Changes in v4 - Revert v2 change of introducing a bool parameter when updating the boot option. Use short-form of device path by default Changes in v5 - Add warning log when a short-form device path doesn't exist Changes in v6 - Revert v5 change and use original device path if short-form does not exist lib/efi_loader/efi_bootmgr.c | 6 ++++++ 1 file changed, 6 insertions(+)