From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84792 invoked by alias); 12 Jul 2017 08:46:02 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 84464 invoked by uid 89); 12 Jul 2017 08:45:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-101.9 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=etc=e2, eacces, wellons, eexist?= X-HELO: drew.franken.de Received: from mail-n.franken.de (HELO drew.franken.de) (193.175.24.27) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Jul 2017 08:45:51 +0000 Received: from aqua.hirmke.de (aquarius.franken.de [193.175.24.89]) (Authenticated sender: aquarius) by mail-n.franken.de (Postfix) with ESMTPSA id 568CC721E281E for ; Wed, 12 Jul 2017 10:45:47 +0200 (CEST) Received: from calimero.vinschen.de (calimero.vinschen.de [192.168.129.6]) by aqua.hirmke.de (Postfix) with ESMTP id 8441C5E0409 for ; Wed, 12 Jul 2017 10:45:46 +0200 (CEST) Received: by calimero.vinschen.de (Postfix, from userid 500) id 63080A805EB; Wed, 12 Jul 2017 10:45:46 +0200 (CEST) Date: Wed, 12 Jul 2017 08:46:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: mkdir(2) prefers EACCES over EEXIST Message-ID: <20170712084546.GF30071@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20170712011209.GK17540@nullprogram.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qOrJKOH36bD5yhNe" Content-Disposition: inline In-Reply-To: <20170712011209.GK17540@nullprogram.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-07/txt/msg00204.txt.bz2 --qOrJKOH36bD5yhNe Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1401 On Jul 11 21:12, Christopher Wellons wrote: > This isn't _really_ a bug, more of an oddity. Calling mkdir(2) on an > existing directory will fail with EACCES instead of EEXIST if the directo= ry > couldn't have been created in the first place. For example, this is the > typical situation for /cygdrive/c: >=20 > mkdir("/cygdrive/c", 0700); > // errno =3D=3D EACCES >=20 > Or from the shell: >=20 > $ mkdir /cygdrive/c > mkdir: cannot create directory =E2=80=98/cygdrive/c=E2=80=99: Permissi= on denied >=20 > Compare that to Linux or *BSD (giving EEXIST): >=20 > $ mkdir /etc > mkdir: cannot create directory =E2=80=98/etc=E2=80=99: File exists >=20 > $ mkdir /etc > mkdir: /etc: File exists >=20 > This behavior seems to be permitted by POSIX =E2=80=94 both are valid rea= sons for > this system call to fail =E2=80=94 but it's a surprising result. I'd expe= ct > existence to take priority. That's a result of calling the Windows function without prior check for existence. The Windows function apparently prefers it's variation of EACCES over EEXIST, *iff* the target of the function is a drive. I don't think it's worth to add a check to mkdir for such a border case, just to prefer one error code over another. Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --qOrJKOH36bD5yhNe Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJZZeG6AAoJEPU2Bp2uRE+gr0kQAKK0TNPlAHCfoOQVmSDJ9eFw v6tC22fZiBFo9eKXLPBSVpenpGjPcmqWzv3Kov+TDKmJL6Gmqdvqh9EyWXCOLvl9 8Q0/xO1s26CXGp1c+RcXGRlyWt9VViCY8iUajPnG0tvlXPlFkLU+ZJNxpZxyVyKo aAYvxH6oIShVd+Uvn7a9HgLagIUgE0grfeN3QxtaN3MbyAmBaWvDpfWcnR+qeU5L i+DB1VMaJ5zuYA+tl27FSSSjccQwzvUHvFJReIQ40bCWGvhLu4T6DP1z/VMetlqB Ioprsz+chcEaeU0slInN1qAQraZTAs0Rgqq0aLjoorMsybEHIjP+f9dghI2zXzYb XVuWZ1rNHhgL0y4KQd3hV99S2BCvvw4QY9M2DY7lhRN0Qrsp9nTGQHK2lSCbEW5o ggr4nsMFsHkqwMZ+plYx3kz1+2a3dEMf5LsD8uFIqoMzassenIHBpRR2TE3UNVqM oeXnVyp/En1Zw2ktxinsWfzYGgBwGpHoYvx0AhISV2p7QSImKh33seAQnpQ3BNnw +bUZoZXIyiI1/byPp2s7VbdOkEeWuQL++KQWgg6fBP1tCcCW8ed3sl4VKXheImbF QEBem10uSyK3UhWb1tpmOyTjBCw2/XbqPCe6qvfbpl33YtMoCqf1lpi3OOif3aZD OUv4AuEPTIzKH0+fbd52 =B/05 -----END PGP SIGNATURE----- --qOrJKOH36bD5yhNe--