git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] mingw: cope with the Isilon network file system
@ 2020-04-09 10:24 Johannes Schindelin via GitGitGadget
  2020-04-09 10:57 ` Martin Ågren
  2020-04-10 11:28 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-04-09 10:24 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Nathan Sanders

From: Nathan Sanders <spekbukkem@gmail.com>

On certain network filesystems (currently encounterd with Isilon, but in
theory more network storage solutions could be causing the same issue),
when the directory in question is missing, `raceproof_create_file()`
fails with an `ERROR_INVALID_PARAMETER` instead of an
`ERROR_PATH_NOT_FOUND`.

Since it is highly unlikely that we produce such an error by mistake
(the parameters we pass are fairly benign), we can be relatively certain
that the directory is missing in this instance. So let's just translate
that error automagically.

This fixes https://github.com/git-for-windows/git/issues/1345.

Signed-off-by: Nathan Sanders <spekbukkem@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    mingw: cope with the Isilon network file system
    
    Yet another patch that has lived in Git for Windows for a while. In
    contrast to the other patches I submitted today, it is younger than a
    year, but not by much: its author date is Independence Day 2019.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-756%2Fdscho%2Fwork-around-isilon-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-756/dscho/work-around-isilon-v1
Pull-Request: https://github.com/git/git/pull/756

 compat/mingw.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index d14065d60ec..201e99292fd 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -460,8 +460,19 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
 	handle = CreateFileW(wfilename, FILE_APPEND_DATA,
 			FILE_SHARE_WRITE | FILE_SHARE_READ,
 			NULL, create, FILE_ATTRIBUTE_NORMAL, NULL);
-	if (handle == INVALID_HANDLE_VALUE)
-		return errno = err_win_to_posix(GetLastError()), -1;
+	if (handle == INVALID_HANDLE_VALUE) {
+		DWORD err = GetLastError();
+		/*
+		 * Some network storage solutions (e.g. Isilon) might return
+		 * ERROR_INVALID_PARAMETER instead of expected error
+		 * ERROR_PATH_NOT_FOUND, which results in a unknow error. If
+		 * so, the error is now forced to be an ERROR_PATH_NOT_FOUND
+		 * error instead.
+		 */
+		if (err == ERROR_INVALID_PARAMETER)
+			err = ERROR_PATH_NOT_FOUND;
+		return errno = err_win_to_posix(err), -1;
+	}
 
 	/*
 	 * No O_APPEND here, because the CRT uses it only to reset the

base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mingw: cope with the Isilon network file system
  2020-04-09 10:24 [PATCH] mingw: cope with the Isilon network file system Johannes Schindelin via GitGitGadget
@ 2020-04-09 10:57 ` Martin Ågren
  2020-04-09 12:02   ` Johannes Schindelin
  2020-04-10 11:28 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Ågren @ 2020-04-09 10:57 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: Git Mailing List, Johannes Schindelin, Nathan Sanders

On Thu, 9 Apr 2020 at 12:26, Johannes Schindelin via GitGitGadget
<gitgitgadget@gmail.com> wrote:

>         handle = CreateFileW(wfilename, FILE_APPEND_DATA,
>                         FILE_SHARE_WRITE | FILE_SHARE_READ,
>                         NULL, create, FILE_ATTRIBUTE_NORMAL, NULL);
> -       if (handle == INVALID_HANDLE_VALUE)
> -               return errno = err_win_to_posix(GetLastError()), -1;

(This code, which is being removed, used "," to avoid having to introduce
braces. There's another instance of this pattern a bit above.)

> +       if (handle == INVALID_HANDLE_VALUE) {

(Adding a brace here.)

> +               DWORD err = GetLastError();
> +               /*
> +                * Some network storage solutions (e.g. Isilon) might return
> +                * ERROR_INVALID_PARAMETER instead of expected error
> +                * ERROR_PATH_NOT_FOUND, which results in a unknow error. If

s/ a / an /
s/unknow/&n/

> +                * so, the error is now forced to be an ERROR_PATH_NOT_FOUND
> +                * error instead.
> +                */

"is now forced" sounds more like it describes this change/commit, rather
than this piece of code. Maybe this final sentence can be scrapped
entirely, since the forcing/translating/mapping is obvious from the code
anyway? The remainder of the comment goes into *why* and looks more
useful. Just my 2 cents.

> +               if (err == ERROR_INVALID_PARAMETER)
> +                       err = ERROR_PATH_NOT_FOUND;
> +               return errno = err_win_to_posix(err), -1;
> +       }

Now there's no need to avoid introducing braces, so maybe split this
into two lines for a lower huh-factor?

  errno = err_win_to_posix(err);
  return -1;

Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mingw: cope with the Isilon network file system
  2020-04-09 10:57 ` Martin Ågren
