This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mkdir(2) prefers EACCES over EEXIST


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]