From 87f4ed678691f65ec4d2da6faa76845cb691b4e5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 22 Aug 2013 00:06:23 -0400 Subject: [PATCH] Backport to stable-2.0: don't fsync read-only files. --- CREDITS.txt | 3 +++ platform/posix.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CREDITS.txt b/CREDITS.txt index 558e3590..91ab0936 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -109,6 +109,9 @@ Bug fixes: Bug fixes: Lauri Kasanen +Bug fixes: + Andreas Karlsson + Other stuff: Your name here! Patches go to icculus@icculus.org ... diff --git a/platform/posix.c b/platform/posix.c index 652d9f77..85568ea2 100644 --- a/platform/posix.c +++ b/platform/posix.c @@ -390,7 +390,8 @@ int __PHYSFS_platformEOF(void *opaque) 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 */