From d8cfca3a9bd2b6b6c562fd202377d95a98eb5472 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 May 2011 11:25:29 +0200 Subject: s3: only include tdb headers where needed. Guenther --- source3/lib/tdb_validate.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/tdb_validate.c') diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index b91ea7af834..7dd7dae5ac1 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -21,6 +21,7 @@ #include "includes.h" #include "system/filesys.h" +#include "util_tdb.h" #include "tdb_validate.h" /* -- cgit From 5a7874e119acbc80410b2f2c1847371236c22a56 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_traverse/tdb_traverse_read: check returns for negative, not -1. TDB2 returns a negative error number on failure. This is compatible if we always check for < 0 instead of == -1. Also, there's no tdb_traverse_read in TDB2: we don't try to make traverse reliable any more, so there are no write locks anyway. Signed-off-by: Rusty Russell --- source3/lib/tdb_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/tdb_validate.c') diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index 7dd7dae5ac1..210d91eeb04 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -71,7 +71,7 @@ static int tdb_validate_child(struct tdb_context *tdb, num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status); if (!v_status.success) { goto out; - } else if (num_entries == -1) { + } else if (num_entries < 0) { v_status.tdb_error = True; v_status.success = False; goto out; -- cgit From 61867eaa8458431c452352df021169c100fa9188 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:32 +0930 Subject: tdb_validate: TDB2 support for tdb_validate_child and tdb_backup. We don't expose freelist or hash size for TDB2. Signed-off-by: Rusty Russell --- source3/lib/tdb_validate.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/lib/tdb_validate.c') diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index 210d91eeb04..617160ee86b 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -57,6 +57,7 @@ static int tdb_validate_child(struct tdb_context *tdb, goto out; } +#ifndef BUILD_TDB2 /* Check if the tdb's freelist is good. */ if (tdb_validate_freelist(tdb, &num_entries) == -1) { v_status.bad_freelist = True; @@ -66,6 +67,7 @@ static int tdb_validate_child(struct tdb_context *tdb, DEBUG(10,("tdb_validate_child: tdb %s freelist has %d entries\n", tdb_name(tdb), num_entries)); +#endif /* Now traverse the tdb to validate it. */ num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status); @@ -289,8 +291,14 @@ static int tdb_backup(TALLOC_CTX *ctx, const char *src_path, } unlink(tmp_path); - dst_tdb = tdb_open_log(tmp_path, - hash_size ? hash_size : tdb_hash_size(src_tdb), + +#ifndef BUILD_TDB2 + if (!hash_size) { + hash_size = tdb_hash_size(src_tdb); + } +#endif + + dst_tdb = tdb_open_log(tmp_path, hash_size, TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, st.st_mode & 0777); if (dst_tdb == NULL) { -- cgit From d925b327f4703cc141c0a7f3eec912dba8440880 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:33 +0930 Subject: tdb_compat: Higher level API fixes. My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell --- source3/lib/tdb_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/tdb_validate.c') diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index 617160ee86b..385f4d0ef81 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -51,7 +51,7 @@ static int tdb_validate_child(struct tdb_context *tdb, * but I don't want to change all the callers... */ ret = tdb_check(tdb, NULL, NULL); - if (ret == -1) { + if (ret != 0) { v_status.tdb_error = True; v_status.success = False; goto out; -- cgit