Skip to content

Commit

Permalink
feat: implement fuse-t feature
Browse files Browse the repository at this point in the history
Use fuse-t to replace MacFUSE as the implementation
of FUSE. fuse-t is based on NFS and does not require
the use of kernel extensions. Installation can be done
with lower privileges and it does not impact system stability.

Signed-off-by: killagu <[email protected]>
  • Loading branch information
killagu authored and bergwolf committed Sep 5, 2023
1 parent 8c89657 commit 1e5b2ac
Show file tree
Hide file tree
Showing 11 changed files with 689 additions and 16 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ jobs:
runs-on: macos-latest
steps:
- name: Install macfuse
run: brew install --cask macfuse
run: |
brew install --cask macfuse
wget https://github.com/macos-fuse-t/fuse-t/releases/download/1.0.24/fuse-t-macos-installer-1.0.24.pkg
sudo installer -pkg fuse-t-macos-installer-1.0.24.pkg -target /
- uses: actions/checkout@v3
- name: build and check
run: make check-macos
run: make smoke-macos

deny:
name: Cargo Deny
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async-io = ["async-trait", "tokio-uring", "tokio/fs", "tokio/net", "tokio/sync",
fusedev = ["vmm-sys-util", "caps", "core-foundation-sys"]
virtiofs = ["virtio-queue", "caps", "vmm-sys-util"]
vhost-user-fs = ["virtiofs", "vhost", "caps"]
fuse-t=[]

[package.metadata.docs.rs]
all-features = true
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ build:

build-macos:
cargo build --features="fusedev"
cargo build --features="fusedev,fuse-t"

check-macos: build-macos
cargo fmt -- --check
cargo clippy --features="fusedev" -- -Dwarnings
cargo test --features="fusedev" -- --nocapture --skip integration
cargo clippy --features="fusedev,fuse-t" -- -Dwarnings
cargo test --features="fusedev,fuse-t" -- --nocapture --skip integration

check: build
cargo fmt -- --check
Expand All @@ -38,7 +41,7 @@ smoke-all: smoke
cargo test --features="fusedev" -- --nocapture --ignored

smoke-macos: check-macos
cargo test --features="fusedev" -- --nocapture
cargo test --features="fusedev,fuse-t" -- --nocapture

docker-smoke:
docker run --env RUST_BACKTRACE=1 --rm --privileged --volume ${current_dir}:/fuse-rs rust:1.68 sh -c "rustup component add clippy rustfmt; cd /fuse-rs; make smoke-all"
10 changes: 10 additions & 0 deletions src/api/server/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,23 @@ impl<F: FileSystem + Sync> Server<F> {
e
})?;

#[cfg(not(feature = "fuse-t"))]
let version = self.vers.load();
let result = self.fs.lookup(ctx.context(), ctx.nodeid(), name);

match result {
// before ABI 7.4 inode == 0 was invalid, only ENOENT means negative dentry
#[cfg(not(feature = "fuse-t"))]
Ok(entry)
if version.minor < KERNEL_MINOR_VERSION_LOOKUP_NEGATIVE_ENTRY_ZERO
&& entry.inode == 0 =>
{
ctx.reply_error(io::Error::from_raw_os_error(libc::ENOENT))
}
#[cfg(feature = "fuse-t")]
Ok(entry) if entry.inode == 0 => {
ctx.reply_error(io::Error::from_raw_os_error(libc::ENOENT))
}
Ok(entry) => {
let out = EntryOut::from(entry);

Expand Down Expand Up @@ -649,7 +655,11 @@ impl<F: FileSystem + Sync> Server<F> {
return ctx.reply_ok(Some(out), None);
}

#[cfg(not(feature = "fuse-t"))]
let mut flags_u64 = flags as u64;
#[cfg(feature = "fuse-t")]
let flags_u64 = flags as u64;
#[cfg(not(feature = "fuse-t"))]
if flags_u64 & FsOptions::INIT_EXT.bits() != 0 {
let InitIn2 { flags2, unused: _ } = ctx.r.read_obj().map_err(Error::DecodeMessage)?;
flags_u64 |= (flags2 as u64) << 32;
Expand Down
Loading

0 comments on commit 1e5b2ac

Please sign in to comment.