From f9785a40f357af996fef6eab2fe906599586a8e7 Mon Sep 17 00:00:00 2001 From: ChengyuZhu6 Date: Tue, 25 Jul 2023 08:23:27 +0800 Subject: [PATCH] image-rs: add image block device dm-verity and mount Signed-off-by: ChengyuZhu6 --- image-rs/Cargo.toml | 3 +-- image-rs/src/image.rs | 46 ++++++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/image-rs/Cargo.toml b/image-rs/Cargo.toml index b6a75f7f2..b28086466 100644 --- a/image-rs/Cargo.toml +++ b/image-rs/Cargo.toml @@ -2,7 +2,7 @@ name = "image-rs" version = "0.1.0" description = "The OCI Images Rust Crate" -repository = "https://github.com/confidential-containers/image-rs" +repository = "https://github.com/confidential-containers/guest-components/tree/main/image-rs" readme = "README.md" license = "Apache-2.0" authors = ["The image-rs Authors"] @@ -18,7 +18,6 @@ cfg-if = { version = "1.0.0", optional = true } devicemapper = "0.33.5" dircpy = { version = "0.3.12", optional = true } flate2 = "1.0" -flume = "0.10.14" fs_extra = { version = "1.2.0", optional = true } futures = { version = "0.3.28", optional = true } futures-util = "0.3" diff --git a/image-rs/src/image.rs b/image-rs/src/image.rs index 3aec5d781..8d64f6c05 100644 --- a/image-rs/src/image.rs +++ b/image-rs/src/image.rs @@ -657,31 +657,27 @@ mod tests { let veritysetup_bin = VERITYSETUP_PATH .iter() .find(|&path| Path::new(path).exists()) - .copied(); - let output = Command::new( - veritysetup_bin - .as_ref() - .map(OsStr::new) - .unwrap_or_else(|| panic!("Veritysetup path not found")), - ) - .args(&[ - "format", - "--no-superblock", - "--format=1", - "-s", - "", - &format!("--hash={}", verity_option.hashtype), - &format!("--data-block-size={}", verity_option.blocksize), - &format!("--hash-block-size={}", verity_option.hashsize), - "--data-blocks", - verity_option.blocknum.as_str(), - "--hash-offset", - verity_option.offset.as_str(), - loop_device_path_str, - loop_device_path_str, - ]) - .output() - .unwrap_or_else(|err| panic!(err)); + .copied() + .unwrap_or_else(|| panic!("Veritysetup path not found")); + let output = Command::new(veritysetup_bin) + .args(&[ + "format", + "--no-superblock", + "--format=1", + "-s", + "", + &format!("--hash={}", verity_option.hashtype), + &format!("--data-block-size={}", verity_option.blocksize), + &format!("--hash-block-size={}", verity_option.hashsize), + "--data-blocks", + verity_option.blocknum.as_str(), + "--hash-offset", + verity_option.offset.as_str(), + loop_device_path_str, + loop_device_path_str, + ]) + .output() + .unwrap_or_else(|err| panic!(err)); if output.status.success() { let stdout = String::from_utf8_lossy(&output.stdout); let lines: Vec<&str> = stdout.lines().collect();