changeset 16349:f34ee844ca92

fsync: Avoid test failure on native Windows. * lib/fsync.c (fsync) [Windows]: Don't fail if the handle is merely read-only.
author Bruno Haible <bruno@clisp.org>
date Sat, 04 Feb 2012 14:59:43 +0100
parents b854ad995083
children 84b5f6cfae4b
files ChangeLog lib/fsync.c
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-04  Bruno Haible  <bruno@clisp.org>
+
+	fsync: Avoid test failure on native Windows.
+	* lib/fsync.c (fsync) [Windows]: Don't fail if the handle is merely
+	read-only.
+
 2012-02-04  Bruno Haible  <bruno@clisp.org>
 
 	sys_select: Avoid syntax error on OpenBSD 5.0.
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -57,6 +57,11 @@
       err = GetLastError ();
       switch (err)
         {
+        case ERROR_ACCESS_DENIED:
+          /* For a read-only handle, fsync should succeed, even though we have
+             no way to sync the access-time changes.  */
+          return 0;
+
           /* eg. Trying to fsync a tty. */
         case ERROR_INVALID_HANDLE:
           errno = EINVAL;