On Linux it is possible to write user-level file system by using FUSE, a toolkit to write user-space tools that can be mounted as file systems.
There is a whole scene of Fuse developers, to satisfy the most unique tastes in file system needs. Cryptographic file systems, gmail-as-a-backing-store, and of course a Wikipedia file system.
Jon Pryor has released Mono and FUSE bridge: Mono.Fuse. With Mono.Fuse it is possible to author file system extensions with Mono using any of the libraries or languages supported by Mono.
To create a file system with Mono.Fuse, you must create a class that derives from Mono.Fuse.FileSystem, like this:
using Mono.Fuse class TypeNavigator : FileSystem { static void Main (string [] args) { using (TypeNavigator t = new TypeNavigator ()){ t.MountPoint = args [0]; t.Start (); } } }
Then you need to implement a couple of methods, you override the directory reading and attribute fetching methods like this:
protected override Errno OnReadDirectory (string path, [Out] out string[] paths, OpenedFileInfo fi) { ... } protected override Errno OnGetFileAttributes (string path, ref Stat stbuf) { ... }
I wrote a small file system to browse assemblies, you can get the source here.
To run my toy file system, do this:
$ mono fuse.exe /tmp/u
That will get the file system going (currently you need the Mono.Fuse.dll library in the same directory where fuse.exe lives, and the libMonoFuseHelper.so in your library path).
With this, you can browse the types in your favorite assemblies from the shell (or for the less manly hackers in my readership: a file manager) like this:
$ ls /tmp/u/mscorlib ... Mono.Security.Cryptography.RSAManaged+KeyGeneratedEventHandler/ Mono.Security.Cryptography.SymmetricTransform/ Mono.Security.PKCS7/ Mono.Security.PKCS7+ContentInfo/ Mono.Security.PKCS7+EncryptedData/ Mono.Security.PKCS7+EnvelopedData/ ... $ ls /tmp/u/mscorlib/Mono.Security.Cryptography.SymmetricTransform CanReuseTransform GetHashCode OutputBlockSize CanTransformMultipleBlocks get_InputBlockSize ToString Equals get_OutputBlockSize TransformBlock get_CanReuseTransform GetType TransformFinalBlock get_CanTransformMultipleBlocks InputBlockSize
Once you are done with the exciting world of browsing your assemblies with ls and cd you can umount your file system like this:
$ fusermount -u /tmp/u
Very nice work Jon!
Posted on 01 Sep 2006