efi: move get_dropin_dir to util.c
Will be used elsewhere in a later commit. Rename to clarify that it provides .extra.d/ directories.
This commit is contained in:
+1
-24
@@ -301,29 +301,6 @@ static EFI_STATUS pack_cpio_trailer(
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
static char16_t *get_dropin_dir(const EFI_DEVICE_PATH *file_path) {
|
||||
if (!file_path)
|
||||
return NULL;
|
||||
|
||||
/* A device path is allowed to have more than one file path node. If that is the case they are
|
||||
* supposed to be concatenated. Unfortunately, the device path to text protocol simply converts the
|
||||
* nodes individually and then combines those with the usual '/' for device path nodes. But this does
|
||||
* not create a legal EFI file path that the file protocol can use. */
|
||||
|
||||
/* Make sure we really only got file paths. */
|
||||
for (const EFI_DEVICE_PATH *node = file_path; !device_path_is_end(node);
|
||||
node = device_path_next_node(node))
|
||||
if (node->Type != MEDIA_DEVICE_PATH || node->SubType != MEDIA_FILEPATH_DP)
|
||||
return NULL;
|
||||
|
||||
_cleanup_free_ char16_t *file_path_str = NULL;
|
||||
if (device_path_to_str(file_path, &file_path_str) != EFI_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
convert_efi_path(file_path_str);
|
||||
return xasprintf("%ls.extra.d", file_path_str);
|
||||
}
|
||||
|
||||
EFI_STATUS pack_cpio(
|
||||
EFI_LOADED_IMAGE_PROTOCOL *loaded_image,
|
||||
const char16_t *dropin_dir,
|
||||
@@ -363,7 +340,7 @@ EFI_STATUS pack_cpio(
|
||||
return log_error_status(err, "Unable to open root directory: %m");
|
||||
|
||||
if (!dropin_dir)
|
||||
dropin_dir = rel_dropin_dir = get_dropin_dir(loaded_image->FilePath);
|
||||
dropin_dir = rel_dropin_dir = get_extra_dir(loaded_image->FilePath);
|
||||
|
||||
err = open_directory(root, dropin_dir, &extra_dir);
|
||||
if (err == EFI_NOT_FOUND)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "device-path-util.h"
|
||||
#include "proto/device-path.h"
|
||||
#include "proto/simple-text-io.h"
|
||||
#include "ticks.h"
|
||||
@@ -665,3 +666,26 @@ void *find_configuration_table(const EFI_GUID *guid) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char16_t *get_extra_dir(const EFI_DEVICE_PATH *file_path) {
|
||||
if (!file_path)
|
||||
return NULL;
|
||||
|
||||
/* A device path is allowed to have more than one file path node. If that is the case they are
|
||||
* supposed to be concatenated. Unfortunately, the device path to text protocol simply converts the
|
||||
* nodes individually and then combines those with the usual '/' for device path nodes. But this does
|
||||
* not create a legal EFI file path that the file protocol can use. */
|
||||
|
||||
/* Make sure we really only got file paths. */
|
||||
for (const EFI_DEVICE_PATH *node = file_path; !device_path_is_end(node);
|
||||
node = device_path_next_node(node))
|
||||
if (node->Type != MEDIA_DEVICE_PATH || node->SubType != MEDIA_FILEPATH_DP)
|
||||
return NULL;
|
||||
|
||||
_cleanup_free_ char16_t *file_path_str = NULL;
|
||||
if (device_path_to_str(file_path, &file_path_str) != EFI_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
convert_efi_path(file_path_str);
|
||||
return xasprintf("%ls.extra.d", file_path_str);
|
||||
}
|
||||
|
||||
@@ -212,3 +212,5 @@ static inline bool efi_guid_equal(const EFI_GUID *a, const EFI_GUID *b) {
|
||||
}
|
||||
|
||||
void *find_configuration_table(const EFI_GUID *guid);
|
||||
|
||||
char16_t *get_extra_dir(const EFI_DEVICE_PATH *file_path);
|
||||
|
||||
Reference in New Issue
Block a user