From 84af61957693b65b6ef5de775dc7a7ae1bae11ac Mon Sep 17 00:00:00 2001 From: Nathan Sanders Date: Thu, 4 Jul 2019 13:24:53 +0200 Subject: [PATCH] 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`. 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 Signed-off-by: Johannes Schindelin --- compat/mingw.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 402c1ad91c..e4d73aff74 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -447,8 +447,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