Skip to content

Commit

Permalink
mount: Use task infra to clean up error handling
Browse files Browse the repository at this point in the history
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 <walters@verbum.org>
  • Loading branch information
cgwalters committed Dec 10, 2023
1 parent b101d9d commit 88e7b56
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/src/mount.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,16 +23,12 @@ pub(crate) struct Findmnt {

#[context("Inspecting filesystem {path}")]
pub(crate) fn inspect_filesystem(path: &Utf8Path) -> Result<Filesystem> {
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()
Expand Down

0 comments on commit 88e7b56

Please sign in to comment.