Re: [PATCH] mkdir: always check-for-existence

2019-06-04 Thread Corinna Vinschen
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

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH v2] cygcheck: expand common_apps list

2019-06-04 Thread Corinna Vinschen
Hi Yaakov,

On Jun  3 18:19, Yaakov Selkowitz wrote:
> An increasing number of tools are being included in Windows which have the
> same names as those included in Cygwin packages.  Indicating which one is
> first in PATH can be helpful in diagnosing behavioural discrepencies
> between them.
> 
> Also, fix the alphabetization of ssh.

Sure, please push.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] mkdir: always check-for-existence

2019-06-04 Thread Ben

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



>From 190b5bc9497a1332ce53afd831debe1ac3e53ffb Mon Sep 17 00:00:00 2001
From: Ben Wijen 
Date: Mon, 3 Jun 2019 20:15:50 +0200
Subject: [PATCH] mkdir: always check-for-existence
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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’.
---
 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