mail-index-private.h revision 2b8fab6d39e8d1dbd3d546d2577fc1caeafdd64a
#ifndef MAIL_INDEX_PRIVATE_H
#define MAIL_INDEX_PRIVATE_H
#include "file-lock.h"
#include "mail-index.h"
#include "mail-index-view-private.h"
#include "mail-index-transaction-private.h"
struct mail_transaction_header;
struct mail_transaction_log_view;
struct mail_index_sync_map_ctx;
/* How large index files to mmap() instead of reading to memory. */
This happens with NFS when the file has been deleted (ie. index file was
rewritten by another computer than us). */
/* Large extension header sizes are probably caused by file corruption, so
try to catch them by limiting the header size. */
#define MAIL_INDEX_IS_IN_MEMORY(index) \
#define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
((struct mail_index_record *) \
#define MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u) \
((((u)->add_flags | (u)->remove_flags) & \
MAIL_INDEX_FLAGS_MASK) == 0)
void **sync_context, void *context);
#define MAIL_INDEX_HEADER_SIZE_ALIGN(size) \
struct mail_index_ext {
const char *name;
};
struct mail_index_ext_header {
/* unsigned char name[name_size] */
/* unsigned char data[hdr_size] (starting 64bit aligned) */
};
struct mail_index_keyword_header {
/* struct mail_index_keyword_header_rec[] */
/* char name[][] */
};
struct mail_index_keyword_header_rec {
};
enum mail_index_sync_handler_type {
MAIL_INDEX_SYNC_HANDLER_FILE = 0x01,
MAIL_INDEX_SYNC_HANDLER_HEAD = 0x02,
MAIL_INDEX_SYNC_HANDLER_VIEW = 0x04
};
struct mail_index_sync_handler {
};
struct mail_index_registered_ext {
const char *name;
struct mail_index_sync_handler sync_handler;
void *expunge_context;
unsigned int expunge_handler_call_always:1;
};
struct mail_index_record_map {
void *mmap_base;
unsigned int lock_id;
void *records; /* struct mail_index_record[] */
unsigned int records_count;
struct mail_index_map_modseq *modseq;
/* If this mapping is written to disk and write_atomic=FALSE,
write_seq_* specify the message sequence range that needs to be
written. */
};
struct mail_index_map {
struct mail_index *index;
int refcount;
struct mail_index_header hdr;
const void *hdr_base;
struct mail_index_record_map *rec_map;
unsigned int write_base_header:1;
unsigned int write_ext_header:1;
};
struct mail_index_module_register {
unsigned int id;
};
union mail_index_module_context {
struct mail_index_module_register *reg;
};
struct mail_index {
struct mail_cache *cache;
struct mail_transaction_log *log;
char *filepath;
int fd;
struct mail_index_map *map;
unsigned int inconsistency_id;
the main index file's headers. these are used to figure out when
the main index file should be updated, and if we can update it
by writing on top of it or if we need to recreate it. */
struct stat last_read_stat;
unsigned int lock_id_counter;
enum file_lock_method lock_method;
/* Module-specific contexts. */
char *error;
unsigned int nodiskspace:1;
unsigned int index_lock_timeout:1;
unsigned int opened:1;
unsigned int log_locked:1;
unsigned int mmap_disable:1;
unsigned int fsync_disable:1;
unsigned int use_excl_dotlocks:1;
unsigned int nfs_flush:1;
unsigned int readonly:1;
unsigned int mapping:1;
unsigned int syncing:1;
unsigned int need_recreate:1;
unsigned int modseqs_enabled:1;
unsigned int initial_create:1;
unsigned int initial_mapped:1;
};
extern struct mail_index_module_register mail_index_module_register;
void *context);
enum mail_index_sync_handler_type type);
/* Returns 0 = ok, -1 = error. */
/* Returns 1 = ok, 0 = already locked, -1 = error. */
unsigned int *lock_id_r);
/* Returns TRUE if given lock_id is valid. */
int lock_type, unsigned int timeout_secs,
/* Allocate a new empty map. */
/* Replace index->map with the latest index changes. This may reopen the index
read up to EOF, but non-synced expunges are skipped.
If we mmap()ed the index file, the map is returned locked.
Returns 1 = ok, 0 = corrupted, -1 = error. */
enum mail_index_sync_handler_type type);
/* Unreference given mapping and unmap it if it's dropped to zero. */
/* Clone a map. The returned map is always in memory. */
/* Move a mmaped map to memory. */
const struct mail_index_ext_header *ext_hdr);
const struct mail_index_ext *
unsigned int *offset,
const struct mail_index_ext_header **ext_hdr_r,
const char **name_r);
const struct mail_index_ext_header *ext_hdr,
unsigned int mail_index_map_ext_hdr_offset(unsigned int name_len);
/* "%s failed with index file %s: %m" */
const char *function);
/* "%s failed with file %s: %m" */
const char *filepath,
const char *function);
#endif