summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-12-17 07:17:54 +1100
committerAndrew Tridgell <tridge@samba.org>2008-12-17 07:17:54 +1100
commit1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3 (patch)
treecee337a9c93890605fb12490faec2a7f0b2188d8 /lib
parente294c4799bf6ad8da043aadf8341391644147056 (diff)
parent54dc421f5820099531a77879f52a904c2fefcf49 (diff)
downloadsamba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.tar.gz
samba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.tar.bz2
samba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/tools/tdbtool.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index d104ccd7c4..2a11cdaef3 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -57,6 +57,7 @@ enum commands {
CMD_FIRST,
CMD_NEXT,
CMD_SYSTEM,
+ CMD_CHECK,
CMD_QUIT,
CMD_HELP
};
@@ -87,6 +88,7 @@ COMMAND_TABLE cmd_table[] = {
{"1", CMD_FIRST},
{"next", CMD_NEXT},
{"n", CMD_NEXT},
+ {"check", CMD_CHECK},
{"quit", CMD_QUIT},
{"q", CMD_QUIT},
{"!", CMD_SYSTEM},
@@ -179,7 +181,8 @@ static void help(void)
" delete key : delete a record by key\n"
" list : print the database hash table and freelist\n"
" free : print the database freelist\n"
-" ! command : execute system command\n"
+" check : check the integrity of an opened database\n"
+" ! command : execute system command\n"
" 1 | first : print the first record\n"
" n | next : print the next record\n"
" q | quit : terminate\n"
@@ -452,6 +455,27 @@ static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
print_rec(the_tdb, *pkey, dbuf, NULL);
}
+static int test_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
+{
+ return 0;
+}
+
+static void check_db(TDB_CONTEXT *the_tdb)
+{
+ int tdbcount=-1;
+ if (the_tdb) {
+ tdbcount = tdb_traverse(the_tdb, test_fn, NULL);
+ } else {
+ printf("Error: No database opened!\n");
+ }
+
+ if (tdbcount<0) {
+ printf("Integrity check for the opened database failed.\n");
+ } else {
+ printf("Database integrity is OK and has %d records.\n", tdbcount);
+ }
+}
+
static int do_command(void)
{
COMMAND_TABLE *ctp = cmd_table;
@@ -552,6 +576,9 @@ static int do_command(void)
if (bIterate)
next_record(tdb, &iterate_kbuf);
return 0;
+ case CMD_CHECK:
+ check_db(tdb);
+ return 0;
case CMD_HELP:
help();
return 0;