public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* mkdir(2) prefers EACCES over EEXIST
@ 2017-07-12  1:12 Christopher Wellons
  2017-07-12  8:46 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Wellons @ 2017-07-12  1:12 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-12  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12  1:12 mkdir(2) prefers EACCES over EEXIST Christopher Wellons
2017-07-12  8:46 ` Corinna Vinschen

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).