Skip to content

Commit

Permalink
mkdir: always check-for-existence
Browse files Browse the repository at this point in the history
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â??.
  • Loading branch information
bwijen authored and dscho committed Jul 3, 2019
1 parent c10b418 commit e0e7936
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion winsup/cygwin/dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e0e7936

Please sign in to comment.