Commit 43c71e1a authored by Julius Plenz's avatar Julius Plenz

sync_if_writable() now correctly checks O_ACCMODE

parent e15e0a9f
...@@ -12,8 +12,8 @@ int fadv_dontneed(int fd, off_t offset, off_t len) ...@@ -12,8 +12,8 @@ int fadv_dontneed(int fd, off_t offset, off_t len)
void sync_if_writable(int fd) void sync_if_writable(int fd)
{ {
int r; int r;
if((r = fcntl(fd, F_GETFL, 0)) == -1) if((r = fcntl(fd, F_GETFL)) == -1)
return; return;
if(!(r & O_RDONLY)) if((r & O_ACCMODE) != O_RDONLY)
fdatasync(fd); fdatasync(fd);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment