Fuse::PDF

ChrisDolan on 2007-11-15T03:46:34

I have a lot of programming niche interests -- video, VNC, static analysis, PDF, filesystems, Flash, SOAP, etc. Most of all, I love it when these interests intersect. For example, I wrote still-closed-source (sigh) library that converts a VNC stream to QuickTime. A prototype of that software was the basis for the YAPC::NA 2006 videos I produced.

Another convergence happened last week. Google released MacFUSE 1.x, a Mac port of the Linux user-mode filesystem code. I had tried an earlier version, but I never got the Perl bindings (Fuse.pm) to work right. What can this do? It lets you write your own mountable virtual filesystem in a couple hundred lines of code.

Back in 2002-2005, I did a ton of PDF work. A result of that was a base library, CAM::PDF. I got authority to release it to CPAN about the same time the business motivation for the library dried up. But in the process, I learned the PDF specification inside and out. PDF is basically a serialization of an arbitrary tree structure: strings, numbers, hashes, arrays, references and blobs, all in an almost-human-readable syntax.

You can store anything in PDF. Most of that tree is focused on storing pages, text and graphics, but the fascinating part is that's just convention. The underlying data structure is generic.

So why not put filesystem data and metadata inside a PDF? I mentioned the idea at the last Madison Perl Mongers meeting and they laughed at me! (LAUGHED! at ME!) Well, that was enough motivation! A weekend later, I released Fuse:PDF v0.01 to CPAN. It's still very worthy of the v0.01 label (no symlinks, no hardlinks, no large files) but it's usable.

What do you think? Inspired or daft? Should I have put it in the Acme:: namespace? :-)

[Along the way, I'm also writing Test::Virtual::Filesystem which is a collection of typical file I/O actions that should work on any mounted filesystem.]


If they laughed at your idea...

sigzero on 2007-11-15T12:55:52

You must build it!

Figuring out perl FUSE

bill_mcgonigle on 2008-06-06T05:04:41

I saw in your CPAN review that it was difficult to figure out the minimum number of functions required to be implemented by a perl FUSE filesystem - did you find this documented anywhere (or document it yourself)?

Re:Figuring out perl FUSE

ChrisDolan on 2008-06-06T05:42:57

No, I just kept implementing methods until I was satisfied with the behavior. :-)

Seriously, though, statfs and getattr are probably the bare minimum, followed by mknod getdir open and read.

Take a peek at Test::Virtual::Filesystem which can help to validate your FUSE implementation.

Re:Figuring out perl FUSE

bill_mcgonigle on 2008-06-06T15:39:54

Oh, fantastic, I didn't even see the test suite when I was looking last night. Your methodology is admirable.



I'm going to take a stab at an 'md5uniqfs', which stores one copy of a given file per filesytem, hardlinking duplicates. Should be useful for backups.



Having a good test should really help. Thanks!

Re:Figuring out perl FUSE

ChrisDolan on 2008-06-07T01:19:46

Very cool! Drop me an email when it's ready for use. I'd like to try it out.