@ 2020-04-09 12:02   ` Johannes Schindelin
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2020-04-09 12:02 UTC (permalink / raw)
  To: Martin Ågren
  Cc: Johannes Schindelin via GitGitGadget, Git Mailing List, Nathan Sanders

[-- Attachment #1: Type: text/plain, Size: 2338 bytes --]

Hi Martin,

On Thu, 9 Apr 2020, Martin Ågren wrote:

> On Thu, 9 Apr 2020 at 12:26, Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>
> >         handle = CreateFileW(wfilename, FILE_APPEND_DATA,
> >                         FILE_SHARE_WRITE | FILE_SHARE_READ,
> >                         NULL, create, FILE_ATTRIBUTE_NORMAL, NULL);
> > -       if (handle == INVALID_HANDLE_VALUE)
> > -               return errno = err_win_to_posix(GetLastError()), -1;
>
> (This code, which is being removed, used "," to avoid having to introduce
> braces. There's another instance of this pattern a bit above.)

Oh yes, that's an important point I had missed.

> > +       if (handle == INVALID_HANDLE_VALUE) {
>
> (Adding a brace here.)
>
> > +               DWORD err = GetLastError();
> > +               /*
> > +                * Some network storage solutions (e.g. Isilon) might return
> > +                * ERROR_INVALID_PARAMETER instead of expected error
> > +                * ERROR_PATH_NOT_FOUND, which results in a unknow error. If
>
> s/ a / an /
> s/unknow/&n/

Oh shucks. Usually I try to do a final review of the patches before I
"upstream" them. Seems like the quality of my submission here is not what
I want it to be.

>
> > +                * so, the error is now forced to be an ERROR_PATH_NOT_FOUND
> > +                * error instead.
> > +                */
>
> "is now forced" sounds more like it describes this change/commit, rather
> than this piece of code. Maybe this final sentence can be scrapped
> entirely, since the forcing/translating/mapping is obvious from the code
> anyway? The remainder of the comment goes into *why* and looks more
> useful. Just my 2 cents.
>
> > +               if (err == ERROR_INVALID_PARAMETER)
> > +                       err = ERROR_PATH_NOT_FOUND;
> > +               return errno = err_win_to_posix(err), -1;
> > +       }
>
> Now there's no need to avoid introducing braces, so maybe split this
> into two lines for a lower huh-factor?
>
>   errno = err_win_to_posix(err);
>   return -1;

Absolutely.

I updated the PR at https://github.com/git/git/pull/756 (also addressing
issues with the commit message) and will wait for while before sending v2.

Thank you for your excellent review,
Dscho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] mingw: cope with the Isilon network file system
  2020-04-09 10:24 [PATCH] mingw: cope with the Isilon network file system Johannes Schindelin via GitGitGadget
  2020-04-09 10:57 ` Martin Ågren
