X-Spam-Check-By: sourceware.org Message-ID: <43DA9F10.8090804@byu.net> Date: Fri, 27 Jan 2006 15:30:40 -0700 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: Alex Riesen CC: cygwin AT cygwin DOT com Subject: Re: cygwin-1.5.19-2: mkdir returns inconsistent errno References: <012620061525 DOT 1038 DOT 43D8EA05000B44680000040E22007358340A050E040D0C079D0A AT comcast DOT net> <81b0412b0601260821p2a0525dane12307a43e6897f1 AT mail DOT gmail DOT com> <20060127182655 DOT GA6169 AT steel DOT home> In-Reply-To: <20060127182655.GA6169@steel.home> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Alex Riesen on 1/27/2006 11:26 AM: > > This was a bit prematurely. There is a big problem with this aproach: > it changes current directory of the process. So you can't really use > it in multithreaded or signalled environment. > So chdir is not a real solution. Is it really that hard to workaround > the problem in cygwin? If the Austin Group API set 2 is approved (http://www.opengroup.org/austin/mailarchives/ag/msg08954.html), you will have mkdirat() that creates directories relative to an open file descriptor on an existing directory; that would alleviate the non-threadsafe use of chdir(). Until then, I don't know of ANY race-free way to create a directory immediately followed by chdir() or open() that guarantees that you used the same directory already made by mkdir(). Maybe if you call mkdir() restricting the access to just the user, then open(O_NOFOLLOW), then fchmod(). What would be cool would be something like giving valid semantics to open(O_CREAT|O_DIRECTORY) that acts as mkdir(), but I doubt that will happen, either, thanks to current Linux semantics (http://lkml.org/lkml/2005/9/24/8). Meanwhile, you can always spawn mkdir(1) and have another process, with no restrictions on using chdir(), do the directory creation for you. If it is really that much of a problem for you, you should consider raising a defect against the POSIX standard requesting that mkdir() be guaranteed to fail with EEXIST on an existing directory, even if EROFS or EACCES or EPERM would also otherwise apply. - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD2p8Q84KuGfSFAYARAvITAKCHIEaVqyvIiEYnBDVM6Ihy2QyRmQCfZ+z0 p8JdUvzJYfWr3f/a2BV8dIw= =+t2b -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/