boot: Use device_path_to_str

This commit is contained in:
Jan Janssen
2022-10-12 13:19:34 +02:00
parent 3b3eb196a2
commit 616a80fe1a
4 changed files with 19 additions and 15 deletions
+8 -5
View File
@@ -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);
+7 -2
View File
@@ -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)
+3 -3
View File
@@ -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)
+1 -5
View File
@@ -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 */