The Samba-Bugzilla – Attachment 3703 Details for
Bug 5800
please provide "tdbtool check" subcommand
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
reviewed patch
0001-Added-a-simple-tdb-integrity-check-to-tdbtool.-The-c.patch (text/plain), 2.24 KB, created by
Holger Hetterich
on 2008-11-01 17:46:29 UTC
(
hide
)
Description:
reviewed patch
Filename:
MIME Type:
Creator:
Holger Hetterich
Created:
2008-11-01 17:46:29 UTC
Size:
2.24 KB
patch
obsolete
>From ab83d1a0494f10e4e85b10fce591698c288bd1d3 Mon Sep 17 00:00:00 2001 >From: Holger Hetterich <hhetter@novell.com> >Date: Sat, 1 Nov 2008 23:44:06 +0100 >Subject: [PATCH] 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. > >--- > lib/tdb/tools/tdbtool.c | 27 +++++++++++++++++++++++++++ > 1 files changed, 27 insertions(+), 0 deletions(-) > >diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c >index d104ccd..31ffcba 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,6 +181,7 @@ 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" >+" 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" >@@ -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 (tdb) { >+ tdbcount = tdb_traverse(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; >-- >1.5.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5800
:
3702
|
3703
|
3704
|
3755