diff options
author | Michael Adam <obnox@samba.org> | 2014-02-10 07:39:31 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2014-06-26 10:00:11 +0200 |
commit | 6502df58391cc8d3477d1c5cce4a6aa027d439bd (patch) | |
tree | 6eef9cf77393452974f9347ea42213d917f856bb /lib/tdb/tools | |
parent | 56f9231c8ee3afb7ba7a1f56deee5181522ef5f4 (diff) | |
download | samba-6502df58391cc8d3477d1c5cce4a6aa027d439bd.tar.gz |
tdb: add "freelist_size" sub-command to tdbtool
With the new code, this has the side effect of
merging adjacent records in the freelist if the
database is not read-only.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'lib/tdb/tools')
-rw-r--r-- | lib/tdb/tools/tdbtool.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c index 2f93e338b85..780782b3c45 100644 --- a/lib/tdb/tools/tdbtool.c +++ b/lib/tdb/tools/tdbtool.c @@ -55,6 +55,7 @@ enum commands { CMD_DELETE, CMD_LIST_HASH_FREE, CMD_LIST_FREE, + CMD_FREELIST_SIZE, CMD_INFO, CMD_MMAP, CMD_SPEED, @@ -89,6 +90,7 @@ COMMAND_TABLE cmd_table[] = { {"delete", CMD_DELETE}, {"list", CMD_LIST_HASH_FREE}, {"free", CMD_LIST_FREE}, + {"freelist_size", CMD_FREELIST_SIZE}, {"info", CMD_INFO}, {"speed", CMD_SPEED}, {"mmap", CMD_MMAP}, @@ -232,6 +234,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" +" freelist_size : print the number of records in the freelist\n" " check : check the integrity of an opened database\n" " repack : repack the database\n" " speed : perform speed tests on the database\n" @@ -710,6 +713,18 @@ static int do_command(void) case CMD_LIST_FREE: tdb_printfreelist(tdb); return 0; + case CMD_FREELIST_SIZE: { + int count; + + count = tdb_freelist_size(tdb); + if (count < 0) { + printf("Error getting freelist size.\n"); + } else { + printf("freelist size: %d\n", count); + } + + return 0; + } case CMD_INFO: info_tdb(); return 0; |