OK, here's what we are proposing to do in BitKeeper as a work around:
replace readdir() with an internal getdir() function
getdir() returns all directory entries in a sorted list
getdir() works by doing
for (;;) {
lstat(dir);
while (e = readdir(..)) save(e->d_name);
lstat(dir)
if (dir size && dir mtime have NOT changed) break;
cleanup the array and go start over
}
sort entries
return sorted list
The basic idea being that we first of all narrow the race window and
second of all detect the race in all cases where the mods to the dir
result in either a changed mtime or a changed size. So yes, that leaves
us open to cases where the size didn't change but the contents did but
I'll be ding danged if I can see a way around that.
As for the sorting, we want deterministic ordering of the entries for
our own reasons. It also means that we can do the duplicate suppression
in the list processing.
Anyone see a fixable flaw in this approach?
----- Larry McVoy lm at bitmover.com http://www.bitmover.com/lm - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/