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]

Re: mkdir(2) prefers EACCES over EEXIST

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 Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature

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