FUSE Filesystem

FUSE (Filesystem in Userspace) is an interface for userspace programs to export a filesystem to the Linux kernel. The FUSE project consists of two components: the fuse kernel module (maintained in the regular kernel repositories) and the libfuse userspace library (maintained in this repository). libfuse provides the reference implementation for communicating with the FUSE kernel module. - libfuse

Pros/cons

Mounting special

Building your own filesystem

libfuse offers two APIs: a “high-level”, synchronous API, and a “low-level” asynchronous API. In both cases, incoming requests from the kernel are passed to the main program using callbacks.

  • When using the high-level API, the callbacks may work with file names and paths instead of inodes, and processing of a request finishes when the callback function returns.
  • When using the low-level API, the callbacks must work with inodes and responses must be sent explicitly using a separate set of API functions.

The documentation of the API functions and necessary callbacks is mostly contained in the files:

An autogenerated html version of the API is available in the doc/html directory.

Tutorials

Example FUSE

  • MirrorFS - Just mirror the operations done on the mount directory to another directory.
  • trapexit/mergerfs - a union filesystem geared towards simplifying storage and management of files across numerous commodity storage devices. It is similar to mhddfs, unionfs, and aufs.

Documentation

  • init - The initialization function accepts a fuse_conn_info structure, which can be used to investigate and control the system’s capabilities.
  • readdir - Return one or more directory entries (struct dirent) to the caller. This is one of the most complex FUSE functions.

Debugging tips

There are a couple features of FUSE that can make it difficult to debug: it normally runs in the background (which means it detaches from stdin/out) and is multithreaded (which can introduce race conditions and is more complicated to debug with gdb). Luckily, both features can be disabled (see doc:

  • Use the -d or -f switch to keep your application in the foreground. This will make your printf lines work.
  • Use the -s switch to disable multithreading. Disabling multithreading will limit performance, but will also hide certain bugs (race conditions), simplify the use of gdb, and ensure printf output is readable (when multiple threads call printf at about the same time their output can get mixed up).

FUSE MODULES (STACKING)

Modules are filesystem stacking support to high level API. Filesystem modules can be built into libfuse or loaded from shared object.

Version

see also Fuse Changelog

Latest version is 3, bug fix + API clean up

sudo apt-get install libfuse3-dev

using a previous version may lead to warning:

fuse: warning: library too old, some operations may not not work

Perf

We start with a detailed explanation of FUSE’s design and implementation - Performance and Resource Utilization of FUSE User-Space File Systems

Binding

Written on July 27, 2020, Last update on September 18, 2020
software filesystem