Пример #1
0
/*
 * list_print_checkpoint --
 *	List the checkpoint information.
 */
static int
list_print_checkpoint(WT_SESSION *session, const char *key)
{
    WT_DECL_RET;
    WT_CKPT *ckpt, *ckptbase;
    size_t len;
    time_t t;
    uint64_t v;

    /*
     * We may not find any checkpoints for this file, in which case we don't
     * report an error, and continue our caller's loop.  Otherwise, read the
     * list of checkpoints and print each checkpoint's name and time.
     */
    if ((ret = __wt_metadata_get_ckptlist(session, key, &ckptbase)) != 0)
        return (ret == WT_NOTFOUND ? 0 : ret);

    /* Find the longest name, so we can pretty-print. */
    len = 0;
    WT_CKPT_FOREACH(ckptbase, ckpt)
    if (strlen(ckpt->name) > len)
        len = strlen(ckpt->name);
    ++len;

    WT_CKPT_FOREACH(ckptbase, ckpt) {
        /*
         * Call ctime, not ctime_r; ctime_r has portability problems,
         * the Solaris version is different from the POSIX standard.
         */
        t = (time_t)ckpt->sec;
        printf("\t%*s: %.24s", (int)len, ckpt->name, ctime(&t));

        v = ckpt->ckpt_size;
        if (v >= WT_PETABYTE)
            printf(" (%" PRIu64 " PB)\n", v / WT_PETABYTE);
        else if (v >= WT_TERABYTE)
            printf(" (%" PRIu64 " TB)\n", v / WT_TERABYTE);
        else if (v >= WT_GIGABYTE)
            printf(" (%" PRIu64 " GB)\n", v / WT_GIGABYTE);
        else if (v >= WT_MEGABYTE)
            printf(" (%" PRIu64 " MB)\n", v / WT_MEGABYTE);
        else if (v >= WT_KILOBYTE)
            printf(" (%" PRIu64 " KB)\n", v / WT_KILOBYTE);
        else
            printf(" (%" PRIu64 " B)\n", v);
    }
Пример #2
0
/*
 * list_print_checkpoint --
 *	List the checkpoint information.
 */
static int
list_print_checkpoint(WT_SESSION *session, const char *key)
{
	WT_BLOCK_CKPT ci;
	WT_DECL_RET;
	WT_CKPT *ckpt, *ckptbase;
	size_t allocsize, len;
	time_t t;
	uint64_t v;

	/*
	 * We may not find any checkpoints for this file, in which case we don't
	 * report an error, and continue our caller's loop.  Otherwise, read the
	 * list of checkpoints and print each checkpoint's name and time.
	 */
	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)
		return (ret);

	/* Find the longest name, so we can pretty-print. */
	len = 0;
	WT_CKPT_FOREACH(ckptbase, ckpt)
		if (strlen(ckpt->name) > len)
			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) {
			(void)util_err(session, ret, "__wt_block_ckpt_decode");
			/* 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.
		 */
		t = (time_t)ckpt->sec;
		printf("\t%*s: %.24s", (int)len, ckpt->name, ctime(&t));

		v = ckpt->ckpt_size;
		if (v >= WT_PETABYTE)
			printf(" (%" PRIu64 " PB)\n", v / WT_PETABYTE);
		else if (v >= WT_TERABYTE)
			printf(" (%" PRIu64 " TB)\n", v / WT_TERABYTE);
		else if (v >= WT_GIGABYTE)
			printf(" (%" PRIu64 " GB)\n", v / WT_GIGABYTE);
		else if (v >= WT_MEGABYTE)
			printf(" (%" PRIu64 " MB)\n", v / WT_MEGABYTE);
		else if (v >= WT_KILOBYTE)
			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_checksum, ci.root_checksum);
		}
	}

	__wt_metadata_free_ckptlist(session, ckptbase);
	return (0);
}