mail-index-private.h revision 0add8c99ca65e56dbf613595fc37c41aafff3f7f
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* number of records to always keep allocated in index file,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher either used or unused */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* when empty space in index file gets full, grow the file n% larger */
481ec0e1eb0058195732cb320845b41f6f4d43ebJakub Hrozek/* ftruncate() the index file when only n% of it is in use */
a7797068c4deb6ce2bdbcda27c45ff1bbb4a8e78Jakub Hrozek/* don't truncate whole file anyway, keep n% of the empty space */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* Compress the file when deleted space reaches n% of total size */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* Compress the file when searching deleted records tree has to go this deep */
7a14e8f66c0e932fe2954d792614a3b61d444bd1Jakub Hrozek/* How many times to retry opening index files if read/fstat returns ESTALE.
481ec0e1eb0058195732cb320845b41f6f4d43ebJakub Hrozek This happens with NFS when the file has been deleted (ie. index file was
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher rewritten by another computer than us). */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher int lock_type, shared_lock_count, excl_lock_count;
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallaghervoid mail_index_header_init(struct mail_index_header *hdr);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_write_header(struct mail_index *index,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_create(struct mail_index *index, struct mail_index_header *hdr);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_try_open_only(struct mail_index *index);
65a9065538fd85e6ead925d344e6b421900eb8c2Jakub Hrozekint mail_index_try_open(struct mail_index *index, unsigned int *lock_id_r);
ea929f1b022fc2cb77dec89b0e12accef983ec85Jakub Hrozekint mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallagher/* Returns 0 = ok, -1 = error. If update_index is TRUE, reopens the index
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher file if needed to get later version of it (not necessarily latest due to
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher races, unless transaction log is exclusively locked). */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_lock_shared(struct mail_index *index, int update_index,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher unsigned int *lock_id_r);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* Returns 0 = ok, -1 = error. */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_lock_exclusive(struct mail_index *index,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher unsigned int *lock_id_r);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallaghervoid mail_index_unlock(struct mail_index *index, unsigned int lock_id);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallagher/* Returns 1 if given lock_id is valid, 0 if not. */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_is_locked(struct mail_index *index, unsigned int lock_id);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_map_lock_mprotect(struct mail_index *index,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher struct mail_index_map *map, int lock_type);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* Map index file to memory, replacing the previous mapping for index.
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher Returns 1 = ok, 0 = corrupted, -1 = error. If index needs fscking, it
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher returns 1 but sets index->fsck = TRUE. */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_map(struct mail_index *index, int force);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallagher/* Unreference given mapping and unmap it if it's dropped to zero. */
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallaghervoid mail_index_unmap(struct mail_index *index, struct mail_index_map *map);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallagherstruct mail_index_map *mail_index_map_to_memory(struct mail_index_map *map);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallaghervoid mail_index_update_cache(struct mail_index_transaction *t,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_fix_header(struct mail_index *index, struct mail_index_map *map,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher struct mail_index_header *hdr, const char **error_r);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallaghervoid mail_index_view_transaction_ref(struct mail_index_view *view);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallaghervoid mail_index_view_transaction_unref(struct mail_index_view *view);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_sync_get_rec(struct mail_index_view *view,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher const struct mail_transaction_header *hdr,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallaghervoid mail_index_set_inconsistent(struct mail_index *index);
2ea6196484055397cc4bc011c5960f790431fa9dStephen Gallagherint mail_index_mark_corrupted(struct mail_index *index);
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_set_error(struct mail_index *index, const char *fmt, ...)
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* "%s failed with index file %s: %m" */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_set_syscall_error(struct mail_index *index,
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagher/* "%s failed with file %s: %m" */
52261fe16203dec6e6f69177c6d0a810b47d073fStephen Gallagherint mail_index_file_set_syscall_error(struct mail_index *index,
65a9065538fd85e6ead925d344e6b421900eb8c2Jakub Hrozek const char *function);