Getting AVFS to work with SuSE 9.2 (and possibly other 2.6 kernel distros)

Disclaimer

Everything here is presented in good faith, but without any warranty of any kind... I hope it's helpful, but if something goes horribly wrong for you then that's your problem. Getting this to work isn't exactly a newbie friendly process, although it's not exactly rocket science, either. Basically, read through what I've written and if you're comfortable with it (and equally comfortable with putting things back as they should be if it goes wrong) then go for it. Otherwise, tread very carefully.

Background

I recently upgraded from SuSE 8.2 to 9.2 and thus from the 2.4 kernel to 2.6. On my old system I used AVFS (in the avfscoda style) to access archives, etc. as if they were directories (much like image filing systems in Acorn's RISC OS). Sadly this didn't want to play with the 2.6 kernel in a number of subtle but significant ways. I ignored the problem for a while but eventually I figured either I, or (more likely) someone else, would figure it out and I'd be able to go back to using it. Well, as it happens, I couldn't sleep last night and, google being the wonderful thing it is, I turned up some useful info and a patch, and started fiddling myself. Now I have AVFS back again, albeit without the (rather useful) redir module.

Ingredients

Preparation

Unpack the AVFS source code. Apply Olivier's patch (cd into the avfscoda directory and apply it with patch -p0 <name_you_saved_the_patch_with ).

Do the usual ./configure thing. If you get an error about expat (or libxml, or whatever), try passing --disable-dav to configure.

Now, since the redir module simply isn't going to work with kernel 2.6, delete the entire contents of the avfscoda/redir/redir.c file. Don't delete the file, just its contents.

And, since we're not going to build the redir module, we'd probably better remove it from the installation target in the Makefile – simply delete the last 3 lines of avfscoda/redir/Makefile (ie. the ones after install: all)

Okay, so so far all we've done is to remove the redir module from the build. Now it's time to do some EVIL things and get the avfscoda daemon to build properly. The main problems I had building it were, in order of appearance, conflicts with header files (linux/time.h) and an incorrect coda.h location. Fortunately, each of these is easy to fix.

Here's the only really nasty part of the whole thing. We need to temporarily edit the /usr/include/linux/time.h file to comment out the parts that would otherwise cause an error during compilation. For goodness' sake, take a backup of the file before fiddling with it.

As root, edit /usr/include/linux/time.h and comment out the definitions of struct timespec, struct timeval, struct timezone, struct itimerspec, and struct itimerval.

That should fix the 'error redifinition of blahblah' problems. Now to sort out the coda.h location.

Take a look at avfscoda/Makefile. The CCFLAGS definition will include a something like this: -DCODAINCLUDE=\"/usr/src/linux-2.6.8-24.13-obj/i386/default/include/linux/coda.h\" Now, this might, or might not be correct. Have a look yourself and see if you can find coda.h on that path. Chances are that you won't be able to. The actual path should be something like /usr/src/linux-2.6.8-24.13/include/linux/coda.h, or (assuming you're running with the kernel you intend to use) simply /usr/src/linux/include/linux/coda.h so edit that part of the Makefile to suit.

You should now be able to build (make) AVFS and (as root) do the make install to install everything.

Don't forget to restore time.h to it's unedited state!

If you try make start to check that all is well, don't worry about it failing to load redir.o – we didn't build that...

Finishing Touches

If you want AVFS to be started along with everything else, you'll want to edit the /etc/init.d/avfscoda initscript that got installed in order to make it fit in with the SuSE boot concept. It also needs editing in order to remove the lines that try to (un)load the redir module since we've had to ditch that.

Here's the /etc/init.d/avfscoda script that I use:

#! /bin/sh
# avfscoda
# generic init script

### BEGIN INIT INFO
# Provides:       avfs
# Required-Start: $network $named $syslog $time
# X-UnitedLinux-Should-Start: cyrus ldap ypbind openslp
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    start the AVFS daemon
### END INIT INFO

rc_failed="\tFAILED"
rc_done="\tOK"

return=$rc_done
case "$1" in
    start)
	
	# try to load coda module (no problem if it fails, because it can be
	# in the kernel)
	/sbin/modprobe coda > /dev/null 2>&1

	return=$rc_done
	echo -n "Starting avfscoda"
	/usr/sbin/avfscoda || return=$rc_failed
	echo -e "$return"
	;;

    stop)
	echo -n "Shutting down avfscoda"
	if test -x /usr/sbin/flushredir; then
	    /usr/sbin/flushredir
	fi
	/usr/bin/killall avfscoda || return=$rc_failed
	echo -e "$return"
	;;

    restart|reload)
	$0 stop && $0 start || return=$rc_failed
	;;

    status)
	echo "Checking for avfscoda: ???"
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac

# Inform the caller not only verbosely and set an exit status.
test "$return" = "$rc_done" || exit 1
exit 0

It's pretty arbitrary (at the top, anyway) and should mean that it gets started about the same time as the MTA in run levels 3 and 5 (full multi-user and full multi-user with X).

As root, cd into /etc/init.d and run insserv avfscoda to get everything set up properly.

Using AVFS

There's a few unavoidable differences between using AVFS with a 2.6 kernel and a 2.4 kernel. It's that pesky redir module's fault. We could use it with 2.4, but it's not there for us anymore with 2.6.

But, it's not that bad. All it means is that there's no automatic mapping of 'special' filenames to the /overlay directory. So where before you'd access /home/me/some.archive.tgz#some_file.txt you now have to access that file as /overlay/home/me/some.archive.tgz#some_file.txt – in other words, you just stick a /overlay on the start of the path (which is exactly what the redir module did, by the way).

As another example, if you're using the ROX-Filer file manager (and if not, why not? Go and try it now!) you can set the run action for archives to, say, rox “/overlay/$@#/” so that when you open an archive it'll open a filer window on it using AVFS.

References

http://article.gmane.org/gmane.comp.file-systems.avfs.user/6

This is where I found the info on commenting out sections of time.h. I didn't have the other compile problems mentioned in that message but that was, at least in part, because I'd already applied Olivier's patch. The (a little similar looking) compile problems I did get were caused the incorrect location of coda.h in the Makefile.

http://comments.gmane.org/gmane.comp.file-systems.avfs.user/55

This is where I found Olivier's patch.

http://rox.sourceforge.net/phpwiki/

The homepage of the ROX desktop. Even if you're not interested in the whole desktop (maybe you use KDE or GNOME – I use KDE) it's well worth looking at the ROX-Filer. It's quite simply the best graphical file manager for X out there, in my opinion. Lean where it should be, and full featured where it matters.

Contact Details

I can be contacted via email as musus@verelanthe.co.uk