From a6195f11da80438ac4c7efe8b407dd2006968c11 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 10 Dec 2023 09:26:00 -0500 Subject: [PATCH] mount: Use task infra to clean up error handling We were missing the "copy child stderr to our stderr" bits here on error. Motivated by this bit failing with an overlayfs root. Signed-off-by: Colin Walters --- lib/src/mount.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/src/mount.rs b/lib/src/mount.rs index 42d2c3929..7aca72a38 100644 --- a/lib/src/mount.rs +++ b/lib/src/mount.rs @@ -1,7 +1,5 @@ //! Helpers for interacting with mountpoints -use std::process::Command; - use anyhow::{anyhow, Context, Result}; use camino::Utf8Path; use fn_error_context::context; @@ -25,16 +23,12 @@ pub(crate) struct Findmnt { #[context("Inspecting filesystem {path}")] pub(crate) fn inspect_filesystem(path: &Utf8Path) -> Result { - tracing::debug!("Inspecting {path}"); - let o = Command::new("findmnt") + let desc = format!("Inspecting {path}"); + let o = Task::new(&desc, "findmnt") .args(["-J", "-v", "--output-all", path.as_str()]) - .output()?; - let st = o.status; - if !st.success() { - anyhow::bail!("findmnt {path} failed: {st:?}"); - } - let o: Findmnt = serde_json::from_reader(std::io::Cursor::new(&o.stdout)) - .context("Parsing findmnt output")?; + .quiet() + .read()?; + let o: Findmnt = serde_json::from_str(&o).context("Parsing findmnt output")?; o.filesystems .into_iter() .next()