mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 18:42:21 +00:00
fix(boot): boot a counted unified kernel image by its renamed file
This commit is contained in:
1 parent
4198dfbb8c
commit
7c4b2e87b0
1 file changed
+18
-2
+18
-2
@@ -722,6 +722,7 @@ fn run(reboot_on_error: &mut bool) -> Result<()> {
|
|||||||
// still be marked as good.
|
// still be marked as good.
|
||||||
// The tries that were left before this boot used one up, if it did.
|
// The tries that were left before this boot used one up, if it did.
|
||||||
let mut consumed_tries_left = None;
|
let mut consumed_tries_left = None;
|
||||||
|
let mut entry_context = entry.context();
|
||||||
if let Some(target) = entry.boot_counter()
|
if let Some(target) = entry.boot_counter()
|
||||||
&& target.counting
|
&& target.counting
|
||||||
{
|
{
|
||||||
@@ -729,6 +730,21 @@ fn run(reboot_on_error: &mut bool) -> Result<()> {
|
|||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
info!("updated boot counter of entry {}: {}", entry.name(), path);
|
info!("updated boot counter of entry {}: {}", entry.name(), path);
|
||||||
consumed_tries_left = Some(target.counter.tries_left);
|
consumed_tries_left = Some(target.counter.tries_left);
|
||||||
|
// A unified kernel image is the entry file itself, so it has to be booted by
|
||||||
|
// its new name.
|
||||||
|
if let Some(chainload) = entry_context.get("chainload")
|
||||||
|
&& let Some(directory) = chainload.len().checked_sub(target.file_name.len())
|
||||||
|
&& chainload
|
||||||
|
.get(directory..)
|
||||||
|
.is_some_and(|name| name.eq_ignore_ascii_case(&target.file_name))
|
||||||
|
&& let Some(renamed) =
|
||||||
|
path.to_string().rsplit('\\').next().map(String::from)
|
||||||
|
{
|
||||||
|
let renamed = format!("{}{}", &chainload[..directory], renamed);
|
||||||
|
let mut context = entry_context.fork();
|
||||||
|
context.set("chainload", renamed);
|
||||||
|
entry_context = context.freeze();
|
||||||
|
}
|
||||||
// Tell the system where the counter is, so it can mark the boot as good.
|
// Tell the system where the counter is, so it can mark the boot as good.
|
||||||
let path = edera_sprout_bls::boot_path(&path.to_string());
|
let path = edera_sprout_bls::boot_path(&path.to_string());
|
||||||
advisory(
|
advisory(
|
||||||
@@ -752,8 +768,8 @@ fn run(reboot_on_error: &mut bool) -> Result<()> {
|
|||||||
|
|
||||||
// Execute all the actions for the selected entry.
|
// Execute all the actions for the selected entry.
|
||||||
for action in &entry.declaration().actions {
|
for action in &entry.declaration().actions {
|
||||||
let action = entry.context().stamp(action);
|
let action = entry_context.stamp(action);
|
||||||
actions::execute(entry.context().clone(), &action)
|
actions::execute(entry_context.clone(), &action)
|
||||||
.context(format!("unable to execute action '{}'", action))?;
|
.context(format!("unable to execute action '{}'", action))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user