mail-transaction-log.h revision 5a3f143585110536a7f72628e66a42b998bfc5fc
#ifndef MAIL_TRANSACTION_LOG_H
#define MAIL_TRANSACTION_LOG_H
#include "mail-index.h"
#define MAIL_TRANSACTION_LOG_SUFFIX ".log"
#define MAIL_TRANSACTION_LOG_MAJOR_VERSION 1
#define MAIL_TRANSACTION_LOG_MINOR_VERSION 2
#define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24
struct mail_transaction_log_header {
};
enum mail_transaction_type {
MAIL_TRANSACTION_EXPUNGE = 0x00000001,
MAIL_TRANSACTION_APPEND = 0x00000002,
MAIL_TRANSACTION_FLAG_UPDATE = 0x00000004,
MAIL_TRANSACTION_HEADER_UPDATE = 0x00000020,
MAIL_TRANSACTION_EXT_INTRO = 0x00000040,
MAIL_TRANSACTION_EXT_RESET = 0x00000080,
MAIL_TRANSACTION_EXT_HDR_UPDATE = 0x00000100,
MAIL_TRANSACTION_EXT_REC_UPDATE = 0x00000200,
MAIL_TRANSACTION_KEYWORD_UPDATE = 0x00000400,
MAIL_TRANSACTION_KEYWORD_RESET = 0x00000800,
MAIL_TRANSACTION_EXT_ATOMIC_INC = 0x00001000,
MAIL_TRANSACTION_EXPUNGE_GUID = 0x00002000,
MAIL_TRANSACTION_UID_UPDATE = 0x00004000,
MAIL_TRANSACTION_MODSEQ_UPDATE = 0x00008000,
MAIL_TRANSACTION_EXT_HDR_UPDATE32 = 0x00010000,
MAIL_TRANSACTION_TYPE_MASK = 0x000fffff,
#define MAIL_TRANSACTION_EXT_MASK \
/* since we'll expunge mails based on data read from transaction log,
try to avoid the possibility of corrupted transaction log expunging
messages. this value is ORed to the actual MAIL_TRANSACTION_EXPUNGE*
flag. if it's not present, assume corrupted log. */
MAIL_TRANSACTION_EXPUNGE_PROT = 0x0000cd90,
/* Mailbox synchronization noticed this change. */
MAIL_TRANSACTION_EXTERNAL = 0x10000000
};
struct mail_transaction_header {
};
struct mail_transaction_uid_update {
};
struct mail_transaction_modseq_update {
/* don't use uint64_t here. it adds extra 32 bits of paddiong and also
causes problems with CPUs that require alignment */
};
struct mail_transaction_expunge {
};
struct mail_transaction_expunge_guid {
};
struct mail_transaction_flag_update {
};
struct mail_transaction_keyword_update {
/* unsigned char name[];
array of { uint32_t uid1, uid2; }
*/
};
struct mail_transaction_keyword_reset {
};
struct mail_transaction_header_update {
/* unsigned char data[]; */
};
enum {
/* Don't shrink hdr_size, record_size or record_align but grow them
if necessary. */
};
struct mail_transaction_ext_intro {
/* old extension: set ext_id. don't set name.
new extension: ext_id = (uint32_t)-1. give name. */
/* unsigned char name[]; */
};
struct mail_transaction_ext_reset {
};
/* these are set for the last ext_intro */
struct mail_transaction_ext_hdr_update {
/* unsigned char data[]; */
};
/* this _update32 version should have been the only ext_hdr_update,
but since 16bit integers were originally used for now we'll just use this
only when actually needed to be backwards compatible. */
struct mail_transaction_ext_hdr_update32 {
/* unsigned char data[]; */
};
struct mail_transaction_ext_rec_update {
/* unsigned char data[]; */
};
struct mail_transaction_ext_atomic_inc {
};
struct mail_transaction_log_append_ctx {
struct mail_transaction_log *log;
unsigned int external:1;
unsigned int append_sync_offset:1;
unsigned int sync_includes_this:1;
unsigned int want_fsync:1;
};
struct mail_transaction_log *
/* Open the transaction log. Returns 1 if ok, 0 if file doesn't exist or it's
is corrupted, -1 if there was some I/O error. */
/* Create, or recreate, the transaction log. Returns 0 if ok, -1 if error. */
/* Close all the open transactions log files. */
/* Notify of indexid change */
Since the log is rotated only when mailbox is fully synced, the sequence
points always to the latest file. This function doesn't actually find the
latest sync position, so you'll need to use eg. log_view_set() before
calling this. */
/* Set the current mailbox sync position. file_seq must always be the latest
log file's sequence. The offset written automatically to the log when
other transactions are being written. */
struct mail_transaction_log_view *
/* Set view boundaries. Returns -1 if error, 0 if files are lost, 1 if ok.
reset_r=TRUE if the whole index should be reset before applying any
changes. */
bool *reset_r);
/* Clear the view. Keep oldest_file_seq and newer log files referenced so we
don't get desynced. */
/* Read next transaction record from current position. The position is updated.
Returns -1 if error, 0 if we're at end of the view, 1 if ok. */
const struct mail_transaction_header **hdr_r,
const void **data_r);
/* Mark the current view's position to the record returned previously with
_log_view_next(). */
/* Seek to previously marked position. */
/* Returns the position of the record returned previously with
mail_transaction_log_view_next() */
void
/* Return the modseq of the change returned previously with _view_next(). */
/* Returns TRUE if we're at the end of the view window. */
/* Marks the log file in current position to be corrupted. */
void
const char *fmt, ...)
bool
struct mail_transaction_log_append_ctx **ctx_r);
enum mail_transaction_type type,
/* Lock transaction log for index synchronization. Log cannot be read or
written to while it's locked. Returns end offset. */
/* Returns the current head. Works only when log is locked. */
/* Returns the current tail from which all files are open to head. */
/* Move currently opened log head file to memory (called by
mail_index_move_to_memory()) */
#endif