public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Christopher Wellons <wellons@nullprogram.com>
To: cygwin@cygwin.com
Subject: mkdir(2) prefers EACCES over EEXIST
Date: Wed, 12 Jul 2017 01:12:00 -0000	[thread overview]
Message-ID: <20170712011209.GK17540@nullprogram.com> (raw)

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.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

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

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=20170712011209.GK17540@nullprogram.com \
    --to=wellons@nullprogram.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).