summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/fhandler.cc4
-rw-r--r--winsup/cygwin/syscalls.cc6
2 files changed, 7 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index e2d0344aa..ba81cd3a6 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -520,9 +520,7 @@ fhandler_base::open_9x (int flags, mode_t mode)
{
if (pc.isdir ())
{
- if (flags & (O_CREAT | O_EXCL) == (O_CREAT | O_EXCL))
- set_errno (EEXIST);
- else if (flags & (O_WRONLY | O_RDWR))
+ if (flags & (O_WRONLY | O_RDWR))
set_errno (EISDIR);
else
nohandle (true);
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index bf4d6a3fa..5f2b4420d 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -564,6 +564,12 @@ open (const char *unix_path, int flags, ...)
{
if (!(fh = build_fh_name (unix_path, NULL, PC_SYM_FOLLOW)))
res = -1; // errno already set
+ else if (((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) && fh->exists ())
+ {
+ delete fh;
+ res = -1;
+ set_errno (EEXIST);
+ }
else if (fh->is_fs_special () && fh->device_access_denied (flags))
{
delete fh;