Subject: Re: CVS commit: src/usr.bin/find
To: None <tech-userlevel@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 02/11/2007 23:46:05
> In this case passing an open file won't help, as it is the directory
> entry (ie the name) that has to be removed, not the open file.

Passing an open file will indeed help, provided it's done right: pass a
fd on the directory along with the name.  Then rm can fchdir() to the
directory and unlink() the name, safely.

> I think this means that there is always a race between any stat of
> the name and an attempt to unlink it.

Yes, there is a race in that the name may no longer refer to what it
used to.  That doesn't matter for the purposes -delete was added for.
And passing an fd on the directory plus the name is precisely as good
as -delete for this....

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B