@ 2020-04-10 11:28 ` Johannes Schindelin via GitGitGadget
  2020-04-10 20:21   ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-04-10 11:28 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Nathan Sanders

From: Nathan Sanders <spekbukkem@gmail.com>

On certain network filesystems (currently encountered with Isilon, but
in theory more network storage solutions could be causing the same
issue), when the directory in question is missing,
`raceproof_create_file()` fails with an `ERROR_INVALID_PARAMETER`
instead of an `ERROR_PATH_NOT_FOUND`.

Since it is highly unlikely that we produce such an error by mistake
(the parameters we pass are fairly benign), we can be relatively certain
that the directory is missing in this instance. So let's just translate
that error automagically.

This fixes https://github.com/git-for-windows/git/issues/1345.

Signed-off-by: Nathan Sanders <spekbukkem@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    mingw: cope with the Isilon network file system
    
    Yet another patch that has lived in Git for Windows for a while.
    
    Changes since v1:
    
     * fixed a typo in the commit message ("encounterd")
     * re-wrapped the first paragraph of the commit message to fit inside 72
       columns/line
     * fixed a typo in the code comment ("a unknow")
     * reworded the code comment to read less like a commit message
     * avoided the comma operator
     * added some white-space to structure the code better

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-756%2Fdscho%2Fwork-around-isilon-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-756/dscho/work-around-isilon-v2
Pull-Request: https://github.com/git/git/pull/756

Range-diff vs v1:

 1:  e49df0e07fb ! 1:  c9b1d5c46cc mingw: cope with the Isilon network file system
     @@ Metadata
       ## Commit message ##
          mingw: cope with the Isilon network file system
      
     -    On certain network filesystems (currently encounterd with Isilon, but in
     -    theory more network storage solutions could be causing the same issue),
     -    when the directory in question is missing, `raceproof_create_file()`
     -    fails with an `ERROR_INVALID_PARAMETER` instead of an
     -    `ERROR_PATH_NOT_FOUND`.
     +    On certain network filesystems (currently encountered with Isilon, but
     +    in theory more network storage solutions could be causing the same
     +    issue), when the directory in question is missing,
     +    `raceproof_create_file()` fails with an `ERROR_INVALID_PARAMETER`
     +    instead of an `ERROR_PATH_NOT_FOUND`.
      
          Since it is highly unlikely that we produce such an error by mistake
          (the parameters we pass are fairly benign), we can be relatively certain
     @@ compat/mingw.c: static int mingw_open_append(wchar_t const *wfilename, int oflag
      -		return errno = err_win_to_posix(GetLastError()), -1;
      +	if (handle == INVALID_HANDLE_VALUE) {
      +		DWORD err = GetLastError();
     ++
      +		/*
      +		 * Some network storage solutions (e.g. Isilon) might return
      +		 * ERROR_INVALID_PARAMETER instead of expected error
     -+		 * ERROR_PATH_NOT_FOUND, which results in a unknow error. If
     -+		 * so, the error is now forced to be an ERROR_PATH_NOT_FOUND
     -+		 * error instead.
     ++		 * ERROR_PATH_NOT_FOUND, which results in an unknown error. If
     ++		 * so, let's turn the error to ERROR_PATH_NOT_FOUND instead.
      +		 */
      +		if (err == ERROR_INVALID_PARAMETER)
      +			err = ERROR_PATH_NOT_FOUND;
     -+		return errno = err_win_to_posix(err), -1;
     ++
     ++		errno = err_win_to_posix(err);
     ++		return -1;
      +	}
       
       	/*


 compat/mingw.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index d14065d60ec..0c71a223a97 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -460,8 +460,21 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
 	handle = CreateFileW(wfilename, FILE_APPEND_DATA,
 			FILE_SHARE_WRITE | FILE_SHARE_READ,
 			NULL, create, FILE_ATTRIBUTE_NORMAL, NULL);
-	if (handle == INVALID_HANDLE_VALUE)
-		return errno = err_win_to_posix(GetLastError()), -1;
+	if (handle == INVALID_HANDLE_VALUE) {
+		DWORD err = GetLastError();
+
+		/*
+		 * Some network storage solutions (e.g. Isilon) might return
+		 * ERROR_INVALID_PARAMETER instead of expected error
+		 * ERROR_PATH_NOT_FOUND, which results in an unknown error. If
+		 * so, let's turn the error to ERROR_PATH_NOT_FOUND instead.
+		 */
+		if (err == ERROR_INVALID_PARAMETER)
+			err = ERROR_PATH_NOT_FOUND;
+
+		errno = err_win_to_posix(err);
+		return -1;
+	}
 
 	/*
 	 * No O_APPEND here, because the CRT uses it only to reset the

base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] mingw: cope with the Isilon network file system
  2020-04-10 11:28 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
@ 2020-04-10 20:21   ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2020-04-10 20:21 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Johannes Schindelin, Nathan Sanders

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Nathan Sanders <spekbukkem@gmail.com>
>
> On certain network filesystems (currently encountered with Isilon, but
> in theory more network storage solutions could be causing the same
> issue), when the directory in question is missing,
> `raceproof_create_file()` fails with an `ERROR_INVALID_PARAMETER`
> instead of an `ERROR_PATH_NOT_FOUND`.

Queued.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-10 20:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 10:24 [PATCH] mingw: cope with the Isilon network file system Johannes Schindelin via GitGitGadget
2020-04-09 10:57 ` Martin Ågren
2020-04-09 12:02   ` Johannes Schindelin
2020-04-10 11:28 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
2020-04-10 20:21   ` Junio C Hamano

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

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