On 10/7/06, Miklos Szeredi <[EMAIL PROTECTED]> wrote:
> Yes, for systems with O_NOFOLLOW, that is a perfect (efficient, race
> free) solution. For systems without O_NOFOLLOW, just moving the
> lstat() and the open() close to each other
Actually moving the lstat() _after_ the open() totally removes the
race for inode-less filesystems. The following should be equivalent
to open(O_NOFOLLOW):
fd = open(path);
lstat(path, &st1);
fstat(fd, &st2);
if (st1.st_ino != st2.st_ino)
/* ELOOP */;
For find, the stat result (in the absence of type information in
struct dient) determines if we need to consider descending into a
directory. I'm very reluctant to try opening every file in the
filesystem just in case it turns out to be a directory we need to
descend into. But then, the underlying principle of your technique
will doubtless be useful even if it needs to be adapted to work
efficiently for find.
James
_______________________________________________
Bug-findutils mailing list
Bug-findutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-findutils