2009/03/17

Dokan: Filesystem in userspace (FUSE) for Windows

As Wikipedia explains, a filesystem is a method for storing and organizing computer files and the data they contain to make it easy to find and access them.

There are many different filesystems, like ext3 (Linux) or NTFS (Windows), only to name a few. These filesystems allow the usual and necessary file operations we do every day: creating, copying, moving or deleting files or directories, listing directories or showing the content of files. We usually do these operations with "real" files and directories of a hard disk or a USB device, but nothing prevents us from doing them on other kind of systems which have not been prepared from the beginning to be used as filesystems in an operating system. An example of this system would be an FTP server. It clearly organizes like a filesystem, with directories, files, attributes of files and so on. So it would be possible to access an FTP server like a hard disk using your favourite file explorer if you were able to mount a "virtual" filesystem which connects automagically to the FTP server and lists the root files and directories when you go to the root of the filesystem, it deletes a file in the FTP server when you delete it in the filesystem and so on.

In fact, this is not new at all. In Linux, there exist currently many different "virtual" filesystems you can mount to ease the access of different types of resources, be them local or remote. What is more, Linux has a package called FUSE (Filesystem in Userspace), which allows mounting your own filesystem without having to make a device driver and compile it. FUSE is based on callback functions you have to implement that will be called when the different operations are invoked from the operating system. There exist a lot of language bindings for FUSE, so you can write your filesystem in Java, C#, Haskell, TCL, Python and many more (besides C or C++, which would be the expected languages for such a low level based feature). With FUSE, writing your own filesystem for Linux can be a much easier task.

But what about Windows ? A Windows port of FUSE has not existed for a long time and, from what I know, nothing similar was available as open source. But on May 2008 a project called Dokan was released as open source (LGPL). This project is the equivalent of FUSE for the Windows platform. You can download it from here. It has bindings for Ruby and .NET. In Yukoba's blog you can find very interesting contributions that enhance this project, like a Java binding (JDokan), MemoryFS (a filesystem on memory) or JSFlickerFS (a filesystem for managing Flicker albums, written in Javascript).

So if you need to write your own virtual filesystem in Windows, you have no excuse...give Dokan a try!