Wednesday, November 21, 2012

Libferris as a KIO Slave

The libferris virtual filesystem can now be exposed as a KIO Slove too. This allows you to use KDE applications to list, read and write the vast number of virtual filesystems that libferris makes available. For those who don't know, ferris is a little project I've been working on over the last decade to make everything a file: XML, db, relational data, web services, and even applications like XWindow, Amarok, pulseaudio, and gstreamer.

The following will create a Berkeley db4 file from the command line and show it to you. To dig into such files with libferris you can just read the file directly. So in this case I just grab the "base" directory in this db4 file with konq. You should see the sample and file2 files in that directory view and be able to load and save those "files" into kwrite. Sorry about the video being a tad jumpy, I have to work out what part of my desktop is causing that :/


Using libferris through the KIO interface from Ben Martin on Vimeo.

The commands as plain text:

$ cd /tmp
$ db45_load -T -t btree foo.db
base/sample
value here
base/file2
contents

$ db_dump -p foo.db
$ konqueror ferris:/tmp/foo.db/base

little tricks I found during the hacking, your listDir() method might call listEntry( e, false ) with a final call using ( e, true ). The last call is impotent with regard to "e" and just a finalizer call. The get() method uses data() to deliver bytes to the KIO user (application). The put() method uses dataReq() in a loop to grab chunks frrom the KIO user. Currently I have lazy methods, for example the put() just grabs everything from the KIO user and then operates on the data once it has everything. Really bad for 4gb files, but for smallish files to get a feel for things it works quite well.

Also, if you are using library init, in my case using gmodule to dynamically load some plugins from libferris itself, you might be in for a world of fun and games. Currently I spawn processes and interact with them from the KIO slave to get around this issue. I imagine for a more efficient implementation being able to tell KDE to load my KIO Slave as an application with a normal full init leading to a main() but haven't looked at that little technicality yet.

I've mostly been tinkering with kioclient, konq, and kwrite on libferris files at the moment. Things are turning out well, though there are still many glitches to this early days integration. This will be released in the next libferris version once I clean it up a bit more.

5 comments:

Jens Staal said...

I would love to get a 9P2000 binding to KIO :) I tried once to look at libixp (a C-library implementation) or py9p (http://mirtchovski.com/p9/py9p/) together with the instructions for making a KIO slave in python. I never got that far though... On Linux 9P2000 is also implemented in the kernel as a file system and there are lots of implementations (http://9p.cat-v.org/implementations). 9P is for example used for resource sharing between virtual machines and hosts in some cases and should be better than NTP.

monkeyiq said...

I found that the API docs are one of the better sources to getting things to happen. Also poking into the file kio slave and others to see what they are doing in order to do their stuff.

For debugging having kioclient able to do a "list" command would be really handy, but I guess I should have a patch to make that happen rather than a comment about it :o

The plan9 stuff is always extremely cool!

monkeyiq said...

Oh, and BTW all ya'll, I have comment moderation on, so if you stuff doesn't appear right away, it didn't get eaten by the cookie monster or anything (well probably).

vivo said...

very interesting, good work

Vishesh Handa said...

> For debugging having kioclient able to do a "list" command would be really handy, but I guess I should have a patch to make that happen rather than a comment about it :o

I was having similar problems when debugging some nepomuk kioslave issues. I finally asked David Faure to implement it during Akademy. He's awesome!