1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00

boot: don't hardcode drop-in paths at multiple places

Instead, let's define them once, and pass them through as parameters
everywhere.
This commit is contained in:
Lennart Poettering 2024-07-04 17:09:06 +02:00
parent 382e4da4a5
commit 8c0d7222b4

View File

@ -1661,7 +1661,9 @@ static void config_load_type1_entries(
/* Adds Boot Loader Type #1 entries (i.e. /loader/entries/….conf) */
err = open_directory(root_dir, u"\\loader\\entries", &entries_dir);
const uint16_t dropin_path[] = u"\\loader\\entries";
err = open_directory(root_dir, dropin_path, &entries_dir);
if (err != EFI_SUCCESS)
return;
@ -1690,7 +1692,7 @@ static void config_load_type1_entries(
if (err != EFI_SUCCESS)
continue;
boot_entry_add_type1(config, device, root_dir, u"\\loader\\entries", f->FileName, content, loaded_image_path);
boot_entry_add_type1(config, device, root_dir, dropin_path, f->FileName, content, loaded_image_path);
}
}
@ -2136,6 +2138,7 @@ static void boot_entry_add_type2(
Config *config,
EFI_HANDLE *device,
EFI_FILE *dir,
const uint16_t *path,
const uint16_t *filename) {
enum {
@ -2156,6 +2159,7 @@ static void boot_entry_add_type2(
assert(config);
assert(device);
assert(dir);
assert(path);
assert(filename);
_cleanup_(file_closep) EFI_FILE *handle = NULL;
@ -2322,7 +2326,7 @@ static void boot_entry_add_type2(
.title = TAKE_PTR(title),
.version = xstrdup16(good_version),
.device = device,
.loader = xasprintf("\\EFI\\Linux\\%ls", filename),
.loader = xasprintf("%ls\\%ls", path, filename),
.sort_key = xstrdup16(good_sort_key),
.key = 'l',
.tries_done = -1,
@ -2331,7 +2335,7 @@ static void boot_entry_add_type2(
};
config_add_entry(config, entry);
boot_entry_parse_tries(entry, u"\\EFI\\Linux", filename, u".efi");
boot_entry_parse_tries(entry, path, filename, u".efi");
if (!PE_SECTION_VECTOR_IS_SET(sections + SECTION_CMDLINE))
return;
@ -2369,7 +2373,9 @@ static void config_load_type2_entries(
assert(device);
assert(root_dir);
err = open_directory(root_dir, u"\\EFI\\Linux", &linux_dir);
const uint16_t dropin_path[] = u"\\EFI\\Linux";
err = open_directory(root_dir, dropin_path, &linux_dir);
if (err != EFI_SUCCESS)
return;
@ -2387,7 +2393,7 @@ static void config_load_type2_entries(
if (startswith_no_case(f->FileName, u"auto-"))
continue;
boot_entry_add_type2(config, device, linux_dir, f->FileName);
boot_entry_add_type2(config, device, linux_dir, dropin_path, f->FileName);
}
}