Skip to content

Commit

Permalink
rust/src/bwrap.rs: check for fuse version
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Aug 30, 2024
1 parent cd6fd88 commit b2d79d4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use std::os::unix::io::AsRawFd;
use std::os::unix::process::CommandExt;
use std::path::Path;
use std::process::Command;
use camino::Utf8Path;
use camino::Utf8PathBuf;

// Links in the rootfs to /usr
static USR_LINKS: &[&str] = &["lib", "lib32", "lib64", "bin", "sbin"];
Expand Down Expand Up @@ -114,6 +116,20 @@ impl RoFilesMount {
}
}

fn get_fusermount_path() -> Result<Utf8PathBuf> {
let path = std::env::var("PATH").expect("PATH set");
let fusermount_binaries = ["fusermount", "fusermount3"];
for elt in path.split(':').map(Utf8Path::new) {
for bin in fusermount_binaries {
let target = elt.join(bin);
if target.try_exists()? {
return Ok(target);
}
}
}
anyhow::bail!("No fusermount path found")
}

impl Drop for RoFilesMount {
fn drop(&mut self) {
let tempdir = if let Some(d) = self.tempdir.take() {
Expand All @@ -122,7 +138,7 @@ impl Drop for RoFilesMount {
return;
};
// We need to unmount before letting the tempdir cleanup run.
let success = Command::new("fusermount")
let success = Command::new(get_fusermount_path().unwrap().to_string())
.arg("-u")
.arg(tempdir.path())
.status()
Expand Down

0 comments on commit b2d79d4

Please sign in to comment.