summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb2/tdb1.h17
-rw-r--r--lib/tdb2/tdb1_open.c54
-rw-r--r--lib/tdb2/tdb1_tdb.c2
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c6
-rw-r--r--lib/tdb2/test/run-tdb1-bad-tdb-header.c18
-rw-r--r--lib/tdb2/test/run-tdb1-check.c22
-rw-r--r--lib/tdb2/test/run-tdb1-corrupt.c10
-rw-r--r--lib/tdb2/test/run-tdb1-die-during-transaction.c6
-rw-r--r--lib/tdb2/test/run-tdb1-endian.c12
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c79
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c12
-rw-r--r--lib/tdb2/test/run-tdb1-nested-traverse.c6
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c8
-rw-r--r--lib/tdb2/test/run-tdb1-oldhash.c23
-rw-r--r--lib/tdb2/test/run-tdb1-open-during-transaction.c8
-rw-r--r--lib/tdb2/test/run-tdb1-readonly-check.c12
-rw-r--r--lib/tdb2/test/run-tdb1-rwlock-check.c15
-rw-r--r--lib/tdb2/test/run-tdb1-summary.c2
-rw-r--r--lib/tdb2/test/run-tdb1-traverse-in-transaction.c8
-rw-r--r--lib/tdb2/test/run-tdb1-wronghash-fail.c66
-rw-r--r--lib/tdb2/test/run-tdb1-zero-append.c6
-rw-r--r--lib/tdb2/test/run-tdb1.c6
-rw-r--r--lib/tdb2/test/tdb1-external-agent.c6
-rw-r--r--lib/tdb2/test/tdb1-logging.c25
-rw-r--r--lib/tdb2/test/tdb1-logging.h10
25 files changed, 229 insertions, 210 deletions
diff --git a/lib/tdb2/tdb1.h b/lib/tdb2/tdb1.h
index 78d42b398c..a2a0afe808 100644
--- a/lib/tdb2/tdb1.h
+++ b/lib/tdb2/tdb1.h
@@ -37,23 +37,10 @@
typedef int (*tdb1_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
-typedef void (*tdb1_log_func)(struct tdb_context *, enum tdb_log_level, enum TDB_ERROR,
- const char *, void *);
-typedef uint64_t (*tdb1_hash_func)(const void *key, size_t len, uint64_t seed,
- void *data);
-
-struct tdb1_logging_context {
- tdb1_log_func log_fn;
- void *log_private;
-};
struct tdb_context *tdb1_open(const char *name, int hash_size, int tdb1_flags,
- int open_flags, mode_t mode);
-
-struct tdb_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags,
- int open_flags, mode_t mode,
- const struct tdb1_logging_context *log_ctx,
- tdb1_hash_func hash_fn);
+ int open_flags, mode_t mode,
+ union tdb_attribute *attributes);
void tdb1_set_max_dead(struct tdb_context *tdb, int max_dead);
diff --git a/lib/tdb2/tdb1_open.c b/lib/tdb2/tdb1_open.c
index 5d0097b2a7..1f23db0126 100644
--- a/lib/tdb2/tdb1_open.c
+++ b/lib/tdb2/tdb1_open.c
@@ -95,23 +95,15 @@ static int tdb1_new_database(struct tdb_context *tdb, int hash_size)
return ret;
}
+typedef void (*tdb1_log_func)(struct tdb_context *, enum tdb_log_level, enum TDB_ERROR,
+ const char *, void *);
+typedef uint64_t (*tdb1_hash_func)(const void *key, size_t len, uint64_t seed,
+ void *data);
-
-/* open the database, creating it if necessary
-
- The open_flags and mode are passed straight to the open call on the
- database file. A flags value of O_WRONLY is invalid. The hash size
- is advisory, use zero for a default value.
-
- Return is NULL on error, in which case errno is also set. Don't
- try to call tdb1_error or tdb1_errname, just do strerror(errno).
-
- @param name may be NULL for internal databases. */
-struct tdb_context *tdb1_open(const char *name, int hash_size, int tdb1_flags,
- int open_flags, mode_t mode)
-{
- return tdb1_open_ex(name, hash_size, tdb1_flags, open_flags, mode, NULL, NULL);
-}
+struct tdb1_logging_context {
+ tdb1_log_func log_fn;
+ void *log_private;
+};
static bool hash_correct(struct tdb_context *tdb,
uint32_t *m1, uint32_t *m2)
@@ -137,7 +129,7 @@ static bool check_header_hash(struct tdb_context *tdb,
return hash_correct(tdb, m1, m2);
}
-struct tdb_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags,
+static struct tdb_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags,
int open_flags, mode_t mode,
const struct tdb1_logging_context *log_ctx,
tdb1_hash_func hash_fn)
@@ -366,6 +358,34 @@ struct tdb_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags
}
}
+/* Temporart wrapper for transition. */
+struct tdb_context *tdb1_open(const char *name, int hash_size, int tdb1_flags,
+ int open_flags, mode_t mode,
+ union tdb_attribute *attr)
+{
+ struct tdb1_logging_context *log_ctx = NULL, log;
+ tdb1_hash_func hash_fn = NULL;
+
+ while (attr) {
+ switch (attr->base.attr) {
+ case TDB_ATTRIBUTE_HASH:
+ hash_fn = attr->hash.fn;
+ break;
+ case TDB_ATTRIBUTE_LOG:
+ log.log_fn = attr->log.fn;
+ log.log_private = attr->log.data;
+ log_ctx = &log;
+ break;
+ default:
+ abort();
+ }
+ attr = attr->base.next;
+ }
+
+ return tdb1_open_ex(name, hash_size, tdb1_flags, open_flags, mode,
+ log_ctx, hash_fn);
+}
+
/*
* Set the maximum number of dead records per hash chain
*/
diff --git a/lib/tdb2/tdb1_tdb.c b/lib/tdb2/tdb1_tdb.c
index 400c9866e8..e9696000b8 100644
--- a/lib/tdb2/tdb1_tdb.c
+++ b/lib/tdb2/tdb1_tdb.c
@@ -843,7 +843,7 @@ int tdb1_repack(struct tdb_context *tdb)
return -1;
}
- tmp_db = tdb1_open("tmpdb", tdb1_hash_size(tdb), TDB_INTERNAL, O_RDWR|O_CREAT, 0);
+ tmp_db = tdb1_open("tmpdb", tdb1_hash_size(tdb), TDB_INTERNAL, O_RDWR|O_CREAT, 0, NULL);
if (tmp_db == NULL) {
tdb->last_error = tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
__location__ " Failed to create tmp_db");
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index d5aeda5dde..1eab447671 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -4,7 +4,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
static int tdb1_expand_file_sparse(struct tdb_context *tdb,
tdb1_off_t size,
@@ -66,8 +66,8 @@ int main(int argc, char *argv[])
struct tdb1_record rec;
plan_tests(24);
- tdb = tdb1_open_ex("run-36-file.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-36-file.tdb", 1024, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
tdb->tdb1.io = &large_io_methods;
diff --git a/lib/tdb2/test/run-tdb1-bad-tdb-header.c b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
index fe2501081a..a32b817c1d 100644
--- a/lib/tdb2/test/run-tdb1-bad-tdb-header.c
+++ b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -16,11 +16,11 @@ int main(int argc, char *argv[])
ok1(fd >= 0);
ok1(write(fd, "hello world", 11) == 11);
close(fd);
- tdb = tdb1_open_ex("run-bad-tdb-header.tdb", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(!tdb);
- tdb = tdb1_open_ex("run-bad-tdb-header.tdb", 1024, 0, O_CREAT|O_RDWR,
- 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_CREAT|O_RDWR,
+ 0600, &tap_log_attr);
ok1(tdb);
tdb1_close(tdb);
@@ -34,14 +34,14 @@ int main(int argc, char *argv[])
ok1(write(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
close(fd);
- tdb = tdb1_open_ex("run-bad-tdb-header.tdb", 1024, 0, O_RDWR|O_CREAT,
- 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_RDWR|O_CREAT,
+ 0600, &tap_log_attr);
ok1(errno == EIO);
ok1(!tdb);
/* With truncate, will be fine. */
- tdb = tdb1_open_ex("run-bad-tdb-header.tdb", 1024, 0,
- O_RDWR|O_CREAT|O_TRUNC, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0,
+ O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
ok1(tdb);
tdb1_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c
index 9864e42c56..017eb8328a 100644
--- a/lib/tdb2/test/run-tdb1-check.c
+++ b/lib/tdb2/test/run-tdb1-check.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -10,8 +10,8 @@ int main(int argc, char *argv[])
TDB_DATA key, data;
plan_tests(13);
- tdb = tdb1_open_ex("run-check.tdb", 1, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-check.tdb", 1, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -25,28 +25,28 @@ int main(int argc, char *argv[])
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("run-check.tdb", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("run-check.tdb", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("test/tdb1.corrupt", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("test/tdb1.corrupt", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == -1);
ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
tdb1_close(tdb);
/* Big and little endian should work! */
- tdb = tdb1_open_ex("test/old-nohash-le.tdb1", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("test/old-nohash-be.tdb1", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c
index 2e70da7ce5..833e9c1ee1 100644
--- a/lib/tdb2/test/run-tdb1-corrupt.c
+++ b/lib/tdb2/test/run-tdb1-corrupt.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
static int check(TDB_DATA key, TDB_DATA data, void *private)
{
@@ -97,8 +97,8 @@ int main(int argc, char *argv[])
plan_tests(4);
/* This should use mmap. */
- tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-corrupt.tdb", 2, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
if (!tdb)
abort();
@@ -106,8 +106,8 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* This should not. */
- tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-corrupt.tdb", 2, TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
if (!tdb)
abort();
diff --git a/lib/tdb2/test/run-tdb1-die-during-transaction.c b/lib/tdb2/test/run-tdb1-die-during-transaction.c
index 1d03a30a1a..9ff75d1020 100644
--- a/lib/tdb2/test/run-tdb1-die-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-die-during-transaction.c
@@ -18,7 +18,7 @@ static int ftruncate_check(int fd, off_t length);
#include <err.h>
#include <setjmp.h>
#include "tdb1-external-agent.h"
-#include "tdb1-logging.h"
+#include "logging.h"
#undef write
#undef pwrite
@@ -89,8 +89,8 @@ static bool test_death(enum operation op, struct agent *agent)
current = target = 0;
reset:
unlink(TEST_DBNAME);
- tdb = tdb1_open_ex(TEST_DBNAME, 1024, TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open(TEST_DBNAME, 1024, TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
if (setjmp(jmpbuf) != 0) {
/* We're partway through. Simulate our death. */
diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c
index 245b65446c..a06bfb6e99 100644
--- a/lib/tdb2/test/run-tdb1-endian.c
+++ b/lib/tdb2/test/run-tdb1-endian.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -10,9 +10,9 @@ int main(int argc, char *argv[])
TDB_DATA key, data;
plan_tests(13);
- tdb = tdb1_open_ex("run-endian.tdb", 1024,
- TDB_CONVERT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-endian.tdb", 1024,
+ TDB_CONVERT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
key.dsize = strlen("hi");
@@ -38,8 +38,8 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* Reopen: should read it */
- tdb = tdb1_open_ex("run-endian.tdb", 1024, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("run-endian.tdb", 1024, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index 9e58161462..baf40ed4e6 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -49,7 +49,29 @@ int main(int argc, char *argv[])
struct tdb_context *tdb;
unsigned int log_count, flags;
TDB_DATA d;
- struct tdb1_logging_context log_ctx = { log_fn, &log_count };
+ union tdb_attribute log_attr, jhash_attr, ohash_attr,
+ incompat_hash_attr, dumbhash_attr;
+
+ log_attr.base.attr = TDB_ATTRIBUTE_LOG;
+ log_attr.base.next = NULL;
+ log_attr.log.fn = log_fn;
+ log_attr.log.data = &log_count;
+
+ jhash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ jhash_attr.base.next = &log_attr;
+ jhash_attr.hash.fn = jenkins_hashfn;
+
+ ohash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ ohash_attr.base.next = &log_attr;
+ ohash_attr.hash.fn = old_hash;
+
+ incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ incompat_hash_attr.base.next = &log_attr;
+ incompat_hash_attr.hash.fn = tdb1_incompatible_hash;
+
+ dumbhash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ dumbhash_attr.base.next = &log_attr;
+ dumbhash_attr.hash.fn = tdb1_dumb_hash;
plan_tests(38 * 2);
@@ -61,9 +83,8 @@ int main(int argc, char *argv[])
/* Create an old-style hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_ctx,
- NULL);
+ tdb = tdb1_open("run-incompatible.tdb", 0, flags,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -76,10 +97,9 @@ int main(int argc, char *argv[])
/* We can still open any old-style with incompat hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0,
- TDB_DEFAULT,
- O_RDWR, 0600, &log_ctx,
- tdb1_incompatible_hash);
+ tdb = tdb1_open("run-incompatible.tdb", 0,
+ TDB_DEFAULT,
+ O_RDWR, 0600, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
@@ -89,16 +109,16 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
- 0, &log_ctx, jenkins_hashfn);
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
+ 0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
- 0, &log_ctx, jenkins_hashfn);
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
+ 0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -106,10 +126,10 @@ int main(int argc, char *argv[])
/* OK, now create with incompatible hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0,
- flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_ctx,
- tdb1_incompatible_hash);
+ tdb = tdb1_open("run-incompatible.tdb", 0,
+ flags,
+ O_CREAT|O_RDWR|O_TRUNC, 0600,
+ &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -122,15 +142,15 @@ int main(int argc, char *argv[])
/* Cannot open with old hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, 0,
- O_RDWR, 0600, &log_ctx, old_hash);
+ tdb = tdb1_open("run-incompatible.tdb", 0, 0,
+ O_RDWR, 0600, &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Can open with jenkins hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, 0,
- O_RDWR, 0600, &log_ctx, jenkins_hashfn);
+ tdb = tdb1_open("run-incompatible.tdb", 0, 0,
+ O_RDWR, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
@@ -141,8 +161,8 @@ int main(int argc, char *argv[])
/* Can open by letting it figure it out itself. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, 0,
- O_RDWR, 0600, &log_ctx, NULL);
+ tdb = tdb1_open("run-incompatible.tdb", 0, 0,
+ O_RDWR, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -156,10 +176,9 @@ int main(int argc, char *argv[])
/* FIXME: Not possible with TDB2 :( */
/* We can also use incompatible hash with other hashes. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0,
- flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_ctx,
- tdb1_dumb_hash);
+ tdb = tdb1_open("run-incompatible.tdb", 0,
+ flags,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -172,15 +191,15 @@ int main(int argc, char *argv[])
/* It should not open if we don't specify. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, 0, O_RDWR, 0,
- &log_ctx, NULL);
+ tdb = tdb1_open("run-incompatible.tdb", 0, 0, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Should reopen with correct hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-incompatible.tdb", 0, 0, O_RDWR, 0,
- &log_ctx, tdb1_dumb_hash);
+ tdb = tdb1_open("run-incompatible.tdb", 0, 0, O_RDWR, 0,
+ &dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index be4e926946..d5886123ea 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -14,9 +14,9 @@ int main(int argc, char *argv[])
key.dsize = strlen("hi");
key.dptr = (void *)"hi";
- tdb = tdb1_open_ex("run-nested-transactions.tdb",
- 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-nested-transactions.tdb",
+ 1024, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
/* No nesting by default. */
@@ -42,8 +42,8 @@ int main(int argc, char *argv[])
free(data.dptr);
tdb1_close(tdb);
- tdb = tdb1_open_ex("run-nested-transactions.tdb",
- 1024, TDB_ALLOW_NESTING, O_RDWR, 0, &taplogctx, NULL);
+ tdb = tdb1_open("run-nested-transactions.tdb",
+ 1024, TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_transaction_start(tdb) == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c
index 3d15082a03..1fc8d09277 100644
--- a/lib/tdb2/test/run-tdb1-nested-traverse.c
+++ b/lib/tdb2/test/run-tdb1-nested-traverse.c
@@ -7,7 +7,7 @@
#include <stdbool.h>
#include <err.h>
#include "tdb1-external-agent.h"
-#include "tdb1-logging.h"
+#include "logging.h"
static struct agent *agent;
@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
if (!agent)
err(1, "preparing agent");
- tdb = tdb1_open_ex("run-nested-traverse.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-nested-traverse.tdb", 1024, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
index 10d57bacfb..cb1c23606b 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -8,7 +8,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
#undef fcntl
@@ -70,9 +70,9 @@ int main(int argc, char *argv[])
int errors = 0;
plan_tests(41);
- tdb = tdb1_open_ex("run-no-lock-during-traverse.tdb",
- 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-no-lock-during-traverse.tdb",
+ 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &tap_log_attr);
ok1(tdb);
ok1(prepare_entries(tdb));
diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c
index ea56dd3c8c..5219d5c30a 100644
--- a/lib/tdb2/test/run-tdb1-oldhash.c
+++ b/lib/tdb2/test/run-tdb1-oldhash.c
@@ -2,36 +2,41 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
struct tdb_context *tdb;
+ union tdb_attribute incompat_hash_attr;
+
+ incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ incompat_hash_attr.base.next = &tap_log_attr;
+ incompat_hash_attr.hash.fn = tdb1_incompatible_hash;
plan_tests(8);
/* Old format (with zeroes in the hash magic fields) should
* open with any hash (since we don't know what hash they used). */
- tdb = tdb1_open_ex("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
- &taplogctx, tdb1_incompatible_hash);
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
+ &incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open_ex("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
- &taplogctx, tdb1_incompatible_hash);
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
+ &incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-open-during-transaction.c b/lib/tdb2/test/run-tdb1-open-during-transaction.c
index 3cb0685bbc..e0b28a536e 100644
--- a/lib/tdb2/test/run-tdb1-open-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-open-during-transaction.c
@@ -18,7 +18,7 @@ static int ftruncate_check(int fd, off_t length);
#include <stdarg.h>
#include <err.h>
#include "tdb1-external-agent.h"
-#include "tdb1-logging.h"
+#include "logging.h"
static struct agent *agent;
static bool opened;
@@ -145,9 +145,9 @@ int main(int argc, char *argv[])
"DEFAULT",
(flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap");
unlink(TEST_DBNAME);
- tdb = tdb1_open_ex(TEST_DBNAME, 1024, flags[i],
- O_CREAT|O_TRUNC|O_RDWR, 0600,
- &taplogctx, NULL);
+ tdb = tdb1_open(TEST_DBNAME, 1024, flags[i],
+ O_CREAT|O_TRUNC|O_RDWR, 0600,
+ &tap_log_attr);
ok1(tdb);
opened = true;
diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c
index 2eda33d9b6..762c576f92 100644
--- a/lib/tdb2/test/run-tdb1-readonly-check.c
+++ b/lib/tdb2/test/run-tdb1-readonly-check.c
@@ -4,7 +4,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -12,9 +12,9 @@ int main(int argc, char *argv[])
TDB_DATA key, data;
plan_tests(11);
- tdb = tdb1_open_ex("run-readonly-check.tdb", 1024,
- TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-readonly-check.tdb", 1024,
+ TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
key.dsize = strlen("hi");
@@ -30,8 +30,8 @@ int main(int argc, char *argv[])
ok1(tdb1_check(tdb, NULL, NULL) == 0);
ok1(tdb1_close(tdb) == 0);
- tdb = tdb1_open_ex("run-readonly-check.tdb", 1024,
- TDB_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
+ tdb = tdb1_open("run-readonly-check.tdb", 1024,
+ TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == -1);
diff --git a/lib/tdb2/test/run-tdb1-rwlock-check.c b/lib/tdb2/test/run-tdb1-rwlock-check.c
index cd227f4cd7..6f4406c026 100644
--- a/lib/tdb2/test/run-tdb1-rwlock-check.c
+++ b/lib/tdb2/test/run-tdb1-rwlock-check.c
@@ -16,20 +16,25 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
unsigned int log_count;
- struct tdb1_logging_context log_ctx = { log_fn, &log_count };
+ union tdb_attribute log_attr;
+
+ log_attr.base.attr = TDB_ATTRIBUTE_LOG;
+ log_attr.base.next = NULL;
+ log_attr.log.fn = log_fn;
+ log_attr.log.data = &log_count;
plan_tests(4);
/* We should fail to open rwlock-using tdbs of either endian. */
log_count = 0;
- tdb = tdb1_open_ex("test/rwlock-le.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, NULL);
+ tdb = tdb1_open("test/rwlock-le.tdb1", 0, 0, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open_ex("test/rwlock-be.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, NULL);
+ tdb = tdb1_open("test/rwlock-be.tdb1", 0, 0, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c
index ffd8bc8caa..8b9b74ffe7 100644
--- a/lib/tdb2/test/run-tdb1-summary.c
+++ b/lib/tdb2/test/run-tdb1-summary.c
@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
tdb = tdb1_open("run-summary.tdb", 131, flags[i],
- O_RDWR|O_CREAT|O_TRUNC, 0600);
+ O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
ok1(tdb);
if (!tdb)
continue;
diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
index 243f2d653f..0395bff7ce 100644
--- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
+++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
@@ -8,7 +8,7 @@
#include <stdbool.h>
#include <err.h>
#include "tdb1-external-agent.h"
-#include "tdb1-logging.h"
+#include "logging.h"
static struct agent *agent;
@@ -42,9 +42,9 @@ int main(int argc, char *argv[])
if (!agent)
err(1, "preparing agent");
- tdb = tdb1_open_ex("run-traverse-in-transaction.tdb",
- 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run-traverse-in-transaction.tdb",
+ 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &tap_log_attr);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c
index 90e16832f4..54524fc1ff 100644
--- a/lib/tdb2/test/run-tdb1-wronghash-fail.c
+++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c
@@ -30,14 +30,32 @@ int main(int argc, char *argv[])
struct tdb_context *tdb;
unsigned int log_count;
TDB_DATA d;
- struct tdb1_logging_context log_ctx = { log_fn, &log_count };
+ union tdb_attribute log_attr, jhash_attr, ohash_attr,
+ incompat_hash_attr;
+
+ log_attr.base.attr = TDB_ATTRIBUTE_LOG;
+ log_attr.base.next = NULL;
+ log_attr.log.fn = log_fn;
+ log_attr.log.data = &log_count;
+
+ jhash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ jhash_attr.base.next = &log_attr;
+ jhash_attr.hash.fn = jenkins_hashfn;
+
+ ohash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ ohash_attr.base.next = &log_attr;
+ ohash_attr.hash.fn = old_hash;
+
+ incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH;
+ incompat_hash_attr.base.next = &log_attr;
+ incompat_hash_attr.hash.fn = tdb1_incompatible_hash;
plan_tests(28);
/* Create with default hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-wronghash-fail.tdb", 0, 0,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_ctx, NULL);
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -46,51 +64,51 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* Fail to open with different hash. */
- tdb = tdb1_open_ex("run-wronghash-fail.tdb", 0, 0, O_RDWR, 0,
- &log_ctx, jenkins_hashfn);
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0, O_RDWR, 0,
+ &jhash_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Create with different hash. */
log_count = 0;
- tdb = tdb1_open_ex("run-wronghash-fail.tdb", 0, 0,
- O_CREAT|O_RDWR|O_TRUNC,
- 0600, &log_ctx, jenkins_hashfn);
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0,
+ O_CREAT|O_RDWR|O_TRUNC,
+ 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
tdb1_close(tdb);
/* Endian should be no problem. */
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, old_hash);
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, old_hash);
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
/* Fail to open with old default hash. */
- tdb = tdb1_open_ex("run-wronghash-fail.tdb", 0, 0, O_RDWR, 0,
- &log_ctx, old_hash);
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
- 0, &log_ctx, tdb1_incompatible_hash);
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
+ 0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
- 0, &log_ctx, tdb1_incompatible_hash);
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
+ 0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -98,24 +116,24 @@ int main(int argc, char *argv[])
/* It should open with jenkins hash if we don't specify. */
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, NULL);
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
+ &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open_ex("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
- &log_ctx, NULL);
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
+ &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open_ex("run-wronghash-fail.tdb", 0, 0, O_RDONLY,
- 0, &log_ctx, NULL);
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0, O_RDONLY,
+ 0, &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c
index 80458728d6..3541fe08c8 100644
--- a/lib/tdb2/test/run-tdb1-zero-append.c
+++ b/lib/tdb2/test/run-tdb1-zero-append.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -10,8 +10,8 @@ int main(int argc, char *argv[])
TDB_DATA key, data;
plan_tests(4);
- tdb = tdb1_open_ex(NULL, 1024, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &taplogctx, NULL);
+ tdb = tdb1_open(NULL, 1024, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &tap_log_attr);
ok1(tdb);
/* Tickle bug on appending zero length buffer to zero length buffer. */
diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c
index 39b156b499..d206545c68 100644
--- a/lib/tdb2/test/run-tdb1.c
+++ b/lib/tdb2/test/run-tdb1.c
@@ -2,7 +2,7 @@
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
-#include "tdb1-logging.h"
+#include "logging.h"
int main(int argc, char *argv[])
{
@@ -10,8 +10,8 @@ int main(int argc, char *argv[])
TDB_DATA key, data;
plan_tests(10);
- tdb = tdb1_open_ex("run.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+ tdb = tdb1_open("run.tdb", 1024, TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c
index 08c024b5cc..dcd825dc82 100644
--- a/lib/tdb2/test/tdb1-external-agent.c
+++ b/lib/tdb2/test/tdb1-external-agent.c
@@ -1,6 +1,6 @@
#include "tdb1-external-agent.h"
#include "tdb1-lock-tracking.h"
-#include "tdb1-logging.h"
+#include "logging.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -39,8 +39,8 @@ static enum agent_return do_operation(enum operation op, const char *name)
diag("Already have tdb %s open", tdb->name);
return OTHER_FAILURE;
}
- tdb = tdb1_open_ex(name, 0, TDB_DEFAULT, O_RDWR, 0,
- &taplogctx, NULL);
+ tdb = tdb1_open(name, 0, TDB_DEFAULT, O_RDWR, 0,
+ &tap_log_attr);
if (!tdb) {
if (!locking_would_block1)
diag("Opening tdb gave %s", strerror(errno));
diff --git a/lib/tdb2/test/tdb1-logging.c b/lib/tdb2/test/tdb1-logging.c
deleted file mode 100644
index cb058296d4..0000000000
--- a/lib/tdb2/test/tdb1-logging.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "tdb1-logging.h"
-#include <ccan/tap/tap.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-/* Turn log messages into tap diag messages. */
-static void taplog(struct tdb_context *tdb,
- enum tdb_log_level level,
- enum TDB_ERROR ecode,
- const char *message,
- void *data)
-{
- if (suppress_logging)
- return;
-
- /* Strip trailing \n: diag adds it. */
- if (message[0] && message[strlen(message)-1] == '\n')
- diag("%s%.*s", log_prefix, (unsigned)strlen(message)-1, message);
- else
- diag("%s%s", log_prefix, message);
-}
-
-struct tdb1_logging_context taplogctx = { taplog, NULL };
diff --git a/lib/tdb2/test/tdb1-logging.h b/lib/tdb2/test/tdb1-logging.h
deleted file mode 100644
index 128ec7f81d..0000000000
--- a/lib/tdb2/test/tdb1-logging.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef TDB_TEST_LOGGING_H
-#define TDB_TEST_LOGGING_H
-#include <ccan/tdb2/tdb1.h>
-#include <stdbool.h>
-
-extern bool suppress_logging;
-extern const char *log_prefix;
-extern struct tdb1_logging_context taplogctx;
-
-#endif /* TDB_TEST_LOGGING_H */