mail-index-open.c revision 5024402a628e9a6fc21eb8cdf2778486c6f2f92c
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "file-lock.h"
#include "file-set-size.h"
#include "hostpid.h"
#include "mmap-util.h"
#include "unlink-lockfiles.h"
#include "write-full.h"
#include "mail-index.h"
#include "mail-index-util.h"
#include "mail-cache.h"
#include "mail-modifylog.h"
#include "mail-custom-flags.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
enum mail_index_open_flags flags)
{
struct mail_index_header *hdr;
/* update \Recent message counters */
if ((flags & MAIL_INDEX_OPEN_FLAG_UPDATE_RECENT) != 0 &&
/* keep last_recent_uid to next_uid-1 */
return FALSE;
}
return FALSE;
} else {
}
/* UID values are getting too high, rebuild index */
}
/* finally reset the modify log marks, fsck or syncing might
have deleted some messages, and since we're only just
opening the index, there's no need to remember them */
return FALSE;
}
return TRUE;
}
enum mail_index_open_flags flags)
{
int rebuilt;
/* upgrading from older index file. */
if (!mail_index_compress(index))
return FALSE;
}
if (!mail_cache_open_or_create(index))
return FALSE;
return FALSE;
return FALSE;
/* no inconsistency problems since we're still opening
the index */
} else {
}
/* custom flags file needs to be open before rebuilding index */
return FALSE;
if ((flags & _MAIL_INDEX_OPEN_FLAG_CREATING) == 0) {
return FALSE;
} else {
if (!mail_modifylog_create(index))
return FALSE;
}
/* index needs fscking */
return FALSE;
}
if (!rebuilt) {
/* sync ourself. do it before compression which may happen
as a result of this. */
MAIL_LOCK_SHARED, NULL) &&
!index->nodiskspace)
return FALSE;
}
/* we never want to keep shared lock if syncing happens to set it.
either exclusive or nothing (NOTE: drop it directly, not through
index->set_lock() so mbox lock won't be affected). */
return FALSE;
}
if ((flags & MAIL_INDEX_OPEN_FLAG_FAST) == 0) {
/* remove deleted blocks from index file */
if (!mail_index_compress(index))
return FALSE;
}
/* remove unused space from index data file. */
return FALSE;
}
}
return FALSE;
return TRUE;
}
struct mail_index_header *hdr)
{
if (ret < 0) {
return -1;
}
/* missing data */
return 0;
}
return 1;
}
const struct mail_index_header *hdr)
{
return FALSE;
}
return FALSE;
}
INDEX_MIN_RECORDS_COUNT * sizeof(struct mail_index_record);
return FALSE;
}
return TRUE;
}
{
/* mark the index requiring rebuild - rebuild() removes this flag
when it succeeds */
}
static void mail_index_cleanup_temp_files(const char *dir)
{
}
{
}
}
enum mail_index_open_flags flags)
{
if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
return FALSE;
}
return FALSE;
}
return TRUE;
}
enum mail_index_open_flags flags)
{
struct mail_index_header hdr;
int ret;
if ((flags & _MAIL_INDEX_OPEN_FLAG_CREATING) == 0)
else
/* if index is being created, we'll wait here until it's finished */
return FALSE;
#ifdef DEBUG
}
#endif
return FALSE;
if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
return FALSE;
/* so, we're creating the index */
/* have to get exclusive lock first */
return FALSE;
}
return FALSE;
}
/* we don't want to keep the shared lock while opening
indexes. opening should work unlocked and some
things want exclusive lock */
return FALSE;
}
(flags & _MAIL_INDEX_OPEN_FLAG_CREATING) != 0)
return FALSE;
/* needs a rebuild */
return FALSE;
}
return FALSE;
return TRUE;
}
{
const char *path;
if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) != 0)
else
}
}
return TRUE;
}