(2) In an parallel development, Damion Yates has produced a very featureful Perl based gphoto2 file system project. This one has a clever extension which creates a virtual .xvpics thumbnail directory (for XV) using the thumbnail download feature of gphoto2. Other features: mkdir, rmdir, deleting files, opening (for read only at the moment) files, listing files in directories with correct fileinfo (including perms, sizes and dates).
Both work with recent versions of fuse and gphoto2.
If you have a camera that communicates with linux via gphoto2 (which itself uses libgphoto2) you may have been annoyed to discover that there is no means of mounting the camera's filesystem as a normal directory. This means that you have to use custom tools like gtkam to view your pictures, and cannot do simple things like "tar up all the pictures and scp them somewhere else" using your favourite common unix commands. At least, not very easily.
In fact I could never get gtkam to work on my machine, and I couldn't understand how it worked, so instead I wrote a 200 line fuse based userland/userspace filesystem that runs on top of gphoto2 and lets you mount your camera's filesystem READ-ONLY on a directory of your choice. Once mounted, you can use it with all your favourite programs gthumb, tar, firefox, netscape etc.
I have not done anything remotely close to "packaging" my filesystem, or in making it work "well", but I make it available here in case someone/somebody finds it of use. As it stands, it "works" but is fairly slow, as I have not made any serious attempts to buffer transfers from the camera. Furthermore, I could not be bothered to find out how to use libgphoto2 so rather than have a program which makes simple (fast!) calls to a library, I instead have a program that makes slow system calls which fire up the gphoto2 command line interface to libgphoto2. This made it very easy for me to develop, but does not make it the fastest program in the world. If you already have a flash card reader for your gphoto2 based camera, then your best bet is to pull the flash card out of your camera and mount it as a usb filesystem. If you don't have such a card reader, and are still interested, read on!
What you need to do to make my filesystem work:
FIRST: PREPARATION:
gphoto2-2.1.4/gphoto2/actions.c
(obviously your version number may be different to mine!). You should search for the line which says:
printf(" %5ld KB", (info.file.size+1023) / 1024);
and change so that it becomes:
printf(" %d B", info.file.size);
gphoto2 -L
which should auto-detect you camera and then return a list of all the files you have stored on it. I just did this on my camera which has about a hundred images stored on it at the moment, and I received this output. Note that if you have made the change to the sourcecode correctly, you will see the file-size for each file in this output reported in bytes (and followed by a "B") rather than the default which is to show it in "rounded up kilobytes" and followed by a "KB". If you see KB then go back and try to modify the source again! You might find that you need to be root (superuser) to have the necessary access rights to your USB ports ...
cd fuse-2.1-pre0/example
(your version may be different than mine) and then running the "hello" example filesystem. e.g. to create an example "hello" filesystem mounted on a directory called /tmp/kkk you could do:
mkdir -p /tmp/kkk
./hello -f /tmp/kkk
after which from another shell you do:
ls -la /tmp/kkk
which should show you a "fake" filesystem containing a single file "hello". If you cat this file you should see it contains the message "Hello World". When you kill the "./hello -f /tmp/kkk" program, the fake hello-world filesystem will be unmounted. Very (very!) occasionally this fails (I'm not sure why!) and you need to "unount /tmp/kkk".
SECOND: INSTALL MY gphoto2-fuse-fs:
fuse-2.1-pre0/example/Makefile
as follows:
Change the line which reads:
am_hello_OBJECTS = hello.$(OBJEXT)
so that is reads instead:
am_hello_OBJECTS = hello.$(OBJEXT) lester.o
Then add at the end of the Makefile the lines:
lester.o: lester.cpp
g++ -DHAVE_CONFIG_H -I. -I. -I../include -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -W -g -O2 -MT hello.o -MD -MP -c $^
Here is a copy of my Makefile once I made the above changes. Yours will probably be substantially different to mine, though, as this file was autogenerated during the installation of fuse and so it will be peppered with your directories!
fuse-2.1-pre0/example/hello.cwith my replacement hello.c.
fuse-2.1-pre0/example/lester.cppidentical to lester.cpp.
fuse-2.1-pre0/example/pstream.hidentical to pstream.h.
cd fuse-2.1-pre0/example rm -f hello.o make
./hello -f /tmp/kkkwhich takes a while (sorry! I said it was slow!), produces a lot of debug output, and finally finishes with the message "Handing over to fuse". Here is the full output I see when I mount my own camera.
ls -la /tmp/kkkwhich gives me this or by trying
find /tmp/kkkwhich gives me this.
I know gphoto2-fuse-fs works for me, but it may well not work for you. If there is enough interest, I may consider trying to make it work better / faster (improve the caching, speed up the mount time, make the fs writeable). However one thing I do NOT expect to do is figure out how to package it better. If anybody else wants to figure out how to do that so that my many lines of instructions above can be rendered much saner then I would much appreciate their input. I am not a package manager!
All the above was tested with my digital camera, a "CANON PowerShot A75", connected via USB. Redhat 9 and a modified 2.4.23 kernel were used. I believe there should be no problem with any 2.4 or 2.6 kernel.
Contact details:
My name is Christopher Lester.
I can be conacted via email at:
lester-@-hep.phy.cam.ac.ukin which you should obviously replace "-@-" with plain "@" if you want the email to reach me!