[SCM] Samba Shared Repository - branch master updated - 37be72c6c1549195b3fbe5bb1554f5f1cea30894

Karolin Seeger kseeger at samba.org
Tue Dec 16 12:59:36 GMT 2008


The branch, master has been updated
       via  37be72c6c1549195b3fbe5bb1554f5f1cea30894 (commit)
       via  42366bcbbdd42bb9d5821dfcc9dbe71a1eafa330 (commit)
      from  5ee0392a55d3a35692c026f1b88909d7fd2d2666 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 37be72c6c1549195b3fbe5bb1554f5f1cea30894
Author: Holger Hetterich <hhetter at novell.com>
Date:   Thu Nov 20 10:32:14 2008 +0100

    Add an entry for the "check" command to the tdbtool manpage.

commit 42366bcbbdd42bb9d5821dfcc9dbe71a1eafa330
Author: Holger Hetterich <hhetter at novell.com>
Date:   Sun Nov 2 00:12:32 2008 +0100

    Added a simple tdb integrity check to tdbtool. The command "check" runs traverse on the currently open tdb, and returns the number of entries if the integrity check is successful.

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages-3/tdbtool.8.xml |    8 ++++++++
 lib/tdb/tools/tdbtool.c           |   29 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/tdbtool.8.xml b/docs-xml/manpages-3/tdbtool.8.xml
index 3f5dec4..c75059b 100644
--- a/docs-xml/manpages-3/tdbtool.8.xml
+++ b/docs-xml/manpages-3/tdbtool.8.xml
@@ -193,6 +193,14 @@
 
 		<varlistentry>
 		<term>
+		<option>check</option>
+		</term>
+		<listitem><para>Check the integrity of the current database.
+		</para></listitem>
+		</varlistentry>
+
+		<varlistentry>
+		<term>
 		<option>quit</option>
 		</term>
 		<listitem><para>Exit <command>tdbtool</command>.
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index d104ccd..1ecad62 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 *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;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list