LWN.net Logo

FUSE - implementing filesystems in user space

Last week we looked at implementing device drivers in user space. Drivers are not the only kernel functionality which can be moved across the divide, however; it is also possible to implement filesystems with user-space code. Linux has a long tradition of user-space filesystems, actually; NFS was implemented that way for quite some time. Even so, user-space filesystems are not widely used, for a number of obvious reasons (performance, security, ...). But there are situations where a user-space filesystem can be a nice thing to have.

For those situations, there is a project called FUSE. Its associated SourceForge page is not particularly enlightening; one really has to look at the project's code to understand what FUSE has to offer. Since the second FUSE 1.1 release candidate has just been announced, this seems like a good time for such an examination.

FUSE is a three-part system. The first of those parts is a kernel module which hooks into the VFS code and looks like a filesystem module. It also implements a special-purpose device which can be opened by a user-space process. It then spends its time accepting filesystem requests, translating them into its own protocol, and sending them out via the device interface. Responses to requests come back from user space via the FUSE device, and are translated back into the form expected by the kernel.

In user space, FUSE implements a library which manages communications with the kernel module. It accepts filesystem requests from the FUSE device and translates them into a set of function calls which look similar (but not identical) to the kernel's VFS interface. These functions have names like open(), read(), write(), rename(), symlink(), etc.

Finally, there is a user-supplied component which actually implements the filesystem of interest. It fills a fuse_operations structure with pointers to its functions which implement the required operations in whatever way makes sense. This interface is not well documented, but the example filesystem provided with FUSE (which implements a simple sort of loopback filesystem) is reasonably easy to follow.

An old filesystem module (AVFS) uses FUSE to make filesystems out of tar and zip files, but one could imagine any number of other possibilities. It would not be that hard to make filesystems which mirror a web site (in read-only mode, at least), provide access to an object database, or provide a file-per-user view of the password file, for example. FUSE could be an ideal platform for experimenters who want to take the "everything is a file" idea to its limit.


(Log in to post comments)

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 2:17 UTC (Thu) by flewellyn (subscriber, #5047) [Link]

Interesting. So, how long before Linux becomes a microkernel, then? :-)

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 2:50 UTC (Thu) by marduk (subscriber, #3831) [Link]

It certainly does seem like Linux is becoming more and more microkernel-like every day. One wonders what Linus says about this.

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 8:38 UTC (Thu) by stuart2048 (subscriber, #6241) [Link]

One of the cool features of userland isolation is that it's much easier to watch behaviour and resource consumption. Curious about how much memory or CPU your protocol stack is consuming? Easy...

--Stuart

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 3:54 UTC (Thu) by iabervon (subscriber, #722) [Link]

I think it's a good idea to support microkernel-like behavior, so that
users can trade off performance for isolation. I'd certainly prefer that
drivers be in userspace when performance isn't an issue; if my PDA sync
takes twice as many context switches, I probably won't even notice the
difference, but I will be glad if it doesn't take the system down if it
is buggy. On the other hand, I don't think that Linux will get
particularly micro; just because you can have filesystems and drivers in
userspace doesn't mean that having your root filesystem or video drivers
in userspace is going to be a good idea.

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 2:41 UTC (Thu) by pynm0001 (guest, #18379) [Link]

Actually, there is a project to implement the KIO protocol using FUSE.
This would enable GTK/GNOME applications to use the KIO slaves, for
example.

I don't know the link offhand, but I think http://dot.kde.org/ has news
about it.

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 6:56 UTC (Thu) by aleXXX (subscriber, #2742) [Link]

KIO fuse "gateway":

http://kde.ground.cz/tiki-index.php?page=KIO+Fuse+Gateway

And it works :-)
Only the file mode flags (for opening) are still ignored, mainly I need more
users/testers now :-)

Bye
Alex
<neundorf at kde dot org >

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 5:45 UTC (Thu) by mcatkins (guest, #4270) [Link]

Unfortunately, this seems to be something of a graveyard of projects, I also know of (at least):

Podfuk: http://atrey.karlin.mff.cuni.cz/~pavel/podfuk/podfuk.html
userfs: http://www.penguin.cz/~jim/userfs/
uvfs: http://www.sciencething.org/geekthings/index.html
virtualfs: http://www.solucorp.qc.ca/virtualfs/

(although the last subverts libc, rather than using a kernel module)

as well as my own effort (not yet released!) allowing filesystems to be written in Python (as does fuse), but without requiring a non-standard kernel module.

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 10:03 UTC (Thu) by mjr (guest, #6979) [Link]

There's also LUFS (which incidentally supports gnome-vfs modules like fuse supports kioslaves - can't have one doing both, it seems ;). I'd really like to see one of these make it to the default kernel...

Anyway, anyone know if the fuse kernel interface is secure nowadays, in a sense that one can safely allow users to freely use even their own filesystem code to mount things? I asked basically the same on the lufs list a good while back, and there were, in effect, no answers, and the lufs daemons seem to run as root which is a kind of telltale sign that one doesn't want arbitrary user code there...

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 14:00 UTC (Thu) by mszeredi (subscriber, #19041) [Link]

Security is one of the main design principles of FUSE. The only operation that requires root access is the mounting, and that can be done fairly securely by a non-root user with the help of a suid program (fusermount).

Userspace NFS

Posted Jan 29, 2004 9:18 UTC (Thu) by Ross (guest, #4065) [Link]

I thought only the NFS server was in userspace but the client was always
in the kernel. Or am I just not remembering correctly?

Userspace NFS

Posted Jan 31, 2004 21:19 UTC (Sat) by kamil (subscriber, #3802) [Link]

That has always been my recollection, as well. NFS server in user space, using Linux-specific calls like setfsuid(2), client in the kernel.

SieFS

Posted Jan 29, 2004 10:55 UTC (Thu) by hensema (guest, #980) [Link]

SieFS is an example of a filesystem implemented with FUSE. SieFS can mount the filesystems of recent Siemens mobile phones (such as the S55) on Linux. Site: http://mirror01.iptelecom.net.ua/~dmitry_z/siefs/

FUSE - implementing filesystems in user space

Posted Jan 29, 2004 14:17 UTC (Thu) by mszeredi (subscriber, #19041) [Link]

OK, so making homepages is not my strong point :). This is not the first time somebody complains, and it's now being worked on by a brave volunteer (SF job recruitment is cool).

Anyway here's a link to a list of filesystems (that I know of) that are using FUSE:

http://www.inf.bme.hu/~mszeredi/fuse/Filesystems

FUSE - implementing filesystems in user space

Posted Feb 6, 2004 3:47 UTC (Fri) by xoddam (subscriber, #2322) [Link]

Has anyone ever written a 9P (aka 9fs) client for Linux? I know there are a couple of servers but I can't see anything obvious on Google.

a kernel-space 9P client would let you implement almost anything you like in terms of filesystems as userspace servers.

FUSE - implementing filesystems in user space

Posted Feb 6, 2004 4:59 UTC (Fri) by mcatkins (guest, #4270) [Link]

Ron Minnich had a good go at it, but I don't think it was really
completed - pitty, because as you say, it would "let you implement
almost anything you like..."

Some stuff is on his homepage at:
http://public.lanl.gov/rminnich/
and there is an inactive sourceforge site at:
http://v9fs.sourceforge.net/

There was also work on private namespaces for Linux and BSD, which is
the other key technology to getting this all to work properly!

Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds