]> git.ozlabs.org Git - ccan/commitdiff
tdb2: move open routines into a separate file (open.c)
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:21 +0000 (22:12 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:21 +0000 (22:12 +1030)
Simply tidying up.

32 files changed:
ccan/tdb2/open.c [new file with mode: 0644]
ccan/tdb2/tdb.c
ccan/tdb2/test/failtest_helper.h
ccan/tdb2/test/run-001-encode.c
ccan/tdb2/test/run-001-fls.c
ccan/tdb2/test/run-01-new_database.c
ccan/tdb2/test/run-02-expand.c
ccan/tdb2/test/run-03-coalesce.c
ccan/tdb2/test/run-04-basichash.c
ccan/tdb2/test/run-10-simple-store.c
ccan/tdb2/test/run-11-simple-fetch.c
ccan/tdb2/test/run-12-store.c
ccan/tdb2/test/run-13-delete.c
ccan/tdb2/test/run-15-append.c
ccan/tdb2/test/run-20-growhash.c
ccan/tdb2/test/run-25-hashoverload.c
ccan/tdb2/test/run-30-exhaust-before-expand.c
ccan/tdb2/test/run-50-multiple-freelists.c
ccan/tdb2/test/run-55-transaction.c
ccan/tdb2/test/run-56-open-during-transaction.c
ccan/tdb2/test/run-57-die-during-transaction.c
ccan/tdb2/test/run-add-remove-flags.c
ccan/tdb2/test/run-features.c
ccan/tdb2/test/run-firstkey-nextkey.c
ccan/tdb2/test/run-missing-entries.c
ccan/tdb2/test/run-record-expand.c
ccan/tdb2/test/run-remap-in-read_traverse.c
ccan/tdb2/test/run-seed.c
ccan/tdb2/test/run-simple-delete.c
ccan/tdb2/test/run-summary.c
ccan/tdb2/test/run-tdb_errorstr.c
ccan/tdb2/test/run-traverse.c

diff --git a/ccan/tdb2/open.c b/ccan/tdb2/open.c
new file mode 100644 (file)
index 0000000..21881c3
--- /dev/null
@@ -0,0 +1,479 @@
+#include "private.h"
+
+/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */
+static struct tdb_context *tdbs = NULL;
+
+static bool tdb_already_open(dev_t device, ino_t ino)
+{
+       struct tdb_context *i;
+
+       for (i = tdbs; i; i = i->next) {
+               if (i->device == device && i->inode == ino) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+static bool read_all(int fd, void *buf, size_t len)
+{
+       while (len) {
+               ssize_t ret;
+               ret = read(fd, buf, len);
+               if (ret < 0)
+                       return false;
+               if (ret == 0) {
+                       /* ETOOSHORT? */
+                       errno = EWOULDBLOCK;
+                       return false;
+               }
+               buf = (char *)buf + ret;
+               len -= ret;
+       }
+       return true;
+}
+
+static uint64_t random_number(struct tdb_context *tdb)
+{
+       int fd;
+       uint64_t ret = 0;
+       struct timeval now;
+
+       fd = open("/dev/urandom", O_RDONLY);
+       if (fd >= 0) {
+               if (read_all(fd, &ret, sizeof(ret))) {
+                       close(fd);
+                       return ret;
+               }
+               close(fd);
+       }
+       /* FIXME: Untested!  Based on Wikipedia protocol description! */
+       fd = open("/dev/egd-pool", O_RDWR);
+       if (fd >= 0) {
+               /* Command is 1, next byte is size we want to read. */
+               char cmd[2] = { 1, sizeof(uint64_t) };
+               if (write(fd, cmd, sizeof(cmd)) == sizeof(cmd)) {
+                       char reply[1 + sizeof(uint64_t)];
+                       int r = read(fd, reply, sizeof(reply));
+                       if (r > 1) {
+                               /* Copy at least some bytes. */
+                               memcpy(&ret, reply+1, r - 1);
+                               if (reply[0] == sizeof(uint64_t)
+                                   && r == sizeof(reply)) {
+                                       close(fd);
+                                       return ret;
+                               }
+                       }
+               }
+               close(fd);
+       }
+
+       /* Fallback: pid and time. */
+       gettimeofday(&now, NULL);
+       ret = getpid() * 100132289ULL + now.tv_sec * 1000000ULL + now.tv_usec;
+       tdb_logerr(tdb, TDB_SUCCESS, TDB_LOG_WARNING,
+                  "tdb_open: random from getpid and time");
+       return ret;
+}
+
+struct new_database {
+       struct tdb_header hdr;
+       struct tdb_freetable ftable;
+};
+
+/* initialise a new database */
+static enum TDB_ERROR tdb_new_database(struct tdb_context *tdb,
+                                      struct tdb_attribute_seed *seed,
+                                      struct tdb_header *hdr)
+{
+       /* We make it up in memory, then write it out if not internal */
+       struct new_database newdb;
+       unsigned int magic_len;
+       ssize_t rlen;
+       enum TDB_ERROR ecode;
+
+       /* Fill in the header */
+       newdb.hdr.version = TDB_VERSION;
+       if (seed)
+               newdb.hdr.hash_seed = seed->seed;
+       else
+               newdb.hdr.hash_seed = random_number(tdb);
+       newdb.hdr.hash_test = TDB_HASH_MAGIC;
+       newdb.hdr.hash_test = tdb->khash(&newdb.hdr.hash_test,
+                                        sizeof(newdb.hdr.hash_test),
+                                        newdb.hdr.hash_seed,
+                                        tdb->hash_priv);
+       newdb.hdr.recovery = 0;
+       newdb.hdr.features_used = newdb.hdr.features_offered = TDB_FEATURE_MASK;
+       memset(newdb.hdr.reserved, 0, sizeof(newdb.hdr.reserved));
+       /* Initial hashes are empty. */
+       memset(newdb.hdr.hashtable, 0, sizeof(newdb.hdr.hashtable));
+
+       /* Free is empty. */
+       newdb.hdr.free_table = offsetof(struct new_database, ftable);
+       memset(&newdb.ftable, 0, sizeof(newdb.ftable));
+       ecode = set_header(NULL, &newdb.ftable.hdr, TDB_FTABLE_MAGIC, 0,
+                          sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr),
+                          sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr),
+                          0);
+       if (ecode != TDB_SUCCESS) {
+               return ecode;
+       }
+
+       /* Magic food */
+       memset(newdb.hdr.magic_food, 0, sizeof(newdb.hdr.magic_food));
+       strcpy(newdb.hdr.magic_food, TDB_MAGIC_FOOD);
+
+       /* This creates an endian-converted database, as if read from disk */
+       magic_len = sizeof(newdb.hdr.magic_food);
+       tdb_convert(tdb,
+                   (char *)&newdb.hdr + magic_len, sizeof(newdb) - magic_len);
+
+       *hdr = newdb.hdr;
+
+       if (tdb->flags & TDB_INTERNAL) {
+               tdb->map_size = sizeof(newdb);
+               tdb->map_ptr = malloc(tdb->map_size);
+               if (!tdb->map_ptr) {
+                       return tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
+                                         "tdb_new_database:"
+                                         " failed to allocate");
+               }
+               memcpy(tdb->map_ptr, &newdb, tdb->map_size);
+               return TDB_SUCCESS;
+       }
+       if (lseek(tdb->fd, 0, SEEK_SET) == -1) {
+               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                 "tdb_new_database:"
+                                 " failed to seek: %s", strerror(errno));
+       }
+
+       if (ftruncate(tdb->fd, 0) == -1) {
+               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                 "tdb_new_database:"
+                                 " failed to truncate: %s", strerror(errno));
+       }
+
+       rlen = write(tdb->fd, &newdb, sizeof(newdb));
+       if (rlen != sizeof(newdb)) {
+               if (rlen >= 0)
+                       errno = ENOSPC;
+               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                 "tdb_new_database: %zi writing header: %s",
+                                 rlen, strerror(errno));
+       }
+       return TDB_SUCCESS;
+}
+
+struct tdb_context *tdb_open(const char *name, int tdb_flags,
+                            int open_flags, mode_t mode,
+                            union tdb_attribute *attr)
+{
+       struct tdb_context *tdb;
+       struct stat st;
+       int saved_errno = 0;
+       uint64_t hash_test;
+       unsigned v;
+       ssize_t rlen;
+       struct tdb_header hdr;
+       struct tdb_attribute_seed *seed = NULL;
+       tdb_bool_err berr;
+       enum TDB_ERROR ecode;
+
+       tdb = malloc(sizeof(*tdb));
+       if (!tdb) {
+               /* Can't log this */
+               errno = ENOMEM;
+               return NULL;
+       }
+       tdb->name = NULL;
+       tdb->map_ptr = NULL;
+       tdb->direct_access = 0;
+       tdb->fd = -1;
+       tdb->map_size = sizeof(struct tdb_header);
+       tdb->flags = tdb_flags;
+       tdb->logfn = NULL;
+       tdb->transaction = NULL;
+       tdb->stats = NULL;
+       tdb->access = NULL;
+       tdb_hash_init(tdb);
+       tdb_io_init(tdb);
+       tdb_lock_init(tdb);
+
+       while (attr) {
+               switch (attr->base.attr) {
+               case TDB_ATTRIBUTE_LOG:
+                       tdb->logfn = attr->log.log_fn;
+                       tdb->log_private = attr->log.log_private;
+                       break;
+               case TDB_ATTRIBUTE_HASH:
+                       tdb->khash = attr->hash.hash_fn;
+                       tdb->hash_priv = attr->hash.hash_private;
+                       break;
+               case TDB_ATTRIBUTE_SEED:
+                       seed = &attr->seed;
+                       break;
+               case TDB_ATTRIBUTE_STATS:
+                       tdb->stats = &attr->stats;
+                       /* They have stats we don't know about?  Tell them. */
+                       if (tdb->stats->size > sizeof(attr->stats))
+                               tdb->stats->size = sizeof(attr->stats);
+                       break;
+               default:
+                       ecode = tdb_logerr(tdb, TDB_ERR_EINVAL,
+                                          TDB_LOG_USE_ERROR,
+                                          "tdb_open:"
+                                          " unknown attribute type %u",
+                                          attr->base.attr);
+                       goto fail;
+               }
+               attr = attr->base.next;
+       }
+
+       if (tdb_flags & ~(TDB_INTERNAL | TDB_NOLOCK | TDB_NOMMAP | TDB_CONVERT
+                         | TDB_NOSYNC)) {
+               ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
+                                  "tdb_open: unknown flags %u", tdb_flags);
+               goto fail;
+       }
+
+       if ((open_flags & O_ACCMODE) == O_WRONLY) {
+               ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
+                                  "tdb_open: can't open tdb %s write-only",
+                                  name);
+               goto fail;
+       }
+
+       if ((open_flags & O_ACCMODE) == O_RDONLY) {
+               tdb->read_only = true;
+               tdb->mmap_flags = PROT_READ;
+       } else {
+               tdb->read_only = false;
+               tdb->mmap_flags = PROT_READ | PROT_WRITE;
+       }
+
+       /* internal databases don't need any of the rest. */
+       if (tdb->flags & TDB_INTERNAL) {
+               tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
+               ecode = tdb_new_database(tdb, seed, &hdr);
+               if (ecode != TDB_SUCCESS) {
+                       goto fail;
+               }
+               tdb_convert(tdb, &hdr.hash_seed, sizeof(hdr.hash_seed));
+               tdb->hash_seed = hdr.hash_seed;
+               tdb_ftable_init(tdb);
+               return tdb;
+       }
+
+       if ((tdb->fd = open(name, open_flags, mode)) == -1) {
+               /* errno set by open(2) */
+               saved_errno = errno;
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open: could not open file %s: %s",
+                                  name, strerror(errno));
+               goto fail;
+       }
+
+       /* on exec, don't inherit the fd */
+       v = fcntl(tdb->fd, F_GETFD, 0);
+        fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
+
+       /* ensure there is only one process initialising at once */
+       ecode = tdb_lock_open(tdb, TDB_LOCK_WAIT|TDB_LOCK_NOCHECK);
+       if (ecode != TDB_SUCCESS) {
+               goto fail;
+       }
+
+       /* If they used O_TRUNC, read will return 0. */
+       rlen = read(tdb->fd, &hdr, sizeof(hdr));
+       if (rlen == 0 && (open_flags & O_CREAT)) {
+               ecode = tdb_new_database(tdb, seed, &hdr);
+               if (ecode != TDB_SUCCESS) {
+                       goto fail;
+               }
+       } else if (rlen < 0) {
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open: error %s reading %s",
+                                  strerror(errno), name);
+               goto fail;
+       } else if (rlen < sizeof(hdr)
+                  || strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0) {
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open: %s is not a tdb file", name);
+               goto fail;
+       }
+
+       if (hdr.version != TDB_VERSION) {
+               if (hdr.version == bswap_64(TDB_VERSION))
+                       tdb->flags |= TDB_CONVERT;
+               else {
+                       /* wrong version */
+                       ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                          "tdb_open:"
+                                          " %s is unknown version 0x%llx",
+                                          name, (long long)hdr.version);
+                       goto fail;
+               }
+       }
+
+       tdb_convert(tdb, &hdr, sizeof(hdr));
+       tdb->hash_seed = hdr.hash_seed;
+       hash_test = TDB_HASH_MAGIC;
+       hash_test = tdb_hash(tdb, &hash_test, sizeof(hash_test));
+       if (hdr.hash_test != hash_test) {
+               /* wrong hash variant */
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open:"
+                                  " %s uses a different hash function",
+                                  name);
+               goto fail;
+       }
+
+       if (fstat(tdb->fd, &st) == -1) {
+               saved_errno = errno;
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open: could not stat open %s: %s",
+                                  name, strerror(errno));
+               goto fail;
+       }
+
+       /* Is it already in the open list?  If so, fail. */
+       if (tdb_already_open(st.st_dev, st.st_ino)) {
+               /* FIXME */
+               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_USE_ERROR,
+                                  "tdb_open: %s (%d,%d) is already open"
+                                  " in this process",
+                                  name, (int)st.st_dev, (int)st.st_ino);
+               goto fail;
+       }
+
+       tdb->name = strdup(name);
+       if (!tdb->name) {
+               ecode = tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
+                                  "tdb_open: failed to allocate name");
+               goto fail;
+       }
+
+       /* Clear any features we don't understand. */
+       if ((open_flags & O_ACCMODE) != O_RDONLY) {
+               hdr.features_used &= TDB_FEATURE_MASK;
+               if (tdb_write_convert(tdb, offsetof(struct tdb_header,
+                                                   features_used),
+                                     &hdr.features_used,
+                                     sizeof(hdr.features_used)) == -1)
+                       goto fail;
+       }
+
+       tdb->device = st.st_dev;
+       tdb->inode = st.st_ino;
+       tdb_unlock_open(tdb);
+
+       /* This make sure we have current map_size and mmap. */
+       tdb->methods->oob(tdb, tdb->map_size + 1, true);
+
+       /* Now it's fully formed, recover if necessary. */
+       berr = tdb_needs_recovery(tdb);
+       if (unlikely(berr != false)) {
+               if (berr < 0) {
+                       ecode = berr;
+                       goto fail;
+               }
+               ecode = tdb_lock_and_recover(tdb);
+               if (ecode != TDB_SUCCESS) {
+                       goto fail;
+               }
+       }
+
+       ecode = tdb_ftable_init(tdb);
+       if (ecode != TDB_SUCCESS) {
+               goto fail;
+       }
+
+       tdb->next = tdbs;
+       tdbs = tdb;
+       return tdb;
+
+ fail:
+       /* Map ecode to some logical errno. */
+       if (!saved_errno) {
+               switch (ecode) {
+               case TDB_ERR_CORRUPT:
+               case TDB_ERR_IO:
+                       saved_errno = EIO;
+                       break;
+               case TDB_ERR_LOCK:
+                       saved_errno = EWOULDBLOCK;
+                       break;
+               case TDB_ERR_OOM:
+                       saved_errno = ENOMEM;
+                       break;
+               case TDB_ERR_EINVAL:
+                       saved_errno = EINVAL;
+                       break;
+               default:
+                       saved_errno = EINVAL;
+                       break;
+               }
+       }
+
+#ifdef TDB_TRACE
+       close(tdb->tracefd);
+#endif
+       if (tdb->map_ptr) {
+               if (tdb->flags & TDB_INTERNAL) {
+                       free(tdb->map_ptr);
+               } else
+                       tdb_munmap(tdb);
+       }
+       free(tdb->lockrecs);
+       free((char *)tdb->name);
+       if (tdb->fd != -1)
+               if (close(tdb->fd) != 0)
+                       tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
+                                  "tdb_open: failed to close tdb->fd"
+                                  " on error: %s", strerror(errno));
+       free(tdb);
+       errno = saved_errno;
+       return NULL;
+}
+
+int tdb_close(struct tdb_context *tdb)
+{
+       struct tdb_context **i;
+       int ret = 0;
+
+       tdb_trace(tdb, "tdb_close");
+
+       if (tdb->transaction) {
+               tdb_transaction_cancel(tdb);
+       }
+
+       if (tdb->map_ptr) {
+               if (tdb->flags & TDB_INTERNAL)
+                       free(tdb->map_ptr);
+               else
+                       tdb_munmap(tdb);
+       }
+       free((char *)tdb->name);
+       if (tdb->fd != -1) {
+               ret = close(tdb->fd);
+               tdb->fd = -1;
+       }
+       free(tdb->lockrecs);
+
+       /* Remove from contexts list */
+       for (i = &tdbs; *i; i = &(*i)->next) {
+               if (*i == tdb) {
+                       *i = tdb->next;
+                       break;
+               }
+       }
+
+#ifdef TDB_TRACE
+       close(tdb->tracefd);
+#endif
+       free(tdb);
+
+       return ret;
+}
index b5e5457691257cbc8034a393f9d2bdeaf091a3cf..02642f58c97427b27a03e9bd8c7bd0c17d087328 100644 (file)
 #include "private.h"
 #include <ccan/asprintf/asprintf.h>
