Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ libfuse2 = ["libfuse"]
libfuse3 = ["libfuse"]
serializable = ["serde"]
macfuse-4-compat = []
direct-mount = ["nix/resource", "nix/signal"]
# abi-7-xx feature flags are deprecated and don't do anything.
abi-7-20 = []
abi-7-21 = []
Expand Down
8 changes: 6 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn main() {
// Register rustc cfg for switching between mount implementations.
println!(
"cargo::rustc-check-cfg=cfg(fuser_mount_impl, values(\"pure-rust\", \"libfuse2\", \"libfuse3\", \"macos-no-mount\"))"
"cargo::rustc-check-cfg=cfg(fuser_mount_impl, values(\"direct-mount\", \"pure-rust\", \"libfuse2\", \"libfuse3\", \"macos-no-mount\"))"
);

let target_os =
Expand All @@ -12,7 +12,11 @@ fn main() {
"linux" | "freebsd" | "dragonfly" | "openbsd" | "netbsd"
) && cfg!(not(feature = "libfuse"))
{
println!("cargo::rustc-cfg=fuser_mount_impl=\"pure-rust\"");
if cfg!(feature = "direct-mount") {
println!("cargo::rustc-cfg=fuser_mount_impl=\"direct-mount\"");
} else {
println!("cargo::rustc-cfg=fuser_mount_impl=\"pure-rust\"");
}
} else if target_os == "macos" {
if cfg!(feature = "macos-no-mount") {
println!("cargo::rustc-cfg=fuser_mount_impl=\"macos-no-mount\"");
Expand Down
13 changes: 12 additions & 1 deletion fuser-tests/src/commands/bsd_mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ use crate::ansi::green;
use crate::canonical_temp_dir::CanonicalTempDir;
use crate::cargo::cargo_build_example;
use crate::command_utils::command_success;
use crate::features::Feature;
use crate::mount_util::wait_for_fuse_mount;

pub(crate) async fn run_bsd_mount_tests() -> anyhow::Result<()> {
// Run tests using pure-rust (fusermount) implementation
run_bsd_mount_tests_with_features(&[]).await?;

// Run tests using direct-mount (direct mount syscall) implementation
run_bsd_mount_tests_with_features(&[Feature::DirectMount]).await?;

Ok(())
}

async fn run_bsd_mount_tests_with_features(features: &[Feature]) -> anyhow::Result<()> {
let mount_dir = CanonicalTempDir::new()?;
let mount_path = mount_dir.path();

let hello_exe = cargo_build_example("hello", &[]).await?;
let hello_exe = cargo_build_example("hello", features).await?;

eprintln!("Starting hello filesystem...");
let mut fuse_process = Command::new(&hello_exe)
Expand Down
35 changes: 35 additions & 0 deletions fuser-tests/src/commands/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ async fn run_mount_tests_inner(libfuse: Libfuse) -> anyhow::Result<()> {
run_test(&[], Unmount::Auto, libfuse.fusermount(), 1, false).await?;
test_no_user_allow_other(&[], &libfuse).await?;

// Tests without libfuse feature (direct mount syscall implementation)
run_test(
&[Feature::DirectMount],
Unmount::Manual,
Fusermount::False,
1,
false,
)
.await?;
run_test(
&[Feature::DirectMount],
Unmount::Auto,
Fusermount::False,
1,
false,
)
.await?;
test_no_user_allow_other(&[Feature::DirectMount], &libfuse).await?;

// Tests with libfuse
run_test(
&[libfuse.feature()],
Expand All @@ -65,6 +84,22 @@ async fn run_mount_tests_inner(libfuse: Libfuse) -> anyhow::Result<()> {
// Multi-threaded tests
run_test(&[], Unmount::Auto, libfuse.fusermount(), 2, false).await?;
run_test(&[], Unmount::Auto, libfuse.fusermount(), 2, true).await?;
run_test(
&[Feature::DirectMount],
Unmount::Auto,
Fusermount::False,
2,
false,
)
.await?;
run_test(
&[Feature::DirectMount],
Unmount::Auto,
Fusermount::False,
2,
true,
)
.await?;

if let Libfuse::Libfuse3 = libfuse {
run_allow_root_test()
Expand Down
3 changes: 3 additions & 0 deletions fuser-tests/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub(crate) enum Feature {
Libfuse2,
/// Use libfuse3 for mounting.
Libfuse3,
/// Use mount syscall directly for mounting.
DirectMount,
}

impl Feature {
Expand All @@ -20,6 +22,7 @@ impl Feature {
Feature::Experimental => "experimental",
Feature::Libfuse2 => "libfuse2",
Feature::Libfuse3 => "libfuse3",
Feature::DirectMount => "direct-mount",
}
}
}
Expand Down
Loading
Loading