From ba119d398f66da35d3dbc97fce5a7d36cb5f9aff Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Mon, 28 Nov 2022 02:10:41 +0100 Subject: [PATCH] lanzatool: add function documentation --- rust/lanzatool/src/pe.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rust/lanzatool/src/pe.rs b/rust/lanzatool/src/pe.rs index fa74696..17122a2 100644 --- a/rust/lanzatool/src/pe.rs +++ b/rust/lanzatool/src/pe.rs @@ -51,19 +51,27 @@ pub fn lanzaboote_image( wrap_in_pe(target_dir, "lanzaboote-stub.efi", lanzaboote_stub, sections) } +/// Wrap an initrd into a PE binary. +/// +/// This is required for lanzaboote to verify the signature of the +/// initrd. pub fn wrap_initrd(target_dir: &TempDir, initrd_stub: &Path, initrd: &Path) -> Result { let initrd_offs = stub_offset(initrd_stub)?; let sections = vec![s(".initrd", initrd, initrd_offs)]; wrap_in_pe(target_dir, "wrapped-initrd.exe", initrd_stub, sections) } +/// Take a PE binary stub and attach sections to it. +/// +/// The result is then written to a new file. Returns the filename of +/// the generated file. fn wrap_in_pe( target_dir: &TempDir, - filename: &str, + output_filename: &str, stub: &Path, sections: Vec
, ) -> Result { - let image_path = target_dir.path().join(filename); + let image_path = target_dir.path().join(output_filename); let _ = fs::OpenOptions::new() .create(true) .write(true)