mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
sd-boot: Skip adding boot entries when the loader does not exist
This commit is contained in:
parent
b5395600a0
commit
f9f1d01cbd
@ -1300,6 +1300,7 @@ static VOID config_entry_bump_counters(
|
|||||||
static VOID config_entry_add_from_file(
|
static VOID config_entry_add_from_file(
|
||||||
Config *config,
|
Config *config,
|
||||||
EFI_HANDLE *device,
|
EFI_HANDLE *device,
|
||||||
|
EFI_FILE *root_dir,
|
||||||
CHAR16 *path,
|
CHAR16 *path,
|
||||||
CHAR16 *file,
|
CHAR16 *file,
|
||||||
CHAR8 *content,
|
CHAR8 *content,
|
||||||
@ -1310,6 +1311,8 @@ static VOID config_entry_add_from_file(
|
|||||||
UINTN pos = 0;
|
UINTN pos = 0;
|
||||||
CHAR8 *key, *value;
|
CHAR8 *key, *value;
|
||||||
UINTN len;
|
UINTN len;
|
||||||
|
EFI_STATUS err;
|
||||||
|
EFI_FILE_HANDLE handle;
|
||||||
_cleanup_freepool_ CHAR16 *initrd = NULL;
|
_cleanup_freepool_ CHAR16 *initrd = NULL;
|
||||||
|
|
||||||
entry = AllocatePool(sizeof(ConfigEntry));
|
entry = AllocatePool(sizeof(ConfigEntry));
|
||||||
@ -1406,6 +1409,14 @@ static VOID config_entry_add_from_file(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check existence */
|
||||||
|
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
|
||||||
|
if (EFI_ERROR(err)) {
|
||||||
|
config_entry_free(entry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uefi_call_wrapper(handle->Close, 1, handle);
|
||||||
|
|
||||||
/* add initrd= to options */
|
/* add initrd= to options */
|
||||||
if (entry->type == LOADER_LINUX && initrd) {
|
if (entry->type == LOADER_LINUX && initrd) {
|
||||||
if (entry->options) {
|
if (entry->options) {
|
||||||
@ -1503,7 +1514,7 @@ static VOID config_load_entries(
|
|||||||
|
|
||||||
err = file_read(entries_dir, f->FileName, 0, 0, &content, NULL);
|
err = file_read(entries_dir, f->FileName, 0, 0, &content, NULL);
|
||||||
if (!EFI_ERROR(err))
|
if (!EFI_ERROR(err))
|
||||||
config_entry_add_from_file(config, device, L"\\loader\\entries", f->FileName, content, loaded_image_path);
|
config_entry_add_from_file(config, device, root_dir, L"\\loader\\entries", f->FileName, content, loaded_image_path);
|
||||||
}
|
}
|
||||||
uefi_call_wrapper(entries_dir->Close, 1, entries_dir);
|
uefi_call_wrapper(entries_dir->Close, 1, entries_dir);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user