From cbad6e2c140e59a6ec653bcfe773599a57a5042f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 07:49:13 +0930 Subject: tdb2: unify tdb1_open into tdb_open Finally, we gut tdb1_open() to the tdb1-specific parts, and call it from tdb_open if they specify the TDB_VERSION1 flag or the version is a TDB1. We also unify tdb_close(), based on the TDB_VERSION1 flag. Note that tdb_open(TDB_VERSION1) will fail on an existing tdb if it's a TDB2. Signed-off-by: Rusty Russell (Imported from CCAN commit c8c3b3568677e8b0105f84e4ab068c580faf4591) --- lib/tdb2/private.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/tdb2/private.h') diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h index 33d756f291..b7fd5959d1 100644 --- a/lib/tdb2/private.h +++ b/lib/tdb2/private.h @@ -67,6 +67,7 @@ typedef uint64_t tdb_off_t; #define TDB_MAGIC_FOOD "TDB file\n" #define TDB_VERSION ((uint64_t)(0x26011967 + 7)) +#define TDB1_VERSION (0x26011967 + 6) #define TDB_USED_MAGIC ((uint64_t)0x1999) #define TDB_HTABLE_MAGIC ((uint64_t)0x1888) #define TDB_CHAIN_MAGIC ((uint64_t)0x1777) @@ -640,6 +641,23 @@ struct tdb_context { } tdb1; }; +#define TDB1_BYTEREV(x) (((((x)&0xff)<<24)|((x)&0xFF00)<<8)|(((x)>>8)&0xFF00)|((x)>>24)) + +/* tdb1_open.c: */ +int tdb1_new_database(struct tdb_context *tdb, + struct tdb_attribute_tdb1_hashsize *hashsize); +enum TDB_ERROR tdb1_open(struct tdb_context *tdb); + +/* tdb1_io.c: */ +enum TDB_ERROR tdb1_probe_length(struct tdb_context *tdb); + +/* tdb1_lock.c: */ +int tdb1_allrecord_unlock(struct tdb_context *tdb, int ltype); + +/* tdb1_transaction.c: */ +int tdb1_transaction_recover(struct tdb_context *tdb); +int tdb1_transaction_cancel(struct tdb_context *tdb); + /* tdb.c: */ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb, enum TDB_ERROR ecode, -- cgit