-#include <ccan/tdb2/tdb2.h>
-#include <assert.h>
 #include <stdarg.h>
 
 /* The null return. */
 struct tdb_data tdb_null = { .dptr = NULL, .dsize = 0 };
 
-/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */
-static struct tdb_context *tdbs = NULL;
-
-static bool tdb_already_open(dev_t device, ino_t ino)
-{
-       struct tdb_context *i;
-       
-       for (i = tdbs; i; i = i->next) {
-               if (i->device == device && i->inode == ino) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-static bool read_all(int fd, void *buf, size_t len)
-{
-       while (len) {
-               ssize_t ret;
-               ret = read(fd, buf, len);
-               if (ret < 0)
-                       return false;
-               if (ret == 0) {
-                       /* ETOOSHORT? */
-                       errno = EWOULDBLOCK;
-                       return false;
-               }
-               buf = (char *)buf + ret;
-               len -= ret;
-       }
-       return true;
-}
-
-static uint64_t random_number(struct tdb_context *tdb)
-{
-       int fd;
-       uint64_t ret = 0;
-       struct timeval now;
-
-       fd = open("/dev/urandom", O_RDONLY);
-       if (fd >= 0) {
-               if (read_all(fd, &ret, sizeof(ret))) {
-                       close(fd);
-                       return ret;
-               }
-               close(fd);
-       }
-       /* FIXME: Untested!  Based on Wikipedia protocol description! */
-       fd = open("/dev/egd-pool", O_RDWR);
-       if (fd >= 0) {
-               /* Command is 1, next byte is size we want to read. */
-               char cmd[2] = { 1, sizeof(uint64_t) };
-               if (write(fd, cmd, sizeof(cmd)) == sizeof(cmd)) {
-                       char reply[1 + sizeof(uint64_t)];
-                       int r = read(fd, reply, sizeof(reply));
-                       if (r > 1) {
-                               /* Copy at least some bytes. */
-                               memcpy(&ret, reply+1, r - 1);
-                               if (reply[0] == sizeof(uint64_t)
-                                   && r == sizeof(reply)) {
-                                       close(fd);
-                                       return ret;
-                               }
-                       }
-               }
-               close(fd);
-       }
-
-       /* Fallback: pid and time. */
-       gettimeofday(&now, NULL);
-       ret = getpid() * 100132289ULL + now.tv_sec * 1000000ULL + now.tv_usec;
-       tdb_logerr(tdb, TDB_SUCCESS, TDB_LOG_WARNING,
-                  "tdb_open: random from getpid and time");
-       return ret;
-}
-
-struct new_database {
-       struct tdb_header hdr;
-       struct tdb_freetable ftable;
-};
-
-/* initialise a new database */
-static enum TDB_ERROR tdb_new_database(struct tdb_context *tdb,
-                                      struct tdb_attribute_seed *seed,
-                                      struct tdb_header *hdr)
-{
-       /* We make it up in memory, then write it out if not internal */
-       struct new_database newdb;
-       unsigned int magic_len;
-       ssize_t rlen;
-       enum TDB_ERROR ecode;
-
-       /* Fill in the header */
-       newdb.hdr.version = TDB_VERSION;
-       if (seed)
-               newdb.hdr.hash_seed = seed->seed;
-       else
-               newdb.hdr.hash_seed = random_number(tdb);
-       newdb.hdr.hash_test = TDB_HASH_MAGIC;
-       newdb.hdr.hash_test = tdb->khash(&newdb.hdr.hash_test,
-                                        sizeof(newdb.hdr.hash_test),
-                                        newdb.hdr.hash_seed,
-                                        tdb->hash_priv);
-       newdb.hdr.recovery = 0;
-       newdb.hdr.features_used = newdb.hdr.features_offered = TDB_FEATURE_MASK;
-       memset(newdb.hdr.reserved, 0, sizeof(newdb.hdr.reserved));
-       /* Initial hashes are empty. */
-       memset(newdb.hdr.hashtable, 0, sizeof(newdb.hdr.hashtable));
-
-       /* Free is empty. */
-       newdb.hdr.free_table = offsetof(struct new_database, ftable);
-       memset(&newdb.ftable, 0, sizeof(newdb.ftable));
-       ecode = set_header(NULL, &newdb.ftable.hdr, TDB_FTABLE_MAGIC, 0,
-                          sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr),
-                          sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr),
-                          0);
-       if (ecode != TDB_SUCCESS) {
-               return ecode;
-       }
-
-       /* Magic food */
-       memset(newdb.hdr.magic_food, 0, sizeof(newdb.hdr.magic_food));
-       strcpy(newdb.hdr.magic_food, TDB_MAGIC_FOOD);
-
-       /* This creates an endian-converted database, as if read from disk */
-       magic_len = sizeof(newdb.hdr.magic_food);
-       tdb_convert(tdb,
-                   (char *)&newdb.hdr + magic_len, sizeof(newdb) - magic_len);
-
-       *hdr = newdb.hdr;
-
-       if (tdb->flags & TDB_INTERNAL) {
-               tdb->map_size = sizeof(newdb);
-               tdb->map_ptr = malloc(tdb->map_size);
-               if (!tdb->map_ptr) {
-                       return tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
-                                         "tdb_new_database:"
-                                         " failed to allocate");
-               }
-               memcpy(tdb->map_ptr, &newdb, tdb->map_size);
-               return TDB_SUCCESS;
-       }
-       if (lseek(tdb->fd, 0, SEEK_SET) == -1) {
-               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                 "tdb_new_database:"
-                                 " failed to seek: %s", strerror(errno));
-       }
-
-       if (ftruncate(tdb->fd, 0) == -1) {
-               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                 "tdb_new_database:"
-                                 " failed to truncate: %s", strerror(errno));
-       }
-
-       rlen = write(tdb->fd, &newdb, sizeof(newdb));
-       if (rlen != sizeof(newdb)) {
-               if (rlen >= 0)
-                       errno = ENOSPC;
-               return tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                 "tdb_new_database: %zi writing header: %s",
-                                 rlen, strerror(errno));
-       }
-       return TDB_SUCCESS;
-}
-
-struct tdb_context *tdb_open(const char *name, int tdb_flags,
-                            int open_flags, mode_t mode,
-                            union tdb_attribute *attr)
-{
-       struct tdb_context *tdb;
-       struct stat st;
-       int saved_errno = 0;
-       uint64_t hash_test;
-       unsigned v;
-       ssize_t rlen;
-       struct tdb_header hdr;
-       struct tdb_attribute_seed *seed = NULL;
-       tdb_bool_err berr;
-       enum TDB_ERROR ecode;
-
-       tdb = malloc(sizeof(*tdb));
-       if (!tdb) {
-               /* Can't log this */
-               errno = ENOMEM;
-               return NULL;
-       }
-       tdb->name = NULL;
-       tdb->map_ptr = NULL;
-       tdb->direct_access = 0;
-       tdb->fd = -1;
-       tdb->map_size = sizeof(struct tdb_header);
-       tdb->flags = tdb_flags;
-       tdb->logfn = NULL;
-       tdb->transaction = NULL;
-       tdb->stats = NULL;
-       tdb->access = NULL;
-       tdb_hash_init(tdb);
-       tdb_io_init(tdb);
-       tdb_lock_init(tdb);
-
-       while (attr) {
-               switch (attr->base.attr) {
-               case TDB_ATTRIBUTE_LOG:
-                       tdb->logfn = attr->log.log_fn;
-                       tdb->log_private = attr->log.log_private;
-                       break;
-               case TDB_ATTRIBUTE_HASH:
-                       tdb->khash = attr->hash.hash_fn;
-                       tdb->hash_priv = attr->hash.hash_private;
-                       break;
-               case TDB_ATTRIBUTE_SEED:
-                       seed = &attr->seed;
-                       break;
-               case TDB_ATTRIBUTE_STATS:
-                       tdb->stats = &attr->stats;
-                       /* They have stats we don't know about?  Tell them. */
-                       if (tdb->stats->size > sizeof(attr->stats))
-                               tdb->stats->size = sizeof(attr->stats);
-                       break;
-               default:
-                       ecode = tdb_logerr(tdb, TDB_ERR_EINVAL,
-                                          TDB_LOG_USE_ERROR,
-                                          "tdb_open:"
-                                          " unknown attribute type %u",
-                                          attr->base.attr);
-                       goto fail;
-               }
-               attr = attr->base.next;
-       }
-
-       if (tdb_flags & ~(TDB_INTERNAL | TDB_NOLOCK | TDB_NOMMAP | TDB_CONVERT
-                         | TDB_NOSYNC)) {
-               ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
-                                  "tdb_open: unknown flags %u", tdb_flags);
-               goto fail;
-       }
-
-       if ((open_flags & O_ACCMODE) == O_WRONLY) {
-               ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
-                                  "tdb_open: can't open tdb %s write-only",
-                                  name);
-               goto fail;
-       }
-
-       if ((open_flags & O_ACCMODE) == O_RDONLY) {
-               tdb->read_only = true;
-               tdb->mmap_flags = PROT_READ;
-       } else {
-               tdb->read_only = false;
-               tdb->mmap_flags = PROT_READ | PROT_WRITE;
-       }
-
-       /* internal databases don't need any of the rest. */
-       if (tdb->flags & TDB_INTERNAL) {
-               tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
-               ecode = tdb_new_database(tdb, seed, &hdr);
-               if (ecode != TDB_SUCCESS) {
-                       goto fail;
-               }
-               tdb_convert(tdb, &hdr.hash_seed, sizeof(hdr.hash_seed));
-               tdb->hash_seed = hdr.hash_seed;
-               tdb_ftable_init(tdb);
-               return tdb;
-       }
-
-       if ((tdb->fd = open(name, open_flags, mode)) == -1) {
-               /* errno set by open(2) */
-               saved_errno = errno;
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open: could not open file %s: %s",
-                                  name, strerror(errno));
-               goto fail;
-       }
-
-       /* on exec, don't inherit the fd */
-       v = fcntl(tdb->fd, F_GETFD, 0);
-        fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
-
-       /* ensure there is only one process initialising at once */
-       ecode = tdb_lock_open(tdb, TDB_LOCK_WAIT|TDB_LOCK_NOCHECK);
-       if (ecode != TDB_SUCCESS) {
-               goto fail;
-       }
-
-       /* If they used O_TRUNC, read will return 0. */
-       rlen = read(tdb->fd, &hdr, sizeof(hdr));
-       if (rlen == 0 && (open_flags & O_CREAT)) {
-               ecode = tdb_new_database(tdb, seed, &hdr);
-               if (ecode != TDB_SUCCESS) {
-                       goto fail;
-               }
-       } else if (rlen < 0) {
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open: error %s reading %s",
-                                  strerror(errno), name);
-               goto fail;
-       } else if (rlen < sizeof(hdr)
-                  || strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0) {
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open: %s is not a tdb file", name);
-               goto fail;
-       }
-
-       if (hdr.version != TDB_VERSION) {
-               if (hdr.version == bswap_64(TDB_VERSION))
-                       tdb->flags |= TDB_CONVERT;
-               else {
-                       /* wrong version */
-                       ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                          "tdb_open:"
-                                          " %s is unknown version 0x%llx",
-                                          name, (long long)hdr.version);
-                       goto fail;
-               }
-       }
-
-       tdb_convert(tdb, &hdr, sizeof(hdr));
-       tdb->hash_seed = hdr.hash_seed;
-       hash_test = TDB_HASH_MAGIC;
-       hash_test = tdb_hash(tdb, &hash_test, sizeof(hash_test));
-       if (hdr.hash_test != hash_test) {
-               /* wrong hash variant */
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open:"
-                                  " %s uses a different hash function",
-                                  name);
-               goto fail;
-       }
-
-       if (fstat(tdb->fd, &st) == -1) {
-               saved_errno = errno;
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open: could not stat open %s: %s",
-                                  name, strerror(errno));
-               goto fail;
-       }
-
-       /* Is it already in the open list?  If so, fail. */
-       if (tdb_already_open(st.st_dev, st.st_ino)) {
-               /* FIXME */
-               ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_USE_ERROR,
-                                  "tdb_open: %s (%d,%d) is already open"
-                                  " in this process",
-                                  name, (int)st.st_dev, (int)st.st_ino);
-               goto fail;
-       }
-
-       tdb->name = strdup(name);
-       if (!tdb->name) {
-               ecode = tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
-                                  "tdb_open: failed to allocate name");
-               goto fail;
-       }
-
-       /* Clear any features we don't understand. */
-       if ((open_flags & O_ACCMODE) != O_RDONLY) {
-               hdr.features_used &= TDB_FEATURE_MASK;
-               if (tdb_write_convert(tdb, offsetof(struct tdb_header,
-                                                   features_used),
-                                     &hdr.features_used,
-                                     sizeof(hdr.features_used)) == -1)
-                       goto fail;
-       }
-
-       tdb->device = st.st_dev;
-       tdb->inode = st.st_ino;
-       tdb_unlock_open(tdb);
-
-       /* This make sure we have current map_size and mmap. */
-       tdb->methods->oob(tdb, tdb->map_size + 1, true);
-
-       /* Now it's fully formed, recover if necessary. */
-       berr = tdb_needs_recovery(tdb);
-       if (unlikely(berr != false)) {
-               if (berr < 0) {
-                       ecode = berr;
-                       goto fail;
-               }
-               ecode = tdb_lock_and_recover(tdb);
-               if (ecode != TDB_SUCCESS) {
-                       goto fail;
-               }
-       }
-
-       ecode = tdb_ftable_init(tdb);
-       if (ecode != TDB_SUCCESS) {
-               goto fail;
-       }
-
-       tdb->next = tdbs;
-       tdbs = tdb;
-       return tdb;
-
- fail:
-       /* Map ecode to some logical errno. */
-       if (!saved_errno) {
-               switch (ecode) {
-               case TDB_ERR_CORRUPT:
-               case TDB_ERR_IO:
-                       saved_errno = EIO;
-                       break;
-               case TDB_ERR_LOCK:
-                       saved_errno = EWOULDBLOCK;
-                       break;
-               case TDB_ERR_OOM:
-                       saved_errno = ENOMEM;
-                       break;
-               case TDB_ERR_EINVAL:
-                       saved_errno = EINVAL;
-                       break;
-               default:
-                       saved_errno = EINVAL;
-                       break;
-               }
-       }
-
-#ifdef TDB_TRACE
-       close(tdb->tracefd);
-#endif
-       if (tdb->map_ptr) {
-               if (tdb->flags & TDB_INTERNAL) {
-                       free(tdb->map_ptr);
-               } else
-                       tdb_munmap(tdb);
-       }
-       free(tdb->lockrecs);
-       free((char *)tdb->name);
-       if (tdb->fd != -1)
-               if (close(tdb->fd) != 0)
-                       tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-                                  "tdb_open: failed to close tdb->fd"
-                                  " on error: %s", strerror(errno));
-       free(tdb);
-       errno = saved_errno;
-       return NULL;
-}
-
 static enum TDB_ERROR update_rec_hdr(struct tdb_context *tdb,
                                     tdb_off_t off,
                                     tdb_len_t keylen,
@@ -718,46 +278,6 @@ unlock:
        return ecode;
 }
 
