]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/io.c
gitify the tree, especially the web makefile.
[ccan] / ccan / tdb2 / io.c
index 9f0582e0df338998302422aeba94396ea72b9a15..8f14d5b12e37563d101084e222c08d15b3fc0a4f 100644 (file)
@@ -48,8 +48,7 @@ void tdb_mmap(struct tdb_context *tdb)
        if (tdb->flags & TDB_NOMMAP)
                return;
 
-       tdb->map_ptr = mmap(NULL, tdb->map_size, 
-                           PROT_READ|(tdb->read_only? 0:PROT_WRITE), 
+       tdb->map_ptr = mmap(NULL, tdb->map_size, tdb->mmap_flags,
                            MAP_SHARED, tdb->fd, 0);
 
        /*
@@ -74,7 +73,9 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe)
        int ret;
 
        /* We can't hold pointers during this: we could unmap! */
-       assert(!tdb->direct_access || tdb_has_expansion_lock(tdb));
+       assert(!tdb->direct_access
+              || (tdb->flags & TDB_NOLOCK)
+              || tdb_has_expansion_lock(tdb));
 
        if (len <= tdb->map_size)
                return 0;
@@ -310,7 +311,8 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
                        tdb->ecode = TDB_ERR_IO;
                        tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv,
                                 "tdb_write failed at %llu len=%llu (%s)\n",
-                                off, len, strerror(errno));
+                                (long long)off, (long long)len,
+                                strerror(errno));
                        return -1;
                }
        }