From cf5a038adf0bd609e00039b44e197ea589eeb9cb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Dec 2001 11:13:57 +0000 Subject: obey "use mmap" on case tables (This used to be commit 505a1bdd15313698a6024a847f3771ea30a51f89) --- source3/lib/util_file.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 5ecf526280..0cd60fed26 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -430,17 +430,19 @@ void *map_file(char *fname, size_t size) size_t s2 = 0; void *p = NULL; #ifdef HAVE_MMAP - int fd; - fd = open(fname, O_RDONLY, 0); - if (fd == -1) { - DEBUG(1,("Failed to load %s - %s\n", fname, strerror(errno))); - return NULL; - } - p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0); - close(fd); - if (p == MAP_FAILED) { - DEBUG(1,("Failed to mmap %s - %s\n", fname, strerror(errno))); - return NULL; + if (lp_use_mmap()) { + int fd; + fd = open(fname, O_RDONLY, 0); + if (fd == -1) { + DEBUG(1,("Failed to load %s - %s\n", fname, strerror(errno))); + return NULL; + } + p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0); + close(fd); + if (p == MAP_FAILED) { + DEBUG(1,("Failed to mmap %s - %s\n", fname, strerror(errno))); + return NULL; + } } #endif if (!p) { -- cgit