summaryrefslogtreecommitdiffabout
path: root/src/gdbmtool.c
Side-by-side diff
Diffstat (limited to 'src/gdbmtool.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/gdbmtool.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 33bdf93..9c6eebe 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -549,30 +549,35 @@ err_printer (void *data GDBM_ARG_UNUSED, char const *fmt, ...)
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
fprintf (stderr, "\n");
}
-/* recover verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */
+/* recover sumamry verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */
void
recover_handler (struct handler_param *param)
{
gdbm_recovery rcvr;
int flags = 0;
int rc;
int i;
char *p;
+ int summary = 0;
- for (i = 1; i < param->argc; i++)
+ for (i = 0; i < param->argc; i++)
{
char *arg = PARAM_STRING (param, i);
if (strcmp (arg, "verbose") == 0)
{
rcvr.errfun = err_printer;
flags |= GDBM_RCVR_ERRFUN;
}
+ else if (strcmp (arg, "summary") == 0)
+ {
+ summary = 1;
+ }
else if (strcmp (arg, "backup") == 0)
{
rcvr.errfun = err_printer;
flags |= GDBM_RCVR_BACKUP;
}
else if (strncmp (arg, "max-failures=", 13) == 0)
@@ -614,12 +619,25 @@ recover_handler (struct handler_param *param)
rc = gdbm_recover (gdbm_file, &rcvr, flags);
if (rc == 0)
{
fprintf (param->fp, _("Recovery succeeded.\n"));
+ if (summary)
+ {
+ fprintf (param->fp,
+ _("Keys recovered: %lu, failed: %lu, duplicate: %lu\n"),
+ (unsigned long) rcvr.recovered_keys,
+ (unsigned long) rcvr.failed_keys,
+ (unsigned long) rcvr.duplicate_keys);
+ fprintf (param->fp,
+ _("Buckets recovered: %lu, failed: %lu\n"),
+ (unsigned long) rcvr.recovered_buckets,
+ (unsigned long) rcvr.failed_buckets);
+ }
+
if (rcvr.backup_name)
{
fprintf (param->fp,
_("Original database preserved in file %s"),
rcvr.backup_name);
free (rcvr.backup_name);
@@ -922,13 +940,13 @@ export_handler (struct handler_param *param)
{
int format = GDBM_DUMP_FMT_ASCII;
int flags = GDBM_WRCREAT;
int i;
int filemode;
- for (i = 1; i < param->argc; i++)
+ for (i = 0; i < param->argc; i++)
{
if (strcmp (PARAM_STRING (param, i), "truncate") == 0)
flags = GDBM_NEWDB;
else if (strcmp (PARAM_STRING (param, i), "binary") == 0)
format = GDBM_DUMP_FMT_BINARY;
else if (strcmp (PARAM_STRING (param, i), "ascii") == 0)
@@ -956,13 +974,13 @@ import_handler (struct handler_param *param)
int flag = GDBM_INSERT;
unsigned long err_line;
int meta_mask = 0;
int i;
int rc;
- for (i = 1; i < param->argc; i++)
+ for (i = 0; i < param->argc; i++)
{
if (strcmp (PARAM_STRING (param, i), "replace") == 0)
flag = GDBM_REPLACE;
else if (strcmp (PARAM_STRING (param, i), "nometa") == 0)
meta_mask = GDBM_META_MASK_MODE | GDBM_META_MASK_OWNER;
else
@@ -1217,12 +1235,13 @@ struct command command_tab[] = {
FALSE,
REPEAT_NEVER,
N_("reorganize") },
{ S(recover), T_CMD,
checkdb, recover_handler, NULL,
{ { "[verbose]", GDBM_ARG_STRING },
+ { "[summary]", GDBM_ARG_STRING },
{ "[backup]", GDBM_ARG_STRING },
{ "[max-failed-keys=N]", GDBM_ARG_STRING },
{ "[max-failed-buckets=N]", GDBM_ARG_STRING },
{ "[max-failures=N]", GDBM_ARG_STRING },
{ NULL } },
FALSE,

Return to:

Send suggestions and report system problems to the System administrator.