Skip to content

Commit

Permalink
Merge pull request #142 from asomers/lsvfs
Browse files Browse the repository at this point in the history
Fix spurious failure in pjdfstest::tests::rmdir::ebusy
  • Loading branch information
asomers committed Mar 2, 2024
2 parents c722dea + d9ff58b commit a914397
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rust/src/tests/rmdir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::{
ffi::OsStr,
fs::metadata,
os::unix::ffi::OsStrExt,
path::{Path, PathBuf},
process::Command,
};
Expand Down Expand Up @@ -62,7 +64,8 @@ impl DummyMnt {
}

let result = mount.arg(&from).arg(&path).output()?;
assert!(result.status.success());
let stderr = OsStr::from_bytes(&result.stderr).to_string_lossy();
assert!(result.status.success(), "{}", stderr);

Ok(Self { path })
}
Expand Down Expand Up @@ -100,6 +103,13 @@ fn has_mount_cap(_: &Config, _: &Path) -> anyhow::Result<()> {
if !Uid::effective().is_root() && ctl.value()? == CtlValue::Int(0) {
anyhow::bail!("process doesn't have the rights to mount the dummy file system")
}
if !Uid::effective().is_root() &&
!OsStr::from_bytes(&Command::new("lsvfs").output().unwrap().stdout)
.to_string_lossy()
.contains("nullfs")
{
anyhow::bail!("nullfs module is not loaded")
}

Ok(())
}
Expand Down

0 comments on commit a914397

Please sign in to comment.