folly: MemoryMapping: respect writable when opening the file
[folly.git] / folly / MemoryMapping.cpp
index 3750ef618405483d98ec0438f23a43449e48e51f..43889257b5aa6c307a4cc9785264f4d1ab95e0f6 100644 (file)
@@ -52,7 +52,10 @@ MemoryMapping::MemoryMapping(File file, off_t offset, off_t length,
 
 MemoryMapping::MemoryMapping(const char* name, off_t offset, off_t length,
                              Options options)
-  : MemoryMapping(File(name), offset, length, options) { }
+    : MemoryMapping(File(name, options.writable ? O_RDWR : O_RDONLY),
+                    offset,
+                    length,
+                    options) { }
 
 MemoryMapping::MemoryMapping(int fd, off_t offset, off_t length,
                              Options options)