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