mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-05 00:52:21 +00:00
* feat(bls): read PE sections without loading the whole image * feat(bls): produce entries from unified kernel images * feat(bls): boot unified kernel images as type 2 entries Scan the EFI/Linux directory, or the new uki-path option of the BLS generator, for .efi files and turn each one into an entry using the metadata in its PE sections. Autoconfigure now also detects a disk that only has unified kernel images. An image with the id of a type 1 entry is skipped, and boot counting works on the .efi file name. * fix(boot): rename boot counter files in place instead of copying them * fix(bls): skip hidden files and keep unified kernel images when the type 1 scan fails Check file name suffixes without slicing by byte offset, drop the PE section bytes once an image has been parsed, and only fail the generator on a type 1 error when unified kernel images are disabled.
This commit is contained in:
9 files changed
+948
-95
No files matched your search
@@ -28,6 +28,8 @@ pub fn scan(
|
||||
let bls_loader_conf_path = Path::new(cstr16!("\\loader\\loader.conf"));
|
||||
// BLS also has an entries directory that can specify explicit entries.
|
||||
let bls_entries_path = Path::new(cstr16!("\\loader\\entries"));
|
||||
// BLS Type #2 entries are unified kernel images in the EFI/Linux directory.
|
||||
let bls_uki_path = Path::new(cstr16!("\\EFI\\Linux"));
|
||||
|
||||
// Convert the device path root to a string we can use in the configuration.
|
||||
let mut root = root
|
||||
@@ -64,9 +66,27 @@ pub fn scan(
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
// Whether we have any unified kernel images.
|
||||
let has_ukis = filesystem
|
||||
.read_dir(bls_uki_path)
|
||||
.map(|mut iterator| {
|
||||
iterator.any(|entry| {
|
||||
entry.is_ok_and(|entry| {
|
||||
entry.is_regular_file()
|
||||
&& entry
|
||||
.file_name()
|
||||
.to_string()
|
||||
.to_lowercase()
|
||||
.ends_with(".efi")
|
||||
})
|
||||
})
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
// Detect if a BLS supported configuration is on this filesystem.
|
||||
// We check both loader.conf and entries directory as only one of them is required.
|
||||
if !(has_loader_conf || has_entries_dir) {
|
||||
// We check loader.conf, the entries directory and unified kernel images, as only one of
|
||||
// them is required.
|
||||
if !(has_loader_conf || has_entries_dir || has_ukis) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -81,6 +101,7 @@ pub fn scan(
|
||||
..Default::default()
|
||||
},
|
||||
path: format!("{}\\loader", root),
|
||||
uki_path: None,
|
||||
pin_names: true,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user