]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Use device_path_to_str
authorJan Janssen <medhefgo@web.de>
Tue, 11 Oct 2022 07:45:01 +0000 (09:45 +0200)
committerJan Janssen <medhefgo@web.de>
Wed, 12 Oct 2022 11:19:34 +0000 (13:19 +0200)
src/boot/efi/boot.c
src/boot/efi/cpio.c
src/boot/efi/shim.c
src/boot/efi/stub.c

index 3e3268b4d4ab55b0bbd7d999b42477afb1849392..087d6bf434515ce1b5226132518adfbd4943ebbd 100644 (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);
 
index a800959c884c1038980a381387b50a451a0007dc..6497b05455d67f6e6e3ef1a716c74c6cd76ae976 100644 (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)
index 9a5c1396fd6d1322327eb9cd82b18fd16b147508..8b0407857e9d1b34f0184085ed91de0840ad58ec 100644 (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)
index b4395c2307e5c250918a06dbe462db5d855ae4c7..8bd1e985c917307dce7814e81637958fbaf91818 100644 (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 */