mail-index-fsck.c revision d67f6ca7e313e9192268f6bf9952594524655dcd
/* Copyright (c) 2004-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "mail-index-private.h"
#include "mail-transaction-log-private.h"
const char *fmt, ...)
{
}
}
static void
struct mail_index_header *hdr)
{
sizeof(struct mail_transaction_log_header);
} else {
}
CHECK(log_file_seq, !=);
/* don't bother complaining about these if file changed too */
CHECK(log_file_head_offset, !=);
CHECK(log_file_tail_offset, !=);
}
}
static void
struct mail_index_header *hdr)
{
/* mail_index_map_check_header() has already checked that the index
isn't completely broken. */
}
static bool
{
const char *const *str;
unsigned int i, count;
for (i = 0; i < count; i++) {
return TRUE;
}
return FALSE;
}
static unsigned int
const struct mail_index_ext_header *ext_hdr)
{
const struct mail_index_record *rec;
if (kw[i] != 0) {
for (j = 0; j < 8; j++) {
if ((kw[i] & (1 << j)) != 0)
}
}
}
return max;
}
}
return max;
}
static bool
{
return TRUE;
/* control characters aren't valid */
return FALSE;
}
}
return FALSE;
}
static void
struct mail_index_header *hdr,
const struct mail_index_ext_header *ext_hdr,
unsigned int ext_offset, unsigned int *offset_p)
{
const struct mail_index_keyword_header *kw_hdr;
struct mail_index_keyword_header *new_kw_hdr;
const struct mail_index_keyword_header_rec *kw_rec;
hdr_offset = ext_offset +
/* the header is completely broken */
name_size = 0;
} else {
}
/* create keyword name array. invalid keywords are added as
empty strings */
for (i = 0; i < keywords_count; i++) {
if (name_size == 0 ||
name = "";
else
/* duplicate */
name = "";
}
}
/* give new names to invalid keywords */
changed_count = 0;
for (i = j = 0; i < keywords_count; i++) {
while (name_array[i][0] == '\0') {
name_array[i] = name;
}
}
}
if (!changed) {
/* nothing was broken */
return;
}
/* add keyword records so we can start appending names directly */
/* write the actual records and names */
for (i = 0; i < keywords_count; i++) {
}
/* keep the header size at least the same size as before */
/* need to resize the header */
struct mail_index_ext_header new_ext_hdr;
new_ext_hdr = *ext_hdr;
&new_ext_hdr, sizeof(new_ext_hdr));
}
/* keywords changed unexpectedly, so all views are broken now */
buffer_free(&dest);
}
static void
struct mail_index_header *hdr)
{
const struct mail_index_ext_header *ext_hdr;
unsigned int offset, ext_offset, i;
ext_offset = offset;
/* the extension continued outside header, drop it */
"Dropped extension #%d (%s) "
"with invalid header size",
i, name);
break;
}
&error) < 0) {
"Dropped broken extension #%d (%s)", i, name);
"Dropped duplicate extension %s", name);
} else {
/* name may change if header buffer is changed */
&offset);
}
continue;
}
/* drop the field */
offset = ext_offset;
}
}
static void
struct mail_index_header *hdr)
{
bool records_dropped = FALSE;
hdr->messages_count = 0;
hdr->seen_messages_count = 0;
hdr->deleted_messages_count = 0;
hdr->first_unseen_uid_lowwater = 0;
/* log an error once, and skip this record */
if (!logged_zero_uids) {
"Record UIDs have zeroes");
}
} else {
if (!logged_unordered_uids) {
"Record UIDs unordered");
}
}
/* not the fastest way when we're skipping lots of
records, but this should happen rarely so don't
bother optimizing. */
continue;
}
hdr->messages_count++;
hdr->first_unseen_uid_lowwater == 0)
hdr->first_deleted_uid_lowwater == 0)
i++;
}
if (records_dropped) {
/* all existing views are broken now */
}
}
if (hdr->first_unseen_uid_lowwater == 0)
if (hdr->first_deleted_uid_lowwater == 0)
if (hdr->first_recent_uid == 0)
CHECK(uid_validity, !=);
CHECK(messages_count, !=);
CHECK(seen_messages_count, !=);
CHECK(deleted_messages_count, !=);
CHECK(first_recent_uid, !=);
}
static void
{
struct mail_index_header hdr;
/* Remember the log head position. If we go back in the index's
head offset, ignore errors in the log up to this offset. */
}
}
{
struct mail_index_map *map;
/* we're trying to open the index files, but there wasn't
any .log file. this should be rare, so just fsck it without
locking. */
orig_locked = TRUE;
}
if (!orig_locked) {
&file_offset) < 0)
return -1;
}
T_BEGIN {
} T_END;
if (!orig_locked)
return 0;
}
{
int ret;
}