The fuse
crate is an implementation of the FUSE protocol, which
allows filesystems and character devices to be backed by a userspace process.
It currently provides enough coverage to implement basic FUSE and CUSE servers.
This is a pre-v0.1 library. Many of FUSE’s more advanced capabilities do not work yet, and test coverage is incomplete. Please file issues if there is functionality you’d like to see implemented.
Feature | Tracking issue |
---|---|
FreeBSD support |
|
High-level API |
|
Interrupts |
|
macOS support |
Not planned due to lack of open-source kernel drivers. |
Unprivileged mounts |
I am happy to accept contributions in the form of bug reports, pull requests, or emailed patches.
Add a dependency in Cargo.toml
:
[dependencies]
fuse = { git = "https://github.com/jmillikin/rust-fuse" }
Implement the FuseHandlers
trait for your filesystem:
extern crate fuse;
use fuse::server;
use fuse::server::fuse_rpc;
struct HelloFS {}
impl<S: server::io::FuseSocket> fuse_rpc::Handlers<S> for HelloFS {
// your filesystem handlers here
}
Use fuse-libc
(requires libc
) or fuse-linux
(requires a supported
target architecture) to build and run your filesystem server:
fn mount(target: &OsStr) -> fuse_libc::FuseServerSocket {
let mount_options = fuse::os::linux::MountOptions::new();
fuse_libc::os::linux::mount(&target_cstr, mount_options).unwrap()
}
fn main() {
let handlers = HelloWorldFS {};
let mount_target = std::env::args_os().nth(1).unwrap();
let dev_fuse = mount(&mount_target);
let conn = server::FuseServer::new().connect(dev_fuse).unwrap();
fuse_rpc::serve(&conn, &handlers);
}
Please see the documentation for advanced options.
It is possible to run a minimal single-threaded FUSE server in a no_std
binary.
[dependencies.fuse]
default-features = false
Note that some functionality is not available in no_std
mode. Please see
the documentation for details on which parts of the API depend
on std
.