public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: mkdir(2) prefers EACCES over EEXIST
Date: Wed, 12 Jul 2017 08:46:00 -0000	[thread overview]
Message-ID: <20170712084546.GF30071@calimero.vinschen.de> (raw)
In-Reply-To: <20170712011209.GK17540@nullprogram.com>

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]

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 directory
> couldn't have been created in the first place. For example, this is the
> typical situation for /cygdrive/c:
> 
>    mkdir("/cygdrive/c", 0700);
>    // errno == EACCES
> 
> Or from the shell:
> 
>    $ mkdir /cygdrive/c
>    mkdir: cannot create directory ‘/cygdrive/c’: Permission denied
> 
> Compare that to Linux or *BSD (giving EEXIST):
> 
>    $ mkdir /etc
>    mkdir: cannot create directory ‘/etc’: File exists
> 
>    $ mkdir /etc
>    mkdir: /etc: File exists
> 
> This behavior seems to be permitted by POSIX — both are valid reasons for
> this system call to fail — but it's a surprising result. I'd expect
> 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

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2017-07-12  8:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  1:12 Christopher Wellons
2017-07-12  8:46 ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170712084546.GF30071@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).