summaryrefslogtreecommitdiff
path: root/source3/tdb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-12-02 01:04:11 +0000
committerJeremy Allison <jra@samba.org>2000-12-02 01:04:11 +0000
commit040de369b2bb983c853577f57da1c972a93a0acf (patch)
treef0158c4165a50b799ff7b6e44e311865c0f889b0 /source3/tdb
parente23067ad65778aed2437d96719968757101ec08e (diff)
downloadsamba-040de369b2bb983c853577f57da1c972a93a0acf.tar.gz
samba-040de369b2bb983c853577f57da1c972a93a0acf.tar.bz2
samba-040de369b2bb983c853577f57da1c972a93a0acf.zip
Added print_freelist command.
Jeremy. (This used to be commit ee89ca9e68abb23fc26cd1378e02e56d0d725e55)
Diffstat (limited to 'source3/tdb')
-rw-r--r--source3/tdb/tdb.c35
-rw-r--r--source3/tdb/tdbtool.c3
2 files changed, 38 insertions, 0 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 7e39e8fa6f..87c145cb8c 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -1308,3 +1308,38 @@ int tdb_unlockchain(TDB_CONTEXT *tdb, TDB_DATA key)
}
+#if TDB_DEBUG
+void tdb_printfreelist(TDB_CONTEXT *tdb)
+{
+ tdb_off offset, rec_ptr, last_ptr;
+ struct list_struct rec, lastrec, newrec;
+
+ tdb_lock(tdb, -1, F_WRLCK);
+
+ last_ptr = 0;
+ offset = FREELIST_TOP;
+
+ /* read in the freelist top */
+ if (ofs_read(tdb, offset, &rec_ptr) == -1) {
+ return;
+ }
+
+ while (rec_ptr) {
+ if (tdb_read(tdb, rec_ptr, (char *)&rec, sizeof(rec)) == -1) {
+ return;
+ }
+
+ if (rec.magic != TDB_FREE_MAGIC) {
+ printf("bad magic 0x%08x in free list\n", rec.magic);
+ return;
+ }
+
+ printf("entry offset=[0x%08x], rec.rec_len = [0x%08x]\n", rec.next, rec.rec_len );
+
+ /* move to the next record */
+ rec_ptr = rec.next;
+ }
+
+ tdb_unlock(tdb, -1);
+}
+#endif
diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c
index 4400f5d8e0..0373aee9a7 100644
--- a/source3/tdb/tdbtool.c
+++ b/source3/tdb/tdbtool.c
@@ -67,6 +67,7 @@ tdbtool:
store key data : store a record (replace)
show key : show a record by key
delete key : delete a record by key
+ free : print the database freelist
");
}
@@ -273,6 +274,8 @@ int main(int argc, char *argv[])
tdb_traverse(tdb, print_rec, NULL);
} else if (strcmp(tok,"info") == 0) {
info_tdb();
+ } else if (strcmp(tok, "free") == 0) {
+ tdb_printfreelist(tdb);
} else {
help();
}