[PATCH] mkdir: always check-for-existence
Ben
cygwin@wijen.net
Tue Jun 4 17:45:00 GMT 2019
Hi Corinna,
Please see the attachment for my patch.
My MUA indeed replaced the tabs with spaces.
I did notice that the indentation was mixed tabs and spaces,
but as stated on the website I have kept the surrounding indentation.
Ben...
On 04-06-2019 09:41, Corinna Vinschen wrote:
> Hi Ben,
>
> On Jun 3 22:07, Ben wrote:
>> When creating a directory which already exists, NtCreateFile will correctly
>> return 'STATUS_OBJECT_NAME_COLLISION'.
>>
>> However when creating 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â.
>>
>> So we better check for existence prior to calling NtCreateFile.
>> ---
>> Â 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 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;
>>
>> --
>> 2.21.0
> I was just trying to apply your patch but it fails to apply cleanly.
> Can you please check your indentation? The `else' lines are indented
> more than the lines in between and TABs are missing.
>
> Maybe your MUA breaks the output? If all else fails, you could attach
> your patch as plain/text attachement to your mail, usually that's left
> alone by the MUA.
>
>
> Thanks,
> Corinna
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mkdir-always-check-for-existence.patch
Type: text/x-patch
Size: 1291 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20190604/6b753a29/attachment.bin>
More information about the Cygwin-patches
mailing list