mail-index.c revision 003079baf8056c81c25162a176a89f9169cc374f
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (C) 2003-2004 Timo Sirainen */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenstatic int mail_index_try_open_only(struct mail_index *index);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void mail_index_create_in_memory(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_index *mail_index_alloc(const char *dir, const char *prefix)
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen index->extension_pool = pool_alloconly_create("extension", 512);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_CREATE(&index->extensions, index->extension_pool,
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen ARRAY_CREATE(&index->sync_lost_handlers, default_pool,
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen ARRAY_CREATE(&index->mail_index_module_contexts, default_pool,
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen mail_index_ext_register(index, "keywords", 128, 2, 1);
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen index->keywords_pool = pool_alloconly_create("keywords", 512);
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen ARRAY_CREATE(&index->keywords, default_pool, const char *, 16);
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen hash_create(default_pool, index->keywords_pool, 0,
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen strcase_hash, (hash_cmp_callback_t *)strcasecmp);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_index_free(struct mail_index **_index)
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainenvoid mail_index_set_permissions(struct mail_index *index,
ec1e30ecc38f0deddaf655413cf02d5972ddbc70Timo Sirainenuint32_t mail_index_ext_register(struct mail_index *index, const char *name,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_index_registered_ext *extensions;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int i, ext_count;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen extensions = array_get(&index->extensions, &ext_count);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* see if it's already there */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < ext_count; i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rext.name = p_strdup(index->extension_pool, name);
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainenvoid mail_index_register_expunge_handler(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rext->expunge_handler_call_always = call_always;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_index_unregister_expunge_handler(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen i_assert(rext->sync_handler.callback == NULL);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainenvoid mail_index_unregister_sync_handler(struct mail_index *index,
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen rext = array_idx_modifiable(&index->extensions, ext_id);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen i_assert(rext->sync_handler.callback != NULL);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainenvoid mail_index_register_sync_lost_handler(struct mail_index *index,
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen array_append(&index->sync_lost_handlers, &cb, 1);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainenvoid mail_index_unregister_sync_lost_handler(struct mail_index *index,
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen mail_index_sync_lost_handler_t *const *handlers;
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen unsigned int i, count;
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen handlers = array_get(&index->sync_lost_handlers, &count);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen for (i = 0; i < count; i++) {
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen array_delete(&index->sync_lost_handlers, i, 1);
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenstatic void mail_index_map_init_extbufs(struct mail_index_map *map,
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen ((sizeof(map->extensions) + BUFFER_APPROX_SIZE) * 2)
f99575e1d6cd251bd7b6d0654bd75b475e6a894cTimo Sirainen sizeof(struct mail_index_ext) + sizeof(uint32_t))
5a58037ad75b88356d82240fab2bc604de03107eTimo Sirainen /* try to use the existing pool's size for initial_count so
5a58037ad75b88356d82240fab2bc604de03107eTimo Sirainen we don't grow it unneededly */
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen size = p_get_max_easy_alloc_size(map->extension_pool);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (size > EXT_GLOBAL_ALLOC_SIZE + EXT_PER_ALLOC_SIZE) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen initial_count = (size - EXT_GLOBAL_ALLOC_SIZE) /
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_CREATE(&map->extensions, map->extension_pool,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_CREATE(&map->ext_id_map, map->extension_pool,
f99575e1d6cd251bd7b6d0654bd75b475e6a894cTimo Sirainenuint32_t mail_index_map_lookup_ext(struct mail_index_map *map, const char *name)
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen unsigned int i, size;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen extensions = array_get(&map->extensions, &size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < size; i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_index_map_register_ext(struct mail_index *index,
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainen i_assert(mail_index_map_lookup_ext(map, name) == (uint32_t)-1);
7c5b51bdf43a98e12c654ad437e0b258c5fffbc1Timo Sirainen ext->name = p_strdup(map->extension_pool, name);
b5ea11802f2bafbec06282a7b3b6704dc5fae584Timo Sirainen ext->index_idx = mail_index_ext_register(index, name, hdr_size,
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen /* Update index ext_id -> map ext_id mapping. Fill non-used
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen ext_ids with (uint32_t)-1 */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen while (array_count(&map->ext_id_map) < ext->index_idx)
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen array_append(&map->ext_id_map, &empty_idx, 1);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen array_idx_set(&map->ext_id_map, ext->index_idx, &idx);
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainenstatic bool size_check(size_t *size_left, size_t size)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen size_t size = sizeof(struct mail_index_ext_header) + name_len;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen return MAIL_INDEX_HEADER_SIZE_ALIGN(size) - size;
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainenstatic int mail_index_parse_extensions(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int i, old_count;
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen /* extension headers always start from 64bit offsets, so if base header
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen doesn't happen to be 64bit aligned we'll skip some bytes */
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen offset = MAIL_INDEX_HEADER_SIZE_ALIGN(map->hdr.base_header_size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (offset >= map->hdr.header_size && map->extension_pool == NULL) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* nothing to do, skip allocatations and all */
62950eeff28f00989a17b20eeade3af7e200c6bcTimo Sirainen mail_index_map_init_extbufs(map, old_count + 5);
62950eeff28f00989a17b20eeade3af7e200c6bcTimo Sirainen for (i = 0; i < old_count; i++)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ext_hdr = CONST_PTR_OFFSET(map->hdr_base, offset);
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen /* Extension header contains:
5a58037ad75b88356d82240fab2bc604de03107eTimo Sirainen - struct mail_index_ext_header
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen - name (not 0-terminated)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen - 64bit alignment padding
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen - extension header contents
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen - 64bit alignment padding
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!size_check(&size_left, sizeof(*ext_hdr)) ||
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen !size_check(&size_left, ext_hdr->name_size) ||
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen !size_check(&size_left, get_align(ext_hdr->name_size)) ||
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen "Header extension goes outside header",
f99575e1d6cd251bd7b6d0654bd75b475e6a894cTimo Sirainen offset += ext_hdr->name_size + get_align(ext_hdr->name_size);
b0a446671b8f09a1d2ed1d8c86a47298309e989dTimo Sirainen name = t_strndup(CONST_PTR_OFFSET(map->hdr_base, name_offset),
b0a446671b8f09a1d2ed1d8c86a47298309e989dTimo Sirainen if (mail_index_map_lookup_ext(map, name) != (uint32_t)-1) {
b0a446671b8f09a1d2ed1d8c86a47298309e989dTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
b0a446671b8f09a1d2ed1d8c86a47298309e989dTimo Sirainen "Duplicate header extension %s",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if ((ext_hdr->record_offset % ext_hdr->record_align) != 0 ||
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen (map->hdr.record_size % ext_hdr->record_align) != 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "Record field %s alignmentation %u not used",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen index->filepath, name, ext_hdr->record_align);
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen offset += MAIL_INDEX_HEADER_SIZE_ALIGN(ext_hdr->hdr_size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenbool mail_index_keyword_lookup(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int *idx_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* keywords_hash keeps a name => index mapping of keywords.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen Keywords are never removed from it, so the index values are valid
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo 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);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen keyword = keyword_dup = p_strdup(index->keywords_pool, keyword);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen hash_insert(index->keywords_hash, keyword_dup, POINTER_CAST(*idx_r));
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainenint mail_index_map_parse_keywords(struct mail_index *index,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_index_keyword_header *kw_hdr;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_index_keyword_header_rec *kw_rec;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int i, name_area_end_offset, old_count;
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen ext_id = mail_index_map_lookup_ext(map, "keywords");
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* Extension header contains:
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen - struct mail_index_keyword_header
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen - struct mail_index_keyword_header_rec * keywords_count
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen - const char names[] * keywords_count
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen i_assert(ext->hdr_offset < map->hdr.header_size);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen kw_hdr = CONST_PTR_OFFSET(map->hdr_base, ext->hdr_offset);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen name = (const char *)(kw_rec + kw_hdr->keywords_count);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen old_count = !array_is_created(&map->keyword_idx_map) ? 0 :
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* Keywords can only be added into same mapping. Removing requires a
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen new mapping (recreating the index file) */
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* nothing changed */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen /* make sure the header is valid */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen "Keywords removed unexpectedly",
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen if ((size_t)(name - (const char *)kw_hdr) > ext->hdr_size) {
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen "keywords_count larger than header size",
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen name_area_end_offset = (const char *)kw_hdr + ext->hdr_size - name;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen for (i = 0; i < kw_hdr->keywords_count; i++) {
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen if (kw_rec[i].name_offset > name_area_end_offset) {
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen "name_offset points outside allocated header",
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen "Keyword header doesn't end with NUL",
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* create file -> index mapping */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen if (!array_is_created(&map->keyword_idx_map)) {
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen ARRAY_CREATE(&map->keyword_idx_map, default_pool,
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen /* Check that existing headers are still the same. It's behind DEBUG
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen since it's pretty useless waste of CPU normally. */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen for (i = 0; i < array_count(&map->keyword_idx_map); i++) {
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen const char *keyword = name + kw_rec[i].name_offset;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen const unsigned int *old_idx;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen unsigned int idx;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen old_idx = array_idx(&map->keyword_idx_map, i);
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen if (!mail_index_keyword_lookup(index, keyword, FALSE, &idx) ||
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen mail_index_set_error(index, "Corrupted index file %s: "
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen "Keywords changed unexpectedly",
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen /* Register the newly seen keywords */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen const char *keyword = name + kw_rec[i].name_offset;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen unsigned int idx;
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen (void)mail_index_keyword_lookup(index, keyword, TRUE, &idx);
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenconst ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index)
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen /* Make sure all the keywords are in index->keywords. It's quick to do
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen if nothing has changed. */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen (void)mail_index_map_parse_keywords(index, index->map);
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenstatic int mail_index_check_header(struct mail_index *index,
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen const struct mail_index_header *hdr = &map->hdr;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen enum mail_index_header_compat_flags compat_flags = 0;
sizeof(struct mail_index_record));
unsigned int records_count;
int ret;
pos = 0;
if (ret > 0)
return ret;
pos);
if (ret > 0) {
if (ret < 0) {
if (ret == 0) {
&prev_offset);
bool sync_to_index)
const void *tdata;
int ret;
if (sync_to_index) {
MAIL_TRANSACTION_TYPE_MASK) <= 0) {
&skipped)) > 0) {
ret = 0;
&prev_offset);
return ret;
bool sync_to_index)
unsigned int i, count;
int ret;
bool retry;
if (ret != 0)
return ret;
for (i = 0; i < count; i++)
return ret;
if (ret <= 0) {
if (ret == 0) {
int ret;
if (ret != 0) {
return ret;
if (ret > 0) {
if (ret < 0)
ret = 0;
else if (ret == 0) {
if (ret <= 0) {
return ret;
int ret;
if (ret > 0)
return ret;
&pos);
if (ret <= 0) {
if (ret == 0) {
if (ret < 0)
return ret;
struct mail_index_map *
unsigned int i, count;
for (i = 0; i < count; i++) {
return mem_map;
unsigned int lock_id;
int ret;
*lock_id_r = 0;
if (ret <= 0)
return ret;
if (ret == 0) {
*lock_id_r = 0;
return ret;
const char *path;
int fd;
return fd;
const char *path;
int ret;
if (ret != 0) {
/* create it fully in index.tmp first */
if (ret == 0) {
if (ret < 0) {
return ret;
#ifndef WORDS_BIGENDIAN
unsigned int lock_id = 0;
int ret;
if (ret > 0)
else if (ret == 0) {
} else if (ret < 0)
if (lock_id != 0) {
lock_id = 0;
if (lock_id == 0) {
int i = 0, ret;
if (ret <= 0)
if (ret == 0) {
if (ret <= 0)
return ret;
ret = 0;
if (ret > 0)
else if (ret == 0) {
if (ret == 0) {
if (lock_id != 0)
if (ret == 0) {
return ret;
unsigned int lock_id;
int ret;
int ret = 0;
return ret;
const char *function)
const char *filepath,
const char *function)
return MAIL_INDEX_ERROR_DISKSPACE;
return MAIL_INDEX_ERROR_INTERNAL;
return MAIL_INDEX_ERROR_NONE;