Gnome VFS on the command line



I have been working on a small hack that might interest people on this
list. 

GnomeVFS is great technology, but unfortunately it works only for
programs that have been written to use it. Would it not be nice if all
programs could read and write to GnomeVFS locations?

I therefore decided that I would try to replace the normal calls to
open, read, write etc. with the GnomeVFS equivalents. What I did was to
make a library that can be loaded with LD_PRELOAD. The library replaces
the symbols mentioned above, and some more. At the moment the whole
thing is on the "proof of concept" stage, but it looks like this hack
could be made to work quite well. 

My general strategy is to first try the normal system call, and if that
fails try to use the GnomeVFS call. Better strategies like checking if a
name is a uri before passing it to Gnome VFS have not been implemented
yet. 

Issues that are still outstanding include what to do with multitreaded
programs and I think some problems with programs that do funky things
with the filedescriptors when forking.

My first goal was to make cp and cat work. I got several other things
too work as well. You can for instance try:
$ cat http://www.gnome.org
$ cp http://www.gnome.org .
$ wc -l http://www.gnome.org

The main problems seem to be the mapping of result-codes and handling
errors. Getting 100% Unix semantics is close to impossible. It is
possible to get quite far without it, just look at for instance the smb
filesystem. I have not tried to replace readdir/opendir, but that should
be doable as well.

The code is available at http://www.newmad.no/~pergj/vfshack.c

-- 
                                                    Per Kristian





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]