From 36b455d95227f8ef2f08e3134e289b2862b319f9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 21 Sep 2011 12:55:59 +0930 Subject: [PATCH] tdb_compat: handle TDB_INCOMPATIBLE_HASH flag. This is only meaningful when using the TDB_VERSION1 flag: it is done by using a magic hash value (which will fall back to the default hash if that works instead). Signed-off-by: Rusty Russell --- lib/tdb_compat/tdb_compat.c | 12 +++++++++++- lib/tdb_compat/tdb_compat.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/tdb_compat/tdb_compat.c b/lib/tdb_compat/tdb_compat.c index fd3a68717ad..9ed6604c4dc 100644 --- a/lib/tdb_compat/tdb_compat.c +++ b/lib/tdb_compat/tdb_compat.c @@ -94,7 +94,7 @@ tdb_open_compat_(const char *name, int hash_size_unused, void *data), void *log_data) { - union tdb_attribute cif, log, *attr = NULL; + union tdb_attribute cif, log, hash, *attr = NULL; if (log_fn) { log.log.base.attr = TDB_ATTRIBUTE_LOG; @@ -112,6 +112,16 @@ tdb_open_compat_(const char *name, int hash_size_unused, tdb_flags &= ~TDB_CLEAR_IF_FIRST; } + if (tdb_flags & TDB_INCOMPATIBLE_HASH) { + if (tdb_flags & TDB_VERSION1) { + hash.hash.base.attr = TDB_ATTRIBUTE_HASH; + hash.hash.base.next = attr; + hash.hash.fn = tdb1_incompatible_hash; + attr = &hash; + } + tdb_flags &= ~TDB_INCOMPATIBLE_HASH; + } + /* Testsuite uses this to speed things up. */ if (getenv("TDB_NO_FSYNC")) { tdb_flags |= TDB_NOSYNC; diff --git a/lib/tdb_compat/tdb_compat.h b/lib/tdb_compat/tdb_compat.h index 1f7e8a9c636..4a01c15fdbd 100644 --- a/lib/tdb_compat/tdb_compat.h +++ b/lib/tdb_compat/tdb_compat.h @@ -82,7 +82,7 @@ int tdb_reopen_all(int parent_longlived); /* These no longer exist in tdb2. */ #define TDB_CLEAR_IF_FIRST 1048576 -#define TDB_INCOMPATIBLE_HASH 0 +#define TDB_INCOMPATIBLE_HASH 2097152 #define TDB_VOLATILE 0 /* tdb2 does nonblocking functions via attibutes. */ -- 2.34.1