Skip to content

Commit

Permalink
image-rs: add image block device dm-verity and mount
Browse files Browse the repository at this point in the history
Signed-off-by: ChengyuZhu6 <[email protected]>
  • Loading branch information
ChengyuZhu6 committed Jul 25, 2023
1 parent b864434 commit f9785a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
3 changes: 1 addition & 2 deletions image-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"
Expand Down
46 changes: 21 additions & 25 deletions image-rs/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f9785a4

Please sign in to comment.