dovecot-2.0: util/*view binaries are now accessed via "doveadm d...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Oct 9 03:49:37 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/c862648185b8
changeset: 10007:c862648185b8
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 08 20:43:25 2009 -0400
description:
util/*view binaries are now accessed via "doveadm dump".
listview binary stays for now, since mailbox list indexes won't work
anyway and they might get a complete redesign.
diffstat:
15 files changed, 1399 insertions(+), 1300 deletions(-)
.hgignore | 4
src/doveadm/Makefile.am | 6
src/doveadm/doveadm-dump-index.c | 531 +++++++++++++++++++++++++++++++++
src/doveadm/doveadm-dump-log.c | 505 +++++++++++++++++++++++++++++++
src/doveadm/doveadm-dump-mailboxlog.c | 121 +++++++
src/doveadm/doveadm-dump-thread.c | 137 ++++++++
src/doveadm/doveadm-dump.c | 79 ++++
src/doveadm/doveadm-dump.h | 17 +
src/doveadm/doveadm.c | 1
src/doveadm/doveadm.h | 1
src/util/Makefile.am | 26 -
src/util/idxview.c | 510 -------------------------------
src/util/logview.c | 492 ------------------------------
src/util/mailboxlogview.c | 90 -----
src/util/threadview.c | 179 -----------
diffs (truncated from 2812 to 300 lines):
diff -r a425ba46a64c -r c862648185b8 .hgignore
--- a/.hgignore Thu Oct 08 20:10:49 2009 -0400
+++ b/.hgignore Thu Oct 08 20:43:25 2009 -0400
@@ -79,14 +79,10 @@ src/pop3-login/pop3-login
src/pop3-login/pop3-login
src/pop3/pop3
src/util/gdbhelper
-src/util/idxview
src/util/imap-utf7
src/util/listview
-src/util/logview
-src/util/mailboxlogview
src/util/maildirlock
src/util/rawlog
-src/util/threadview
src/plugins/quota/rquota_xdr.c
src/plugins/quota/rquota.h
diff -r a425ba46a64c -r c862648185b8 src/doveadm/Makefile.am
--- a/src/doveadm/Makefile.am Thu Oct 08 20:10:49 2009 -0400
+++ b/src/doveadm/Makefile.am Thu Oct 08 20:43:25 2009 -0400
@@ -30,8 +30,14 @@ doveadm_SOURCES = \
doveadm_SOURCES = \
doveadm.c \
doveadm-auth.c \
+ doveadm-dump.c \
+ doveadm-dump-index.c \
+ doveadm-dump-log.c \
+ doveadm-dump-mailboxlog.c \
+ doveadm-dump-thread.c \
doveadm-mail.c \
doveadm-pw.c
noinst_HEADERS = \
+ doveadm-dump.h \
doveadm-mail.h
diff -r a425ba46a64c -r c862648185b8 src/doveadm/doveadm-dump-index.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/doveadm/doveadm-dump-index.c Thu Oct 08 20:43:25 2009 -0400
@@ -0,0 +1,531 @@
+/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "array.h"
+#include "str.h"
+#include "hex-binary.h"
+#include "file-lock.h"
+#include "mail-index-private.h"
+#include "mail-cache-private.h"
+#include "mail-cache-private.h"
+#include "mail-index-modseq.h"
+#include "doveadm-dump.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+struct maildir_index_header {
+ uint32_t new_check_time, new_mtime, new_mtime_nsecs;
+ uint32_t cur_check_time, cur_mtime, cur_mtime_nsecs;
+ uint32_t uidlist_mtime, uidlist_mtime_nsecs, uidlist_size;
+};
+struct mbox_index_header {
+ uint64_t sync_size;
+ uint32_t sync_mtime;
+ uint8_t dirty_flag;
+ uint8_t unused[3];
+ uint8_t mailbox_guid[16];
+};
+struct dbox_index_header {
+ uint32_t map_uid_validity;
+ uint32_t highest_maildir_uid;
+ uint8_t mailbox_guid[16];
+};
+struct dbox_mail_index_record {
+ uint32_t map_uid;
+ uint32_t save_date;
+};
+
+struct virtual_mail_index_record {
+ uint32_t mailbox_id;
+ uint32_t real_uid;
+};
+
+struct dbox_mail_index_map_record {
+ uint32_t file_id;
+ uint32_t offset;
+ uint32_t size;
+};
+
+static const char *unixdate2str(time_t timestamp)
+{
+ static char buf[64];
+ struct tm *tm;
+
+ tm = localtime(×tamp);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
+ return buf;
+}
+
+static void dump_hdr(struct mail_index *index)
+{
+ const struct mail_index_header *hdr = &index->map->hdr;
+ unsigned int i;
+
+ printf("version .................. = %u.%u\n", hdr->major_version, hdr->minor_version);
+ printf("base header size ......... = %u\n", hdr->base_header_size);
+ printf("header size .............. = %u\n", hdr->header_size);
+ printf("record size .............. = %u\n", hdr->record_size);
+ printf("compat flags ............. = %u\n", hdr->compat_flags);
+ printf("index id ................. = %u (%s)\n", hdr->indexid, unixdate2str(hdr->indexid));
+ printf("flags .................... = %u\n", hdr->flags);
+ printf("uid validity ............. = %u (%s)\n", hdr->uid_validity, unixdate2str(hdr->uid_validity));
+ printf("next uid ................. = %u\n", hdr->next_uid);
+ printf("messages count ........... = %u\n", hdr->messages_count);
+ printf("seen messages count ...... = %u\n", hdr->seen_messages_count);
+ printf("deleted messages count ... = %u\n", hdr->deleted_messages_count);
+ printf("first recent uid ......... = %u\n", hdr->first_recent_uid);
+ printf("first unseen uid lowwater = %u\n", hdr->first_unseen_uid_lowwater);
+ printf("first deleted uid lowwater = %u\n", hdr->first_deleted_uid_lowwater);
+ printf("log file seq ............. = %u\n", hdr->log_file_seq);
+ if (hdr->minor_version == 0) {
+ printf("log file int offset ...... = %u\n", hdr->log_file_tail_offset);
+ printf("log file ext offset ...... = %u\n", hdr->log_file_head_offset);
+ } else {
+ printf("log file tail offset ..... = %u\n", hdr->log_file_tail_offset);
+ printf("log file head offset ..... = %u\n", hdr->log_file_head_offset);
+ }
+ printf("sync size ................ = %llu\n", (unsigned long long)hdr->sync_size);
+ printf("sync stamp ............... = %u (%s)\n", hdr->sync_stamp, unixdate2str(hdr->sync_stamp));
+ printf("day stamp ................ = %u (%s)\n", hdr->day_stamp, unixdate2str(hdr->day_stamp));
+ for (i = 0; i < N_ELEMENTS(hdr->day_first_uid); i++)
+ printf("day first uid[%u] ......... = %u\n", i, hdr->day_first_uid[i]);
+}
+
+static void dump_extension_header(struct mail_index *index,
+ const struct mail_index_ext *ext)
+{
+ const void *data;
+
+ if (strcmp(ext->name, MAIL_INDEX_EXT_KEYWORDS) == 0)
+ return;
+
+ data = CONST_PTR_OFFSET(index->map->hdr_base, ext->hdr_offset);
+ if (strcmp(ext->name, "maildir") == 0) {
+ const struct maildir_index_header *hdr = data;
+
+ printf("header\n");
+ printf(" - new_check_time .... = %s\n", unixdate2str(hdr->new_check_time));
+ printf(" - new_mtime ......... = %s\n", unixdate2str(hdr->new_mtime));
+ printf(" - new_mtime_nsecs ... = %u\n", hdr->new_mtime_nsecs);
+ printf(" - cur_check_time .... = %s\n", unixdate2str(hdr->cur_check_time));
+ printf(" - cur_mtime ......... = %s\n", unixdate2str(hdr->cur_mtime));
+ printf(" - cur_mtime_nsecs.... = %u\n", hdr->cur_mtime_nsecs);
+ printf(" - uidlist_mtime ..... = %s\n", unixdate2str(hdr->uidlist_mtime));
+ printf(" - uidlist_mtime_nsecs = %u\n", hdr->uidlist_mtime_nsecs);
+ printf(" - uidlist_size ...... = %u\n", hdr->uidlist_size);
+ } else if (strcmp(ext->name, "mbox") == 0) {
+ const struct mbox_index_header *hdr = data;
+
+ printf("header\n");
+ printf(" - sync_mtime . = %s\n", unixdate2str(hdr->sync_mtime));
+ printf(" - sync_size .. = %llu\n",
+ (unsigned long long)hdr->sync_size);
+ printf(" - dirty_flag . = %d\n", hdr->dirty_flag);
+ printf(" - mailbox_guid = %s\n",
+ binary_to_hex(hdr->mailbox_guid,
+ sizeof(hdr->mailbox_guid)));
+ } else if (strcmp(ext->name, "dbox-hdr") == 0) {
+ const struct dbox_index_header *hdr = data;
+
+ printf("header\n");
+ printf(" - map_uid_validity .. = %u\n", hdr->map_uid_validity);
+ printf(" - highest_maildir_uid = %u\n", hdr->highest_maildir_uid);
+ printf(" - mailbox_guid ...... = %s\n",
+ binary_to_hex(hdr->mailbox_guid,
+ sizeof(hdr->mailbox_guid)));
+ } else if (strcmp(ext->name, "modseq") == 0) {
+ const struct mail_index_modseq_header *hdr = data;
+
+ printf("header\n");
+ printf(" - highest_modseq = %llu\n",
+ (unsigned long long)hdr->highest_modseq);
+ printf(" - log_seq ...... = %u\n", hdr->log_seq);
+ printf(" - log_offset ... = %u\n", hdr->log_offset);
+ } else {
+ printf("header ........ = %s\n",
+ binary_to_hex(data, ext->hdr_size));
+ }
+}
+
+static void dump_extensions(struct mail_index *index)
+{
+ const struct mail_index_ext *extensions;
+ unsigned int i, count;
+
+ if (array_is_created(&index->map->extensions))
+ extensions = array_get(&index->map->extensions, &count);
+ else
+ count = 0;
+ if (count == 0) {
+ printf("no extensions\n");
+ return;
+ }
+
+ for (i = 0; i < count; i++) {
+ const struct mail_index_ext *ext = &extensions[i];
+
+ printf("-- Extension %u --\n", i);
+ printf("name ........ = %s\n", ext->name);
+ printf("hdr_size .... = %u\n", ext->hdr_size);
+ printf("reset_id .... = %u\n", ext->reset_id);
+ printf("record_offset = %u\n", ext->record_offset);
+ printf("record_size . = %u\n", ext->record_size);
+ printf("record_align = %u\n", ext->record_align);
+ if (ext->hdr_size > 0)
+ dump_extension_header(index, ext);
+ }
+}
+
+static void dump_keywords(struct mail_index *index)
+{
+ const unsigned int *kw_indexes;
+ const char *const *keywords;
+ unsigned int i, count;
+
+ printf("-- Keywords --\n");
+ if (!array_is_created(&index->map->keyword_idx_map))
+ return;
+
+ kw_indexes = array_get(&index->map->keyword_idx_map, &count);
+ if (count == 0)
+ return;
+
+ keywords = array_idx(&index->keywords, 0);
+ for (i = 0; i < count; i++)
+ printf("%3u = %s\n", i, keywords[kw_indexes[i]]);
+}
+
+static const char *cache_decision2str(enum mail_cache_decision_type type)
+{
+ const char *str;
+
+ switch (type & ~MAIL_CACHE_DECISION_FORCED) {
+ case MAIL_CACHE_DECISION_NO:
+ str = "no";
+ break;
+ case MAIL_CACHE_DECISION_TEMP:
+ str = "tmp";
+ break;
+ case MAIL_CACHE_DECISION_YES:
+ str = "yes";
+ break;
+ default:
+ return t_strdup_printf("0x%x", type);
+ }
+
+ if ((type & MAIL_CACHE_DECISION_FORCED) != 0)
+ str = t_strconcat(str, "!", NULL);
+ return str;
+}
+
+#define CACHE_TYPE_IS_FIXED_SIZE(type) \
+ ((type) == MAIL_CACHE_FIELD_FIXED_SIZE || \
+ (type) == MAIL_CACHE_FIELD_BITMASK)
+static const char *cache_type2str(enum mail_cache_field_type type)
+{
+ switch (type) {
+ case MAIL_CACHE_FIELD_FIXED_SIZE:
+ return "fix";
+ case MAIL_CACHE_FIELD_VARIABLE_SIZE:
+ return "var";
+ case MAIL_CACHE_FIELD_STRING:
+ return "str";
+ case MAIL_CACHE_FIELD_BITMASK:
+ return "bit";
+ case MAIL_CACHE_FIELD_HEADER:
+ return "hdr";
+ default:
+ return t_strdup_printf("0x%x", type);
+ }
+}
+
+static void dump_cache_hdr(struct mail_cache *cache)
+{
+ const struct mail_cache_header *hdr;
+ const struct mail_cache_field *fields, *field;
+ unsigned int i, count, cache_idx;
+
+ (void)mail_cache_open_and_verify(cache);
+ if (MAIL_CACHE_IS_UNUSABLE(cache)) {
+ printf("cache is unusable\n");
+ return;
+ }
+
+ hdr = cache->hdr;
+ printf("version .............. = %u\n", hdr->version);
+ printf("indexid .............. = %u (%s)\n", hdr->indexid, unixdate2str(hdr->indexid));
+ printf("file_seq ............. = %u (%s) (%d compressions)\n",
+ hdr->file_seq, unixdate2str(hdr->file_seq),
More information about the dovecot-cvs
mailing list