mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 22:02:20 +00:00
fix(chainload): skip initrd paths without a file component
Autoconfigured BLS actions use "$root\\$initrd" as the initrd path. For BLS entries without an initrd line this stamps to the root of the filesystem, and Sprout tried to read that directory as the initrd, failing the boot. Treat a path that resolves to no file as no initrd.
This commit is contained in:
1 parent
9967a7ab80
commit
6f84a1014a
1 file changed
+20
-9
@@ -77,15 +77,26 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
|
|||||||
// If an initrd is provided, register it with the EFI stack.
|
// If an initrd is provided, register it with the EFI stack.
|
||||||
let mut initrd_handle = None;
|
let mut initrd_handle = None;
|
||||||
if let Some(linux_initrd) = initrd {
|
if let Some(linux_initrd) = initrd {
|
||||||
let content = eficore::path::read_file_contents(
|
let resolved_initrd =
|
||||||
Some(context.root().loaded_image_path()?),
|
eficore::path::resolve_path(Some(context.root().loaded_image_path()?), &linux_initrd)
|
||||||
&linux_initrd,
|
.context("unable to resolve linux initrd path")?;
|
||||||
)
|
|
||||||
.context("unable to read linux initrd")?;
|
// A path without a file component refers to the root of the filesystem, not an initrd.
|
||||||
let handle =
|
// This happens when a path template like "$root\\$initrd" is stamped with an empty
|
||||||
MediaLoaderHandle::register(LINUX_EFI_INITRD_MEDIA_GUID, content.into_boxed_slice())
|
// initrd value, such as a BLS entry without an initrd.
|
||||||
.context("unable to register linux initrd")?;
|
let initrd_subpath = eficore::path::device_path_subpath(&resolved_initrd.full_path)
|
||||||
initrd_handle = Some(handle);
|
.context("unable to get linux initrd subpath")?;
|
||||||
|
if !initrd_subpath.trim_matches('\\').is_empty() {
|
||||||
|
let content = resolved_initrd
|
||||||
|
.read_file()
|
||||||
|
.context("unable to read linux initrd")?;
|
||||||
|
let handle = MediaLoaderHandle::register(
|
||||||
|
LINUX_EFI_INITRD_MEDIA_GUID,
|
||||||
|
content.into_boxed_slice(),
|
||||||
|
)
|
||||||
|
.context("unable to register linux initrd")?;
|
||||||
|
initrd_handle = Some(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark execution of an entry in the bootloader interface.
|
// Mark execution of an entry in the bootloader interface.
|
||||||
|
|||||||
Reference in new issue
Block a user