From 945473aac0abffd8509bbeef3ed5a32737b7df51 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jun 2012 15:07:44 +0930 Subject: [PATCH 1/1] dbwrap: dbwrap_hash_size(). Implemented for ntdb and tdb; falls back to 0 for others. Signed-off-by: Rusty Russell --- lib/dbwrap/dbwrap.c | 5 +++++ lib/dbwrap/dbwrap.h | 2 ++ lib/dbwrap/dbwrap_cache.c | 1 + lib/dbwrap/dbwrap_file.c | 1 + lib/dbwrap/dbwrap_private.h | 1 + lib/dbwrap/dbwrap_rbt.c | 1 + lib/dbwrap/dbwrap_tdb.c | 1 + 7 files changed, 12 insertions(+) diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c index f898819b9dbe..4c0160a4740c 100644 --- a/lib/dbwrap/dbwrap.c +++ b/lib/dbwrap/dbwrap.c @@ -407,6 +407,11 @@ int dbwrap_wipe(struct db_context *db) return db->wipe(db); } +int dbwrap_hash_size(struct db_context *db) +{ + return db->hash_size; +} + int dbwrap_check(struct db_context *db) { if (db->check == NULL) { diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h index 796475d3e2c2..30c24fedb3c8 100644 --- a/lib/dbwrap/dbwrap.h +++ b/lib/dbwrap/dbwrap.h @@ -76,6 +76,8 @@ NTSTATUS dbwrap_parse_record(struct db_context *db, TDB_DATA key, int dbwrap_wipe(struct db_context *db); int dbwrap_check(struct db_context *db); int dbwrap_get_seqnum(struct db_context *db); +/* Returns 0 if unknown. */ +int dbwrap_hash_size(struct db_context *db); int dbwrap_transaction_start(struct db_context *db); NTSTATUS dbwrap_transaction_start_nonblock(struct db_context *db); int dbwrap_transaction_commit(struct db_context *db); diff --git a/lib/dbwrap/dbwrap_cache.c b/lib/dbwrap/dbwrap_cache.c index 1badeb13b916..f2a9c5fb0bae 100644 --- a/lib/dbwrap/dbwrap_cache.c +++ b/lib/dbwrap/dbwrap_cache.c @@ -210,6 +210,7 @@ struct db_context *db_open_cache(TALLOC_CTX *mem_ctx, db->exists = dbwrap_cache_exists; db->id = dbwrap_cache_id; db->name = dbwrap_name(ctx->backing); + db->hash_size = dbwrap_hash_size(ctx->backing); db->stored_callback = NULL; db->wipe = NULL; db->lock_order = 0; diff --git a/lib/dbwrap/dbwrap_file.c b/lib/dbwrap/dbwrap_file.c index 4499021c578e..54ed3208642e 100644 --- a/lib/dbwrap/dbwrap_file.c +++ b/lib/dbwrap/dbwrap_file.c @@ -373,6 +373,7 @@ struct db_context *db_open_file(TALLOC_CTX *mem_ctx, result->traverse_read = db_file_traverse; result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0); result->name = name; + result->hash_size = 0; ctx->locked_record = NULL; if (!(ctx->dirname = talloc_strdup(ctx, name))) { diff --git a/lib/dbwrap/dbwrap_private.h b/lib/dbwrap/dbwrap_private.h index f5b214086668..d49a568cd0ec 100644 --- a/lib/dbwrap/dbwrap_private.h +++ b/lib/dbwrap/dbwrap_private.h @@ -64,6 +64,7 @@ struct db_context { int (*check)(struct db_context *db); void (*id)(struct db_context *db, const uint8_t **id, size_t *idlen); const char *name; + int hash_size; void *private_data; enum dbwrap_lock_order lock_order; bool persistent; diff --git a/lib/dbwrap/dbwrap_rbt.c b/lib/dbwrap/dbwrap_rbt.c index 67794e6b96e9..afe9974cb5c2 100644 --- a/lib/dbwrap/dbwrap_rbt.c +++ b/lib/dbwrap/dbwrap_rbt.c @@ -507,6 +507,7 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx) result->lock_order = 0; result->id = db_rbt_id; result->name = "dbwrap rbt"; + result->hash_size = 0; result->stored_callback = NULL; return result; diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c index a6176b75c471..80d41b4ebb8d 100644 --- a/lib/dbwrap/dbwrap_tdb.c +++ b/lib/dbwrap/dbwrap_tdb.c @@ -474,6 +474,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx, result->check = db_tdb_check; result->stored_callback = NULL; result->name = tdb_name(db_tdb->wtdb->tdb); + result->hash_size = hash_size; return result; fail: -- 2.34.1