git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix checkout of large files to network shares under Windows XP

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Apr 19, 2010, 12:45 UTC
Message-ID
<4BCC5083.30801@gmail.com>

This fixes msysGit issue 409, see http://code.google.com/p/msysgit/issues/detail?id=409

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 compat/mingw.c |   24 ++++++++++++++++++++++++
 compat/mingw.h |    3 +++
 2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 7ec615c..672d074 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -293,6 +293,30 @@ int mingw_open (const char *filename, int oflags, ...)
 	return fd;
 }
 
+#undef write
+ssize_t mingw_write(int fd, const void *buf, size_t count)
+{
+	ssize_t written = 0;
+	size_t total = 0, size = count;
+
+	while (total < count && size > 0) {
+		written = write(fd, buf, size);
+		if (written < 0 && errno == EINVAL) {
+			// There seems to be a bug in the Windows XP network stack that
+			// causes writes with sizes > 64 MB to fail, so we halve the size
+			// until we succeed or ultimately fail.
+			size /= 2;
+		} else {
+			buf += written;
+			total += written;
+			if (total + size > count)
+				size = count - total;
+		}
+	}
+
+	return written < 0 ? written : total;
+}
+
 #undef fopen
 FILE *mingw_fopen (const char *filename, const char *otype)
 {
diff --git a/compat/mingw.h b/compat/mingw.h
index 756f3ab..751bb4c 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -178,6 +178,9 @@ int mingw_rmdir(const char *path);
 int mingw_open (const char *filename, int oflags, ...);
 #define open mingw_open
 
+ssize_t mingw_write(int fd, const void *buf, size_t count);
+#define write mingw_write
+
 FILE *mingw_fopen (const char *filename, const char *otype);
 #define fopen mingw_fopen
 
-- 
1.7.0.2.msysgit.0.898.gbf4f.dirty
Next: Junio C Hamano
Message 1 of 15 in “Fix checkout of large files to network shares under Windows XP”
  1. Fix checkout of large files to network shares under Windows XPSebastian Schuberth, Apr 19, 2010
  2. Junio C HamanoApr 19, 2010
  3. Johannes SchindelinApr 20, 2010
  4. René ScharfeApr 19, 2010
  5. Albert DvornikApr 19, 2010
  6. Johannes SixtApr 20, 2010
  7. Sebastian SchuberthApr 20, 2010
  8. Johannes SixtApr 20, 2010
  9. Sebastian SchuberthApr 20, 2010
  10. René ScharfeApr 20, 2010
  11. René ScharfeApr 29, 2010
  12. Johannes SixtApr 30, 2010
  13. Sebastian SchuberthApr 30, 2010
  14. René ScharfeOct 16, 2010
  15. Dmitry PotapovOct 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.