public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] mkdir: always check-for-existence
@ 2019-06-05 11:56 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-06-05 11:56 UTC (permalink / raw)
To: cygwin-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1290 bytes --]
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b0c033bf3fae810b9e5a5c69f17bd4de63725691
commit b0c033bf3fae810b9e5a5c69f17bd4de63725691
Author: Ben Wijen <ben@wijen.net>
Date: Mon Jun 3 20:15:50 2019 +0200
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â.
Diff:
---
winsup/cygwin/dir.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index f43eae4..b757851 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-05 11:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 11:56 [newlib-cygwin] mkdir: always check-for-existence 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).