mail-index.c revision 51b979b6414b940f04677a7e2d064be119345954
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (C) 2003-2004 Timo Sirainen */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_index_module_register mail_index_module_register = { 0 };
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_index *mail_index_alloc(const char *dir, const char *prefix)
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen pool_alloconly_create(MEMPOOL_GROWING"index extension", 1024);
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen p_array_init(&index->extensions, index->extension_pool, 5);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen mail_index_ext_register(index, "keywords", 128, 2, 1);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen index->keywords_pool = pool_alloconly_create("keywords", 512);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen hash_create(default_pool, index->keywords_pool, 0,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen strcase_hash, (hash_cmp_callback_t *)strcasecmp);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen index->log = mail_transaction_log_alloc(index);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_index_free(struct mail_index **_index)
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainenvoid mail_index_set_permissions(struct mail_index *index,
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainenuint32_t mail_index_ext_register(struct mail_index *index, const char *name,
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen const struct mail_index_registered_ext *extensions;
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen unsigned int i, ext_count;
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen extensions = array_get(&index->extensions, &ext_count);
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen /* see if it's already there */
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen for (i = 0; i < ext_count; i++) {
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen rext.name = p_strdup(index->extension_pool, name);
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainenvoid mail_index_register_expunge_handler(struct mail_index *index,
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen i_assert(rext->expunge_handler == NULL || rext->expunge_handler == cb);
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen rext->expunge_handler_call_always = call_always;
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainenvoid mail_index_unregister_expunge_handler(struct mail_index *index,
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainenvoid mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen i_assert(rext->sync_handler.callback == NULL);
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenvoid mail_index_unregister_sync_handler(struct mail_index *index,
c53e8ee216904ffe6de4f6518d9f9f5107b7610eTimo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
c53e8ee216904ffe6de4f6518d9f9f5107b7610eTimo Sirainen i_assert(rext->sync_handler.callback != NULL);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_index_register_sync_lost_handler(struct mail_index *index,
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen array_append(&index->sync_lost_handlers, &cb, 1);
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenvoid mail_index_unregister_sync_lost_handler(struct mail_index *index,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen mail_index_sync_lost_handler_t *const *handlers;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen unsigned int i, count;
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen handlers = array_get(&index->sync_lost_handlers, &count);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen for (i = 0; i < count; i++) {
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen array_delete(&index->sync_lost_handlers, i, 1);
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenbool mail_index_keyword_lookup(struct mail_index *index,
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen unsigned int *idx_r)
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen /* keywords_hash keeps a name => index mapping of keywords.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen Keywords are never removed from it, so the index values are valid
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen for the lifetime of the mail_index. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (hash_lookup_full(index->keywords_hash, keyword, NULL, &value)) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *idx_r = POINTER_CAST_TO(value, unsigned int);
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen keyword = keyword_dup = p_strdup(index->keywords_pool, keyword);
e192a3b1ca8ae857e7d87298ea507d32977ba570Timo Sirainen hash_insert(index->keywords_hash, keyword_dup, POINTER_CAST(*idx_r));
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenint mail_index_map_parse_keywords(struct mail_index_map *map)
8b9342aa96b2f297e23afb261f9f7dd859800952Timo Sirainen const struct mail_index_keyword_header *kw_hdr;
8b9342aa96b2f297e23afb261f9f7dd859800952Timo Sirainen const struct mail_index_keyword_header_rec *kw_rec;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int i, name_area_end_offset, old_count;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ext_id = mail_index_map_lookup_ext(map, "keywords");
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen /* Extension header contains:
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen - struct mail_index_keyword_header
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen - struct mail_index_keyword_header_rec * keywords_count
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen - const char names[] * keywords_count
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_assert(ext->hdr_offset < map->hdr.header_size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen kw_hdr = CONST_PTR_OFFSET(map->hdr_base, ext->hdr_offset);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen name = (const char *)(kw_rec + kw_hdr->keywords_count);
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen old_count = !array_is_created(&map->keyword_idx_map) ? 0 :
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen /* Keywords can only be added into same mapping. Removing requires a
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen new mapping (recreating the index file) */
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen /* nothing changed */
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen /* make sure the header is valid */
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen "Keywords removed unexpectedly",
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen if ((size_t)(name - (const char *)kw_hdr) > ext->hdr_size) {
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen "keywords_count larger than header size",
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen name_area_end_offset = (const char *)kw_hdr + ext->hdr_size - name;
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen for (i = 0; i < kw_hdr->keywords_count; i++) {
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen if (kw_rec[i].name_offset > name_area_end_offset) {
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen "name_offset points outside allocated header",
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
f501ad38c51cf1d8f4f84313922c785e6ae6e81fTimo Sirainen "Keyword header doesn't end with NUL",
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen /* create file -> index mapping */
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen i_array_init(&map->keyword_idx_map, kw_hdr->keywords_count);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Check that existing headers are still the same. It's behind DEBUG
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen since it's pretty useless waste of CPU normally. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < array_count(&map->keyword_idx_map); i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *keyword = name + kw_rec[i].name_offset;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const unsigned int *old_idx;
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen unsigned int idx;
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen old_idx = array_idx(&map->keyword_idx_map, i);
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen if (!mail_index_keyword_lookup(index, keyword, FALSE, &idx) ||
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen "Keywords changed unexpectedly",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Register the newly seen keywords */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *keyword = name + kw_rec[i].name_offset;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int idx;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (void)mail_index_keyword_lookup(index, keyword, TRUE, &idx);
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainenconst ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index)
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen /* Make sure all the keywords are in index->keywords. It's quick to do
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen if nothing has changed. */
d565eaa943f29a49b97230ced57eec40ee65b4f9Timo Sirainen (void)mail_index_map_parse_keywords(index->map);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint mail_index_try_open_only(struct mail_index *index)
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen /* Note that our caller must close index->fd by itself. */
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen index->fd = nfs_safe_open(index->filepath, O_RDWR);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen return mail_index_set_syscall_error(index, "open()");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* have to create it */
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen i_assert(index->map == NULL || index->map->lock_id == 0);
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD);
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen /* it's corrupted - recreate it */
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen mail_index_set_syscall_error(index, "close()");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint mail_index_create_tmp_file(struct mail_index *index, const char **path_r)
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen path = *path_r = t_strconcat(index->filepath, ".tmp", NULL);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen fd = open(path, O_RDWR|O_CREAT|O_TRUNC, index->mode);
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen return mail_index_file_set_syscall_error(index, path, "open()");
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen if (index->gid != (gid_t)-1 && fchown(fd, (uid_t)-1, index->gid) < 0) {
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen mail_index_file_set_syscall_error(index, path, "fchown()");
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainenstatic bool mail_index_open_files(struct mail_index *index,
69bd816e46fdee6182d0cb2e4c6be32399a555c8Timo Sirainen if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
f23298fea47eecbeded985ee2537a34c4c4ef56bTimo Sirainen /* if dovecot.index exists, read it first so that we can get
f23298fea47eecbeded985ee2537a34c4c4ef56bTimo Sirainen the correct indexid and log sequence */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* create a new indexid for us */
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainen ret = mail_transaction_log_create(index->log);
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainen ret = index->map != NULL ? 0 : mail_index_try_open(index);
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainen /* doesn't exist / corrupted */
5196f9ea42d02000f9c3d22f20aa816140af4422Timo Sirainen /* open/create failed, fallback to in-memory indexes */
5196f9ea42d02000f9c3d22f20aa816140af4422Timo Sirainen if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen index->cache = created ? mail_cache_create(index) :
519e0a461271843833a2b42626ad93f6e7ddc497Timo Sirainenint mail_index_open(struct mail_index *index, enum mail_index_open_flags flags,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* corrupted, reopen files */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen index->filepath = MAIL_INDEX_IS_IN_MEMORY(index) ?
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen i_strconcat(index->dir, "/", index->prefix, NULL);
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen (flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) != 0;
5bdad39213d28ab35e615a7f4ea1712ab25b6a80Timo Sirainen (flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;
5bdad39213d28ab35e615a7f4ea1712ab25b6a80Timo Sirainen (flags & MAIL_INDEX_OPEN_FLAG_FSYNC_DISABLE) != 0;
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen (flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen if (index->nfs_flush && index->fsync_disable) {
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen "fsync_disable=no, changing it");
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen if (index->nfs_flush && !index->mmap_disable) {
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen "mmap_disable=yes, changing it");
2af769daebd83719ac696a440e06f6020471cec0Timo Sirainen /* doesn't exist and create flag not used */
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen /* completely broken, reopen */
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen if (i++ < 3) {
ba482d3624ca4f1b3d638e6e8470ba5134f21493Timo Sirainen /* too many tries */
cf3bea6d9b57f8608bec22d98ad547a507b05f66Timo Sirainenstatic void mail_index_close_file(struct mail_index *index)
dc0474dc9d5652d76cb41f439844dd80c8b96642Timo Sirainen mail_index_set_syscall_error(index, "close()");
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenvoid mail_index_close(struct mail_index *index)
114a0f74e0f825c6bd8aeadfafb248a030762a1fTimo Sirainenint mail_index_reopen_if_changed(struct mail_index *index)
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen return mail_index_set_syscall_error(index, "fstat()");
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen if (nfs_safe_stat(index->filepath, &st2) < 0) {
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen return mail_index_set_syscall_error(index, "stat()");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (st1.st_ino == st2.st_ino && CMP_DEV_T(st1.st_dev, st2.st_dev)) {
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen /* the same file */
1a21e7049796c98d6d998fcf7a438d7a97193dc4Timo Sirainen /* new file, new locks. the old fd can keep its locks, they don't
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen matter anymore as no-one's going to modify the file. */
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainenint mail_index_refresh(struct mail_index *index)
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen /* we have index exclusively locked, nothing could
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen have changed. */
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD);
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainenstruct mail_cache *mail_index_get_cache(struct mail_index *index)
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainenint mail_index_set_error(struct mail_index *index, const char *fmt, ...)
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainenint mail_index_move_to_memory(struct mail_index *index)
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen /* set the index as being into memory */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen index->filepath = i_strdup("(in-memory index)");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* index was never even opened. just mark it as being in
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen memory and let the caller re-open the index. */
4b058f90f9e8a2c6b2eed275de4eb8cc5195a71dTimo Sirainen /* move index map to memory */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!MAIL_INDEX_MAP_IS_IN_MEMORY(index->map)) {
4bbee99b3aef449a9a2a11a5b5cf1ca486915c49Timo Sirainen /* move transaction log to memory */
4bbee99b3aef449a9a2a11a5b5cf1ca486915c49Timo Sirainen mail_transaction_log_move_to_memory(index->log);
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen /* close the index file. */
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen mail_index_set_syscall_error(index, "close()");
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainenvoid mail_index_mark_corrupted(struct mail_index *index)
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen index->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED;
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen if (unlink(index->filepath) < 0 && errno != ENOENT && errno != ESTALE)
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen mail_index_set_syscall_error(index, "unlink()");
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainenint mail_index_set_syscall_error(struct mail_index *index,
const char *filepath,
const char *function)
#ifdef WORDS_BIGENDIAN