bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed fix for some race conditions in mkdir and install


From: Paul Eggert
Subject: Re: proposed fix for some race conditions in mkdir and install
Date: Sat, 16 Sep 2006 13:10:41 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> By the way, I've just realized that it *is* possible to implement these
> mkdir-like functions in a thread-safe manner (i.e. traversing via openat,
> operating on files via mkdirat, chmodat, etc.), while remaining efficient
> (O(n)).  The only assumption is that the target directory name does not
> contain too long a sequence of existing unreadable directories (sum
> of length of names + slashes > PATH_MAX).

I initially tried something like that, but got too confused by it,
perhaps partly because I wanted to fall back on something like the
current approach when mkdirat didn't work (which is a common case
these days, even on GNU/Linux systems, alas).

The current code is still too complicated for my taste -- I'd be quite
surprised if it were bug-free.  I considered ripping out the
open(".")/fchdir part of the code, since it's simpler if you assume
that you _always_ create a subprocess, but decided that in this case
simplicity had to yield to performance.

> One nit:

Thanks for catching that.  I fixed it and installed the result.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]