summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/utilities/util_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/utilities/util_list.c')
-rw-r--r--src/third_party/wiredtiger/src/utilities/util_list.c75
1 files changed, 73 insertions, 2 deletions
diff --git a/src/third_party/wiredtiger/src/utilities/util_list.c b/src/third_party/wiredtiger/src/utilities/util_list.c
index 99a1455a74e..c7afea04b1c 100644
--- a/src/third_party/wiredtiger/src/utilities/util_list.c
+++ b/src/third_party/wiredtiger/src/utilities/util_list.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -8,6 +8,7 @@
#include "util.h"
+static int list_get_allocsize(WT_SESSION *, const char *, size_t *);
static int list_print(WT_SESSION *, const char *, bool, bool);
static int list_print_checkpoint(WT_SESSION *, const char *);
static int usage(void);
@@ -56,6 +57,48 @@ util_list(WT_SESSION *session, int argc, char *argv[])
}
/*
+ * list_get_allocsize --
+ * Get the allocation size for this file from the metadata.
+ */
+static int
+list_get_allocsize(WT_SESSION *session, const char *key, size_t *allocsize)
+{
+ WT_CONFIG_ITEM szvalue;
+ WT_CONFIG_PARSER *parser;
+ WT_DECL_RET;
+ WT_EXTENSION_API *wt_api;
+ char *config;
+
+ wt_api = session->connection->get_extension_api(session->connection);
+ if ((ret =
+ wt_api->metadata_search(wt_api, session, key, &config)) != 0) {
+ fprintf(stderr, "%s: %s: extension_api.metadata_search: %s\n",
+ progname, key, session->strerror(session, ret));
+ return (ret);
+ }
+ if ((ret = wt_api->config_parser_open(wt_api, session, config,
+ strlen(config), &parser)) != 0) {
+ fprintf(stderr, "%s: extension_api.config_parser_open: %s\n",
+ progname, session->strerror(session, ret));
+ return (ret);
+ }
+ if ((ret = parser->get(parser, "allocation_size", &szvalue)) != 0) {
+ if (ret != WT_NOTFOUND)
+ fprintf(stderr, "%s: config_parser.get: %s\n",
+ progname, session->strerror(session, ret));
+ (void)parser->close(parser);
+ return (ret);
+ }
+ if ((ret = parser->close(parser)) != 0) {
+ fprintf(stderr, "%s: config_parser.close: %s\n",
+ progname, session->strerror(session, ret));
+ return (ret);
+ }
+ *allocsize = (size_t)szvalue.val;
+ return (0);
+}
+
+/*
* list_print --
* List the high-level objects in the database.
*/
@@ -137,9 +180,10 @@ list_print(WT_SESSION *session, const char *name, bool cflag, bool vflag)
static int
list_print_checkpoint(WT_SESSION *session, const char *key)
{
+ WT_BLOCK_CKPT ci;
WT_DECL_RET;
WT_CKPT *ckpt, *ckptbase;
- size_t len;
+ size_t allocsize, len;
time_t t;
uint64_t v;
@@ -151,6 +195,14 @@ list_print_checkpoint(WT_SESSION *session, const char *key)
if ((ret = __wt_metadata_get_ckptlist(session, key, &ckptbase)) != 0)
return (ret == WT_NOTFOUND ? 0 : ret);
+ /* We need the allocation size for decoding the checkpoint addr */
+ if ((ret = list_get_allocsize(session, key, &allocsize)) != 0) {
+ if (ret == WT_NOTFOUND)
+ allocsize = 0;
+ else
+ return (ret);
+ }
+
/* Find the longest name, so we can pretty-print. */
len = 0;
WT_CKPT_FOREACH(ckptbase, ckpt)
@@ -158,7 +210,15 @@ list_print_checkpoint(WT_SESSION *session, const char *key)
len = strlen(ckpt->name);
++len;
+ memset(&ci, 0, sizeof(ci));
WT_CKPT_FOREACH(ckptbase, ckpt) {
+ if (allocsize != 0 && (ret = __wt_block_ckpt_decode(
+ session, allocsize, ckpt->raw.data, &ci)) != 0) {
+ fprintf(stderr, "%s: __wt_block_buffer_to_ckpt: %s\n",
+ progname, session->strerror(session, ret));
+ /* continue if damaged */
+ ci.root_size = 0;
+ }
/*
* Call ctime, not ctime_r; ctime_r has portability problems,
* the Solaris version is different from the POSIX standard.
@@ -179,6 +239,17 @@ list_print_checkpoint(WT_SESSION *session, const char *key)
printf(" (%" PRIu64 " KB)\n", v / WT_KILOBYTE);
else
printf(" (%" PRIu64 " B)\n", v);
+ if (ci.root_size != 0) {
+ printf("\t\t" "root offset: %" PRIuMAX
+ " (0x%" PRIxMAX ")\n",
+ (intmax_t)ci.root_offset, (intmax_t)ci.root_offset);
+ printf("\t\t" "root size: %" PRIu32
+ " (0x%" PRIx32 ")\n",
+ ci.root_size, ci.root_size);
+ printf("\t\t" "root checksum: %" PRIu32
+ " (0x%" PRIx32 ")\n",
+ ci.root_cksum, ci.root_cksum);
+ }
}
__wt_metadata_free_ckptlist(session, ckptbase);