One of the nice things about the Unix philosophy that Linux inherited is that the filesystem is very modular. That’s good, too, because a typical system might want a choice of filesystems like
btrfs, and even network systems like
nfs. Besides that, there are fake file systems like
/dev that help Linux make everything look like a file. The downside is that building a filesystem required changing the kernel or, at least, writing a loadable module. That’s not as hard as it sounds, but it is a little more difficult than writing a normal program. Then came FUSE — file system in user space. This is a single file system module that allows you to create new file systems by writing ordinary code.
My Favorite Fuses
There are several FUSE filesystems that are really useful. Here are some of my favorites:
- sshfs – Mount a remote filesystem using nothing more than ssh access
- rclone – Rclone can access and mount many remote file systems
- tagassistant – Store files with a unique tag access method
- fuse-zip – Mount zip files
- gitfs – Mount with git
There are many others. You can find systems to work with, for example, NTFS and a slew of cloud service providers.
What about Windows?
If this is such a great idea, is there a Windows equivalent? Yes, there is. Winfsp looks like a great way to get the same effect under Windows, although it isn’t just plug-and-play compatible with FUSE. There is a FUSE compatibility wrapper that lets you more easily port existing FUSE code. In fact, there are two FUSE wrappers, one for version 2.8 and another for version 3.2.
This is a newer project, but there is also Dokan which also claims to have a FUSE wrapper for their API. According to the
Winfsp-provided benchmarks, though,
Winfsp performs better.
If you have a favorite FUSE system, it is probably open source and you could try porting it to Windows, if you were so inclined. If you don’t use Windows, and you want to write your own FUSE system, these systems offer you a way to possibly easily move your work to Windows.
For example, you might have a data logger and want to expose its data as a file system. It isn’t that hard to do. There’s a data structure to fill in, and you don’t have to fill all of it in. You provide functions that the data structure points to that read and write things like directories and file data. Here’s an example in C. Or try a C++ wrapper that enables you to write one with even fewer lines of code. The example has just four simple functions.