mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 23:52:22 +00:00
fix(boot): count tries without using them, add XBOOTLDR once, and warn about dropped initrds
An entry that is not counted in strict mode still has its tries, so it can be bad. Strict mode adds the extended boot loader partition to the first BLS generator only. A chainload chain that does not list an initrd that the entry has now warns, as the kernel may not find its root without it, and strict autoconfigure says when it can't find the partition of Sprout.
This commit is contained in:
1 parent
47020c7b92
commit
5a4bfefb6e
5 files changed
+51
-12
No files matched your search
@@ -8,6 +8,7 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
use anyhow::{Context, Result};
|
||||
use core::sync::atomic::{AtomicBool, Ordering as AtomicOrdering};
|
||||
use core::{cmp::Ordering, str::FromStr};
|
||||
use edera_sprout_bls::{
|
||||
BlsEntry, BootCounter, is_reserved_entry_name, profile_id_suffix, sort_bls, strip_extension,
|
||||
@@ -37,6 +38,10 @@ const ARCHITECTURE: &str = "x64";
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
const ARCHITECTURE: &str = "aa64";
|
||||
|
||||
/// Whether the extended boot loader partition was added by a generator in strict mode, which
|
||||
/// does it once, so that more than one generator does not list its entries twice.
|
||||
static STRICT_XBOOTLDR_ADDED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// The number of initrd slots set on each BLS entry.
|
||||
/// Entries set `initrd-0` through `initrd-31`, and slots without an initrd are empty.
|
||||
pub const BLS_INITRD_SLOTS: usize = 32;
|
||||
@@ -311,9 +316,7 @@ fn generate_type1(
|
||||
// systemd-boot only counts the tries of the entries it boots as a kernel or as a unified
|
||||
// kernel image, and not those of a plain EFI program.
|
||||
let counted = !(strict && entry.linux.is_none() && entry.uki.is_none());
|
||||
if let Some(counter) = boot_counter
|
||||
&& counted
|
||||
{
|
||||
if let Some(counter) = boot_counter {
|
||||
boot.set_boot_counter(BootCounterTarget {
|
||||
counter,
|
||||
filesystem: bls_resolved.filesystem_handle,
|
||||
@@ -321,6 +324,7 @@ fn generate_type1(
|
||||
id: name.clone(),
|
||||
file_name,
|
||||
extension,
|
||||
counting: counted,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -446,6 +450,7 @@ fn generate_type2(
|
||||
id: id.clone(),
|
||||
file_name: file_name.clone(),
|
||||
extension: extension.clone(),
|
||||
counting: true,
|
||||
});
|
||||
}
|
||||
found.push((entry, boot));
|
||||
@@ -532,7 +537,9 @@ pub fn generate(context: Rc<SproutContext>, bls: &BlsConfiguration) -> Result<Ve
|
||||
|
||||
// Add the entries of the Extended Boot Loader Partition, which are sorted together with the
|
||||
// others. A problem with it should not prevent booting from the entries that are found.
|
||||
if bls.xbootldr || context.root().options().bls_strict_mode {
|
||||
let strict_xbootldr = context.root().options().bls_strict_mode
|
||||
&& !STRICT_XBOOTLDR_ADDED.swap(true, AtomicOrdering::Relaxed);
|
||||
if bls.xbootldr || strict_xbootldr {
|
||||
match xbootldr_root(&context) {
|
||||
Ok(Some(root)) => {
|
||||
let xbootldr_uki = uki_path.as_ref().map(|_| format!("{}\\EFI\\Linux", root));
|
||||
|
||||
Reference in new issue
Block a user