mail-index-private.h revision 5a07b37a9df398b5189c14872a600384208ab74b
#ifndef __MAIL_INDEX_PRIVATE_H
#define __MAIL_INDEX_PRIVATE_H
#include "file-dotlock.h"
#include "mail-index.h"
struct mail_transaction_header;
/* Index file is grown exponentially when we're adding less than this many
records. */
This happens with NFS when the file has been deleted (ie. index file was
rewritten by another computer than us). */
#define MAIL_INDEX_ESTALE_RETRY_COUNT 10
#define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
((struct mail_index_record *) \
struct mail_index_extra_record_info {
const char *name;
};
struct mail_index_extra_record_info_header {
};
struct mail_index_map {
int refcount;
const struct mail_index_header *hdr;
const void *hdr_base;
void *records; /* struct mail_index_record[] */
unsigned int records_count;
void *mmap_base;
unsigned int write_to_disk:1;
};
struct mail_index {
struct mail_cache *cache;
struct mail_transaction_log *log;
char *filepath;
int fd;
struct mail_index_map *map;
const struct mail_index_header *hdr;
unsigned int lock_id;
char *copy_lock_path;
unsigned int last_grow_count;
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 mmap_no_write:1;
unsigned int fcntl_locks_disable:1;
unsigned int readonly:1;
unsigned int fsck:1;
};
const struct mail_index_header *hdr);
/* Returns 0 = ok, -1 = error. If update_index is TRUE, reopens the index
file if needed to get later version of it (not necessarily latest due to
races, unless transaction log is exclusively locked). */
unsigned int *lock_id_r);
/* Returns 0 = ok, -1 = error. */
unsigned int *lock_id_r);
/* Returns 1 if given lock_id is valid, 0 if not. */
/* Map index file to memory, replacing the previous mapping for index.
Returns 1 = ok, 0 = corrupted, -1 = error. If index needs fscking, it
returns 1 but sets index->fsck = TRUE. */
/* Unreference given mapping and unmap it if it's dropped to zero. */
struct mail_index_map *
struct mail_index_map *map,
const char *name,
struct mail_index_map **map_r,
const struct mail_index_record **rec_r);
void mail_index_reset_cache(struct mail_index_transaction *t,
int mail_index_update_cache_lookup(struct mail_index_transaction *t,
/* "%s failed with index file %s: %m" */
const char *function);
/* "%s failed with file %s: %m" */
const char *filepath,
const char *function);
#endif