[Gllug] recover deleted files

Nix nix at esperi.org.uk
Sun Nov 30 12:26:49 UTC 2008


On 30 Nov 2008, t. clarke stated:
> Due to people at work occasionally asking me to recover something they deleted
> 'last week sometime' on a multi-user 'nix system, I replaced the 'rm' command
> they would normally use with an alternative which works on a similar 'trash'
> directory basis.

Replacing the rm command works until you have programs that do the unlink()
themselves (i.e. nearly all of them) or that truncate open files. (This is
very common as well.)

To do this right you need a preopened library that hooks at least
open(), fopen() et al (probably by hooking into libio), truncate(),
unlink(), unlinkat() and perhaps more, and links files to the trash on
unlink() and unlinkat() and copies them on open(O_TRUNC) and truncate().
The biggest downside of this is that truncates now take much longer than
before, because of the need to copy the file before opening. (You can't
link it because it's just about to get truncated...)


Am I overdesigning this?

-- 
`Not even vi uses vi key bindings for its command line.' --- PdS
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list