diff options
Diffstat (limited to 'lib/tdb2/io.c')
-rw-r--r-- | lib/tdb2/io.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/tdb2/io.c b/lib/tdb2/io.c index 4166cd4c67..d422d96326 100644 --- a/lib/tdb2/io.c +++ b/lib/tdb2/io.c @@ -42,16 +42,23 @@ void tdb_munmap(struct tdb_file *file) void tdb_mmap(struct tdb_context *tdb) { + int mmap_flags; + if (tdb->flags & TDB_INTERNAL) return; if (tdb->flags & TDB_NOMMAP) return; + if ((tdb->open_flags & O_ACCMODE) == O_RDONLY) + mmap_flags = PROT_READ; + else + mmap_flags = PROT_READ | PROT_WRITE; + /* size_t can be smaller than off_t. */ if ((size_t)tdb->file->map_size == tdb->file->map_size) { tdb->file->map_ptr = mmap(NULL, tdb->file->map_size, - tdb->mmap_flags, + mmap_flags, MAP_SHARED, tdb->file->fd, 0); } else tdb->file->map_ptr = MAP_FAILED; |