Expand description
This crate, based on the fuser crate, allows building FUSE filesystems where the system calls are directed to async functions.
This can be particularly useful when the syscalls benefit from (or require) async IO.
When using a multi-threaded tokio runtime, this can also be useful for CPU-bound code
(although one should be careful with the interactions between IO- and CPU-bound tasks).
More precisely, this crate provides:
- a
Filesystemtrait, analogous to the fuserfuser::Filesystemtrait, which has all its methods returning futures. - a
FilesystemFUSEstruct, which can be constructed from any implementor of theFilesystemtrait, and which implements thefuser::Filesystemtrait, allowing to mount the filesystem using the fuser crate crate.
Behind the scenes, FilesystemFUSE wraps the inner filesystem into an std::sync::Arc<tokio::sync::RwLock> and stores a handle on the tokio runtime.
§Usage
- Implement the
Filesystemtrait. - Instantiate a
FilesystemFUSEobject from a instance implementingFilesystem, withFilesystemFUSE::new. - Mount the filesystem using
fuser, or use file handles programmatically withFileHandle(which implementstokio::io::AsyncRead)
let fs = TestFs::new();
let fuse = FilesystemFUSE::new(fs);
let _mount = fuser::spawn_mount2(
fuse,
mountpoint,
&[fuser::MountOption::RO, fuser::MountOption::Async],
)?;
tokio::signal::ctrl_c().await?;
§Implementations
Two example implementations are provided:
- Local filesystem passthrough.
- S3 object storage, using the
rusty_s3crate.
See the demo binary crate for a binary running these.
$ cargo run -r --features s3,demo --bin demo -- --help
USAGE:
demo [OPTIONS] <MOUNTPOINT> <SUBCOMMAND>
ARGS:
<MOUNTPOINT> Mountpoint
OPTIONS:
-d, --debug
-h, --help Print help information
SUBCOMMANDS:
local
s3§Difference with other solutions
§fuse_mt
See https://github.com/wfraser/fuse-mt/issues/3. The implementation of this crate is fairly similar to the prototype linked in this issue,
except that we use a recent tokio version and support different syscalls.
§Limitations/TODO
- Not all methods from
fuser::Filesystemare supported (they are however easy to add). In particular, the current focus of is on read operations. - No tests yet beyond the demo and the dependent crates.
Modules§
- cache
- Caching utilities
- remapping
- Utility to remap inodes of a
Filesystem - rwlockoption
- Implementation of
RwLockOption<T>, with a similar interface astokio::sync::OnceCell. - utils
- Utilities
Structs§
- DirEntry
- Directory entry (returned by
Filesystem::readdir). - File
Handle - Owned handle on a FUSE filesystem file, implementing
tokio::io::AsyncRead. - FilesystemFUSE
- Wrapper around a
Filesystem, implementingfuser::Filesystem.
Enums§
Traits§
- Filesystem
- Base trait providing asynchronous functions for the system calls.
- FilesystemSSUS
- Trait alias for a
Filesystemthat isSend,Sync,std::marker::Unpinand'static. - Refresh
- Trait for filesystems that can be refreshed.