Skip to content

Resolving ERROR_INVALID_PARAMETER issue with some network storage sol… #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,19 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
handle = CreateFileW(wfilename, FILE_APPEND_DATA,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message needs a little bit of work... Just imagine that you yourself stumble over this commit in six months from now, not remembering what you did, but wanting to figure it out.

To that end, the Git project tries to enforce very informative commit messages, in a somewhat idiomatic form.

In particular, the commit message should focus a bit more on the "Why?" and to a lesser extent the "What?" than the "How?".

In this case, I would strongly suggest something along those lines:

mingw: cope with the Isilon network file system

On certain network filesystems (*cough* Isilon), 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: ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will reuse most of your example, if you are fine by that. I do not what to re-invent the wheel as we say in Dutch :). I personally only work on small scale projects, but I fully understand the more verbose commit.

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
Expand Down