From: Jan Janssen Date: Tue, 11 Oct 2022 07:45:01 +0000 (+0200) Subject: boot: Use device_path_to_str X-Git-Tag: v252-rc2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=616a80fe1aa94fae84e488c3cda4237e7b3c1759;p=thirdparty%2Fsystemd.git boot: Use device_path_to_str --- diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 3e3268b4d4a..087d6bf4345 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -563,6 +563,10 @@ static void print_status(Config *config, char16_t *loaded_image_path) { for (UINTN i = 0; i < config->entry_count; i++) { ConfigEntry *entry = config->entries[i]; + _cleanup_free_ char16_t *dp = NULL; + if (entry->device) + (void) device_path_to_str(DevicePathFromHandle(entry->device), &dp); + Print(L" config entry: %" PRIuN L"/%" PRIuN L"\n", i + 1, config->entry_count); ps_string(L" id: %s\n", entry->id); ps_string(L" title: %s\n", entry->title); @@ -570,8 +574,7 @@ static void print_status(Config *config, char16_t *loaded_image_path) { ps_string(L" sort key: %s\n", entry->sort_key); ps_string(L" version: %s\n", entry->version); ps_string(L" machine-id: %s\n", entry->machine_id); - if (entry->device) - Print(L" device: %D\n", DevicePathFromHandle(entry->device)); + ps_string(L" device: %s\n", dp); ps_string(L" loader: %s\n", entry->loader); STRV_FOREACH(initrd, entry->initrd) Print(L" initrd: %s\n", *initrd); @@ -2666,9 +2669,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { if (err != EFI_SUCCESS) return log_error_status_stall(err, L"Error getting a LoadedImageProtocol handle: %r", err); - loaded_image_path = DevicePathToStr(loaded_image->FilePath); - if (!loaded_image_path) - return log_oom(); + err = device_path_to_str(loaded_image->FilePath, &loaded_image_path); + if (err != EFI_SUCCESS) + return log_error_status_stall(err, L"Error getting loaded image path: %m"); export_variables(loaded_image, loaded_image_path, init_usec); diff --git a/src/boot/efi/cpio.c b/src/boot/efi/cpio.c index a800959c884..6497b05455d 100644 --- a/src/boot/efi/cpio.c +++ b/src/boot/efi/cpio.c @@ -382,8 +382,13 @@ EFI_STATUS pack_cpio( return log_error_status_stall( err, L"Unable to open root directory: %r", err); - if (!dropin_dir) - dropin_dir = rel_dropin_dir = xpool_print(L"%D.extra.d", loaded_image->FilePath); + if (!dropin_dir) { + _cleanup_free_ char16_t *file_path = NULL; + err = device_path_to_str(loaded_image->FilePath, &file_path); + if (err != EFI_SUCCESS) + goto nothing; + dropin_dir = rel_dropin_dir = xpool_print(u"%s.extra.d", file_path); + } err = open_directory(root, dropin_dir, &extra_dir); if (err == EFI_NOT_FOUND) diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index 9a5c1396fd6..8b0407857e9 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -122,9 +122,9 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT if (err != EFI_SUCCESS) return err; - dev_path_str = DevicePathToStr(dp); - if (!dev_path_str) - return EFI_OUT_OF_RESOURCES; + err = device_path_to_str(dp, &dev_path_str); + if (err != EFI_SUCCESS) + return err; err = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size); if (err != EFI_SUCCESS) diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index b4395c2307e..8bd1e985c91 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -104,12 +104,8 @@ static void export_variables(EFI_LOADED_IMAGE_PROTOCOL *loaded_image) { if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS && loaded_image->FilePath) { _cleanup_free_ char16_t *s = NULL; - - s = DevicePathToStr(loaded_image->FilePath); - if (s) + if (device_path_to_str(loaded_image->FilePath, &s) == EFI_SUCCESS) efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0); - else - log_oom(); } /* if LoaderFirmwareInfo is not set, let's set it */