summaryrefslogtreecommitdiffstats
path: root/source3/tdb/tdbtool.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-12-07 17:46:11 +0000
committerJeremy Allison <jra@samba.org>2000-12-07 17:46:11 +0000
commit0d658c35eb9d8ec400ad0302ee11d489bb59bd77 (patch)
tree376abfc6819522969a926a5a8d91f0f7c2b693a8 /source3/tdb/tdbtool.c
parentc31211167bc2b98f51f8f3cc70bb410250b427aa (diff)
downloadsamba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.tar.gz
samba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.tar.xz
samba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.zip
Fixed bug with tdb_next_lock failing when reaching then end of a hashchain
and the next hashchain is empty. Jeremy (This used to be commit f3b5e2a172a777e1c3bbf6ac72fe5c7cdb8324b3)
Diffstat (limited to 'source3/tdb/tdbtool.c')
-rw-r--r--source3/tdb/tdbtool.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c
index 0373aee9a70..508adc5d549 100644
--- a/source3/tdb/tdbtool.c
+++ b/source3/tdb/tdbtool.c
@@ -68,6 +68,8 @@ tdbtool:
show key : show a record by key
delete key : delete a record by key
free : print the database freelist
+ first : print the first record
+ next : print the next record
");
}
@@ -221,10 +223,33 @@ static int do_delete_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf,
return tdb_delete(tdb, key);
}
+static void first_record(TDB_CONTEXT *tdb, TDB_DATA *pkey)
+{
+ TDB_DATA dbuf;
+ *pkey = tdb_firstkey(tdb);
+
+ dbuf = tdb_fetch(tdb, *pkey);
+ if (!dbuf.dptr) terror("fetch failed");
+ /* printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); */
+ print_rec(tdb, *pkey, dbuf, NULL);
+}
+
+static void next_record(TDB_CONTEXT *tdb, TDB_DATA *pkey)
+{
+ TDB_DATA dbuf;
+ *pkey = tdb_nextkey(tdb, *pkey);
+
+ dbuf = tdb_fetch(tdb, *pkey);
+ if (!dbuf.dptr) terror("fetch failed");
+ /* printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); */
+ print_rec(tdb, *pkey, dbuf, NULL);
+}
+
int main(int argc, char *argv[])
{
char *line;
char *tok;
+ TDB_DATA iterate_kbuf;
if (argv[1]) {
static char tmp[1024];
@@ -276,6 +301,10 @@ int main(int argc, char *argv[])
info_tdb();
} else if (strcmp(tok, "free") == 0) {
tdb_printfreelist(tdb);
+ } else if (strcmp(tok, "first") == 0) {
+ first_record(tdb, &iterate_kbuf);
+ } else if (strcmp(tok, "next") == 0) {
+ next_record(tdb, &iterate_kbuf);
} else {
help();
}