Silly Hack of the Day: Mount the Obj-C Runtime as a Filesystem
Update: CocoaHacks was quite a bit of fun. Not only did I demonstrate the rather silly little hack, but I ran it fully garbage collected. With one simple change (that should be in the next release), the MacFUSE framework works just fine with Garbage Collection enabled!
The best compliment came from Amit Singh; something along the lines of “That is absolutely the strangest filesystem I have seen.”
In any case, my little hack repository has been updated to be GC only. retain/release/autorelease/dealloc are dead to me (in this project, anyway).
If you want to build MacFUSE with GC enabled, simply set Objective-C Garbage Collection to “Supported” in Xcode in the MacFUSE framework project’s build settings.
At left, is a screenshot of the Finder browsing the Objective-C classes active in the runtime of a little Cocoa app that I wrote this evening.
The little app is called RuntimeFS and it contains a simple bit of code that traipses through the Objective-C runtime and collects information about the Objective-C classes encountered. This information is then barfed up by the elegantly simple delegate like API required by MacFuse to create a filesystem.
Let me restate that: MacFuse kicks ass. The Objective-C API is trivially easy to use. Trivially easy. I implemented this little hack in less than two hours, not having looked at the MacFuse API before. Nor did I read the docs; just looked at this example and one header file. I have implemented filesystems in a couple of different languages. Filesystems are hard. Or was. Not anymore.
I dropped the source code in the “Silly” directory of my public SVN repository.
Because, really, this is quite a silly hack. And hack it is — it doesn’t crash, but that is about all the quality assurance analysis I have done.
Free as in “MIT License” free. Have fun. I’m accepting patches, of course.
Future Stuff
If I were to go anywhere with this, the first thing I would do would be to move the subclasses into a subdirectory and then add other subdirectories to contain additional data.
Specifically, I would add directories like -1- Instance Variables, -2- Class Methods, -3- Instance Methods, -4- Subclasses, -5- Documentation (or something), etc…
The naming convention serves two purposes. First, it sorts nice like. Secondly, the names are invalid as class names and, thus, it makes handling the metadata vs. class directories trivially easy while also eliminating potential namespace conflicts.



January 10th, 2008 at 2:59 am
[…] filesystem development in user space. Now bbum has written a MacFuse app which allows you to mount the live Objective C runtime as a […]
January 10th, 2008 at 4:29 am
Question: can Spotlight index a MacFuse filesystem? If it could, that would be a clever way around the limitation that spotlight can search only with file level granularity.
January 10th, 2008 at 4:34 am
Silly perhaps, but definitely cool.
-jcr
January 10th, 2008 at 11:13 am
[…] Bill Bumgarner uses the new, ultra-simple Objective-C API for MacFUSE to create a filesystem for browsing Objective-C class hierarchies. […]
January 10th, 2008 at 12:57 pm
Dude. That is so fucking cool.
January 10th, 2008 at 6:00 pm
If you did extend this as stated to include methods, variables, and subclasses (which you might want to symbolically link to a top-level class directory), it could easily replace the now unreliable Docoa Browser.
January 10th, 2008 at 6:17 pm
That’s one of the coolest things I’ve seen in a long, long time. I can’t think of any real serious use for it, but that just makes me admire its awesomeness all the more.
January 11th, 2008 at 12:22 am
You could make individual methods show up as files, with the contents being the documentation for that particular method (:
January 12th, 2008 at 10:53 pm
What was the change you made to the framework? I looked through the header files and didn’t see anything mentioning release or retain (since that is what gcc is complaining about). Did you have to recompile the framework itself?
January 13th, 2008 at 12:09 am
Something I’d love to see, either by MacFUSE or some other project, is a way to browse my cell phone’s contents via Bluetooth using the Finder instead of the gimpy little Bluetooth File Exchange app. Any coders smarter than me up for taking up that project?
January 15th, 2008 at 2:05 am
[…] bbum: “MacFuse kicks ass. The Objective-C API is trivially easy to use. Trivially easy. I implemented this little hack in less than two hours, not having looked at the MacFuse API before.” Comments RSS | Trackback URL […]
March 27th, 2008 at 8:43 am
[…] addition to the talk, there were mind-bending demos of file systems written in Objective-C, such as RunTimeFS and AccessiblityFS. I really enjoyed the CocoaHeads meeting and encourage my fellow Mac developers […]
March 27th, 2008 at 8:43 am
[…] addition to the talk, there were mind-bending demos of file systems written in Objective-C, such as RunTimeFS and AccessiblityFS. I really enjoyed the CocoaHeads meeting and encourage my fellow Mac developers […]
February 5th, 2009 at 2:29 pm
“The strangest filesystem I’ve ever seen” – can’t help but agree with that one. I’m really impressed with what you’ve done here, how long did it take you to throw this together?
[Ed: comment appeared to be to drive traffic to a dieting site. Interesting question, though. It took an hour or so.]