Backport to stable-2.0: don't fsync read-only files. stable-2.0
authorRyan C. Gordon <icculus@icculus.org>
Thu, 22 Aug 2013 00:06:23 -0400
branchstable-2.0
changeset 1336 d13223a9521f
parent 1314 305e3c4985d1
child 1346 5911d50a278f
Backport to stable-2.0: don't fsync read-only files.
CREDITS.txt
platform/posix.c
--- a/CREDITS.txt	Fri Nov 02 00:50:30 2012 -0400
+++ b/CREDITS.txt	Thu Aug 22 00:06:23 2013 -0400
@@ -109,6 +109,9 @@
 Bug fixes:
     Lauri Kasanen
 
+Bug fixes:
+    Andreas Karlsson
+
 Other stuff:
     Your name here! Patches go to icculus@icculus.org ...
 
--- a/platform/posix.c	Fri Nov 02 00:50:30 2012 -0400
+++ b/platform/posix.c	Thu Aug 22 00:06:23 2013 -0400
@@ -390,7 +390,8 @@
 int __PHYSFS_platformFlush(void *opaque)
 {
     int fd = *((int *) opaque);
-    BAIL_IF_MACRO(fsync(fd) == -1, strerror(errno), 0);
+    if ((fcntl(fd, F_GETFL) & O_ACCMODE) != O_RDONLY)
+        BAIL_IF_MACRO(fsync(fd) == -1, strerror(errno), 0);
     return(1);
 } /* __PHYSFS_platformFlush */