diff options
-rw-r--r-- | lib/dbwrap/dbwrap.c | 21 | ||||
-rw-r--r-- | lib/dbwrap/dbwrap.h | 1 | ||||
-rw-r--r-- | lib/dbwrap/dbwrap_private.h | 1 | ||||
-rw-r--r-- | lib/dbwrap/dbwrap_tdb.c | 8 |
4 files changed, 31 insertions, 0 deletions
diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c index a393960428..d46044f0c4 100644 --- a/lib/dbwrap/dbwrap.c +++ b/lib/dbwrap/dbwrap.c @@ -50,6 +50,19 @@ static int dbwrap_fallback_wipe(struct db_context *db) return NT_STATUS_IS_OK(status) ? 0 : -1; } +static int do_nothing(struct db_record *rec, void *unused) +{ + return 0; +} + +/* + * Fallback check operation: just traverse. + */ +static int dbwrap_fallback_check(struct db_context *db) +{ + NTSTATUS status = dbwrap_traverse_read(db, do_nothing, NULL, NULL); + return NT_STATUS_IS_OK(status) ? 0 : -1; +} /* * Wrapper functions for the backend methods @@ -367,6 +380,14 @@ int dbwrap_wipe(struct db_context *db) return db->wipe(db); } +int dbwrap_check(struct db_context *db) +{ + if (db->check == NULL) { + return dbwrap_fallback_check(db); + } + return db->check(db); +} + int dbwrap_get_seqnum(struct db_context *db) { return db->get_seqnum(db); diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h index 6c789e91a4..23a43da019 100644 --- a/lib/dbwrap/dbwrap.h +++ b/lib/dbwrap/dbwrap.h @@ -69,6 +69,7 @@ NTSTATUS dbwrap_parse_record(struct db_context *db, TDB_DATA key, void *private_data), void *private_data); int dbwrap_wipe(struct db_context *db); +int dbwrap_check(struct db_context *db); int dbwrap_get_seqnum(struct db_context *db); int dbwrap_transaction_start(struct db_context *db); int dbwrap_transaction_commit(struct db_context *db); diff --git a/lib/dbwrap/dbwrap_private.h b/lib/dbwrap/dbwrap_private.h index 7f9904c8a5..af8374dbc9 100644 --- a/lib/dbwrap/dbwrap_private.h +++ b/lib/dbwrap/dbwrap_private.h @@ -56,6 +56,7 @@ struct db_context { void *private_data); int (*exists)(struct db_context *db,TDB_DATA key); int (*wipe)(struct db_context *db); + int (*check)(struct db_context *db); void (*id)(struct db_context *db, const uint8_t **id, size_t *idlen); void *private_data; enum dbwrap_lock_order lock_order; diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c index 1452ff7e8a..fb6841bcb6 100644 --- a/lib/dbwrap/dbwrap_tdb.c +++ b/lib/dbwrap/dbwrap_tdb.c @@ -187,6 +187,13 @@ static int db_tdb_wipe(struct db_context *db) return tdb_wipe_all(ctx->wtdb->tdb); } +static int db_tdb_check(struct db_context *db) +{ + struct db_tdb_ctx *ctx = talloc_get_type_abort( + db->private_data, struct db_tdb_ctx); + return tdb_check(ctx->wtdb->tdb, NULL, NULL); +} + struct db_tdb_parse_state { void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data); @@ -434,6 +441,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx, result->exists = db_tdb_exists; result->wipe = db_tdb_wipe; result->id = db_tdb_id; + result->check = db_tdb_check; result->stored_callback = NULL; return result; |