Commit d880214d d880214df6b0261cf5d1e5d6b980d979f6479a55 by Alain Magloire

Only call msync() when the file is open with PROT_WRITE

1 parent e2222e60
...@@ -187,7 +187,7 @@ _mapfile_size (stream_t stream, off_t *psize) ...@@ -187,7 +187,7 @@ _mapfile_size (stream_t stream, off_t *psize)
187 187
188 if (mfs->ptr == MAP_FAILED) 188 if (mfs->ptr == MAP_FAILED)
189 return EINVAL; 189 return EINVAL;
190 if (mfs->ptr) 190 if (mfs->ptr && (mfs->flags & PROT_WRITE))
191 msync (mfs->ptr, mfs->size, MS_SYNC); 191 msync (mfs->ptr, mfs->size, MS_SYNC);
192 if (fstat(mfs->fd, &stbuf) != 0) 192 if (fstat(mfs->fd, &stbuf) != 0)
193 return errno; 193 return errno;
...@@ -229,7 +229,7 @@ static int ...@@ -229,7 +229,7 @@ static int
229 _mapfile_flush (stream_t stream) 229 _mapfile_flush (stream_t stream)
230 { 230 {
231 struct _mapfile_stream *mfs = stream_get_owner (stream); 231 struct _mapfile_stream *mfs = stream_get_owner (stream);
232 if (mfs->ptr != MAP_FAILED && mfs->ptr != NULL) 232 if (mfs->ptr != MAP_FAILED && mfs->ptr != NULL && (mfs->flags & PROT_WRITE))
233 return msync (mfs->ptr, mfs->size, MS_SYNC); 233 return msync (mfs->ptr, mfs->size, MS_SYNC);
234 return 0; 234 return 0;
235 } 235 }
......