]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mingw: cope with the Isilon network file system
authorNathan Sanders <spekbukkem@gmail.com>
Fri, 10 Apr 2020 11:28:56 +0000 (11:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2020 17:34:05 +0000 (10:34 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c

index d14065d60ec497131a23549727439d624ff4c710..0c71a223a97da8366dee581849e21e6c9ad8b7a6 100644 (file)
@@ -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