Skip to content

Commit

Permalink
feat(efiboot): improve logging in efiboot boot delete
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz committed Oct 19, 2023
1 parent 93088a2 commit 4a5c556
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions efiboot/src/cli/boot/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ pub fn run(manager: &mut dyn VarManager, id: u16) -> ExitCode {
// in this function, we assume that boot entry presence and boot order id presence are not correlated,
// so we need to remove both of them, no matter if one of these steps raises an error

// delete the entry (note we do not raise the error, see above)
#[allow(unused_must_use)]
{
manager.delete(&Variable::new(&id.boot_var_name()));
// delete the entry
match manager.delete(&Variable::new(&id.boot_var_name())) {
Ok(_) => println!("Deleted entry with success"),
Err(efivar::Error::VarNotFound { var: _ }) => eprintln!("Boot entry not found"),
Err(err) => eprintln!("Failed to delete entry: {}", err),
}

// remove it from boot order
let mut ids = manager.get_boot_order().unwrap();
let old_size = ids.len();
ids.retain(|v| *v != id);
manager.set_boot_order(ids).unwrap();

println!("Deleted entry with success");
if old_size == ids.len() {
eprintln!("Failed to remove id from boot order");
} else {
manager.set_boot_order(ids).unwrap();
}

ExitCode::SUCCESS
}

0 comments on commit 4a5c556

Please sign in to comment.