win32mmap: set errno appropriately
It is not really helpful when a `git fetch` fails with the message: fatal: mmap failed: No error In the particular instance encountered by a colleague of yours truly, the Win32 error code was ERROR_COMMITMENT_LIMIT which means that the page file is not big enough. Let's make the message fatal: mmap failed: File too large instead, which is only marginally better, but which can be associated with the appropriate work-around: setting `core.packedGitWindowSize` to a relatively small value. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Apr 22, 2016 at 16:31 UTC
6a730e10a76d1e03a9554292419201534c1521f1
1 file changed
+8
-2
compat/win32mmap.c
+8
-2
@@ -24,15 +24,21 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
24
hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL,
25
PAGE_WRITECOPY, 0, 0, NULL);
26
27
- if (!hmap)
27
+ if (!hmap) {
28
+ errno = EINVAL;
29
return MAP_FAILED;
30
+ }
31
32
temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start);
33
34
if (!CloseHandle(hmap))
35
warning("unable to close file mapping handle");
36
35
- return temp ? temp : MAP_FAILED;
37
+ if (temp)
38
+ return temp;
39
+
40
+ errno = GetLastError() == ERROR_COMMITMENT_LIMIT ? EFBIG : EINVAL;
41
+ return MAP_FAILED;
42
}
43
44
int git_munmap(void *start, size_t length)