mail-index-private.h revision 2988b4cbf3540a0c02a9ddf185cafec5938c0cac
#ifndef MAIL_INDEX_PRIVATE_H
#define MAIL_INDEX_PRIVATE_H
#include "file-lock.h"
#include "mail-index.h"
#include "mail-index-util.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. */
/* Write to main index file when bytes-to-be-read-from-log is between these
values. */
#define MAIL_INDEX_IS_IN_MEMORY(index) \
#define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
((struct mail_index_record *) \
((struct mail_index_record *) \
#define MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u) \
(u)->modseq_inc_flag == 0)
#define MAIL_INDEX_EXT_KEYWORDS "keywords"
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;
void *records; /* struct mail_index_record[] */
unsigned int records_count;
struct mail_index_map_modseq *modseq;
};
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;
};
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;
unsigned int open_count;
enum mail_index_open_flags flags;
enum fsync_mode fsync_mode;
char *gid_origin;
void *ext_hdr_init_data;
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. */
/* syncing will update this if non-NULL */
enum file_lock_method lock_method;
unsigned int max_lock_timeout_secs;
struct mail_index_view *views;
/* Module-specific contexts. */
char *error;
unsigned int nodiskspace:1;
unsigned int index_lock_timeout:1;
unsigned int log_sync_locked:1;
unsigned int readonly:1;
unsigned int mapping:1;
unsigned int syncing:1;
unsigned int need_recreate:1;
unsigned int index_min_write:1;
unsigned int modseqs_enabled:1;
unsigned int initial_create:1;
unsigned int initial_mapped:1;
unsigned int fscked:1;
};
extern struct mail_index_module_register mail_index_module_register;
void *context);
enum mail_index_sync_handler_type type);
const char *path_prefix, const char **path_r);
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 *
/* Returns 1 on success, 0 on non-critical errors we want to silently fix,
-1 if map isn't usable. The caller is responsible for logging the errors
if -1 is returned. */
const char **error_r);
/* Returns 1 if header is usable, 0 or -1 if not. The caller should log an
error if -1 is returned, but not if 0 is returned. */
const struct mail_index_header *hdr,
unsigned int initial_count);
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