lanzaboote: cleanup kernel/initrd opening

This commit is contained in:
Julian Stecklina 2022-11-27 20:04:41 +01:00
parent 3f78939d0a
commit d754a87d5c
1 changed files with 14 additions and 11 deletions

View File

@ -85,7 +85,9 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.expect("Failed to extract configuration from binary. Did you run lanzatool?"); .expect("Failed to extract configuration from binary. Did you run lanzatool?");
let mut kernel_file; let mut kernel_file;
let initrd = { let initrd_file;
{
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)
@ -104,15 +106,16 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.into_regular_file() .into_regular_file()
.expect("Kernel is not a regular file"); .expect("Kernel is not a regular file");
root.open( initrd_file = root
&config.initrd_filename, .open(
FileMode::Read, &config.initrd_filename,
FileAttribute::empty(), FileMode::Read,
) FileAttribute::empty(),
.expect("Failed to open initrd for reading") )
.into_regular_file() .expect("Failed to open initrd for reading")
.expect("Initrd is not a regular file") .into_regular_file()
}; .expect("Initrd is not a regular file");
}
let kernel_cmdline = let kernel_cmdline =
booted_image_cmdline(system_table.boot_services()).expect("Failed to fetch command line"); booted_image_cmdline(system_table.boot_services()).expect("Failed to fetch command line");
@ -145,7 +148,7 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
); );
} }
let mut initrd_loader = InitrdLoader::new(system_table.boot_services(), handle, initrd) let mut initrd_loader = InitrdLoader::new(system_table.boot_services(), handle, initrd_file)
.expect("Failed to load the initrd. It may not be there or it is not signed"); .expect("Failed to load the initrd. It may not be there or it is not signed");
let status = system_table let status = system_table
.boot_services() .boot_services()