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

Re: what's the current wisdom on git over NFS/CIFS?

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Jul 3, 2009, 08:56 UTC
Message-ID
<20090703085608.GA18757@dpotapov.dyndns.org>
In-Reply-To
<4A4DA1D6.40301@viscovery.net>
On Fri, Jul 03, 2009 at 08:14:46AM +0200, Johannes Sixt wrote:
> (We don't yet have an implementation of fsync() :-( )

Why? It appears rather straightforward to me. Here is a patch that implements it. Or did I miss something?

Warning: I do not use MinGW/Git, so I have not tested this patch.
-- >8 --
From 0a5e712ff8775e0f27923bedcb3c234288592eaa Mon Sep 17 00:00:00 2001
From: Dmitry Potapov <dpotapov@gmail.com>
Date: Fri, 3 Jul 2009 12:45:30 +0400
Subject: [PATCH] mingw: fsync implementation for Windows
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
 compat/mingw.c |   16 ++++++++++++++++
 compat/mingw.h |    3 +--
 2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index bed4178..65c9e8e 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1231,3 +1231,19 @@ struct dirent *mingw_readdir(DIR *dir)
 	return (struct dirent*)&dir->dd_dir;
 }
 #endif // !NO_MINGW_REPLACE_READDIR
+
+int fsync(int fd)
+{
+	HANDLE h = (HANDLE) _get_osfhandle(fd);
+	if (h == INVALID_HANDLE_VALUE)
+	{
+		errno = EBADF;
+		return -1;
+	}
+	if (!FlushFileBuffers(h))
+	{
+		errno = err_win_to_posix(GetLastError());
+		return -1;
+	}
+	return 0;
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index 4f7ba4c..14d53c0 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -75,8 +75,7 @@ static inline int fork(void)
 { errno = ENOSYS; return -1; }
 static inline unsigned int alarm(unsigned int seconds)
 { return 0; }
-static inline int fsync(int fd)
-{ return 0; }
+int fsync(int fd);
 static inline int getppid(void)
 { return 1; }
 static inline void sync(void)
-- 
1.6.2.3

-- >8 --
Previous: Sitaram ChamartyNext: Johannes Sixt
Message 8 of 10 in “what's the current wisdom on git over NFS/CIFS?”
  1. Sitaram ChamartyJul 2, 2009
  2. Martin LanghoffJul 2, 2009
  3. Martin LanghoffJul 2, 2009
  4. Linus TorvaldsJul 2, 2009
  5. Sitaram ChamartyJul 3, 2009
  6. Johannes SixtJul 3, 2009
  7. Sitaram ChamartyJul 3, 2009
  8. Dmitry PotapovJul 3, 2009
  9. Johannes SixtJul 3, 2009
  10. Linus TorvaldsJul 3, 2009

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.