ksud: exposed the command stdout/stderr to log

This commit is contained in:
weishu
2023-08-17 22:05:49 +08:00
parent ea3b397f34
commit 0af25af1be

View File

@@ -140,8 +140,7 @@ fn get_minimal_image_size(img: &str) -> Result<u64> {
fn check_image(img: &str) -> Result<()> { fn check_image(img: &str) -> Result<()> {
let result = Command::new("e2fsck") let result = Command::new("e2fsck")
.args(["-yf", img]) .args(["-yf", img])
.stdout(Stdio::null()) .stdout(Stdio::piped())
.stderr(Stdio::null())
.status() .status()
.with_context(|| format!("Failed to exec e2fsck {img}"))?; .with_context(|| format!("Failed to exec e2fsck {img}"))?;
let code = result.code(); let code = result.code();
@@ -172,7 +171,7 @@ fn grow_image_size(img: &str, extra_size: u64) -> Result<()> {
info!("resize image to {target_size}K, minimal size is {minimal_size}K"); info!("resize image to {target_size}K, minimal size is {minimal_size}K");
let result = Command::new("resize2fs") let result = Command::new("resize2fs")
.args([img, &format!("{target_size}K")]) .args([img, &format!("{target_size}K")])
.stdout(Stdio::null()) .stdout(Stdio::piped())
.status() .status()
.with_context(|| format!("Failed to exec resize2fs {img}"))?; .with_context(|| format!("Failed to exec resize2fs {img}"))?;
ensure!(result.success(), "Failed to resize2fs: {}", result); ensure!(result.success(), "Failed to resize2fs: {}", result);
@@ -402,7 +401,7 @@ fn _install_module(zip: &str) -> Result<()> {
.arg("-b") .arg("-b")
.arg("1024") .arg("1024")
.arg(tmp_module_img) .arg(tmp_module_img)
.stdout(Stdio::null()) .stdout(Stdio::piped())
.output()?; .output()?;
ensure!( ensure!(
result.status.success(), result.status.success(),