lanzaboote: reorganize to avoid explicit drops

This commit is contained in:
Julian Stecklina 2022-11-26 02:31:01 +01:00
parent 702a38398f
commit 95a03d69bb
1 changed files with 19 additions and 21 deletions

View File

@ -84,13 +84,15 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
EmbeddedConfiguration::new(&mut booted_image_file(system_table.boot_services()).unwrap())
.unwrap();
let mut kernel_file;
let initrd = {
let mut file_system = system_table
.boot_services()
.get_image_file_system(handle)
.unwrap();
let mut root = file_system.open_volume().unwrap();
let mut kernel_file = root
kernel_file = root
.open(
&config.kernel_filename,
FileMode::Read,
@ -100,19 +102,15 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.into_regular_file()
.unwrap();
let initrd = root
.open(
root.open(
&config.initrd_filename,
FileMode::Read,
FileAttribute::empty(),
)
.unwrap()
.into_regular_file()
.unwrap();
// We need to manually drop those to be able to touch the system_table again.
drop(root);
drop(file_system);
.unwrap()
};
let kernel_cmdline = booted_image_cmdline(system_table.boot_services()).unwrap();