Collectfs - fuse trash collecting filesystem - the developers friend

I’ve created a fuse-filesystem that layers trash collection over an existing directory hierarchy. It’s a bit like local-history in the eclipse development environment.

I developed it using OpenSUSE, so I thought I’d mention it here first:Collectfs is intended as a light weight way to preserve changes made throughout the working day. It is not intended as a replacement for revision control or backups. The intention is to protect you during the between-times, when you’re not covered by these other tools: those moments where you misstep with rm, mv, or cat; or those times when you wish you could revert or compare your source to as it was an hour ago.

I’ve used collectfs to help develop collectfs. I haven’t encountered any nasty bugs or stability problems, but testing has been fairly limited - so be careful with it.

At the moment you have to build it from source, but that’s pretty easy (the source includes an RPM spec for OpenSUSE which works fine on OpenSUSE 11.4, but I’m only supporting source at the moment):

Blog entry: Code included: Collectfs - a trash collecting userspace file system for Linux
Project home: collectfs - A Linux userspace filesystem that provides trash collection - Google Project Hosting

openSUSE has a package for Collectfs:

https://build.opensuse.org/package/show?package=collectfs&project=home%3Avodoo

lol!

Thanks for setting this up (I must get around to checking out the build service).

I had to patch the Makefile a bit (need the opportunity to pass additional compile options). I added the install target as well. That way I do not have to install from the spec file. Having uninstall too would be nice. Would you like to fix that upstream with your next release? If yes, here is my new Makefile:

# Makefile for collectfs
#  Copyright 2011, Michael Hamilton
#
#####################
# User configuration:
#####################
# Set this to the directory path of the executable
INSTALLDIR = /usr/bin
#
# Set this to the directory for manual pages
MANUALDIR  = /usr/share/man
#
#####################

PROGNAME = collectfs

ifeq ($(origin FUSE_C_FLAGS), undefined)
FUSE_C_FLAGS := $(shell pkg-config fuse --cflags)
endif

ifeq ($(origin FUSE_LD_FLAGS), undefined)
FUSE_LD_FLAGS := $(shell pkg-config fuse --libs)
endif

MANDIR  ?= $(MANUALDIR)
BINDIR  ?= $(INSTALLDIR)
LDFLAGS ?= $(FUSE_LD_FLAGS)
CFLAGS  ?= $(FUSE_C_FLAGS) 

.PHONY : all doc install clean dist

all : $(PROGNAME)

$(PROGNAME) : $(PROGNAME).o log.o
        gcc -g -o $(PROGNAME) $(PROGNAME).o log.o $(LDFLAGS)

$(PROGNAME).o : $(PROGNAME).c log.h
        gcc -O2 -g -Wall $(CFLAGS) $(OPTFLAGS) -c $(PROGNAME).c

log.o : log.c log.h
        gcc -O2 -g -Wall $(CFLAGS) $(OPTFLAGS) -c log.c

$(PROGNAME).1.html : $(PROGNAME).1
        groff -man -T html $(PROGNAME).1 > $(PROGNAME).1.html

$(PROGNAME).1.man : $(PROGNAME).1
        groff -man -T ascii $(PROGNAME).1 > $(PROGNAME).1.man

$(PROGNAME).1.gz : $(PROGNAME).1
        cat $(PROGNAME).1 | gzip -9 > $(PROGNAME).1.gz

doc : $(PROGNAME).1.html $(PROGNAME).1.man $(PROGNAME).1.gz

install : $(PROGNAME) doc
        install -d -m 755 $(DESTDIR)$(BINDIR)
        install -d -m 755 $(DESTDIR)$(MANDIR)/man1
        install -m 755 $(PROGNAME) $(DESTDIR)$(BINDIR)/
        install -m 644 $(PROGNAME).1.gz $(DESTDIR)$(MANDIR)/man1/

clean :
        rm -f $(PROGNAME) $(PROGNAME).1.gz *.o

dist :
        rm -rf distfiles/$(PROGNAME)/
        mkdir -p distfiles/$(PROGNAME)/
        cp Makefile *.c *.h *.1 *.html *.man COPYING README distfiles/$(PROGNAME)/
        cd distfiles/; tar cvzf ../$(PROGNAME).tar.gz $(PROGNAME)/

Could anyone install and test the openSUSE package of collectfs and check that it’s working as expected? Thanks.

Another note:

Collectfs does not build for SLE_11_SP1. The message I get is:

+ /usr/bin/make 'OPTFLAGS=-march=i586 -mtune=i686 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables'
gcc -O2 -g -Wall -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse   -march=i586 -mtune=i686 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -c collectfs.c
collectfs.c: In function 'fop_init':
collectfs.c:894: error: 'struct fuse_conn_info' has no member named 'capable'
collectfs.c:894: error: 'FUSE_CAP_ATOMIC_O_TRUNC' undeclared (first use in this function)
collectfs.c:894: error: (Each undeclared identifier is reported only once
collectfs.c:894: error: for each function it appears in.)
collectfs.c:898: error: 'struct fuse_conn_info' has no member named 'want'
make: *** [collectfs.o] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.80813 (%build)

Thanks for the Makefile improvements, I’ve checked them into svn.

I’ve also amended collectfs.c to check for the definition of FUSE_CAP_ATOMIC_O_TRUNC. This will probably fix the build issue on SLE_11_SP1. Collectfs cannot detect open-truncate on systems that lack that capability. While rm, mv, ln, unlink would still be covered, operations such as cat>myExistingFile may not be on SLE_11_SP1.

The build service package installs and uninstalls on my system.

All good. Thanks.