Skip to content

Commit

Permalink
Merge pull request #220 from cgwalters/debug-findmnt
Browse files Browse the repository at this point in the history
mount: Use task infra to clean up error handling
  • Loading branch information
jmarrero committed Dec 11, 2023
2 parents cd152f4 + a6195f1 commit 8bf5de7
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 8bf5de7

Please sign in to comment.