diff mbox series

[v2] mingw: cope with the Isilon network file system

Message ID pull.756.v2.git.git.1586518136956.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] mingw: cope with the Isilon network file system | expand

Commit Message

John Passaro via GitGitGadget April 10, 2020, 11:28 a.m. UTC
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(-)


base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775

Comments

Junio C Hamano April 10, 2020, 8:21 p.m. UTC | #1
"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.
diff mbox series

Patch

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