[Gllug] trashman - a trash management utility for Linux filesystem

Nix nix at esperi.org.uk
Mon Jan 30 17:50:29 UTC 2006


On Mon, 30 Jan 2006, Dan Stevens mused:
>> First of all, Ubuntu does in fact have a wastebasket, which is used by
>> desktop applications.  The files get moved first into a hidden
>> directory called '~/.Trash' and you can add a waste bin to your panel
>> which allows you to monitor and empty this place.
> 
> I can't say I've noticed this; I shall have to look into it.
> 
>> Why is it a bad idea to have a safe version of "rm" (or to alias rm=rm
>> -i ?)  Because when you come to administer another system you won't be
>> so careful about using the "rm" command, and then you'll discover that
>> those files you just carelessly deleted can't be recovered, because
>> that system didn't have the "safe rm" but the real rm.[1]
> 
> Well, my idea is not to replace 'rm', but to provide a separate
> utility (via a separate command), which voids any possible
> misunderstanding of the 'rm' command.

Such a utility would be nearly useless. Nearly all deletion is done via
direct calls to unlink(): this is especially true of graphical file
managers and the link. But note that many text editors, including vim
and Emacs, save files via unlink()-and-rename()-of-a-temporary-file;
such an unlink() is *not* a deletion and should probably not land in
the trashcan.

The only reliable ways to hook this are

i) write an LD_PRELOADed library to hook unlink() and move things at
unlink() time; <http://pages.stern.nyu.edu/~marriaga/software/libtrash/>
is an example. Such a tool will be fooled by unlink()-and-rename() and
might move more into the trashcan than you expect.

ii) use a version-controlled filesystem, like VMS had.

(and if my hardware stops failing I might be able to get back to writing
one: one motherboard died, one dicky network card, and one SCA disk on
its last legs *in the last week*. GAH. I can't really continue until I
replace that disk, since it might go *grind* *splat* at any time...)

>> A much better idea is to manage files you really care about using a
>> version control system, and frequently check in changes.
> 
> I would agree, a CVS is a good idea for very important data, however I
> believe for a casual, normal use, a simple trash management utility
> would be much more convenient.

CVS sucks anyway. Want unusual permissions? oops. Want to preserve
any of the timestamps? oops. Want to preserve hardlinks? oops. What
about symlinks? oops.

No, CVS is useless for this application; subversion preserves a bit more
state but is still useless if like me you make heavy use of
hardlinks. Plus you have to remember to check in and out. (That's why
I'm writing Recant. A new version on every open for writing. Do *that*
with a normal version-control system. :) )

-- 
`I won't make a secret of the fact that your statement/question
 sent a wave of shock and horror through us.' --- David Anderson
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list