-int tdb_close(struct tdb_context *tdb)
-{
-       struct tdb_context **i;
-       int ret = 0;
-
-       tdb_trace(tdb, "tdb_close");
-
-       if (tdb->transaction) {
-               tdb_transaction_cancel(tdb);
-       }
-
-       if (tdb->map_ptr) {
-               if (tdb->flags & TDB_INTERNAL)
-                       free(tdb->map_ptr);
-               else
-                       tdb_munmap(tdb);
-       }
-       free((char *)tdb->name);
-       if (tdb->fd != -1) {
-               ret = close(tdb->fd);
-               tdb->fd = -1;
-       }
-       free(tdb->lockrecs);
-
-       /* Remove from contexts list */
-       for (i = &tdbs; *i; i = &(*i)->next) {
-               if (*i == tdb) {
-                       *i = tdb->next;
-                       break;
-               }
-       }
-
-#ifdef TDB_TRACE
-       close(tdb->tracefd);
-#endif
-       free(tdb);
-
-       return ret;
-}
-
 unsigned int tdb_get_flags(struct tdb_context *tdb)
 {
        return tdb->flags;
index 418c19686da4d9292289c272971c346115fc87d7..56cb267aec1caa25efb4883d8cbbdf57ccc12c45 100644 (file)
@@ -4,9 +4,9 @@
 #include <stdbool.h>
 
 /* FIXME: Check these! */
-#define INITIAL_TDB_MALLOC     "tdb.c", 191, FAILTEST_MALLOC
-#define URANDOM_OPEN           "tdb.c", 49, FAILTEST_OPEN
-#define URANDOM_READ           "tdb.c", 29, FAILTEST_READ
+#define INITIAL_TDB_MALLOC     "open.c", 184, FAILTEST_MALLOC
+#define URANDOM_OPEN           "open.c", 43, FAILTEST_OPEN
+#define URANDOM_READ           "open.c", 23, FAILTEST_READ
 
 bool exit_check_log(struct failtest_call *history, unsigned num);
 bool failmatch(const struct failtest_call *call,
index 0c8ab61ef0392f8abe633c2a56786b3ca4adfd9e..bfc9400daf830aca1a232e39dc5d62f9891c98f7 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/hash.c>
index a54d90d676a328c2023e3e93b93efdeba502a8f4..d54cad1d1c4a51beb3af6758f4e7f3ee5ab1547c 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 2d1cfc837768e62c2546119e81c4c9c3a9da05c4..4cfd04d91ce73c558a28d4bbc350474a6e31301f 100644 (file)
@@ -1,5 +1,6 @@
 #include <ccan/failtest/failtest_override.h>
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 0a1bc99176e4a2c2795fcffd0d50e75b19ab4851..7f74cdd5b5c78dbec0465048a540432ce08ad632 100644 (file)
@@ -1,5 +1,6 @@
 #include <ccan/failtest/failtest_override.h>
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index ffa2b6c97bd111e6cadab66ee3c6efb5a2c62d69..d40096515a1ba5c245c2af1f452fb926b89cb471 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 0745a23c5c0bdf5db28172242c320b676fae41ca..8a7566372589fdaece7686045211f5dba3aac2e8 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 760ead3884f0292ebaeca26e8f6bb65fc03486b5..daf975556493a406965a5bd3395ae06e873fd4ac 100644 (file)
@@ -1,5 +1,6 @@
 #include <ccan/failtest/failtest_override.h>
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 1a68b54e20f5fedb2ed21504d1984448608c8399..c16c28f8ea8c1def7ad0a75394fc264c99055d20 100644 (file)
@@ -1,5 +1,6 @@
 #include <ccan/failtest/failtest_override.h>
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 8ab9ddc1cc977c06d31cbe06ec0a841a9da11490..0b3c29651c44b2cebcc9b4c4fb09754f15afa423 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 6295523bb4ad687a73fd30bd86c5461b28a6a138..8322ff50c863702d1f2de552a9a6affdc5f9bb07 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index d24816586790ca7de87522ba5051c10a001d3098..e1b85b4880fc0bf45427e0368eeab18c52540e94 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 160f37deb02f63a2e5db8f9d55984bbb77604e91..b504e4907be88a85b07ba83b66cc5d92a5fda979 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index b96a4cc473689fadf1f9f045a8d772e750f38855..4ddb54bc4efcef72350226ea83a71b081066f3d2 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index f887b8b4cee27c7a143732ede894e7d90aa55580..ed7c66dde92fff47c314b5c56b4830babd4387eb 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index b1a8747e590ab795406a7586a67ce8aef7350ea6..8220b911bf22d95f026745bf3ff7347b18541211 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 4ebf792a8c9d7858c81ed55ec21f999a1d2402ac..d1224a7fdad6b61567d15edf60055773d9ac9c62 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 8a6a0e52720ee2e3ba91da78519fe28adc86f4db..b242eab772ed4cbf73a3dcd8df5650f329aeb49d 100644 (file)
@@ -12,6 +12,7 @@ static int ftruncate_check(int fd, off_t length);
 #define ftruncate ftruncate_check
 
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index b6c3557ad5eea8934afb208f5d3096cbc2850405..59b4d62c1c002403a3086a6c959a486fd4ea37a8 100644 (file)
@@ -59,6 +59,7 @@ static void free_all(void)
 #define free free_noleak
 
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 7c74e53642471d5cf73429f7dbcb9113aa0a1227..23a11cdcc2c5a168ff35dceefa201656e325c2e8 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index a09ddb9659c816e6698367ef511beb116e185a7f..f00c74bc2d62ba31ebc51a019f06174e9c3777f9 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index b8a12bd38c8ae0bbb79a19855ac6c4f44834ec7c..895734a7aac0617b178120425a1baa89dba7e871 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index e197143fa4460d283e791ef386019114b3af0b71..9bc778771df0638d00b29f5e1f3a2ddfee294c6e 100644 (file)
@@ -1,5 +1,6 @@
 /* Another test revealed that we lost an entry.  This reproduces it. */
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 3f008b0a6f91eabcf300eaa123145e20a1cb467f..63bbf18d4fc0cae98769dff1c9851aac7b099214 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 5c473cbe1beab9b40e9453313bc39307e6b67aba..66fc82ed8b4b18b0441ea0bdcae63f9be1141f04 100644 (file)
@@ -1,6 +1,7 @@
 /* We had a bug where we marked the tdb read-only for a tdb_traverse_read.
  * If we then expanded the tdb, we would remap read-only, and later SEGV. */
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 98a6b0b3f81bafe441b1d707eaa79b4a6a075483..09ed1cb31c39207e14adaa64fe132e53f4e4f513 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index d9d0fb1a604911e72220d0f42478caf238b583ab..fef79a9b23a8f8825aad6230e7b3db8c48afd38c 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 24d9428e219307fb58f5cd876ea575dbbff3b695..6217021b73df4d08452481e809840c2ceca9ac2c 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 8a7e378e504376de350b9650364dde1bea09ecca..27bdfcd67cf692ffcba14c63bba26f9b9c94a9de 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
index 13c3d4573d8ab0358d2d2d0f9685271d4c37cf61..36077e4acd7c4ecc316365f51059b6368eed571f 100644 (file)
@@ -1,4 +1,5 @@
 #include <ccan/tdb2/tdb.c>
+#include <ccan/tdb2/open.c>
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>