mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
Added print_freelist command.
Jeremy.
This commit is contained in:
parent
b64e1ae693
commit
ee89ca9e68
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user