16 releases (breaking)

0.15.1 Nov 28, 2024
0.14.0 Nov 5, 2023
0.12.0 Dec 13, 2022
0.11.1 Aug 25, 2022
0.4.0 Jun 19, 2020

#37 in Unix APIs

Download history 14616/week @ 2024-08-20 14050/week @ 2024-08-27 13934/week @ 2024-09-03 15297/week @ 2024-09-10 15448/week @ 2024-09-17 17278/week @ 2024-09-24 13230/week @ 2024-10-01 18434/week @ 2024-10-08 19649/week @ 2024-10-15 18078/week @ 2024-10-22 19388/week @ 2024-10-29 20089/week @ 2024-11-05 19060/week @ 2024-11-12 18701/week @ 2024-11-19 18696/week @ 2024-11-26 20347/week @ 2024-12-03

79,718 downloads per month
Used in 56 crates (50 directly)

MIT license

345KB
8K SLoC

FUSE (Filesystem in Userspace) for Rust

CI Crates.io Documentation MIT License dependency status

About

FUSE-Rust is a Rust library crate for easy implementation of FUSE filesystems in userspace.

FUSE-Rust does not just provide bindings, it is a rewrite of the original FUSE C library to fully take advantage of Rust's architecture.

This library was originally forked from the fuse crate with the intention of continuing development. In particular adding features from ABIs after 7.19

Documentation

FUSE-Rust reference

Details

A working FUSE filesystem consists of three parts:

  1. The kernel driver that registers as a filesystem and forwards operations into a communication channel to a userspace process that handles them.
  2. The userspace library (libfuse) that helps the userspace process to establish and run communication with the kernel driver.
  3. The userspace implementation that actually processes the filesystem operations.

The kernel driver is provided by the FUSE project, the userspace implementation needs to be provided by the developer. FUSE-Rust provides a replacement for the libfuse userspace library between these two. This way, a developer can fully take advantage of the Rust type interface and runtime features when building a FUSE filesystem in Rust.

Except for a single setup (mount) function call and a final teardown (umount) function call to libfuse, everything runs in Rust, and on Linux these calls to libfuse are optional. They can be removed by building without the "libfuse" feature flag.

Dependencies

FUSE must be installed to build or run programs that use FUSE-Rust (i.e. kernel driver and libraries. Some platforms may also require userland utils like fusermount). A default installation of FUSE is usually sufficient.

To build FUSE-Rust or any program that depends on it, pkg-config needs to be installed as well.

Linux

FUSE for Linux is available in most Linux distributions and usually called fuse or fuse3 (this crate is compatible with both). To install on a Debian based system:

sudo apt-get install fuse3 libfuse3-dev

Install on CentOS:

sudo yum install fuse

To build, FUSE libraries and headers are required. The package is usually called libfuse-dev or fuse-devel. Also pkg-config is required for locating libraries and headers.

sudo apt-get install libfuse-dev pkg-config
sudo yum install fuse-devel pkgconfig

macOS (untested)

Installer packages can be downloaded from the FUSE for macOS homepage. This is the kernel part that needs to be installed always.

To install using Homebrew

brew install macfuse

To install using Nix

nix-env -iA nixos.osxfuse

And pkg-config (required for building):

nix-env -iA nixos.pkg-config

When using nix it is required that you specify PKG_CONFIG_PATH environment variable to point at where osxfuse is installed:

export PKG_CONFIG_PATH=${HOME}/.nix-profile/lib/pkgconfig

FreeBSD

Install packages fusefs-libs and pkgconf.

pkg install fusefs-libs pkgconf

Usage

Put this in your Cargo.toml:

[dependencies]
fuser = "0.7"

To create a new filesystem, implement the trait fuser::Filesystem. See the documentation for details or the examples directory for some basic examples.

To Do

Most features of libfuse up to 3.10.3 are implemented. Feel free to contribute. See the list of issues on GitHub and search the source files for comments containing "TODO" or "FIXME" to see what's still missing.

Compatibility

Developed and tested on Linux. Tested under Linux and FreeBSD using stable Rust (see CI for details).

License

Licensed under MIT License, except for those files in examples/ that explicitly contain a different license.

Contribution

Fork, hack, submit pull request. Make sure to make it useful for the target audience, keep the project's philosophy and Rust coding standards in mind. For larger or essential changes, you may want to open an issue for discussion first. Also remember to update the Changelog if your changes are relevant to the users.

Dependencies

~2.8–4MB
~69K SLoC