diff options
author | Ben Wijen <ben@wijen.net> | 2019-06-03 20:15:50 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-06-05 13:53:44 +0200 |
commit | b0c033bf3fae810b9e5a5c69f17bd4de63725691 (patch) | |
tree | d07a234166c6fffac517a3064362281ea177a4de | |
parent | 5c2a3661c1aeefb0591ce46e8ab3274f0c6d9112 (diff) | |
download | cygnal-b0c033bf3fae810b9e5a5c69f17bd4de63725691.tar.gz cygnal-b0c033bf3fae810b9e5a5c69f17bd4de63725691.tar.bz2 cygnal-b0c033bf3fae810b9e5a5c69f17bd4de63725691.zip |
mkdir: always check-for-existence
When using NtCreateFile when creating a directory that already exists,
it will correctly return 'STATUS_OBJECT_NAME_COLLISION'.
However using this function to create a directory (and all its parents)
a normal use would be to start with mkdir(‘/cygdrive/c’) which translates
to ‘C:\’ for which it'll instead return ‘STATUS_ACCESS_DENIED’.
-rw-r--r-- | winsup/cygwin/dir.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index f43eae461..b757851d5 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -331,8 +331,10 @@ mkdir (const char *dir, mode_t mode) debug_printf ("got %d error from build_fh_name", fh->error ()); set_errno (fh->error ()); } + else if (fh->exists ()) + set_errno (EEXIST); else if (has_dot_last_component (dir, true)) - set_errno (fh->exists () ? EEXIST : ENOENT); + set_errno (ENOENT); else if (!fh->mkdir (mode)) res = 0; delete fh; |