mail-index-private.h revision 7e94cf9d70ce9fdeccb7a85ff400b899e6386f36
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Maximum number of extra record data items we allowed. Raising this limit
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg only means it takes a few bytes more memory, but 32 should be enough for a
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg long time, right? :) */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Index file is grown exponentially when we're adding less than this many
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg records. */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg#define MAIL_INDEX_MAX_POWER_GROW (1024*1024 / sizeof(struct mail_index_record))
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* How many times to retry opening index files if read/fstat returns ESTALE.
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg This happens with NFS when the file has been deleted (ie. index file was
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg rewritten by another computer than us). */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg PTR_OFFSET((map)->records, (idx) * (map)->hdr->record_size))
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg const char *name;
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg unsigned int records_count;
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg const struct mail_index_extra_record_info *extra_records;
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg unsigned int lock_id;
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_write_base_header(struct mail_index *index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_reopen(struct mail_index *index, int fd);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Returns 0 = ok, -1 = error. If update_index is TRUE, reopens the index
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg file if needed to get later version of it (not necessarily latest due to
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg races, unless transaction log is exclusively locked). */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_lock_shared(struct mail_index *index, int update_index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg unsigned int *lock_id_r);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Returns 0 = ok, -1 = error. */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_lock_exclusive(struct mail_index *index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg unsigned int *lock_id_r);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_unlock(struct mail_index *index, unsigned int lock_id);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Returns 1 if given lock_id is valid, 0 if not. */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_is_locked(struct mail_index *index, unsigned int lock_id);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_map_lock_mprotect(struct mail_index *index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Map index file to memory, replacing the previous mapping for index.
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg Returns 1 = ok, 0 = corrupted, -1 = error. If index needs fscking, it
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg returns 1 but sets index->fsck = TRUE. */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_map(struct mail_index *index, int force);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* Unreference given mapping and unmap it if it's dropped to zero. */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_unmap(struct mail_index *index, struct mail_index_map *map);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgmail_index_map_to_memory(struct mail_index_map *map, uint32_t new_record_size);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_lookup_full(struct mail_index_view *view, uint32_t seq,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_reset_cache(struct mail_index_transaction *t,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_update_cache(struct mail_index_transaction *t,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_fix_header(struct mail_index *index, struct mail_index_map *map,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg struct mail_index_header *hdr, const char **error_r);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_view_transaction_ref(struct mail_index_view *view);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_view_transaction_unref(struct mail_index_view *view);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgvoid mail_index_set_inconsistent(struct mail_index *index);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_set_error(struct mail_index *index, const char *fmt, ...)
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* "%s failed with index file %s: %m" */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_set_syscall_error(struct mail_index *index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg const char *function);
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg/* "%s failed with file %s: %m" */
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankgint mail_index_file_set_syscall_error(struct mail_index *index,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg const char *filepath,
ef06a12023b00bdbe0b983192e4afdbdb21139e3fuankg const char *function);