From 99c506325fa92be811d07a79969d5cae67750b10 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 21 Jun 2001 19:50:21 +0000 Subject: [PATCH] When mmap fails it returns -1 *NOT NULL*. This got regressed somehow..... Jeremy. (This used to be commit b77c8b536d4b6d2162f4932227f01cffb730c645) --- source3/tdb/tdb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 4d4fb79383e..c27f03fc35d 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -87,7 +87,13 @@ static void tdb_mmap(TDB_CONTEXT *tdb) tdb->map_ptr = mmap(NULL, tdb->map_size, PROT_READ|(tdb->read_only? 0:PROT_WRITE), MAP_SHARED|MAP_FILE, tdb->fd, 0); - if (!tdb->map_ptr) { + + /* + * NB. When mmap fails it returns -1 *NOT* NULL !!!! + */ + + if (tdb->map_ptr == (void *)-1) { + tdb->map_ptr = NULL; TDB_LOG((tdb, 2, "tdb_mmap failed for size %d (%s)\n", tdb->map_size, strerror(errno))); }