git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Potapov <dpotapov@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Sitaram Chamarty <sitaramc@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: what's the current wisdom on git over NFS/CIFS?
Date: Fri, 3 Jul 2009 12:56:08 +0400	[thread overview]
Message-ID: <20090703085608.GA18757@dpotapov.dyndns.org> (raw)
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 --

  parent reply	other threads:[~2009-07-03  8:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-02 13:11 what's the current wisdom on git over NFS/CIFS? Sitaram Chamarty
2009-07-02 13:58 ` Martin Langhoff
2009-07-02 14:00   ` Martin Langhoff
2009-07-02 20:58 ` Linus Torvalds
2009-07-03  0:52   ` Sitaram Chamarty
2009-07-03  6:14     ` Johannes Sixt
2009-07-03  6:37       ` Sitaram Chamarty
2009-07-03  8:56       ` Dmitry Potapov [this message]
2009-07-03  9:18         ` Johannes Sixt
2009-07-03 16:08           ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090703085608.GA18757@dpotapov.dyndns.org \
    --to=dpotapov@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=sitaramc@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).