Skip to content

Commit 8bf5de7

Browse files
authored
Merge pull request #220 from cgwalters/debug-findmnt
mount: Use task infra to clean up error handling
2 parents cd152f4 + a6195f1 commit 8bf5de7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/src/mount.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Helpers for interacting with mountpoints
22
3-
use std::process::Command;
4-
53
use anyhow::{anyhow, Context, Result};
64
use camino::Utf8Path;
75
use fn_error_context::context;
@@ -25,16 +23,12 @@ pub(crate) struct Findmnt {
2523

2624
#[context("Inspecting filesystem {path}")]
2725
pub(crate) fn inspect_filesystem(path: &Utf8Path) -> Result<Filesystem> {
28-
tracing::debug!("Inspecting {path}");
29-
let o = Command::new("findmnt")
26+
let desc = format!("Inspecting {path}");
27+
let o = Task::new(&desc, "findmnt")
3028
.args(["-J", "-v", "--output-all", path.as_str()])
31-
.output()?;
32-
let st = o.status;
33-
if !st.success() {
34-
anyhow::bail!("findmnt {path} failed: {st:?}");
35-
}
36-
let o: Findmnt = serde_json::from_reader(std::io::Cursor::new(&o.stdout))
37-
.context("Parsing findmnt output")?;
29+
.quiet()
30+
.read()?;
31+
let o: Findmnt = serde_json::from_str(&o).context("Parsing findmnt output")?;
3832
o.filesystems
3933
.into_iter()
4034
.next()

0 commit comments

Comments
 (0)