Skip to main content.

Filesystems in userspace: puffs, refuse, FUSE, and more


About (top)

NetBSD now offers full support for running file systems in userspace. Major components are "puffs", which is the kernel subsystem that realizes the pass-to-userspace framework file system, as well as the userland libraries that support constructing file system implementations, libpuffs and the FUSE-compatible librefuse.

puffs is available on NetBSD-current and will be part of the NetBSD 5.0 release.

Components (top)

There are a number of components interacting to provide routines for userland file systems: puffs as the kernel part, and libpuffs and librefuse to provide functions for userland file systems to call. The following image gives an overview of the components and their connections:

Figure. Ïverview about puffs

Overview about puffs

The components themselves are:

  • puffs is the core component inside the kernel. It exposes a file system interface towards the userland programs (accessible via /dev/puffs and libpuffs), and communicates with the kernel's own idea of files, which are represented as vnodes. The puffs kernel component and how to interface it is described further in the puffs(4) manpage.

  • The "libpuffs" library is the interface between userland file systems and the kernel component. It provides a number of convenience routines that userland file systems can use, and is described in the puffs(3) manpage.

  • To facilitate running the huge amount of file systems already available for the FUSE interface, but not dictate the capabilities of puffs by it, it was decided that FUSE support should be provided as a compatibility layer on top of the native puffs interface, which is offered by "librefuse". The re-implementation of the FUSE functionality is designed to be source code compatible with FUSE, and it is further described in the refuse(3) manpage.

Examples for puffs and refuse filesystems can be found in the following directory of the NetBSD source tree in src/share/examples/{puffs,refuse}.

Enabling puffs in the base system (top)

While puffs is stable for users, the library programming interface and the binary interfaces are still likely to change, and therefore puffs and the dependant librefuse are not built by default (as of 20070309). For people tracking NetBSD-current, the following should be used to enable the build and use of puffs.

/etc/mk.conf:
MKPUFFS=yes

kernel config:
file-system PUFFS
OR
/etc/lkm.conf:
# change BEFOREMOUNT to BEFORENET if /var or /usr is puffs
puffs.o -s - - - BEFOREMOUNT
      

Also make sure that the device node /dev/puffs exists by running (cd /dev ; sh MAKEDEV puffs). This is automatically done for new installations from sources after January 2007.

Base system examples (top)

This section presents usage examples for file systems shipped with the NetBSD base system.

puffs sshfs
# mount_psshfs host.name.tld:/directory /puffs
# ls /puffs
AdobeFnt.lst    OS                  bin     public_html
Desktop         OpenOffice.org1.1.0 in      tmp
...
# cd /puffs
# ls -l .cshrc
-rw-r--r--  1 39068  2000  4706 Jun 16 01:01 .cshrc
# head -2 .cshrc
# Default .cshrc for Solaris, Irix, ...
#
# md5 .cshrc
MD5 (.cshrc) = 2ad1d2606a5678f312709a388376c2e5
# ls -l test
ls: test: No such file or directory
# date >test
# ls -l test
-rw-r--r--  1 39068  2000  29 Nov 23 01:19 test
# cat test
Thu Nov 23 01:19:36 MET 2006
      
9P file servers
# mount_9p nobody@192.168.1.2:/tmp /puffs
# cd /puffs
# echo 9puffs in action > msg_from_earth
# ls -l msg_from_earth
-rw-r--r--  1 nobody  wheel  17 Apr 25 23:24 msg_from_earth
# rsh 192.168.1.2 cat /tmp/msg_from_earth
9puffs in action
# 

Since there is currently no support in the implementation for access control or support for authentication, the account nobody was picked just to prove a point. The NFS nobody user really does not have anything to do with 9P. Support for access control and use of pre-established secure connections will be added to mount_9p on a later date.

pkgsrc & FUSE (top)

FUSE compatibility was added within pkgsrc, and besides the required infrastructure work a number of FUSE packages were added to pkgsrc in the new "filesystem" category. Example packages that are currently available include:

  • fuse: Filesystem in Userspace (compat headers, pkg-config files, etc.), needed for pkgsrc on Linux
  • fuse-archivemount: FUSE gateway to libarchive
  • fuse-cddfs: FUSE filesystem that uses libparanoia for audio CDs
  • fuse-ntfs-3g: a NTFS driver with read and write support
  • ...

More packages are currently being worked on, please see pkgsrc/filesystems for a full list.

Here is an example of installing and using the FUSE-enabled NTFS-3g implementation:

# cd pkgsrc/filesystems/fuse-ntfs-3g
# make install
# ntfs-3g ntfs.img /ntfs
    

Further Information (top)

An in-depth technical description of puffs was presented at AsiaBSDCon 2007 in a paper entitled "puffs - Pass-to-Userspace Framework File System". The paper and slides are available.

The ReFUSE emulation layer for FUSE file systems is described in "ReFUSE: Userspace FUSE Reimplementation Using puffs" presented at EuroBSDCon 2007.

The puffs manual pages provide further information from a development perspective.

History (top)

puffs was originally developed during the Google Summer of Code 2005 "userfs" project by Antti Kantee. It was further polished using funding from the Ulla Tuominen Foundation and committed into the NetBSD source tree in October 2006. The "refuse" library was written by Alistair Crooks and committed to NetBSD in February 2007. All components will be available in NetBSD releases starting with NetBSD 5. Work for using FUSE-enabled packages via pkgsrc was done by Juan Romero Pardines following import of the "refuse" library. Hubert Feyrer prepared the initial version of this webpage.