Getting rid of the only race condition that matters:

Create the link first, with an unused name. Instead of
relying on the return code, which may be wrong for NFS,
call stat to find out if you created the file. Rename the
link over top of the file it is intended to replace. In case
that fails, remove the temporary file.

I suggest temporary names that look like these:

.fdupes-vtYoH1PGPa4lj^LIOfL_i~
.fdupes-wz_7uNXC2R4-ftNq-gl,Z~
.fdupes-kf9_9EQmw-v0nv_-HcyKS~
.fdupes-BTR6AlGWjz@rVSC^+@j+-~
.fdupes--SaeXuxNfj1U0mltgmWNN~

(dotfile, string "fdupes", 128 random bits, tilde on end,
and nothing that would be likely to trip up a bash shell)

Note that you can't hope to support all the crazy things
that exist in current and **future** kernels. There are
numerous security modules, "mount --bind" tricks such
as file-on-file mounting, union filesystems, network fs
servers running on non-Linux systems, and so on. You
have to draw the line somewhere; just make a note in
the man page that the tool is intended for single-user
use in non-crazy situations.

Perfection is the enemy of good; we need this option
working again. Right now I'm desperately rewriting this
tool as a pile of nasty shell scripts, and I assure you
that I totally don't care about cross-filesystem issues.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to