]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: *_mailboxes don't descend from index_mailbox anymore, it's now a context.
authorTimo Sirainen <tss@iki.fi>
Sun, 7 Feb 2010 15:30:24 +0000 (17:30 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 7 Feb 2010 15:30:24 +0000 (17:30 +0200)
--HG--
branch : HEAD

69 files changed:
src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/cydir/cydir-storage.h
src/lib-storage/index/cydir/cydir-sync.c
src/lib-storage/index/dbox-common/dbox-mail.c
src/lib-storage/index/dbox-common/dbox-storage.c
src/lib-storage/index/dbox-common/dbox-sync-rebuild.c
src/lib-storage/index/dbox-common/dbox-sync-rebuild.h
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-multi/mdbox-storage.h
src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/dbox-single/sdbox-file.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-save.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.h
src/lib-storage/index/dbox-single/sdbox-sync-file.c
src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/index-mail-headers.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h
src/lib-storage/index/index-mailbox-check.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-status.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/index-sync-changes.c
src/lib-storage/index/index-sync-changes.h
src/lib-storage/index/index-sync-private.h
src/lib-storage/index/index-sync-search.c
src/lib-storage/index/index-sync.c
src/lib-storage/index/index-thread-private.h
src/lib-storage/index/index-thread.c
src/lib-storage/index/index-transaction.c
src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-keywords.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/maildir/maildir-storage.h
src/lib-storage/index/maildir/maildir-sync-index.c
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/index/maildir/maildir-uidlist.h
src/lib-storage/index/maildir/maildir-util.c
src/lib-storage/index/mbox/mbox-file.c
src/lib-storage/index/mbox/mbox-lock.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/mbox/mbox-storage.h
src/lib-storage/index/mbox/mbox-sync-parse.c
src/lib-storage/index/mbox/mbox-sync-update.c
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/index/raw/raw-storage.h
src/lib-storage/index/raw/raw-sync.c
src/lib-storage/index/test-index-fetch.c
src/lib-storage/mail-storage-private.h
src/plugins/virtual/virtual-config.c
src/plugins/virtual/virtual-mail.c
src/plugins/virtual/virtual-search.c
src/plugins/virtual/virtual-storage.c
src/plugins/virtual/virtual-storage.h
src/plugins/virtual/virtual-sync.c

index 8088747efa813a6e91087b97a6446d0008ad2faa..512d708d611b1d0d388cccdbed5b20d3d5493296 100644 (file)
@@ -50,8 +50,7 @@ cydir_get_save_path(struct cydir_save_context *ctx, unsigned int num)
 {
        const char *dir;
 
-       dir = mailbox_list_get_path(ctx->mbox->ibox.box.list,
-                                   ctx->mbox->ibox.box.name,
+       dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name,
                                    MAILBOX_LIST_PATH_TYPE_MAILBOX);
        return t_strdup_printf("%s/%s.%u", dir, ctx->tmp_basename, num);
 }
@@ -262,8 +261,7 @@ int cydir_transaction_save_commit_pre(struct mail_save_context *_ctx)
                                      &_t->changes->saved_uids);
        _t->changes->uid_validity = ctx->sync_ctx->uid_validity;
 
-       dir = mailbox_list_get_path(ctx->mbox->ibox.box.list,
-                                   ctx->mbox->ibox.box.name,
+       dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name,
                                    MAILBOX_LIST_PATH_TYPE_MAILBOX);
 
        src_path = t_str_new(256);
index 0046f2b01db16ed2a5f03f824ebafa44065120cb..21178d5b6a439ec345c503735f6ee12cd2378c26 100644 (file)
@@ -54,6 +54,7 @@ cydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                    enum mailbox_flags flags)
 {
        struct cydir_mailbox *mbox;
+       struct index_mailbox_context *ibox;
        pool_t pool;
 
        /* cydir can't work without index files */
@@ -61,24 +62,25 @@ cydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        pool = pool_alloconly_create("cydir mailbox", 1024+512);
        mbox = p_new(pool, struct cydir_mailbox, 1);
-       mbox->ibox.box = cydir_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &cydir_mail_vfuncs;
+       mbox->box = cydir_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &cydir_mail_vfuncs;
 
-       mbox->ibox.save_commit_pre = cydir_transaction_save_commit_pre;
-       mbox->ibox.save_commit_post = cydir_transaction_save_commit_post;
-       mbox->ibox.save_rollback = cydir_transaction_save_rollback;
-
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    CYDIR_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.box.index,
+       mail_index_set_fsync_types(mbox->box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
+       ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
+       ibox->save_commit_pre = cydir_transaction_save_commit_pre;
+       ibox->save_commit_post = cydir_transaction_save_commit_post;
+       ibox->save_rollback = cydir_transaction_save_rollback;
+
        mbox->storage = (struct cydir_storage *)storage;
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 static int cydir_mailbox_open(struct mailbox *box)
@@ -111,7 +113,7 @@ static int cydir_mailbox_open(struct mailbox *box)
                                          box->path);
                return -1;
        }
-       return index_storage_mailbox_open(box);
+       return index_storage_mailbox_open(box, FALSE);
 }
 
 static int
@@ -222,9 +224,9 @@ static void cydir_notify_changes(struct mailbox *box)
        struct cydir_mailbox *mbox = (struct cydir_mailbox *)box;
 
        if (box->notify_callback == NULL)
-               index_mailbox_check_remove_all(&mbox->ibox);
+               index_mailbox_check_remove_all(&mbox->box);
        else
-               index_mailbox_check_add(&mbox->ibox, mbox->ibox.box.path);
+               index_mailbox_check_add(&mbox->box, mbox->box.path);
 }
 
 static int cydir_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx
index 329fdab162f9ee6750b71e96cdd087f2763f891c..3675fe90cbb720a7548e0724e834e5f987c3ff22 100644 (file)
@@ -14,7 +14,7 @@ struct cydir_storage {
 };
 
 struct cydir_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct cydir_storage *storage;
 };
 
index c395f2ba91b8113cc5904115ec09b3e3aab48c96..a693e6957be3c0b0e476a51b058a97deb47ce616 100644 (file)
@@ -21,7 +21,7 @@ static string_t *cydir_get_path_prefix(struct cydir_mailbox *mbox)
        string_t *path = str_new(default_pool, 256);
        const char *dir;
 
-       dir = mailbox_list_get_path(mbox->ibox.box.list, mbox->ibox.box.name,
+       dir = mailbox_list_get_path(mbox->box.list, mbox->box.name,
                                    MAILBOX_LIST_PATH_TYPE_MAILBOX);
        str_append(path, dir);
        str_append_c(path, '/');
@@ -31,7 +31,7 @@ static string_t *cydir_get_path_prefix(struct cydir_mailbox *mbox)
 static void
 cydir_sync_expunge(struct cydir_sync_context *ctx, uint32_t seq1, uint32_t seq2)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        uint32_t uid;
 
        if (ctx->path == NULL) {
@@ -60,7 +60,7 @@ cydir_sync_expunge(struct cydir_sync_context *ctx, uint32_t seq1, uint32_t seq2)
 
 static void cydir_sync_index(struct cydir_sync_context *ctx)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        const struct mail_index_header *hdr;
        struct mail_index_sync_rec sync_rec;
        uint32_t seq1, seq2;
@@ -74,7 +74,7 @@ static void cydir_sync_index(struct cydir_sync_context *ctx)
        /* mark the newly seen messages as recent */
        if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
                                        hdr->next_uid, &seq1, &seq2)) {
-               index_mailbox_set_recent_seq(&ctx->mbox->ibox, ctx->sync_view,
+               index_mailbox_set_recent_seq(&ctx->mbox->box, ctx->sync_view,
                                             seq1, seq2);
        }
 
@@ -117,17 +117,17 @@ int cydir_sync_begin(struct cydir_mailbox *mbox,
        ctx->mbox = mbox;
 
        sync_flags = MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY;
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
        if (!force)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
 
-       ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->box.index, &ctx->index_sync_ctx,
                                    &ctx->sync_view, &ctx->trans,
                                    sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                i_free(ctx);
                *ctx_r = NULL;
                return ret;
@@ -146,7 +146,7 @@ int cydir_sync_finish(struct cydir_sync_context **_ctx, bool success)
        *_ctx = NULL;
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
+                       mail_storage_set_index_error(&ctx->mbox->box);
                        ret = -1;
                }
        } else {
@@ -180,7 +180,7 @@ cydir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       if (index_mailbox_want_full_sync(&mbox->ibox, flags) && ret == 0)
+       if (index_mailbox_want_full_sync(&mbox->box, flags) && ret == 0)
                ret = cydir_sync(mbox);
 
        return index_mailbox_sync_init(box, flags, ret < 0);
index e864e3bee4bae18668657b59acd6f8231905d1bf..5d0955b9f8c9193dab78fb21646227906e40bcc2 100644 (file)
@@ -148,7 +148,8 @@ dbox_get_cached_metadata(struct dbox_mail *mail, enum dbox_metadata_key key,
                         const char **value_r)
 {
        struct index_mail *imail = &mail->imail;
-       const struct mail_cache_field *cache_fields = imail->ibox->cache_fields;
+       struct index_mailbox_context *ibox =
+               INDEX_STORAGE_CONTEXT(imail->mail.mail.box);
        struct dbox_file *file;
        const char *value;
        string_t *str;
@@ -156,7 +157,7 @@ dbox_get_cached_metadata(struct dbox_mail *mail, enum dbox_metadata_key key,
        str = str_new(imail->data_pool, 64);
        if (mail_cache_lookup_field(imail->trans->cache_view, str,
                                    imail->mail.mail.seq,
-                                   cache_fields[cache_field].idx) > 0) {
+                                   ibox->cache_fields[cache_field].idx) > 0) {
                *value_r = str_c(str);
                return 0;
        }
@@ -167,7 +168,7 @@ dbox_get_cached_metadata(struct dbox_mail *mail, enum dbox_metadata_key key,
        value = dbox_file_metadata_get(file, key);
        if (value == NULL)
                value = "";
-       index_mail_cache_add_idx(imail, cache_fields[cache_field].idx,
+       index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,
                                 value, strlen(value)+1);
        *value_r = value;
        return 0;
index 142e9c6d7b730a540910ea0fdd49a4940ee9070e..2da7e625f52aff243116c4fe47fab6a23eadc6a7 100644 (file)
@@ -39,16 +39,15 @@ uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list)
 
 void dbox_notify_changes(struct mailbox *box)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        const char *dir, *path;
 
        if (box->notify_callback == NULL)
-               index_mailbox_check_remove_all(ibox);
+               index_mailbox_check_remove_all(box);
        else {
                dir = mailbox_list_get_path(box->list, box->name,
                                            MAILBOX_LIST_PATH_TYPE_INDEX);
                path = t_strdup_printf("%s/"DBOX_INDEX_PREFIX".log", dir);
-               index_mailbox_check_add(ibox, path);
+               index_mailbox_check_add(box, path);
        }
 }
 
@@ -86,7 +85,7 @@ static int dbox_mailbox_create_indexes(struct mailbox *box,
        mailbox_list_get_dir_permissions(box->list, NULL, &mode, &gid, &origin);
        if (mkdir_parents_chgrp(box->path, mode, gid, origin) == 0) {
                /* create indexes immediately with the dbox header */
-               if (index_storage_mailbox_open(box) < 0)
+               if (index_storage_mailbox_open(box, FALSE) < 0)
                        return -1;
                if (storage->v.mailbox_create_indexes(box, update) < 0)
                        return -1;
@@ -109,7 +108,7 @@ int dbox_mailbox_open(struct mailbox *box)
        }
 
        if (dbox_cleanup_if_exists(box->list, box->path)) {
-               return index_storage_mailbox_open(box);
+               return index_storage_mailbox_open(box, FALSE);
        } else if (errno == ENOENT) {
                if (strcmp(box->name, "INBOX") == 0 &&
                    (box->list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
@@ -117,7 +116,7 @@ int dbox_mailbox_open(struct mailbox *box)
                        if (dbox_mailbox_create_indexes(box, NULL) < 0)
                                return -1;
                        return box->opened ? 0 :
-                               index_storage_mailbox_open(box);
+                               index_storage_mailbox_open(box, FALSE);
                }
 
                mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
@@ -163,7 +162,7 @@ int dbox_mailbox_create(struct mailbox *box,
            (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0)
                return 0;
 
-       if (index_storage_mailbox_open(box) < 0)
+       if (index_storage_mailbox_open(box, FALSE) < 0)
                return -1;
        if (storage->v.mailbox_create_indexes(box, update) < 0)
                return -1;
index f79de03e34e51a00a49472d084e47a88df4905d8..7848956719004a568a8e3692c25a72733ab1f98c 100644 (file)
@@ -84,21 +84,20 @@ void dbox_sync_rebuild_index_metadata(struct dbox_sync_rebuild_context *ctx,
 }
 
 struct dbox_sync_rebuild_context *
-dbox_sync_index_rebuild_init(struct index_mailbox *ibox,
+dbox_sync_index_rebuild_init(struct mailbox *box,
                             struct mail_index_view *view,
                             struct mail_index_transaction *trans)
 {
-       struct mailbox *box = &ibox->box;
        struct dbox_sync_rebuild_context *ctx;
        const char *index_dir;
        enum mail_index_open_flags open_flags = MAIL_INDEX_OPEN_FLAG_READONLY;
 
        ctx = i_new(struct dbox_sync_rebuild_context, 1);
-       ctx->ibox = ibox;
+       ctx->box = box;
        ctx->view = view;
        ctx->trans = trans;
        mail_index_reset(ctx->trans);
-       index_mailbox_reset_uidvalidity(ibox);
+       index_mailbox_reset_uidvalidity(box);
        mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
 
        /* if backup index file exists, try to use it */
index 8668bfc64c4f8487e2e95a3b0a5394fe19ffc54d..bef90815777cd36f373e4c92786ba9d4c1157489 100644 (file)
@@ -2,7 +2,7 @@
 #define DBOX_SYNC_REBUILD_H
 
 struct dbox_sync_rebuild_context {
-       struct index_mailbox *ibox;
+       struct mailbox *box;
 
        struct mail_index_view *view;
        struct mail_index_transaction *trans;
@@ -16,7 +16,7 @@ struct dbox_sync_rebuild_context {
 };
 
 struct dbox_sync_rebuild_context *
-dbox_sync_index_rebuild_init(struct index_mailbox *mbox,
+dbox_sync_index_rebuild_init(struct mailbox *box,
                             struct mail_index_view *view,
                             struct mail_index_transaction *trans);
 void dbox_sync_index_rebuild_deinit(struct dbox_sync_rebuild_context **ctx);
index 668d094a3f77cd69b0a23d7858befc3a2db72251..0dd7b616967c7c4bdf9883e5b835439228ab8bb4 100644 (file)
@@ -28,7 +28,7 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view,
                mail_index_lookup_uid(view, seq, &uid);
                mail_storage_set_critical(&mbox->storage->storage.storage,
                        "dbox %s: map uid lost for uid %u",
-                       mbox->ibox.box.path, uid);
+                       mbox->box.path, uid);
                mbox->storage->storage.files_corrupted = TRUE;
                return -1;
        }
@@ -47,7 +47,7 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view,
        if (cur_map_uid_validity != mbox->map_uid_validity) {
                mail_storage_set_critical(&mbox->storage->storage.storage,
                        "dbox %s: map uidvalidity mismatch (%u vs %u)",
-                       mbox->ibox.box.path, mbox->map_uid_validity,
+                       mbox->box.path, mbox->map_uid_validity,
                        cur_map_uid_validity);
                mbox->storage->storage.files_corrupted = TRUE;
                return -1;
@@ -58,8 +58,8 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view,
 
 static void dbox_mail_set_expunged(struct dbox_mail *mail, uint32_t map_uid)
 {
-       struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox;
        struct mail *_mail = &mail->imail.mail.mail;
+       struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)_mail->box;
 
        (void)mail_index_refresh(_mail->box->index);
        if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
@@ -75,7 +75,8 @@ static void dbox_mail_set_expunged(struct dbox_mail *mail, uint32_t map_uid)
 
 static int dbox_mail_open_init(struct dbox_mail *mail, uint32_t map_uid)
 {
-       struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox;
+       struct mdbox_mailbox *mbox =
+               (struct mdbox_mailbox *)mail->imail.mail.mail.box;
        uint32_t file_id;
        int ret;
 
@@ -98,8 +99,8 @@ static int dbox_mail_open_init(struct dbox_mail *mail, uint32_t map_uid)
 int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
                    struct dbox_file **file_r)
 {
-       struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox;
        struct mail *_mail = &mail->imail.mail.mail;
+       struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)_mail->box;
        uint32_t prev_file_id = 0, map_uid = 0;
        bool deleted;
 
index 0c9fdd8e68613d6bbc748277b23809fdf59bfa36..fc01afb0bf8bf7643c9d0cf4c9f518d34b83ee7a 100644 (file)
@@ -146,7 +146,7 @@ static int mdbox_save_mail_write_metadata(struct mdbox_save_context *ctx,
                mail->append_offset - mail->file_append->file->msg_header_size;
 
        dbox_save_write_metadata(&ctx->ctx.ctx, ctx->ctx.cur_output,
-                                ctx->mbox->ibox.box.name, guid_128);
+                                ctx->mbox->box.name, guid_128);
        /* save the 128bit GUID to index so if the map index gets corrupted
           we can still find the message */
        mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
@@ -298,9 +298,9 @@ void mdbox_transaction_save_commit_post(struct mail_save_context *_ctx,
        dbox_map_append_free(&ctx->append_ctx);
 
        if (!ctx->mbox->storage->storage.storage.set->fsync_disable) {
-               if (fdatasync_path(ctx->mbox->ibox.box.path) < 0) {
+               if (fdatasync_path(ctx->mbox->box.path) < 0) {
                        i_error("fdatasync_path(%s) failed: %m",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                }
        }
        mdbox_transaction_save_rollback(_ctx);
index c83da17b87dc6f54521a9872f43890dedeb74ec3..f1178ca57d0277abcd61e2156eb2872ea1c4b8c1 100644 (file)
@@ -429,7 +429,7 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,
                return -1;
        }
 
-       rebuild_ctx = dbox_sync_index_rebuild_init(&mbox->ibox, view, trans);
+       rebuild_ctx = dbox_sync_index_rebuild_init(&mbox->box, view, trans);
        rebuild_mailbox_multi(ctx, rebuild_ctx, mbox, view, trans);
        dbox_sync_index_rebuild_deinit(&rebuild_ctx);
 
index 3e0f4259805d0fb71bbf5ea32ebc9f7ad3a5b5c2..9095bb9c5259e545722ce93221110d3b9088abe9 100644 (file)
@@ -105,6 +105,7 @@ mdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                    enum mailbox_flags flags)
 {
        struct mdbox_mailbox *mbox;
+       struct index_mailbox_context *ibox;
        pool_t pool;
 
        /* dbox can't work without index files */
@@ -112,37 +113,37 @@ mdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        pool = pool_alloconly_create("mdbox mailbox", 1024+512);
        mbox = p_new(pool, struct mdbox_mailbox, 1);
-       mbox->ibox.box = mdbox_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &mdbox_mail_vfuncs;
+       mbox->box = mdbox_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &mdbox_mail_vfuncs;
 
-       mbox->ibox.save_commit_pre = mdbox_transaction_save_commit_pre;
-       mbox->ibox.save_commit_post = mdbox_transaction_save_commit_post;
-       mbox->ibox.save_rollback = mdbox_transaction_save_rollback;
-
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    DBOX_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.box.index,
+       mail_index_set_fsync_types(mbox->box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
-       mbox->ibox.index_flags |= MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS |
+       ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
+       ibox->save_commit_pre = mdbox_transaction_save_commit_pre;
+       ibox->save_commit_post = mdbox_transaction_save_commit_post;
+       ibox->save_rollback = mdbox_transaction_save_rollback;
+       ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS |
                MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY;
 
        mbox->storage = (struct mdbox_storage *)storage;
        mbox->ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "mdbox", 0,
+               mail_index_ext_register(mbox->box.index, "mdbox", 0,
                                        sizeof(struct mdbox_mail_index_record),
                                        sizeof(uint32_t));
        mbox->hdr_ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "mdbox-hdr",
+               mail_index_ext_register(mbox->box.index, "mdbox-hdr",
                                        sizeof(struct mdbox_index_header), 0, 0);
        mbox->guid_ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "guid",
+               mail_index_ext_register(mbox->box.index, "guid",
                                        0, MAIL_GUID_128_SIZE, 1);
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 int mdbox_read_header(struct mdbox_mailbox *mbox,
@@ -151,13 +152,13 @@ int mdbox_read_header(struct mdbox_mailbox *mbox,
        const void *data;
        size_t data_size;
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
+       mail_index_get_header_ext(mbox->box.view, mbox->hdr_ext_id,
                                  &data, &data_size);
        if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE &&
            (!mbox->creating || data_size != 0)) {
                mail_storage_set_critical(&mbox->storage->storage.storage,
                        "dbox %s: Invalid dbox header size",
-                       mbox->ibox.box.path);
+                       mbox->box.path);
                return -1;
        }
        memset(hdr, 0, sizeof(*hdr));
@@ -285,7 +286,7 @@ static int
 mdbox_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
 {
        if (!box->opened) {
-               if (index_storage_mailbox_open(box) < 0)
+               if (index_storage_mailbox_open(box, FALSE) < 0)
                        return -1;
        }
        return mdbox_write_index_header(box, update);
index b937f0194d2cf7f10174f97ee70f8c2c0fdf4e38..cf071122170ca7ed2d5b7fb027f2ddff60a36186 100644 (file)
@@ -38,7 +38,7 @@ struct mdbox_mail_index_record {
 };
 
 struct mdbox_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct mdbox_storage *storage;
 
        uint32_t map_uid_validity;
index 94fb61dcdbfa6a91c39bfbb1805782f0869a6fc8..d72f9096371d5624a6e24f71ecdc22d1013b4e8d 100644 (file)
@@ -32,7 +32,7 @@ dbox_sync_verify_expunge_guid(struct mdbox_sync_context *ctx, uint32_t seq,
 
        mail_storage_set_critical(&ctx->mbox->storage->storage.storage,
                "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s",
-               ctx->mbox->ibox.box.vname, uid,
+               ctx->mbox->box.vname, uid,
                binary_to_hex(data, MAIL_GUID_128_SIZE),
                binary_to_hex(guid_128, MAIL_GUID_128_SIZE));
        ctx->mbox->storage->storage.files_corrupted = TRUE;
@@ -86,7 +86,7 @@ static int mdbox_sync_add(struct mdbox_sync_context *ctx,
 
 static void dbox_sync_mark_expunges(struct mdbox_sync_context *ctx)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        struct seq_range_iter iter;
        unsigned int n;
        const void *data;
@@ -123,7 +123,7 @@ static int mdbox_sync_index_finish_expunges(struct mdbox_sync_context *ctx)
 
 static int mdbox_sync_index(struct mdbox_sync_context *ctx)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        const struct mail_index_header *hdr;
        struct mail_index_sync_rec sync_rec;
        uint32_t seq1, seq2;
@@ -138,7 +138,7 @@ static int mdbox_sync_index(struct mdbox_sync_context *ctx)
        /* mark the newly seen messages as recent */
        if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
                                        hdr->next_uid, &seq1, &seq2)) {
-               index_mailbox_set_recent_seq(&ctx->mbox->ibox, ctx->sync_view,
+               index_mailbox_set_recent_seq(&ctx->mbox->box, ctx->sync_view,
                                             seq1, seq2);
        }
 
@@ -167,14 +167,14 @@ static int mdbox_refresh_header(struct mdbox_mailbox *mbox, bool retry)
        struct mdbox_index_header hdr;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.box.index);
+       view = mail_index_view_open(mbox->box.index);
        ret = mdbox_read_header(mbox, &hdr);
        mail_index_view_close(&view);
 
        if (ret == 0) {
                ret = mbox->storage->storage.files_corrupted ? -1 : 0;
        } else if (retry) {
-               (void)mail_index_refresh(mbox->ibox.box.index);
+               (void)mail_index_refresh(mbox->box.index);
                return mdbox_refresh_header(mbox, FALSE);
        }
        return ret;
@@ -183,7 +183,7 @@ static int mdbox_refresh_header(struct mdbox_mailbox *mbox, bool retry)
 int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
                     struct mdbox_sync_context **ctx_r)
 {
-       struct mail_storage *storage = mbox->ibox.box.storage;
+       struct mail_storage *storage = mbox->box.storage;
        struct mdbox_sync_context *ctx;
        enum mail_index_sync_flags sync_flags = 0;
        unsigned int i;
@@ -195,7 +195,7 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
        if (rebuild) {
                if (mdbox_storage_rebuild(mbox->storage) < 0)
                        return -1;
-               index_mailbox_reset_uidvalidity(&mbox->ibox);
+               index_mailbox_reset_uidvalidity(&mbox->box);
                storage_rebuilt = TRUE;
        }
 
@@ -203,7 +203,7 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
        ctx->mbox = mbox;
        ctx->flags = flags;
 
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
        if (!rebuild && (flags & MDBOX_SYNC_FLAG_FORCE) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
@@ -213,13 +213,13 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
        sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
 
        for (i = 0;; i++) {
-               ret = mail_index_sync_begin(mbox->ibox.box.index,
+               ret = mail_index_sync_begin(mbox->box.index,
                                            &ctx->index_sync_ctx,
                                            &ctx->sync_view, &ctx->trans,
                                            sync_flags);
                if (ret <= 0) {
                        if (ret < 0)
-                               mail_storage_set_index_error(&mbox->ibox.box);
+                               mail_storage_set_index_error(&mbox->box);
                        i_free(ctx);
                        *ctx_r = NULL;
                        return ret;
@@ -246,7 +246,7 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
                        }
                        mail_storage_set_critical(storage,
                                "dbox %s: Storage keeps breaking",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        ret = -1;
                }
                mail_index_sync_rollback(&ctx->index_sync_ctx);
@@ -269,7 +269,7 @@ int mdbox_sync_finish(struct mdbox_sync_context **_ctx, bool success)
 
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
+                       mail_storage_set_index_error(&ctx->mbox->box);
                        ret = -1;
                }
        } else {
@@ -304,7 +304,7 @@ mdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       if (ret == 0 && (index_mailbox_want_full_sync(&mbox->ibox, flags) ||
+       if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) ||
                         mbox->storage->storage.files_corrupted)) {
                if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)
                        mdbox_sync_flags |= MDBOX_SYNC_FLAG_FORCE_REBUILD;
index f92b7c5d08fcca5519fc9e397bf858712a58b2c9..b5a0e5574b7b4354f9ca93e6376404e833c95d65 100644 (file)
@@ -13,7 +13,7 @@ static void sdbox_file_init_paths(struct sdbox_file *file, const char *fname)
        i_free(file->file.primary_path);
        i_free(file->file.alt_path);
        file->file.primary_path =
-               i_strdup_printf("%s/%s", file->mbox->ibox.box.path, fname);
+               i_strdup_printf("%s/%s", file->mbox->box.path, fname);
        if (file->mbox->alt_path != NULL) {
                file->file.alt_path =
                        i_strdup_printf("%s/%s", file->mbox->alt_path, fname);
@@ -36,7 +36,7 @@ struct dbox_file *sdbox_file_init(struct sdbox_mailbox *mbox, uint32_t uid)
                } else {
                        file->file.primary_path =
                                i_strdup_printf("%s/%s",
-                                               file->mbox->ibox.box.path,
+                                               file->mbox->box.path,
                                                dbox_generate_tmp_filename());
                }
        } T_END;
@@ -59,7 +59,7 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid)
 
        old_path = file->file.cur_path;
        new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid);
-       new_path = t_strdup_printf("%s/%s", file->mbox->ibox.box.path,
+       new_path = t_strdup_printf("%s/%s", file->mbox->box.path,
                                   new_fname);
        if (rename(old_path, new_path) < 0) {
                mail_storage_set_critical(&file->file.storage->storage,
@@ -75,7 +75,7 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid)
 int sdbox_file_create_fd(struct dbox_file *file, const char *path, bool parents)
 {
        struct sdbox_file *sfile = (struct sdbox_file *)file;
-       struct mailbox *box = &sfile->mbox->ibox.box;
+       struct mailbox *box = &sfile->mbox->box;
        const char *p, *dir;
        mode_t old_mask;
        int fd;
index a337cdb7764c0b9ca8fdfcbab0ff59bf7dcd9b2b..5390bd5a2726a36a7460b647622d2c2ee0ffe703 100644 (file)
@@ -14,8 +14,8 @@
 
 static void sdbox_mail_set_expunged(struct dbox_mail *mail)
 {
-       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)mail->imail.ibox;
        struct mail *_mail = &mail->imail.mail.mail;
+       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)_mail->box;
 
        (void)mail_index_refresh(_mail->box->index);
        if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
index c2073836a7488fdefa77591e3856465ab05b61d5..b9c930007cc19288d44aef63477a2822f7653672 100644 (file)
@@ -270,9 +270,9 @@ void sdbox_transaction_save_commit_post(struct mail_save_context *_ctx,
                ctx->ctx.failed = TRUE;
 
        if (!ctx->mbox->storage->storage.storage.set->fsync_disable) {
-               if (fdatasync_path(ctx->mbox->ibox.box.path) < 0) {
+               if (fdatasync_path(ctx->mbox->box.path) < 0) {
                        i_error("fdatasync_path(%s) failed: %m",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                }
        }
        sdbox_transaction_save_rollback(_ctx);
index 5222d1e1007c2f43130d5e2fab78470184d37022..dd50cf5bd1d04bb00a40d4dc63740393838cfd1d 100644 (file)
@@ -54,6 +54,7 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                    enum mailbox_flags flags)
 {
        struct sdbox_mailbox *mbox;
+       struct index_mailbox_context *ibox;
        pool_t pool;
 
        /* dbox can't work without index files */
@@ -61,23 +62,23 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        pool = pool_alloconly_create("dbox mailbox", 1024+512);
        mbox = p_new(pool, struct sdbox_mailbox, 1);
-       mbox->ibox.box = sdbox_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &sdbox_mail_vfuncs;
+       mbox->box = sdbox_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &sdbox_mail_vfuncs;
 
-       mbox->ibox.save_commit_pre = sdbox_transaction_save_commit_pre;
-       mbox->ibox.save_commit_post = sdbox_transaction_save_commit_post;
-       mbox->ibox.save_rollback = sdbox_transaction_save_rollback;
-
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    DBOX_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.box.index,
+       mail_index_set_fsync_types(mbox->box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
-       mbox->ibox.index_flags |= MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS |
+       ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
+       ibox->save_commit_pre = sdbox_transaction_save_commit_pre;
+       ibox->save_commit_post = sdbox_transaction_save_commit_post;
+       ibox->save_rollback = sdbox_transaction_save_rollback;
+       ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS |
                MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY;
 
        mbox->storage = (struct sdbox_storage *)storage;
@@ -85,9 +86,9 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                p_strconcat(pool, list->set.alt_dir, "/",
                            list->set.maildir_name, NULL);
        mbox->hdr_ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "dbox-hdr",
+               mail_index_ext_register(mbox->box.index, "dbox-hdr",
                                        sizeof(struct sdbox_index_header), 0, 0);
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 int sdbox_read_header(struct sdbox_mailbox *mbox,
@@ -96,13 +97,13 @@ int sdbox_read_header(struct sdbox_mailbox *mbox,
        const void *data;
        size_t data_size;
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
+       mail_index_get_header_ext(mbox->box.view, mbox->hdr_ext_id,
                                  &data, &data_size);
        if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
            (!mbox->creating || data_size != 0)) {
                mail_storage_set_critical(&mbox->storage->storage.storage,
                        "dbox %s: Invalid dbox header size",
-                       mbox->ibox.box.path);
+                       mbox->box.path);
                return -1;
        }
        memset(hdr, 0, sizeof(*hdr));
@@ -224,7 +225,7 @@ static int
 dbox_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
 {
        if (!box->opened) {
-               if (index_storage_mailbox_open(box) < 0)
+               if (index_storage_mailbox_open(box, FALSE) < 0)
                        return -1;
        }
        return sdbox_write_index_header(box, update);
index 34148a30dd3f719451c398062d29adfb3c1c337b..08467e8328a68cbed24a81ac1eee59c032f9a711 100644 (file)
@@ -24,7 +24,7 @@ struct sdbox_storage {
 };
 
 struct sdbox_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct sdbox_storage *storage;
 
        uint32_t hdr_ext_id;
index bd3de850217a469578ab8bff3d9423a2cc15cea8..22d1e225e81307e44a4cc15cb4eb8df68264f1d6 100644 (file)
@@ -32,7 +32,7 @@ static void
 dbox_sync_mark_single_file_expunged(struct sdbox_sync_context *ctx,
                                    const struct sdbox_sync_file_entry *entry)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        uint32_t seq;
 
        mail_index_lookup_seq(ctx->sync_view, entry->uid, &seq);
index 33e22a88f56752573528fa19910418246677ea2a..1842ec90e7b3efda6d9e77cbff72e681909932b3 100644 (file)
 
 static void sdbox_sync_set_uidvalidity(struct dbox_sync_rebuild_context *ctx)
 {
-       struct mailbox *box = &ctx->ibox->box;
        uint32_t uid_validity;
 
        /* if uidvalidity is set in the old index, use it */
        uid_validity = mail_index_get_header(ctx->view)->uid_validity;
        if (uid_validity == 0)
-               uid_validity = dbox_get_uidvalidity_next(box->list);
+               uid_validity = dbox_get_uidvalidity_next(ctx->box->list);
 
        mail_index_update_header(ctx->trans,
                offsetof(struct mail_index_header, uid_validity),
@@ -58,7 +57,7 @@ static int
 sdbox_sync_add_file(struct dbox_sync_rebuild_context *ctx,
                    const char *fname, bool primary)
 {
-       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->ibox;
+       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->box;
        struct dbox_file *file;
        unsigned long uid;
        char *p;
@@ -72,7 +71,7 @@ sdbox_sync_add_file(struct dbox_sync_rebuild_context *ctx,
        uid = strtoul(fname, &p, 10);
        if (*p != '\0' || uid == 0 || uid >= (uint32_t)-1) {
                i_warning("dbox %s: Ignoring invalid filename %s",
-                         ctx->ibox->box.path, fname);
+                         ctx->box->path, fname);
                return 0;
        }
 
@@ -87,7 +86,7 @@ sdbox_sync_add_file(struct dbox_sync_rebuild_context *ctx,
 static int sdbox_sync_index_rebuild_dir(struct dbox_sync_rebuild_context *ctx,
                                        const char *path, bool primary)
 {
-       struct mail_storage *storage = ctx->ibox->box.storage;
+       struct mail_storage *storage = ctx->box->storage;
        DIR *dir;
        struct dirent *d;
        int ret = 0;
@@ -99,7 +98,7 @@ static int sdbox_sync_index_rebuild_dir(struct dbox_sync_rebuild_context *ctx,
                                /* alt directory doesn't exist, ignore */
                                return 0;
                        }
-                       mailbox_set_deleted(&ctx->ibox->box);
+                       mailbox_set_deleted(ctx->box);
                        return -1;
                }
                mail_storage_set_critical(storage,
@@ -129,7 +128,7 @@ static int sdbox_sync_index_rebuild_dir(struct dbox_sync_rebuild_context *ctx,
 
 static void sdbox_sync_update_header(struct dbox_sync_rebuild_context *ctx)
 {
-       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->ibox;
+       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->box;
        struct sdbox_index_header hdr;
 
        if (sdbox_read_header(mbox, &hdr) < 0)
@@ -143,11 +142,11 @@ static void sdbox_sync_update_header(struct dbox_sync_rebuild_context *ctx)
 static int
 sdbox_sync_index_rebuild_singles(struct dbox_sync_rebuild_context *ctx)
 {
-       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->ibox;
+       struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->box;
        int ret = 0;
 
        sdbox_sync_set_uidvalidity(ctx);
-       if (sdbox_sync_index_rebuild_dir(ctx, ctx->ibox->box.path, TRUE) < 0)
+       if (sdbox_sync_index_rebuild_dir(ctx, ctx->box->path, TRUE) < 0)
                ret = -1;
        else if (mbox->alt_path != NULL)
                ret = sdbox_sync_index_rebuild_dir(ctx, mbox->alt_path, FALSE);
@@ -162,11 +161,11 @@ int sdbox_sync_index_rebuild(struct sdbox_mailbox *mbox)
        struct mail_index_transaction *trans;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.box.index);
+       view = mail_index_view_open(mbox->box.index);
        trans = mail_index_transaction_begin(view,
                                        MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
 
-       ctx = dbox_sync_index_rebuild_init(&mbox->ibox, view, trans);
+       ctx = dbox_sync_index_rebuild_init(&mbox->box, view, trans);
        ret = sdbox_sync_index_rebuild_singles(ctx);
        dbox_sync_index_rebuild_deinit(&ctx);
 
index 3498706a2f1c49b1e73f008d94393f46499f69f9..7714271d1f4a66e714897dd2da2d8ade6291b0fe 100644 (file)
@@ -90,7 +90,7 @@ static int sdbox_sync_add(struct sdbox_sync_context *ctx,
 
 static int sdbox_sync_index(struct sdbox_sync_context *ctx)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        const struct mail_index_header *hdr;
        struct mail_index_sync_rec sync_rec;
         struct hash_iterate_context *iter;
@@ -107,7 +107,7 @@ static int sdbox_sync_index(struct sdbox_sync_context *ctx)
        /* mark the newly seen messages as recent */
        if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
                                        hdr->next_uid, &seq1, &seq2)) {
-               index_mailbox_set_recent_seq(&ctx->mbox->ibox, ctx->sync_view,
+               index_mailbox_set_recent_seq(&ctx->mbox->box, ctx->sync_view,
                                             seq1, seq2);
        }
 
@@ -148,14 +148,14 @@ static int sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry)
        struct sdbox_index_header hdr;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.box.index);
+       view = mail_index_view_open(mbox->box.index);
        ret = sdbox_read_header(mbox, &hdr);
        mail_index_view_close(&view);
 
        if (ret == 0) {
                ret = mbox->sync_rebuild ? -1 : 0;
        } else if (retry) {
-               (void)mail_index_refresh(mbox->ibox.box.index);
+               (void)mail_index_refresh(mbox->box.index);
                return sdbox_refresh_header(mbox, FALSE);
        }
        return ret;
@@ -164,7 +164,7 @@ static int sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry)
 int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
                     struct sdbox_sync_context **ctx_r)
 {
-       struct mail_storage *storage = mbox->ibox.box.storage;
+       struct mail_storage *storage = mbox->box.storage;
        struct sdbox_sync_context *ctx;
        enum mail_index_sync_flags sync_flags = 0;
        unsigned int i;
@@ -178,7 +178,7 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
        ctx->mbox = mbox;
        ctx->flags = flags;
 
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
        if (!rebuild && (flags & SDBOX_SYNC_FLAG_FORCE) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
@@ -188,13 +188,13 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
        sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
 
        for (i = 0;; i++) {
-               ret = mail_index_sync_begin(mbox->ibox.box.index,
+               ret = mail_index_sync_begin(mbox->box.index,
                                            &ctx->index_sync_ctx,
                                            &ctx->sync_view, &ctx->trans,
                                            sync_flags);
                if (ret <= 0) {
                        if (ret < 0)
-                               mail_storage_set_index_error(&mbox->ibox.box);
+                               mail_storage_set_index_error(&mbox->box);
                        i_free(ctx);
                        *ctx_r = NULL;
                        return ret;
@@ -214,12 +214,12 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
                        if (i >= SDBOX_REBUILD_COUNT) {
                                mail_storage_set_critical(storage,
                                        "dbox %s: Index keeps breaking",
-                                       ctx->mbox->ibox.box.path);
+                                       ctx->mbox->box.path);
                                ret = -1;
                        } else {
                                /* do a full resync and try again. */
                                i_warning("dbox %s: Rebuilding index",
-                                         ctx->mbox->ibox.box.path);
+                                         ctx->mbox->box.path);
                                ret = sdbox_sync_index_rebuild(mbox);
                        }
                }
@@ -243,7 +243,7 @@ int sdbox_sync_finish(struct sdbox_sync_context **_ctx, bool success)
 
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
+                       mail_storage_set_index_error(&ctx->mbox->box);
                        ret = -1;
                }
        } else {
@@ -280,7 +280,7 @@ sdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       if (ret == 0 && (index_mailbox_want_full_sync(&mbox->ibox, flags) ||
+       if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) ||
                         mbox->sync_rebuild)) {
                if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)
                        sdbox_sync_flags |= SDBOX_SYNC_FLAG_FORCE_REBUILD;
index 0215a80af8d45e901e1dfd11a047316f50670fd0..f6147c945957ef8c91e988d0e1387fc75de17d35 100644 (file)
@@ -180,7 +180,7 @@ static void index_mail_parse_header_register_all_wanted(struct index_mail *mail)
        unsigned int i, count;
 
        all_cache_fields =
-               mail_cache_register_get_list(mail->ibox->box.cache,
+               mail_cache_register_get_list(mail->mail.mail.box->cache,
                                             pool_datastack_create(), &count);
        for (i = 0; i < count; i++) {
                if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0)
@@ -248,7 +248,7 @@ void index_mail_parse_header_init(struct index_mail *mail,
           Date: header. if we have Date field's index set at this point we
           know that we want it. otherwise add it and remember that we don't
           want it cached. */
-       field_idx = get_header_field_idx(&mail->ibox->box, "Date",
+       field_idx = get_header_field_idx(mail->mail.mail.box, "Date",
                                         MAIL_CACHE_DECISION_NO);
        match = array_get(&mail->header_match, &match_count);
        if (field_idx < match_count &&
@@ -284,6 +284,7 @@ void index_mail_parse_header(struct message_part *part,
                             struct message_header_line *hdr,
                             struct index_mail *mail)
 {
+       struct mail *_mail = &mail->mail.mail;
        struct index_mail_data *data = &mail->data;
        unsigned int field_idx, count;
        uint8_t *match;
@@ -319,7 +320,7 @@ void index_mail_parse_header(struct message_part *part,
                        const char *cache_field_name =
                                t_strconcat("hdr.", hdr->name, NULL);
                        data->parse_line.field_idx =
-                               mail_cache_register_lookup(mail->ibox->box.cache,
+                               mail_cache_register_lookup(_mail->box->cache,
                                                           cache_field_name);
                } T_END;
        }
@@ -481,7 +482,7 @@ int index_mail_headers_get_envelope(struct index_mail *mail)
                mail->data.stream->v_offset;
 
        mail->data.save_envelope = TRUE;
-       header_ctx = mailbox_header_lookup_init(&mail->ibox->box,
+       header_ctx = mailbox_header_lookup_init(mail->mail.mail.box,
                                                imap_envelope_headers);
        if (mail_get_header_stream(&mail->mail.mail, header_ctx, &stream) < 0) {
                mailbox_header_lookup_unref(&header_ctx);
@@ -606,7 +607,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field,
 
        i_assert(field != NULL);
 
-       field_idx = get_header_field_idx(&mail->ibox->box, field,
+       field_idx = get_header_field_idx(mail->mail.mail.box, field,
                                         MAIL_CACHE_DECISION_TEMP);
 
        dest = str_new(mail->data_pool, 128);
@@ -620,7 +621,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field,
                        /* parse */
                        headers[0] = field; headers[1] = NULL;
                        headers_ctx = mailbox_header_lookup_init(
-                                               &mail->ibox->box, headers);
+                                               mail->mail.mail.box, headers);
                        ret = index_mail_parse_headers(mail, headers_ctx);
                        mailbox_header_lookup_unref(&headers_ctx);
                        if (ret < 0)
index 6512233fe9feae02fb5767cea2af87b6bca4a4ca..49e5c571c9a0997620a0d448a332bacca89fc0c2 100644 (file)
@@ -69,7 +69,7 @@ static struct message_part *get_unserialized_parts(struct index_mail *mail)
        parts = message_part_deserialize(mail->data_pool, part_buf->data,
                                         part_buf->used, &error);
        if (parts == NULL) {
-               mail_cache_set_corrupted(mail->ibox->box.cache,
+               mail_cache_set_corrupted(mail->mail.mail.box->cache,
                        "Corrupted cached message_part data (%s)", error);
        }
        return parts;
@@ -134,7 +134,7 @@ enum mail_flags index_mail_get_flags(struct mail *_mail)
        flags = rec->flags & (MAIL_FLAGS_NONRECENT |
                              MAIL_INDEX_MAIL_FLAG_BACKEND);
 
-       if (index_mailbox_is_recent(mail->ibox, _mail->uid))
+       if (index_mailbox_is_recent(_mail->box, _mail->uid))
                flags |= MAIL_RECENT;
 
        return flags;
@@ -423,13 +423,14 @@ void index_mail_cache_add(struct index_mail *mail, enum index_cache_field field,
 void index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
                              const void *data, size_t data_size)
 {
-       const struct mail_storage_settings *set = mail->ibox->box.storage->set;
+       const struct mail_storage_settings *set =
+               mail->mail.mail.box->storage->set;
        const struct mail_index_header *hdr;
 
        if (set->mail_cache_min_mail_count > 0) {
                /* First check if we've configured caching not to be used with
                   low enough message count. */
-               hdr = mail_index_get_header(mail->ibox->box.view);
+               hdr = mail_index_get_header(mail->mail.mail.box->view);
                if (hdr->messages_count < set->mail_cache_min_mail_count)
                        return;
        }
@@ -527,7 +528,7 @@ static void index_mail_body_parsed_cache_message_parts(struct index_mail *mail)
                return;
        }
 
-       decision = mail_cache_field_get_decision(mail->ibox->box.cache,
+       decision = mail_cache_field_get_decision(mail->mail.mail.box->cache,
                                                 cache_field);
        if (decision == (MAIL_CACHE_DECISION_NO | MAIL_CACHE_DECISION_FORCED)) {
                /* we never want it cached */
@@ -611,7 +612,7 @@ index_mail_body_parsed_cache_bodystructure(struct index_mail *mail,
 
        /* normally don't cache both BODY and BODYSTRUCTURE, but do it
           if BODY is forced to be cached */
-       dec = mail_cache_field_get_decision(mail->ibox->box.cache,
+       dec = mail_cache_field_get_decision(mail->mail.mail.box->cache,
                                            cache_field_body);
        if (plain_bodystructure ||
            (bodystructure_cached &&
@@ -1080,7 +1081,6 @@ void index_mail_init(struct index_mail *mail,
                     enum mail_fetch_field wanted_fields,
                     struct mailbox_header_lookup_ctx *_wanted_headers)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)_t->box;
        struct index_transaction_context *t =
                (struct index_transaction_context *)_t;
        struct index_header_lookup_ctx *wanted_headers =
@@ -1090,18 +1090,18 @@ void index_mail_init(struct index_mail *mail,
        array_create(&mail->mail.module_contexts, mail->mail.pool,
                     sizeof(void *), 5);
 
-       mail->mail.v = *ibox->box.mail_vfuncs;
-       mail->mail.mail.box = &ibox->box;
+       mail->mail.v = *_t->box->mail_vfuncs;
+       mail->mail.mail.box = _t->box;
        mail->mail.mail.transaction = &t->mailbox_ctx;
        mail->mail.wanted_fields = wanted_fields;
        mail->mail.wanted_headers = _wanted_headers;
 
-       hdr = mail_index_get_header(ibox->box.view);
+       hdr = mail_index_get_header(_t->box->view);
        mail->uid_validity = hdr->uid_validity;
 
        t->mail_ref_count++;
        mail->data_pool = pool_alloconly_create("index_mail", 16384);
-       mail->ibox = ibox;
+       mail->ibox = INDEX_STORAGE_CONTEXT(_t->box);
        mail->trans = t;
        mail->wanted_fields = wanted_fields;
        if (wanted_headers != NULL) {
@@ -1183,7 +1183,7 @@ static void check_envelope(struct index_mail *mail)
        /* don't waste time doing full checks for all required
           headers. assume that if we have "hdr.message-id" cached,
           we don't need to parse the header. */
-       cache_field_hdr = mail_cache_register_lookup(mail->ibox->box.cache,
+       cache_field_hdr = mail_cache_register_lookup(mail->mail.mail.box->cache,
                                                     "hdr.message-id");
        if (cache_field_hdr == (unsigned int)-1 ||
            mail_cache_field_exists(mail->trans->cache_view,
@@ -1307,7 +1307,7 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq)
 
                /* open the stream only if we didn't get here from
                   mailbox_save_init() */
-               hdr = mail_index_get_header(mail->ibox->box.view);
+               hdr = mail_index_get_header(_mail->box->view);
                if (_mail->uid != 0 && _mail->uid < hdr->next_uid)
                        (void)mail_get_stream(_mail, NULL, NULL, &input);
        }
@@ -1432,7 +1432,7 @@ void index_mail_update_flags(struct mail *mail, enum modify_type modify_type,
        struct index_mail *imail = (struct index_mail *)mail;
 
        if ((flags & MAIL_RECENT) == 0 &&
-           index_mailbox_is_recent(imail->ibox, mail->uid))
+           index_mailbox_is_recent(mail->box, mail->uid))
                index_mail_drop_recent_flag(imail);
 
        flags &= MAIL_FLAGS_NONRECENT | MAIL_INDEX_MAIL_FLAG_BACKEND;
index 5ebe8b866ba3cb08068cca329f1ce17e36eb2ffe..d9c643801e3b943237dad955b4ac05ee9b5d0c0b 100644 (file)
@@ -116,9 +116,9 @@ struct index_mail_data {
 struct index_mail {
         struct mail_private mail;
        struct index_mail_data data;
+       struct index_mailbox_context *ibox;
 
        pool_t data_pool;
-       struct index_mailbox *ibox;
        struct index_transaction_context *trans;
        uint32_t uid_validity;
 
index 15602d894648e36f0981fa380bc18ca555f0ecfa..8c50d6b3d1447ae3f684f005c61f4dc39bceb581 100644 (file)
@@ -23,15 +23,18 @@ struct index_notify_io {
        struct io *io;
 };
 
-static void notify_delay_callback(struct index_mailbox *ibox)
+static void notify_delay_callback(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        if (ibox->notify_delay_to != NULL)
                timeout_remove(&ibox->notify_delay_to);
-       ibox->box.notify_callback(&ibox->box, ibox->box.notify_context);
+       box->notify_callback(box, box->notify_context);
 }
 
-static void check_timeout(struct index_mailbox *ibox)
+static void check_timeout(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        struct index_notify_file *file;
        struct stat st;
        bool notify = FALSE;
@@ -45,29 +48,31 @@ static void check_timeout(struct index_mailbox *ibox)
        }
 
        if (notify)
-               notify_delay_callback(ibox);
+               notify_delay_callback(box);
 }
 
-static void notify_callback(struct index_mailbox *ibox)
+static void notify_callback(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        timeout_reset(ibox->notify_to);
 
        if (ibox->notify_delay_to == NULL) {
                ibox->notify_delay_to =
                        timeout_add(NOTIFY_DELAY_MSECS,
-                                   notify_delay_callback, ibox);
+                                   notify_delay_callback, box);
        }
 }
 
-void index_mailbox_check_add(struct index_mailbox *ibox,
-                            const char *path)
+void index_mailbox_check_add(struct mailbox *box, const char *path)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        struct index_notify_file *file;
        struct stat st;
        struct io *io = NULL;
        struct index_notify_io *aio;
 
-       (void)io_add_notify(path, notify_callback, ibox, &io);
+       (void)io_add_notify(path, notify_callback, box, &io);
        if (io != NULL) {
                aio = i_new(struct index_notify_io, 1);
                aio->io = io;
@@ -87,13 +92,14 @@ void index_mailbox_check_add(struct index_mailbox *ibox,
         * when the filesystem is remote (NFS, ...) */
        if (ibox->notify_to == NULL) {
                ibox->notify_to =
-                       timeout_add(ibox->box.notify_min_interval * 1000,
-                                   check_timeout, ibox);
+                       timeout_add(box->notify_min_interval * 1000,
+                                   check_timeout, box);
        }
 }
 
-void index_mailbox_check_remove_all(struct index_mailbox *ibox)
+void index_mailbox_check_remove_all(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        struct index_notify_file *file;
        struct index_notify_io *aio;
 
index f8a3ae215c69166f7049151a59072e9e13e4b81a..49dc2766747f3ef6a4b71bba3882d2d88ddbe599 100644 (file)
@@ -40,7 +40,7 @@
 struct index_search_context {
         struct mail_search_context mail_ctx;
        struct mail_index_view *view;
-       struct index_mailbox *ibox;
+       struct mailbox *box;
 
        uint32_t seq1, seq2;
        struct mail *mail;
@@ -96,7 +96,7 @@ static void search_init_arg(struct mail_search_arg *arg,
        case SEARCH_KEYWORDS:
        case SEARCH_MODSEQ:
                if (arg->type == SEARCH_MODSEQ)
-                       mail_index_modseq_enable(ctx->ibox->box.index);
+                       mail_index_modseq_enable(ctx->box->index);
                ctx->have_index_args = TRUE;
                break;
        case SEARCH_ALL:
@@ -162,7 +162,7 @@ static int search_arg_match_index(struct index_search_context *ctx,
                   may contain it. */
                flags = rec->flags & ~MAIL_RECENT;
                if ((arg->value.flags & MAIL_RECENT) != 0 &&
-                   index_mailbox_is_recent(ctx->ibox, rec->uid))
+                   index_mailbox_is_recent(ctx->box, rec->uid))
                        flags |= MAIL_RECENT;
                return (flags & arg->value.flags) == arg->value.flags;
        case SEARCH_KEYWORDS:
@@ -605,8 +605,7 @@ static int search_arg_match_text(struct mail_search_arg *args,
                        /* FIXME: do this once in init */
                        i_assert(*headers != NULL);
                        headers_ctx =
-                               mailbox_header_lookup_init(&ctx->ibox->box,
-                                                          headers);
+                               mailbox_header_lookup_init(ctx->box, headers);
                        if (mail_get_header_stream(ctx->mail, headers_ctx,
                                                   &input) < 0) {
                                mailbox_header_lookup_unref(&headers_ctx);
@@ -1017,7 +1016,7 @@ index_storage_search_init(struct mailbox_transaction_context *_t,
 
        ctx = i_new(struct index_search_context, 1);
        ctx->mail_ctx.transaction = _t;
-       ctx->ibox = (struct index_mailbox *)_t->box;
+       ctx->box = _t->box;
        ctx->view = t->trans_view;
        ctx->mail_ctx.args = args;
        ctx->mail_ctx.sort_program = index_sort_program_init(_t, sort_program);
@@ -1067,7 +1066,7 @@ int index_storage_search_deinit(struct mail_search_context *_ctx)
        ret = ctx->failed || ctx->error != NULL ? -1 : 0;
 
        if (ctx->error != NULL) {
-               mail_storage_set_error(ctx->ibox->box.storage,
+               mail_storage_set_error(ctx->box->storage,
                                       MAIL_ERROR_PARAMS, ctx->error);
        }
 
index c65058bba99d5aa5abd3d035f42f3c2f4424ca52..b4af44e4a1295b2080ec0fb8be551655260a692a 100644 (file)
@@ -34,7 +34,6 @@ void index_storage_get_status(struct mailbox *box,
                              enum mailbox_status_items items,
                              struct mailbox_status *status_r)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        const struct mail_index_header *hdr;
 
        i_assert(box->opened);
@@ -45,7 +44,7 @@ void index_storage_get_status(struct mailbox *box,
        hdr = mail_index_get_header(box->view);
        status_r->messages = hdr->messages_count;
        if ((items & STATUS_RECENT) != 0) {
-               status_r->recent = index_mailbox_get_recent_count(ibox);
+               status_r->recent = index_mailbox_get_recent_count(box);
                i_assert(status_r->recent <= status_r->messages);
        }
        status_r->unseen = hdr->messages_count - hdr->seen_messages_count;
index e9bfa3a3c16cef9ffb079c2417e70444f6271ca0..395ad3659b35395aceff076a8d25b2c98b5bdd78 100644 (file)
@@ -22,6 +22,9 @@
 
 #define LOCK_NOTIFY_INTERVAL 30
 
+struct index_storage_module index_storage_module =
+       MODULE_CONTEXT_INIT(&mail_storage_module_register);
+
 int index_list_create_missing_index_dir(struct mailbox_list *list,
                                        const char *name)
 {
@@ -104,11 +107,12 @@ static void set_cache_decisions(const char *set, const char *fields,
        }
 }
 
-static void index_cache_register_defaults(struct index_mailbox *ibox)
+static void index_cache_register_defaults(struct mailbox *box)
 {
-       const struct mail_storage_settings *set = ibox->box.storage->set;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+       const struct mail_storage_settings *set = box->storage->set;
        static bool initialized = FALSE;
-       struct mail_cache *cache = ibox->box.cache;
+       struct mail_cache *cache = box->cache;
 
        if (!initialized) {
                initialized = TRUE;
@@ -129,11 +133,12 @@ static void index_cache_register_defaults(struct index_mailbox *ibox)
                                   MAIL_INDEX_CACHE_FIELD_COUNT);
 }
 
-void index_storage_lock_notify(struct index_mailbox *ibox,
+void index_storage_lock_notify(struct mailbox *box,
                               enum mailbox_lock_notify_type notify_type,
                               unsigned int secs_left)
 {
-       struct mail_storage *storage = ibox->box.storage;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+       struct mail_storage *storage = box->storage;
        const char *str;
        time_t now;
 
@@ -162,8 +167,8 @@ void index_storage_lock_notify(struct index_mailbox *ibox,
 
                str = t_strdup_printf("Mailbox is locked, will abort in "
                                      "%u seconds", secs_left);
-               storage->callbacks.notify_no(&ibox->box, str,
-                                            storage->callback_context);
+               storage->callbacks.
+                       notify_no(box, str, storage->callback_context);
                break;
        case MAILBOX_LOCK_NOTIFY_MAILBOX_OVERRIDE:
                if (storage->callbacks.notify_ok == NULL)
@@ -171,21 +176,23 @@ void index_storage_lock_notify(struct index_mailbox *ibox,
 
                str = t_strdup_printf("Stale mailbox lock file detected, "
                                      "will override in %u seconds", secs_left);
-               storage->callbacks.notify_ok(&ibox->box, str,
-                                            storage->callback_context);
+               storage->callbacks.
+                       notify_ok(box, str, storage->callback_context);
                break;
        }
 }
 
-void index_storage_lock_notify_reset(struct index_mailbox *ibox)
+void index_storage_lock_notify_reset(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
        ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE;
 }
 
-int index_storage_mailbox_open(struct mailbox *box)
+int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        enum file_lock_method lock_method =
                box->storage->set->parsed_lock_method;
        enum mail_index_open_flags index_flags;
@@ -194,7 +201,7 @@ int index_storage_mailbox_open(struct mailbox *box)
        i_assert(!box->opened);
 
        index_flags = ibox->index_flags;
-       if (ibox->move_to_memory)
+       if (move_to_memory)
                ibox->index_flags &= ~MAIL_INDEX_OPEN_FLAG_CREATE;
 
        if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
@@ -211,7 +218,7 @@ int index_storage_mailbox_open(struct mailbox *box)
        }
 
        ret = mail_index_open(box->index, index_flags, lock_method);
-       if (ret <= 0 || ibox->move_to_memory) {
+       if (ret <= 0 || move_to_memory) {
                if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
                        mail_storage_set_index_error(box);
                        return -1;
@@ -228,13 +235,13 @@ int index_storage_mailbox_open(struct mailbox *box)
        }
 
        box->cache = mail_index_get_cache(box->index);
-       index_cache_register_defaults(ibox);
+       index_cache_register_defaults(box);
        box->view = mail_index_view_open(box->index);
        ibox->keyword_names = mail_index_get_keywords(box->index);
 
        box->opened = TRUE;
 
-       index_thread_mailbox_opened(ibox);
+       index_thread_mailbox_opened(box);
        if (hook_mailbox_opened != NULL)
                hook_mailbox_opened(box);
 
@@ -245,12 +252,12 @@ int index_storage_mailbox_open(struct mailbox *box)
        return 0;
 }
 
-void index_storage_mailbox_alloc(struct index_mailbox *ibox, const char *name,
+void index_storage_mailbox_alloc(struct mailbox *box, const char *name,
                                 struct istream *input,
                                 enum mailbox_flags flags,
                                 const char *index_prefix)
 {
-       struct mailbox *box = &ibox->box;
+       struct index_mailbox_context *ibox;
        const char *path;
        string_t *vname;
 
@@ -276,16 +283,16 @@ void index_storage_mailbox_alloc(struct index_mailbox *ibox, const char *name,
        array_create(&box->module_contexts,
                     box->pool, sizeof(void *), 5);
 
-       path = mailbox_list_get_path(box->list, name,
-                                    MAILBOX_LIST_PATH_TYPE_MAILBOX);
-       ibox->box.path = p_strdup(box->pool, path);
-
+       ibox = p_new(box->pool, struct index_mailbox_context, 1);
        ibox->index_flags = MAIL_INDEX_OPEN_FLAG_CREATE |
                mail_storage_settings_to_index_flags(box->storage->set);
-
        ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
-       box->index = index_storage_alloc(box->list, name, flags, index_prefix);
+       MODULE_CONTEXT_SET(box, index_storage_module, ibox);
 
+       path = mailbox_list_get_path(box->list, name,
+                                    MAILBOX_LIST_PATH_TYPE_MAILBOX);
+       box->path = p_strdup(box->pool, path);
+       box->index = index_storage_alloc(box->list, name, flags, index_prefix);
        if (box->file_create_mode == 0)
                mailbox_refresh_permissions(box);
        mail_index_set_permissions(box->index, box->file_create_mode,
@@ -311,14 +318,14 @@ int index_storage_mailbox_enable(struct mailbox *box,
 
 void index_storage_mailbox_close(struct mailbox *box)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *) box;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
 
        if (box->view != NULL)
                mail_index_view_close(&box->view);
 
-       index_mailbox_check_remove_all(ibox);
-       if (ibox->box.input != NULL)
-               i_stream_unref(&ibox->box.input);
+       index_mailbox_check_remove_all(box);
+       if (box->input != NULL)
+               i_stream_unref(&box->input);
        if (box->index != NULL)
                mail_index_alloc_cache_unref(box->index);
        if (array_is_created(&ibox->recent_flags))
@@ -329,7 +336,7 @@ void index_storage_mailbox_close(struct mailbox *box)
 }
 
 static void
-index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
+index_storage_mailbox_update_cache_fields(struct mailbox *box,
                                          const struct mailbox_update *update)
 {
        const char *const *field_names = update->cache_fields;
@@ -338,7 +345,7 @@ index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
        struct mail_cache_field field;
        unsigned int i, j, old_count;
 
-       old_fields = mail_cache_register_get_list(ibox->box.cache,
+       old_fields = mail_cache_register_get_list(box->cache,
                                                  pool_datastack_create(),
                                                  &old_count);
 
@@ -368,7 +375,7 @@ index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
                }
        }
        if (array_count(&new_fields) > 0) {
-               mail_cache_register_fields(ibox->box.cache,
+               mail_cache_register_fields(box->cache,
                                           array_idx_modifiable(&new_fields, 0),
                                           array_count(&new_fields));
        }
@@ -377,7 +384,6 @@ index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
 int index_storage_mailbox_update(struct mailbox *box,
                                 const struct mailbox_update *update)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        const struct mail_index_header *hdr;
        struct mail_index_view *view;
        struct mail_index_transaction *trans;
@@ -388,11 +394,11 @@ int index_storage_mailbox_update(struct mailbox *box,
                        return -1;
        }
        if (update->cache_fields != NULL)
-               index_storage_mailbox_update_cache_fields(ibox, update);
+               index_storage_mailbox_update_cache_fields(box, update);
 
        /* make sure we get the latest index info */
-       (void)mail_index_refresh(ibox->box.index);
-       view = mail_index_view_open(ibox->box.index);
+       (void)mail_index_refresh(box->index);
+       view = mail_index_view_open(box->index);
        hdr = mail_index_get_header(view);
 
        trans = mail_index_transaction_begin(view,
@@ -427,10 +433,8 @@ int index_storage_mailbox_update(struct mailbox *box,
 
 bool index_storage_is_readonly(struct mailbox *box)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *) box;
-
        return (box->flags & MAILBOX_FLAG_READONLY) != 0 ||
-               ibox->backend_readonly;
+               box->backend_readonly;
 }
 
 bool index_storage_allow_new_keywords(struct mailbox *box)
@@ -447,7 +451,6 @@ bool index_storage_is_inconsistent(struct mailbox *box)
 bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
                            const char **error_r)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        unsigned int i, idx;
 
        /* if it already exists, skip validity checks */
@@ -471,7 +474,7 @@ bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
                        return FALSE;
                }
        }
-       if (i > ibox->box.storage->set->mail_max_keyword_length) {
+       if (i > box->storage->set->mail_max_keyword_length) {
                *error_r = "Keyword length too long";
                return FALSE;
        }
@@ -479,7 +482,7 @@ bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
 }
 
 static struct mail_keywords *
-index_keywords_create_skip(struct index_mailbox *ibox,
+index_keywords_create_skip(struct mailbox *box,
                           const char *const keywords[])
 {
        ARRAY_DEFINE(valid_keywords, const char *);
@@ -487,39 +490,37 @@ index_keywords_create_skip(struct index_mailbox *ibox,
 
        t_array_init(&valid_keywords, 32);
        for (; *keywords != NULL; keywords++) {
-               if (mailbox_keyword_is_valid(&ibox->box, *keywords, &error))
+               if (mailbox_keyword_is_valid(box, *keywords, &error))
                        array_append(&valid_keywords, keywords, 1);
        }
        (void)array_append_space(&valid_keywords); /* NULL-terminate */
-       return mail_index_keywords_create(ibox->box.index, keywords);
+       return mail_index_keywords_create(box->index, keywords);
 }
 
-int index_keywords_create(struct mailbox *_box, const char *const keywords[],
+int index_keywords_create(struct mailbox *box, const char *const keywords[],
                          struct mail_keywords **keywords_r, bool skip_invalid)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)_box;
        const char *error;
        unsigned int i;
 
        for (i = 0; keywords[i] != NULL; i++) {
-               if (mailbox_keyword_is_valid(_box, keywords[i], &error))
+               if (mailbox_keyword_is_valid(box, keywords[i], &error))
                        continue;
 
                if (!skip_invalid) {
-                       mail_storage_set_error(_box->storage,
+                       mail_storage_set_error(box->storage,
                                               MAIL_ERROR_PARAMS, error);
                        return -1;
                }
 
                /* found invalid keywords, do this the slow way */
                T_BEGIN {
-                       *keywords_r = index_keywords_create_skip(ibox,
-                                                                keywords);
+                       *keywords_r = index_keywords_create_skip(box, keywords);
                } T_END;
                return 0;
        }
 
-       *keywords_r = mail_index_keywords_create(ibox->box.index, keywords);
+       *keywords_r = mail_index_keywords_create(box->index, keywords);
        return 0;
 }
 
index 692ad22eea7b267d041f4d084ecf9d439eaefc47..fd81f084cd1adabc51d3512d933b56bb30dbc28b 100644 (file)
@@ -29,8 +29,8 @@ struct index_transaction_context {
        struct mail_cache_transaction_ctx *cache_trans;
 };
 
-struct index_mailbox {
-       struct mailbox box;
+struct index_mailbox_context {
+       union mailbox_module_context module_ctx;
        enum mail_index_open_flags index_flags;
 
        int (*save_commit_pre)(struct mail_save_context *save_ctx);
@@ -54,22 +54,23 @@ struct index_mailbox {
        uint32_t recent_flags_count;
 
        time_t sync_last_check;
-
-       /* we've discovered there aren't enough permissions to modify mailbox */
-       unsigned int backend_readonly:1;
-       unsigned int move_to_memory:1;
 };
 
-void index_storage_lock_notify(struct index_mailbox *ibox,
+#define INDEX_STORAGE_CONTEXT(obj) \
+       MODULE_CONTEXT(obj, index_storage_module)
+extern MODULE_CONTEXT_DEFINE(index_storage_module,
+                            &mail_storage_module_register);
+
+void index_storage_lock_notify(struct mailbox *box,
                               enum mailbox_lock_notify_type notify_type,
                               unsigned int secs_left);
-void index_storage_lock_notify_reset(struct index_mailbox *ibox);
+void index_storage_lock_notify_reset(struct mailbox *box);
 
-void index_storage_mailbox_alloc(struct index_mailbox *ibox, const char *name,
+void index_storage_mailbox_alloc(struct mailbox *box, const char *name,
                                 struct istream *input,
                                 enum mailbox_flags flags,
                                 const char *index_prefix);
-int index_storage_mailbox_open(struct mailbox *box);
+int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory);
 int index_storage_mailbox_enable(struct mailbox *box,
                                 enum mailbox_feature feature);
 void index_storage_mailbox_close(struct mailbox *box);
@@ -90,19 +91,18 @@ void index_keywords_unref(struct mail_keywords *keywords);
 bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
                            const char **error_r);
 
-void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid);
-void index_mailbox_set_recent_seq(struct index_mailbox *ibox,
+void index_mailbox_set_recent_uid(struct mailbox *box, uint32_t uid);
+void index_mailbox_set_recent_seq(struct mailbox *box,
                                  struct mail_index_view *view,
                                  uint32_t seq1, uint32_t seq2);
-bool index_mailbox_is_recent(struct index_mailbox *ibox, uint32_t uid);
-unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox);
-void index_mailbox_reset_uidvalidity(struct index_mailbox *ibox);
+bool index_mailbox_is_recent(struct mailbox *box, uint32_t uid);
+unsigned int index_mailbox_get_recent_count(struct mailbox *box);
+void index_mailbox_reset_uidvalidity(struct mailbox *box);
 
-void index_mailbox_check_add(struct index_mailbox *ibox,
-                            const char *path);
-void index_mailbox_check_remove_all(struct index_mailbox *ibox);
+void index_mailbox_check_add(struct mailbox *box, const char *path);
+void index_mailbox_check_remove_all(struct mailbox *box);
 
-bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
+bool index_mailbox_want_full_sync(struct mailbox *box,
                                  enum mailbox_sync_flags flags);
 struct mailbox_sync_context *
 index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
index 191374d9fba9ee648ce8567e10a2eb60196127d6..1df64ea805f3ef6d9a2f907f5e16dc606a53a559 100644 (file)
@@ -6,7 +6,6 @@
 #include "index-sync-changes.h"
 
 struct index_sync_changes_context {
-       struct index_mailbox *ibox;
        struct mail_index_sync_ctx *index_sync_ctx;
        struct mail_index_view *sync_view;
        struct mail_index_transaction *sync_trans;
@@ -17,8 +16,7 @@ struct index_sync_changes_context {
 };
 
 struct index_sync_changes_context *
-index_sync_changes_init(struct index_mailbox *ibox,
-                       struct mail_index_sync_ctx *index_sync_ctx,
+index_sync_changes_init(struct mail_index_sync_ctx *index_sync_ctx,
                        struct mail_index_view *sync_view,
                        struct mail_index_transaction *sync_trans,
                        bool dirty_flag_updates)
@@ -26,7 +24,6 @@ index_sync_changes_init(struct index_mailbox *ibox,
        struct index_sync_changes_context *ctx;
 
        ctx = i_new(struct index_sync_changes_context, 1);
-       ctx->ibox = ibox;
        ctx->index_sync_ctx = index_sync_ctx;
        ctx->sync_view = sync_view;
        ctx->sync_trans = sync_trans;
index d62cb202a998296ddfa392fdbb8220b292edf5e6..d4e83bcd8d99e50db335ee530e35d0e91e92705f 100644 (file)
@@ -2,8 +2,7 @@
 #define INDEX_SYNC_CHANGES_H
 
 struct index_sync_changes_context *
-index_sync_changes_init(struct index_mailbox *ibox,
-                       struct mail_index_sync_ctx *index_sync_ctx,
+index_sync_changes_init(struct mail_index_sync_ctx *index_sync_ctx,
                        struct mail_index_view *sync_view,
                        struct mail_index_transaction *sync_trans,
                        bool dirty_flag_updates);
index 2d164983b5161bcddaea9d679e29ee57d75d208c..b033640f3c6936fb74d787dfdce0dc353c553c88 100644 (file)
@@ -5,7 +5,6 @@
 
 struct index_mailbox_sync_context {
        struct mailbox_sync_context ctx;
-       struct index_mailbox *ibox;
        struct mail_index_view_sync_ctx *sync_ctx;
        uint32_t messages_count;
 
index 1f0a2581ed9184f878f8e80a198722e39f962117..a816b51ae29b1e2fe6f984812c7f561588506d08 100644 (file)
@@ -27,7 +27,7 @@ static void index_sync_uidify_array(struct index_mailbox_sync_context *ctx,
 
        array_foreach(changes, range) {
                for (seq = range->seq1; seq <= range->seq2; seq++) {
-                       mail_index_lookup_uid(ctx->ibox->box.view, seq, &uid);
+                       mail_index_lookup_uid(ctx->ctx.box->view, seq, &uid);
                        seq_range_array_add(&ctx->all_flag_update_uids, 0, uid);
                }
        }
@@ -52,7 +52,7 @@ void index_sync_search_results_uidify(struct index_mailbox_sync_context *ctx)
 
        i_assert(!array_is_created(&ctx->all_flag_update_uids));
 
-       results = array_get(&ctx->ibox->box.search_results, &count);
+       results = array_get(&ctx->ctx.box->search_results, &count);
        for (i = 0; i < count; i++) {
                if ((results[i]->flags & MAILBOX_SEARCH_RESULT_FLAG_UPDATE) != 0 &&
                    search_result_want_flag_updates(results[i])) {
@@ -83,7 +83,7 @@ void index_sync_search_results_update(struct index_mailbox_sync_context *ctx)
        struct mail_search_result *const *results;
        unsigned int i, count;
 
-       results = array_get(&ctx->ibox->box.search_results, &count);
+       results = array_get(&ctx->ctx.box->search_results, &count);
        for (i = 0; i < count; i++)
                search_result_update(ctx, results[i]);
 }
@@ -91,7 +91,7 @@ void index_sync_search_results_update(struct index_mailbox_sync_context *ctx)
 void index_sync_search_results_expunge(struct index_mailbox_sync_context *ctx)
 {
        if (ctx->expunges != NULL) {
-               index_search_results_update_expunges(&ctx->ibox->box,
+               index_search_results_update_expunges(ctx->ctx.box,
                                                     ctx->expunges);
        }
 }
index 164b78c0f2c598fa6f050d420e0956f856a4460a..30e7cb518b6f148bd529caf900e1fdcea3ff67ab 100644 (file)
@@ -6,9 +6,11 @@
 #include "array.h"
 #include "index-sync-private.h"
 
-bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
+bool index_mailbox_want_full_sync(struct mailbox *box,
                                  enum mailbox_sync_flags flags)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
            ioloop_time < ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL)
                return FALSE;
@@ -19,8 +21,10 @@ bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
        return TRUE;
 }
 
-void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid)
+void index_mailbox_set_recent_uid(struct mailbox *box, uint32_t uid)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        if (uid <= ibox->recent_flags_prev_uid) {
                i_assert(seq_range_exists(&ibox->recent_flags, uid));
                return;
@@ -31,7 +35,7 @@ void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid)
        ibox->recent_flags_count++;
 }
 
-void index_mailbox_set_recent_seq(struct index_mailbox *ibox,
+void index_mailbox_set_recent_seq(struct mailbox *box,
                                  struct mail_index_view *view,
                                  uint32_t seq1, uint32_t seq2)
 {
@@ -39,18 +43,22 @@ void index_mailbox_set_recent_seq(struct index_mailbox *ibox,
 
        for (; seq1 <= seq2; seq1++) {
                mail_index_lookup_uid(view, seq1, &uid);
-               index_mailbox_set_recent_uid(ibox, uid);
+               index_mailbox_set_recent_uid(box, uid);
        }
 }
 
-bool index_mailbox_is_recent(struct index_mailbox *ibox, uint32_t uid)
+bool index_mailbox_is_recent(struct mailbox *box, uint32_t uid)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        return array_is_created(&ibox->recent_flags) &&
                seq_range_exists(&ibox->recent_flags, uid);
 }
 
-void index_mailbox_reset_uidvalidity(struct index_mailbox *ibox)
+void index_mailbox_reset_uidvalidity(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
+
        /* can't trust the currently cached recent flags anymore */
        if (array_is_created(&ibox->recent_flags))
                array_clear(&ibox->recent_flags);
@@ -58,8 +66,9 @@ void index_mailbox_reset_uidvalidity(struct index_mailbox *ibox)
        ibox->recent_flags_prev_uid = 0;
 }
 
-unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox)
+unsigned int index_mailbox_get_recent_count(struct mailbox *box)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        const struct mail_index_header *hdr;
        const struct seq_range *range;
        unsigned int i, count, recent_count;
@@ -67,7 +76,7 @@ unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox)
        if (!array_is_created(&ibox->recent_flags))
                return 0;
 
-       hdr = mail_index_get_header(ibox->box.view);
+       hdr = mail_index_get_header(box->view);
        recent_count = ibox->recent_flags_count;
        range = array_get(&ibox->recent_flags, &count);
        for (i = count; i > 0; ) {
@@ -87,16 +96,17 @@ unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox)
        return recent_count;
 }
 
-static void index_mailbox_expunge_recent(struct index_mailbox *ibox,
-                                        uint32_t seq1, uint32_t seq2)
+static void
+index_mailbox_expunge_recent(struct mailbox *box, uint32_t seq1, uint32_t seq2)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        uint32_t uid;
 
        if (!array_is_created(&ibox->recent_flags))
                return;
 
        for (; seq1 <= seq2; seq1++) {
-               mail_index_lookup_uid(ibox->box.view, seq1, &uid);
+               mail_index_lookup_uid(box->view, seq1, &uid);
                if (seq_range_array_remove(&ibox->recent_flags, uid))
                        ibox->recent_flags_count--;
        }
@@ -112,7 +122,7 @@ static void index_view_sync_recs_get(struct index_mailbox_sync_context *ctx)
        while (mail_index_view_sync_next(ctx->sync_ctx, &sync_rec)) {
                switch (sync_rec.type) {
                case MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS:
-                       if (!mail_index_lookup_seq_range(ctx->ibox->box.view,
+                       if (!mail_index_lookup_seq_range(ctx->ctx.box->view,
                                                         sync_rec.uid1,
                                                         sync_rec.uid2,
                                                         &seq1, &seq2))
@@ -145,13 +155,11 @@ struct mailbox_sync_context *
 index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
                        bool failed)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
         struct index_mailbox_sync_context *ctx;
        enum mail_index_view_sync_flags sync_flags = 0;
 
        ctx = i_new(struct index_mailbox_sync_context, 1);
        ctx->ctx.box = box;
-       ctx->ibox = ibox;
 
        if (failed) {
                ctx->failed = TRUE;
@@ -195,7 +203,7 @@ index_mailbox_sync_next_expunge(struct index_mailbox_sync_context *ctx,
        range = array_idx(ctx->expunges, ctx->expunge_pos);
        i_assert(range->seq2 <= ctx->messages_count);
 
-       index_mailbox_expunge_recent(ctx->ibox, range->seq1, range->seq2);
+       index_mailbox_expunge_recent(ctx->ctx.box, range->seq1, range->seq2);
        ctx->messages_count -= range->seq2 - range->seq1 + 1;
 
        sync_rec_r->seq1 = range->seq1;
@@ -241,8 +249,9 @@ bool index_mailbox_sync_next(struct mailbox_sync_context *_ctx,
 static void
 index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
 {
-       struct index_mailbox *ibox = ctx->ibox;
-       struct mail_index_view *view = ibox->box.view;
+       struct index_mailbox_context *ibox =
+               INDEX_STORAGE_CONTEXT(ctx->ctx.box);
+       struct mail_index_view *view = ctx->ctx.box->view;
        const struct mail_index_header *hdr;
        uint32_t seq, start_uid, uid;
 
@@ -303,7 +312,7 @@ int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
 {
        struct index_mailbox_sync_context *ctx =
                (struct index_mailbox_sync_context *)_ctx;
-       struct index_mailbox *ibox = ctx->ibox;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(_ctx->box);
        struct mailbox_sync_rec sync_rec;
        const struct mail_index_header *hdr;
        uint32_t seq1, seq2;
@@ -336,7 +345,7 @@ int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
                                                    hdr->next_uid,
                                                    &seq1, &seq2);
                        if (seq1 != 0) {
-                               index_mailbox_set_recent_seq(ibox,
+                               index_mailbox_set_recent_seq(_ctx->box,
                                                             _ctx->box->view,
                                                             seq1, seq2);
                        }
index 9e473c842907ed97a64f7867252636f2cbab4cbc..4f44319188c353512ac7ea27f798703d33848ed7 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef INDEX_THREAD_PRIVATE_H
 #define INDEX_THREAD_PRIVATE_H
 
-struct index_mailbox;
-
 #include "crc32.h"
 #include "mail-thread.h"
 #include "mail-index-strmap.h"
@@ -79,6 +77,6 @@ mail_thread_iterate_init_full(struct mail_thread_cache *cache,
                              enum mail_thread_type thread_type,
                              bool return_seqs);
 
-void index_thread_mailbox_opened(struct index_mailbox *ibox);
+void index_thread_mailbox_opened(struct mailbox *box);
 
 #endif
index a1f558b82b4bba79b102708f89ab766d9afe1e37..991421cffa071e1b8cf1a671917c1b34959b0005 100644 (file)
@@ -632,9 +632,8 @@ static void mail_thread_mailbox_close(struct mailbox *box)
        i_free(tbox);
 }
 
-void index_thread_mailbox_opened(struct index_mailbox *ibox)
+void index_thread_mailbox_opened(struct mailbox *box)
 {
-       struct mailbox *box = &ibox->box;
        struct mail_thread_mailbox *tbox;
 
        tbox = i_new(struct mail_thread_mailbox, 1);
index 2d1b330cc8549396265cacab71eee582d8c8ec02..e23ccf38913e438ec547f409ab3f2c74f9d60917 100644 (file)
@@ -20,7 +20,7 @@ index_transaction_index_commit(struct mail_index_transaction *index_trans,
        struct index_transaction_context *it =
                MAIL_STORAGE_CONTEXT(index_trans);
        struct mailbox_transaction_context *t = &it->mailbox_ctx;
-       struct index_mailbox *ibox = (struct index_mailbox *)t->box;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(t->box);
        int ret = 0;
 
        if (t->save_ctx != NULL) {
@@ -50,8 +50,8 @@ index_transaction_index_commit(struct mail_index_transaction *index_trans,
 static void index_transaction_index_rollback(struct mail_index_transaction *t)
 {
        struct index_transaction_context *it = MAIL_STORAGE_CONTEXT(t);
-       struct index_mailbox *ibox =
-               (struct index_mailbox *)it->mailbox_ctx.box;
+       struct index_mailbox_context *ibox =
+               INDEX_STORAGE_CONTEXT(it->mailbox_ctx.box);
 
        if (it->mailbox_ctx.save_ctx != NULL)
                ibox->save_rollback(it->mailbox_ctx.save_ctx);
index 0f700a4721e55f25fb21d59df8ed3620cb23ee1f..175c40e2c5f6a807fd448c1225b544003ed06b27 100644 (file)
@@ -170,8 +170,8 @@ maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
                return 0;
        }
 
-       if (mail_index_is_deleted(dest_mbox->ibox.box.index)) {
-               mailbox_set_deleted(&dest_mbox->ibox.box);
+       if (mail_index_is_deleted(dest_mbox->box.index)) {
+               mailbox_set_deleted(&dest_mbox->box);
                return -1;
        }
 
@@ -195,7 +195,7 @@ maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
        /* hard link to tmp/ with basename and later when we
           have uidlist locked, move it to new/cur. */
        str_printfa(do_ctx.dest_path, "%s/tmp/%s",
-                   dest_mbox->ibox.box.path, do_ctx.dest_fname);
+                   dest_mbox->box.path, do_ctx.dest_fname);
        do_ctx.base_end_pos = str_len(do_ctx.dest_path);
        if (src_mbox != NULL) {
                /* maildir */
@@ -237,7 +237,7 @@ int maildir_copy(struct mail_save_context *ctx, struct mail *mail)
        i_assert((_t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
 
        if (mbox->storage->set->maildir_copy_with_hardlinks &&
-           maildir_compatible_file_modes(&mbox->ibox.box, mail->box)) {
+           maildir_compatible_file_modes(&mbox->box, mail->box)) {
                T_BEGIN {
                        ret = maildir_copy_hardlink(ctx, mail);
                } T_END;
index 093807a4bc1cc3d482512707fada53da43dff28c..984730a624079bc8ae3091968e7c60d927d8b751 100644 (file)
@@ -55,7 +55,7 @@ struct maildir_keywords *maildir_keywords_init(struct maildir_mailbox *mbox)
 {
        struct maildir_keywords *mk;
 
-       mk = maildir_keywords_init_readonly(&mbox->ibox.box);
+       mk = maildir_keywords_init_readonly(&mbox->box);
        mk->mbox = mbox;
        return mk;
 }
@@ -286,7 +286,7 @@ static int maildir_keywords_write_fd(struct maildir_keywords *mk,
                                     const char *path, int fd)
 {
        struct maildir_mailbox *mbox = mk->mbox;
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
        const char *const *keywords;
        unsigned int i, count;
        string_t *str;
@@ -367,7 +367,7 @@ static int maildir_keywords_commit(struct maildir_keywords *mk)
                /* we could just create the temp file directly, but doing it
                   this ways avoids potential problems with overwriting
                   contents in malicious symlinks */
-               old_mask = umask(0777 & ~mk->mbox->ibox.box.file_create_mode);
+               old_mask = umask(0777 & ~mk->mbox->box.file_create_mode);
                fd = file_dotlock_open(&mk->dotlock_settings, mk->path,
                                       DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock);
                umask(old_mask);
@@ -381,7 +381,7 @@ static int maildir_keywords_commit(struct maildir_keywords *mk)
                }
                /* the control dir doesn't exist. create it unless the whole
                   mailbox was just deleted. */
-               if (!maildir_set_deleted(&mk->mbox->ibox.box))
+               if (!maildir_set_deleted(&mk->mbox->box))
                        return -1;
        }
 
index c08071896ddb00f9481ee398d97f6c95b1ff50b3..ec14b364c2294303e92b038876313776f9439ee3 100644 (file)
@@ -177,8 +177,8 @@ maildir_mail_get_fname(struct maildir_mailbox *mbox, struct mail *mail,
        /* one reason this could happen is if we delayed opening
           dovecot-uidlist and we're trying to open a mail that got recently
           expunged. Let's test this theory first: */
-       (void)mail_index_refresh(mbox->ibox.box.index);
-       view = mail_index_view_open(mbox->ibox.box.index);
+       (void)mail_index_refresh(mbox->box.index);
+       view = mail_index_view_open(mbox->box.index);
        exists = mail_index_lookup_seq(view, mail->uid, &seq);
        mail_index_view_close(&view);
 
@@ -193,6 +193,8 @@ maildir_mail_get_fname(struct maildir_mailbox *mbox, struct mail *mail,
 
 static int maildir_get_pop3_state(struct index_mail *mail)
 {
+       struct mailbox *box = mail->mail.mail.box;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        const struct mail_cache_field *fields;
        unsigned int i, count, psize_idx, vsize_idx;
        enum mail_cache_decision_type dec, vsize_dec;
@@ -213,16 +215,16 @@ static int maildir_get_pop3_state(struct index_mail *mail)
                not_pop3_only = TRUE;
 
        /* get vsize decisions */
-       psize_idx = mail->ibox->cache_fields[MAIL_CACHE_PHYSICAL_FULL_SIZE].idx;
-       vsize_idx = mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
+       psize_idx = ibox->cache_fields[MAIL_CACHE_PHYSICAL_FULL_SIZE].idx;
+       vsize_idx = ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
        if (not_pop3_only) {
-               vsize_dec = mail_cache_field_get_decision(mail->ibox->box.cache,
+               vsize_dec = mail_cache_field_get_decision(box->cache,
                                                          vsize_idx);
                vsize_dec &= ~MAIL_CACHE_DECISION_FORCED;
        } else {
                /* also check if there are any non-[pv]size cached fields */
                vsize_dec = MAIL_CACHE_DECISION_NO;
-               fields = mail_cache_register_get_list(mail->ibox->box.cache,
+               fields = mail_cache_register_get_list(box->cache,
                                                      pool_datastack_create(),
                                                      &count);
                for (i = 0; i < count; i++) {
@@ -239,7 +241,7 @@ static int maildir_get_pop3_state(struct index_mail *mail)
                /* either nothing is cached, or only vsize is cached. */
                mail->pop3_state = 1;
        } else if (vsize_dec != MAIL_CACHE_DECISION_YES &&
-                  (mail->ibox->box.flags & MAILBOX_FLAG_POP3_SESSION) == 0) {
+                  (box->flags & MAILBOX_FLAG_POP3_SESSION) == 0) {
                /* if virtual size isn't cached permanently,
                   POP3 isn't being used */
                mail->pop3_state = -1;
@@ -255,7 +257,7 @@ static int maildir_quick_size_lookup(struct index_mail *mail, bool vsize,
                                     uoff_t *size_r)
 {
        struct mail *_mail = &mail->mail.mail;
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
        enum maildir_uidlist_rec_ext_key key;
        const char *path, *fname, *value;
        uoff_t size;
@@ -299,7 +301,8 @@ static void
 maildir_handle_size_caching(struct index_mail *mail, bool quick_check,
                            bool vsize)
 {
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct mailbox *box = mail->mail.mail.box;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
        enum mail_fetch_field field;
        uoff_t size;
        int pop3_state;
@@ -313,14 +316,14 @@ maildir_handle_size_caching(struct index_mail *mail, bool quick_check,
                   including to the uidlist if it's already in filename.
                   do some extra checks here to catch potential cache bugs. */
                if (vsize && mail->data.virtual_size != size) {
-                       mail_cache_set_corrupted(mail->ibox->box.cache,
+                       mail_cache_set_corrupted(box->cache,
                                "Corrupted virtual size for uid=%u: "
                                "%"PRIuUOFF_T" != %"PRIuUOFF_T,
                                mail->mail.mail.uid,
                                mail->data.virtual_size, size);
                        mail->data.virtual_size = size;
                } else if (!vsize && mail->data.physical_size != size) {
-                       mail_cache_set_corrupted(mail->ibox->box.cache,
+                       mail_cache_set_corrupted(box->cache,
                                "Corrupted physical size for uid=%u: "
                                "%"PRIuUOFF_T" != %"PRIuUOFF_T,
                                mail->mail.mail.uid,
@@ -382,7 +385,7 @@ static int maildir_mail_get_virtual_size(struct mail *_mail, uoff_t *size_r)
 static int maildir_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
        struct index_mail_data *data = &mail->data;
        struct stat st;
        const char *path;
@@ -431,7 +434,7 @@ maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
                         const char **value_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
        const char *path, *fname, *end, *uidl;
 
        switch (field) {
@@ -481,7 +484,7 @@ static int maildir_mail_get_stream(struct mail *_mail,
                                   struct istream **stream_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
        struct index_mail_data *data = &mail->data;
        bool deleted;
 
@@ -523,8 +526,7 @@ static void maildir_update_pop3_uidl(struct mail *_mail, const char *uidl)
 static void maildir_mail_set_cache_corrupted(struct mail *_mail,
                                             enum mail_fetch_field field)
 {
-       struct index_mail *mail = (struct index_mail *)_mail;
-       struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+       struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
        enum maildir_uidlist_rec_flag flags;
        const char *fname;
        uoff_t size;
@@ -544,7 +546,7 @@ static void maildir_mail_set_cache_corrupted(struct mail *_mail,
                                "new" : "cur";
                        mail_storage_set_critical(_mail->box->storage,
                                "Maildir filename has wrong W value: %s/%s/%s",
-                               mbox->ibox.box.path, subdir, fname);
+                               mbox->box.path, subdir, fname);
                } else if (maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
                                MAILDIR_UIDLIST_REC_EXT_VSIZE) != NULL) {
                        maildir_uidlist_set_ext(mbox->uidlist, _mail->uid,
index 5654c966dae6902f3695b044cb5a70bbc350e1cc..34435c5b6f66be585758086a75dd907a2b9b6467 100644 (file)
@@ -127,9 +127,9 @@ maildir_save_transaction_init(struct mailbox_transaction_context *t)
        ctx->files_tail = &ctx->files;
        ctx->fd = -1;
 
-       ctx->tmpdir = p_strconcat(pool, mbox->ibox.box.path, "/tmp", NULL);
-       ctx->newdir = p_strconcat(pool, mbox->ibox.box.path, "/new", NULL);
-       ctx->curdir = p_strconcat(pool, mbox->ibox.box.path, "/cur", NULL);
+       ctx->tmpdir = p_strconcat(pool, mbox->box.path, "/tmp", NULL);
+       ctx->newdir = p_strconcat(pool, mbox->box.path, "/new", NULL);
+       ctx->curdir = p_strconcat(pool, mbox->box.path, "/cur", NULL);
 
        buffer_create_const_data(&ctx->keywords_buffer, NULL, 0);
        array_create_from_buffer(&ctx->keywords_array, &ctx->keywords_buffer,
@@ -298,14 +298,14 @@ const char *maildir_save_file_get_path(struct mailbox_transaction_context *t,
 static int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir,
                              const char **fname)
 {
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
        struct stat st;
        unsigned int prefix_len;
        const char *tmp_fname = *fname;
        string_t *path;
        int fd;
 
-       if (mail_index_is_deleted(mbox->ibox.box.index)) {
+       if (mail_index_is_deleted(mbox->box.index)) {
                mailbox_set_deleted(box);
                return -1;
        }
@@ -637,14 +637,14 @@ static void maildir_sync_conflict(struct maildir_save_context *ctx,
        if (maildir_uidlist_lookup(ctx->mbox->uidlist, conflict->old_uid,
                                   &flags, &filename) <= 0) {
                i_error("maildir %s: uid %u update failed: lost filename",
-                       ctx->mbox->ibox.box.path, conflict->old_uid);
+                       ctx->mbox->box.path, conflict->old_uid);
                return;
        }
        maildir_uidlist_sync_remove(ctx->uidlist_sync_ctx, filename);
        if (maildir_uidlist_sync_next_uid(ctx->uidlist_sync_ctx, filename,
                                          conflict->new_uid, 0) < 0) {
                i_error("maildir %s: uid %u update failed: sync failed",
-                       ctx->mbox->ibox.box.path, conflict->old_uid);
+                       ctx->mbox->box.path, conflict->old_uid);
        }
 }
 
@@ -728,7 +728,7 @@ maildir_save_set_recent_flags(struct maildir_save_context *ctx)
        uids = array_get(&saved_sorted_uids, &count);
        for (i = 0; i < count; i++) {
                for (uid = uids[i].seq1; uid <= uids[i].seq2; uid++)
-                       index_mailbox_set_recent_uid(&mbox->ibox, uid);
+                       index_mailbox_set_recent_uid(&mbox->box, uid);
        }
        return uids[count-1].seq2 + 1;
 }
@@ -780,7 +780,7 @@ maildir_save_sync_index(struct maildir_save_context *ctx)
                next_uid = maildir_save_set_recent_flags(ctx);
        } T_END;
 
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                first_recent_uid = next_uid;
        else if (ctx->last_nonrecent_uid != 0)
                first_recent_uid = ctx->last_nonrecent_uid + 1;
@@ -957,7 +957,7 @@ int maildir_transaction_save_commit_pre(struct mail_save_context *_ctx)
        if (ret < 0) {
                ctx->keywords_sync_ctx = !ctx->have_keywords ? NULL :
                        maildir_keywords_sync_init(ctx->mbox->keywords,
-                                                  ctx->mbox->ibox.box.index);
+                                                  ctx->mbox->box.index);
 
                /* unlink the files we just moved in an attempt to rollback
                   the transaction. uidlist is still locked, so at least other
index 608736493761aa4debb9ca0e32f22dd336431e8b..529afb19c67e1be93be10ca12c1a291cdde28e91 100644 (file)
@@ -329,30 +329,32 @@ maildir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                      enum mailbox_flags flags)
 {
        struct maildir_mailbox *mbox;
+       struct index_mailbox_context *ibox;
        pool_t pool;
 
        pool = pool_alloconly_create("maildir mailbox", 1024+512);
        mbox = p_new(pool, struct maildir_mailbox, 1);
-       mbox->ibox.box = maildir_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &maildir_mail_vfuncs;
+       mbox->box = maildir_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &maildir_mail_vfuncs;
 
-       mbox->ibox.save_commit_pre = maildir_transaction_save_commit_pre;
-       mbox->ibox.save_commit_post = maildir_transaction_save_commit_post;
-       mbox->ibox.save_rollback = maildir_transaction_save_rollback;
-
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    MAILDIR_INDEX_PREFIX);
 
+       ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
+       ibox->save_commit_pre = maildir_transaction_save_commit_pre;
+       ibox->save_commit_post = maildir_transaction_save_commit_post;
+       ibox->save_rollback = maildir_transaction_save_rollback;
+
        mbox->storage = (struct maildir_storage *)storage;
        mbox->maildir_ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "maildir",
+               mail_index_ext_register(mbox->box.index, "maildir",
                                        sizeof(mbox->maildir_hdr), 0, 0);
        mbox->uidlist = maildir_uidlist_init(mbox);
        mbox->keywords = maildir_keywords_init(mbox);
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 static int maildir_mailbox_open_existing(struct mailbox *box)
@@ -375,8 +377,8 @@ static int maildir_mailbox_open_existing(struct mailbox *box)
 
        if (access(t_strconcat(box->path, "/cur", NULL), W_OK) < 0 &&
            errno == EACCES)
-               mbox->ibox.backend_readonly = TRUE;
-       return index_storage_mailbox_open(box);
+               mbox->box.backend_readonly = TRUE;
+       return index_storage_mailbox_open(box, FALSE);
 }
 
 static int maildir_mailbox_open(struct mailbox *box)
@@ -808,12 +810,12 @@ static void maildir_notify_changes(struct mailbox *box)
        struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
 
        if (box->notify_callback == NULL)
-               index_mailbox_check_remove_all(&mbox->ibox);
+               index_mailbox_check_remove_all(&mbox->box);
        else {
-               index_mailbox_check_add(&mbox->ibox,
-                       t_strconcat(mbox->ibox.box.path, "/new", NULL));
-               index_mailbox_check_add(&mbox->ibox,
-                       t_strconcat(mbox->ibox.box.path, "/cur", NULL));
+               index_mailbox_check_add(&mbox->box,
+                       t_strconcat(mbox->box.path, "/new", NULL));
+               index_mailbox_check_add(&mbox->box,
+                       t_strconcat(mbox->box.path, "/cur", NULL));
        }
 }
 
index 7382e91a397f8382530a8bbd313cb7420f3e25bf..cf9ff67d2f36e20c397f14cfe45ecd03be1c139d 100644 (file)
@@ -74,7 +74,7 @@ struct maildir_storage {
 };
 
 struct maildir_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct maildir_storage *storage;
        struct mail_index_view *flags_view;
 
index 6d9798c5ffd2d34f7de088235db0810e7d787c6b..4c7e6b93cb121c397bb48ea29f0f6cdf2e147003 100644 (file)
@@ -79,7 +79,7 @@ maildir_expunge_is_valid_guid(struct maildir_index_sync_context *ctx,
 
        mail_storage_set_critical(&ctx->mbox->storage->storage,
                "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s",
-               ctx->mbox->ibox.box.vname, ctx->uid,
+               ctx->mbox->box.vname, ctx->uid,
                binary_to_hex(guid_128, sizeof(guid_128)),
                binary_to_hex(expunged_guid_128, MAIL_GUID_128_SIZE));
        return FALSE;
@@ -88,7 +88,7 @@ maildir_expunge_is_valid_guid(struct maildir_index_sync_context *ctx,
 static int maildir_expunge(struct maildir_mailbox *mbox, const char *path,
                           struct maildir_index_sync_context *ctx)
 {
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
 
        if (unlink(path) == 0) {
                if (box->v.sync_notify != NULL) {
@@ -108,7 +108,7 @@ static int maildir_expunge(struct maildir_mailbox *mbox, const char *path,
 static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path,
                              struct maildir_index_sync_context *ctx)
 {
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
        struct stat st;
        const char *dir, *fname, *newfname, *newpath;
        enum mail_index_sync_type sync_type;
@@ -203,7 +203,7 @@ static int maildir_handle_uid_insertion(struct maildir_index_sync_context *ctx,
        maildir_uidlist_sync_finish(ctx->uidlist_sync_ctx);
 
        i_warning("Maildir %s: Expunged message reappeared, giving a new UID "
-                 "(old uid=%u, file=%s)", ctx->mbox->ibox.box.path,
+                 "(old uid=%u, file=%s)", ctx->mbox->box.path,
                  uid, filename);
        return 0;
 }
@@ -212,7 +212,7 @@ int maildir_sync_index_begin(struct maildir_mailbox *mbox,
                             struct maildir_sync_context *maildir_sync_ctx,
                             struct maildir_index_sync_context **ctx_r)
 {
-       struct mailbox *_box = &mbox->ibox.box;
+       struct mailbox *_box = &mbox->box;
        struct maildir_index_sync_context *ctx;
        struct mail_index_sync_ctx *sync_ctx;
        struct mail_index_view *view;
@@ -240,9 +240,8 @@ int maildir_sync_index_begin(struct maildir_mailbox *mbox,
        ctx->keywords_sync_ctx =
                maildir_keywords_sync_init(mbox->keywords, _box->index);
        ctx->sync_changes =
-               index_sync_changes_init(&mbox->ibox, ctx->sync_ctx,
-                                       ctx->view, ctx->trans,
-                                       mbox->ibox.backend_readonly);
+               index_sync_changes_init(ctx->sync_ctx, ctx->view, ctx->trans,
+                                       mbox->box.backend_readonly);
 
        *ctx_r = ctx;
        return 0;
@@ -280,14 +279,14 @@ maildir_sync_index_update_ext_header(struct maildir_index_sync_context *ctx)
        struct stat st;
 
        if (ctx->update_maildir_hdr_cur &&
-           stat(t_strconcat(mbox->ibox.box.path, "/cur", NULL), &st) == 0) {
+           stat(t_strconcat(mbox->box.path, "/cur", NULL), &st) == 0) {
                if ((time_t)mbox->maildir_hdr.cur_check_time < st.st_mtime)
                        mbox->maildir_hdr.cur_check_time = st.st_mtime;
                mbox->maildir_hdr.cur_mtime = st.st_mtime;
                mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
        }
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
+       mail_index_get_header_ext(mbox->box.view, mbox->maildir_ext_id,
                                  &data, &data_size);
        if (data_size != sizeof(mbox->maildir_hdr) ||
            maildir_index_header_has_changed(data, &mbox->maildir_hdr)) {
@@ -314,7 +313,7 @@ static int maildir_sync_index_finish(struct maildir_index_sync_context *ctx,
                   start a second index sync and crash. */
                mbox->syncing_commit = TRUE;
                if (mail_index_sync_commit(&ctx->sync_ctx) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                        ret = -1;
                }
                mbox->syncing_commit = FALSE;
@@ -357,7 +356,7 @@ static int uint_cmp(const void *p1, const void *p2)
 static void
 maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        struct mail_keywords *kw;
        unsigned int i, j, old_count, new_count;
        const unsigned int *old_indexes, *new_indexes;
@@ -465,9 +464,9 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                   first time, reset the index so we can add all messages as
                   new */
                i_warning("Maildir %s: UIDVALIDITY changed (%u -> %u)",
-                         mbox->ibox.box.path, hdr->uid_validity, uid_validity);
+                         mbox->box.path, hdr->uid_validity, uid_validity);
                mail_index_reset(trans);
-               index_mailbox_reset_uidvalidity(&mbox->ibox);
+               index_mailbox_reset_uidvalidity(&mbox->box);
 
                first_uid = hdr->messages_count + 1;
                memset(&empty_hdr, 0, sizeof(empty_hdr));
@@ -491,7 +490,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
 
                /* the private flags are kept only in indexes. don't use them
                   at all even for newly seen mails */
-               ctx->flags &= ~mbox->ibox.box.private_flags_mask;
+               ctx->flags &= ~mbox->box.private_flags_mask;
 
        again:
                seq++;
@@ -524,7 +523,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                                struct mail_keywords *kw;
 
                                kw = mail_index_keywords_create_from_indexes(
-                                       mbox->ibox.box.index, &ctx->keywords);
+                                       mbox->box.index, &ctx->keywords);
                                mail_index_update_keywords(trans, seq,
                                                           MODIFY_REPLACE, kw);
                                mail_index_keywords_unref(&kw);
@@ -564,7 +563,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                }
 
                /* the private flags are stored only in indexes, keep them */
-               ctx->flags |= rec->flags & mbox->ibox.box.private_flags_mask;
+               ctx->flags |= rec->flags & mbox->box.private_flags_mask;
 
                if (index_sync_changes_have(ctx->sync_changes)) {
                        /* apply flag changes to maildir */
@@ -619,7 +618,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                        /* UIDVALIDITY changed, skip over the old messages */
                        seq = first_uid;
                }
-               index_mailbox_set_recent_seq(&mbox->ibox, view2, seq, seq2);
+               index_mailbox_set_recent_seq(&mbox->box, view2, seq, seq2);
        }
        mail_index_view_close(&view2);
 
@@ -629,8 +628,8 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                        ret = -1;
        }
 
-       if (mbox->ibox.box.v.sync_notify != NULL)
-               mbox->ibox.box.v.sync_notify(&mbox->ibox.box, 0, 0);
+       if (mbox->box.v.sync_notify != NULL)
+               mbox->box.v.sync_notify(&mbox->box, 0, 0);
 
        /* check cur/ mtime later. if we came here from saving messages they
           could still be moved to cur/ directory. */
@@ -639,7 +638,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
 
        if (uid_validity == 0) {
                uid_validity = hdr->uid_validity != 0 ? hdr->uid_validity :
-                       maildir_get_uidvalidity_next(mbox->ibox.box.list);
+                       maildir_get_uidvalidity_next(mbox->box.list);
                maildir_uidlist_set_uid_validity(mbox->uidlist, uid_validity);
        }
        maildir_uidlist_set_next_uid(mbox->uidlist, hdr_next_uid, FALSE);
index 782783a2fa07ab9fed6f0006e7ca0816ded08277..feba5fb66e942776d7e3b870cd919448150d9364 100644 (file)
@@ -236,7 +236,7 @@ void maildir_sync_notify(struct maildir_sync_context *ctx)
                ctx->last_touch = now;
        }
        if (now - ctx->last_notify > MAIL_STORAGE_STAYALIVE_SECS) {
-               struct mailbox *box = &ctx->mbox->ibox.box;
+               struct mailbox *box = &ctx->mbox->box;
 
                if (box->storage->callbacks.notify_ok != NULL) {
                        box->storage->callbacks.
@@ -255,8 +255,8 @@ maildir_sync_context_new(struct maildir_mailbox *mbox,
 
        ctx = t_new(struct maildir_sync_context, 1);
        ctx->mbox = mbox;
-       ctx->new_dir = t_strconcat(mbox->ibox.box.path, "/new", NULL);
-       ctx->cur_dir = t_strconcat(mbox->ibox.box.path, "/cur", NULL);
+       ctx->new_dir = t_strconcat(mbox->box.path, "/new", NULL);
+       ctx->cur_dir = t_strconcat(mbox->box.path, "/cur", NULL);
        ctx->last_touch = ioloop_time;
        ctx->last_notify = ioloop_time;
        ctx->flags = flags;
@@ -319,8 +319,7 @@ static int maildir_fix_duplicate(struct maildir_sync_context *ctx,
        }
 
        new_fname = maildir_filename_generate();
-       new_path = t_strconcat(ctx->mbox->ibox.box.path, "/new/",
-                              new_fname, NULL);
+       new_path = t_strconcat(ctx->mbox->box.path, "/new/", new_fname, NULL);
 
        if (rename(path2, new_path) == 0)
                i_warning("Fixed a duplicate: %s -> %s", path2, new_fname);
@@ -336,7 +335,7 @@ static int maildir_fix_duplicate(struct maildir_sync_context *ctx,
 static int
 maildir_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st_r)
 {
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
        int i;
 
        for (i = 0;; i++) {
@@ -386,7 +385,7 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final)
                        return -1;
                }
 
-               if (!maildir_set_deleted(&ctx->mbox->ibox.box))
+               if (!maildir_set_deleted(&ctx->mbox->box))
                        return -1;
                /* try again */
        }
@@ -419,8 +418,8 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final)
        src = t_str_new(1024);
        dest = t_str_new(1024);
 
-       move_new = new_dir && !mailbox_is_readonly(&ctx->mbox->ibox.box) &&
-               (ctx->mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
+       move_new = new_dir && !mailbox_is_readonly(&ctx->mbox->box) &&
+               (ctx->mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
                ctx->locked;
 
        errno = 0;
@@ -537,12 +536,12 @@ int maildir_sync_header_refresh(struct maildir_mailbox *mbox)
        const void *data;
        size_t data_size;
 
-       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
-               mail_storage_set_index_error(&mbox->ibox.box);
+       if (mail_index_refresh(mbox->box.index) < 0) {
+               mail_storage_set_index_error(&mbox->box);
                return -1;
        }
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
+       mail_index_get_header_ext(mbox->box.view, mbox->maildir_ext_id,
                                  &data, &data_size);
        if (data_size == 0) {
                /* doesn't exist */
@@ -636,7 +635,7 @@ static void maildir_sync_update_next_uid(struct maildir_mailbox *mbox)
        const struct mail_index_header *hdr;
        uint32_t uid_validity, next_uid;
 
-       hdr = mail_index_get_header(mbox->ibox.box.view);
+       hdr = mail_index_get_header(mbox->box.view);
        if (hdr->uid_validity == 0)
                return;
 
@@ -662,7 +661,7 @@ static bool have_recent_messages(struct maildir_sync_context *ctx)
 
        /* if there are files in new/, we'll need to move them. we'll check
           this by checking if we have any recent messages */
-       hdr = mail_index_get_header(ctx->mbox->ibox.box.view);
+       hdr = mail_index_get_header(ctx->mbox->box.view);
        return hdr->first_recent_uid <
                maildir_uidlist_get_next_uid(ctx->mbox->uidlist);
 }
@@ -679,7 +678,7 @@ static int maildir_sync_get_changes(struct maildir_sync_context *ctx,
                return -1;
 
        if (have_recent_messages(ctx)) {
-               if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) {
+               if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) {
                        *new_changed_r = TRUE;
                } else if (*new_changed_r) {
                        /* we have some recent messages and new/ has changed.
@@ -693,10 +692,10 @@ static int maildir_sync_get_changes(struct maildir_sync_context *ctx,
        if (*new_changed_r || *cur_changed_r)
                return 1;
 
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
-       return mail_index_sync_have_any(mbox->ibox.box.index, flags) ? 1 : 0;
+       return mail_index_sync_have_any(mbox->box.index, flags) ? 1 : 0;
 }
 
 static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced,
@@ -778,7 +777,7 @@ static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced,
                                        &ctx->uidlist_sync_ctx);
        lock_failure = ret <= 0;
        if (ret <= 0) {
-               struct mail_storage *storage = ctx->mbox->ibox.box.storage;
+               struct mail_storage *storage = ctx->mbox->box.storage;
 
                if (ret == 0) {
                        /* timeout */
@@ -801,7 +800,7 @@ static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced,
                }
 
                if (storage->callbacks.notify_no != NULL) {
-                       storage->callbacks.notify_no(&ctx->mbox->ibox.box,
+                       storage->callbacks.notify_no(&ctx->mbox->box,
                                "Internal mailbox synchronization failure, "
                                "showing only old mails.",
                                storage->callback_context);
@@ -924,7 +923,7 @@ maildir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
        }
 
        force_resync = (flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0;
-       if (index_mailbox_want_full_sync(&mbox->ibox, flags)) {
+       if (index_mailbox_want_full_sync(&mbox->box, flags)) {
                T_BEGIN {
                        ctx = maildir_sync_context_new(mbox, flags);
                        ret = maildir_sync_context(ctx, force_resync, NULL,
@@ -947,12 +946,12 @@ maildir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 
                if (mbox->flags_view == NULL) {
                        mbox->flags_view =
-                               mail_index_view_open(mbox->ibox.box.index);
+                               mail_index_view_open(mbox->box.index);
                }
                sync_ctx = mail_index_view_sync_begin(mbox->flags_view,
                                MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
                if (mail_index_view_sync_commit(&sync_ctx, &b) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                        ret = -1;
                }
                /* make sure the map stays in private memory */
@@ -978,8 +977,8 @@ int maildir_sync_is_synced(struct maildir_mailbox *mbox)
        T_BEGIN {
                const char *new_dir, *cur_dir;
 
-               new_dir = t_strconcat(mbox->ibox.box.path, "/new", NULL);
-               cur_dir = t_strconcat(mbox->ibox.box.path, "/cur", NULL);
+               new_dir = t_strconcat(mbox->box.path, "/new", NULL);
+               cur_dir = t_strconcat(mbox->box.path, "/cur", NULL);
 
                ret = maildir_sync_quick_check(mbox, FALSE, new_dir, cur_dir,
                                               &new_changed, &cur_changed);
index 34274d4b25fe0882aec0c96faf5d864bdc1487a1..5e2c37fc6ffdc0b71f1110a759613439883604b3 100644 (file)
@@ -66,7 +66,6 @@ ARRAY_DEFINE_TYPE(maildir_uidlist_rec_p, struct maildir_uidlist_rec *);
 
 struct maildir_uidlist {
        struct maildir_mailbox *mbox;
-       struct index_mailbox *ibox;
        char *path;
 
        int fd;
@@ -137,7 +136,7 @@ static int maildir_uidlist_lock_timeout(struct maildir_uidlist *uidlist,
                                        bool nonblock, bool refresh,
                                        bool refresh_when_locked)
 {
-       struct mailbox *box = &uidlist->ibox->box;
+       struct mailbox *box = &uidlist->mbox->box;
        const char *control_dir, *path;
        mode_t old_mask;
        const enum dotlock_create_flags dotlock_flags =
@@ -153,7 +152,7 @@ static int maildir_uidlist_lock_timeout(struct maildir_uidlist *uidlist,
                return 1;
        }
 
-        index_storage_lock_notify_reset(uidlist->ibox);
+        index_storage_lock_notify_reset(&uidlist->mbox->box);
 
        control_dir = mailbox_list_get_path(box->list, box->name,
                                            MAILBOX_LIST_PATH_TYPE_CONTROL);
@@ -187,7 +186,7 @@ static int maildir_uidlist_lock_timeout(struct maildir_uidlist *uidlist,
                }
                /* the control dir doesn't exist. create it unless the whole
                   mailbox was just deleted. */
-               if (!maildir_set_deleted(&uidlist->mbox->ibox.box))
+               if (!maildir_set_deleted(&uidlist->mbox->box))
                        return -1;
        }
 
@@ -240,28 +239,26 @@ void maildir_uidlist_unlock(struct maildir_uidlist *uidlist)
 
 static bool dotlock_callback(unsigned int secs_left, bool stale, void *context)
 {
-       struct index_mailbox *ibox = context;
+       struct mailbox *box = context;
 
-       index_storage_lock_notify(ibox, stale ?
+       index_storage_lock_notify(box, stale ?
                                  MAILBOX_LOCK_NOTIFY_MAILBOX_OVERRIDE :
                                  MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
                                  secs_left);
        return TRUE;
 }
 
-struct maildir_uidlist *
-maildir_uidlist_init_readonly(struct index_mailbox *ibox)
+struct maildir_uidlist *maildir_uidlist_init(struct maildir_mailbox *mbox)
 {
-       struct mailbox *box = &ibox->box;
        struct maildir_uidlist *uidlist;
        const char *control_dir;
 
-       control_dir = mailbox_list_get_path(box->list, box->name,
+       control_dir = mailbox_list_get_path(mbox->box.list, mbox->box.name,
                                            MAILBOX_LIST_PATH_TYPE_CONTROL);
 
        uidlist = i_new(struct maildir_uidlist, 1);
+       uidlist->mbox = mbox;
        uidlist->fd = -1;
-       uidlist->ibox = ibox;
        uidlist->path = i_strconcat(control_dir, "/"MAILDIR_UIDLIST_NAME, NULL);
        i_array_init(&uidlist->records, 128);
        uidlist->files = hash_table_create(default_pool, default_pool, 4096,
@@ -272,32 +269,22 @@ maildir_uidlist_init_readonly(struct index_mailbox *ibox)
 
        uidlist->dotlock_settings.use_io_notify = TRUE;
        uidlist->dotlock_settings.use_excl_lock =
-               box->storage->set->dotlock_use_excl;
+               mbox->box.storage->set->dotlock_use_excl;
        uidlist->dotlock_settings.nfs_flush =
-               box->storage->set->mail_nfs_storage;
+               mbox->box.storage->set->mail_nfs_storage;
        uidlist->dotlock_settings.timeout =
                MAILDIR_UIDLIST_LOCK_STALE_TIMEOUT + 2;
        uidlist->dotlock_settings.stale_timeout =
                MAILDIR_UIDLIST_LOCK_STALE_TIMEOUT;
        uidlist->dotlock_settings.callback = dotlock_callback;
-       uidlist->dotlock_settings.context = ibox;
-
-       return uidlist;
-}
-
-struct maildir_uidlist *maildir_uidlist_init(struct maildir_mailbox *mbox)
-{
-       struct maildir_uidlist *uidlist;
-
-       uidlist = maildir_uidlist_init_readonly(&mbox->ibox);
-       uidlist->mbox = mbox;
+       uidlist->dotlock_settings.context = &mbox->box;
        uidlist->dotlock_settings.temp_prefix = mbox->storage->temp_prefix;
        return uidlist;
 }
 
 static void maildir_uidlist_close(struct maildir_uidlist *uidlist)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
 
        if (uidlist->fd != -1) {
                if (close(uidlist->fd) < 0) {
@@ -352,7 +339,7 @@ static void ATTR_FORMAT(2, 3)
 maildir_uidlist_set_corrupted(struct maildir_uidlist *uidlist,
                              const char *fmt, ...)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
        va_list args;
 
        va_start(args, fmt);
@@ -697,7 +684,7 @@ static int
 maildir_uidlist_update_read(struct maildir_uidlist *uidlist,
                            bool *retry_r, bool try_retry)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
        const char *line;
        uint32_t orig_next_uid, orig_uid_validity;
        struct istream *input;
@@ -841,7 +828,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist,
 static int
 maildir_uidlist_stat(struct maildir_uidlist *uidlist, struct stat *st_r)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
 
        if (storage->set->mail_nfs_storage) {
                nfs_flush_file_handle_cache(uidlist->path);
@@ -861,7 +848,7 @@ maildir_uidlist_stat(struct maildir_uidlist *uidlist, struct stat *st_r)
 static int
 maildir_uidlist_has_changed(struct maildir_uidlist *uidlist, bool *recreated_r)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
         struct stat st;
        int ret;
 
@@ -921,7 +908,7 @@ static int maildir_uidlist_open_latest(struct maildir_uidlist *uidlist)
 
        uidlist->fd = nfs_safe_open(uidlist->path, O_RDWR);
        if (uidlist->fd == -1 && errno != ENOENT) {
-               mail_storage_set_critical(uidlist->ibox->box.storage,
+               mail_storage_set_critical(uidlist->mbox->box.storage,
                        "open(%s) failed: %m", uidlist->path);
                return -1;
        }
@@ -961,7 +948,7 @@ int maildir_uidlist_refresh(struct maildir_uidlist *uidlist)
 int maildir_uidlist_refresh_fast_init(struct maildir_uidlist *uidlist)
 {
        const struct maildir_index_header *mhdr = &uidlist->mbox->maildir_hdr;
-       struct mail_index *index = uidlist->mbox->ibox.box.index;
+       struct mail_index *index = uidlist->mbox->box.index;
        struct mail_index_view *view;
        const struct mail_index_header *hdr;
        struct stat st;
@@ -1223,22 +1210,22 @@ maildir_uidlist_generate_uid_validity(struct maildir_uidlist *uidlist)
 {
        const struct mail_index_header *hdr;
 
-       if (uidlist->ibox->box.opened) {
-               hdr = mail_index_get_header(uidlist->ibox->box.view);
+       if (uidlist->mbox->box.opened) {
+               hdr = mail_index_get_header(uidlist->mbox->box.view);
                if (hdr->uid_validity != 0) {
                        uidlist->uid_validity = hdr->uid_validity;
                        return;
                }
        }
        uidlist->uid_validity =
-               maildir_get_uidvalidity_next(uidlist->ibox->box.list);
+               maildir_get_uidvalidity_next(uidlist->mbox->box.list);
 }
 
 static int maildir_uidlist_write_fd(struct maildir_uidlist *uidlist, int fd,
                                    const char *path, unsigned int first_idx,
                                    uoff_t *file_size_r)
 {
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
        struct maildir_uidlist_iter_ctx *iter;
        struct ostream *output;
        struct maildir_uidlist_rec *rec;
@@ -1331,11 +1318,11 @@ maildir_uidlist_records_drop_expunges(struct maildir_uidlist *uidlist)
 
        /* we could get here when opening and locking mailbox,
           before index files have been opened. */
-       if (!uidlist->mbox->ibox.box.opened)
+       if (!uidlist->mbox->box.opened)
                return;
 
-       mail_index_refresh(uidlist->mbox->ibox.box.index);
-       view = mail_index_view_open(uidlist->mbox->ibox.box.index);
+       mail_index_refresh(uidlist->mbox->box.index);
+       view = mail_index_view_open(uidlist->mbox->box.index);
        count = array_count(&uidlist->records);
        hdr = mail_index_get_header(view);
        if (count * UIDLIST_COMPRESS_PERCENTAGE / 100 <= hdr->messages_count) {
@@ -1380,7 +1367,7 @@ maildir_uidlist_records_drop_expunges(struct maildir_uidlist *uidlist)
 
 static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist)
 {
-       struct mailbox *box = &uidlist->ibox->box;
+       struct mailbox *box = &uidlist->mbox->box;
        const char *control_dir, *temp_path;
        struct stat st;
        mode_t old_mask;
@@ -1411,7 +1398,7 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist)
                }
                /* the control dir doesn't exist. create it unless the whole
                   mailbox was just deleted. */
-               if (!maildir_set_deleted(&uidlist->mbox->ibox.box))
+               if (!maildir_set_deleted(&uidlist->mbox->box))
                        return -1;
        }
 
@@ -1486,7 +1473,7 @@ int maildir_uidlist_update(struct maildir_uidlist *uidlist)
 
 static bool maildir_uidlist_want_compress(struct maildir_uidlist_sync_ctx *ctx)
 {
-       struct mail_index_view *view = ctx->uidlist->mbox->ibox.box.view;
+       struct mail_index_view *view = ctx->uidlist->mbox->box.view;
        unsigned int min_rewrite_count, messages_count;
 
        if (!ctx->uidlist->locked_refresh)
@@ -1520,7 +1507,7 @@ static bool maildir_uidlist_want_recreate(struct maildir_uidlist_sync_ctx *ctx)
 static int maildir_uidlist_sync_update(struct maildir_uidlist_sync_ctx *ctx)
 {
        struct maildir_uidlist *uidlist = ctx->uidlist;
-       struct mail_storage *storage = uidlist->ibox->box.storage;
+       struct mail_storage *storage = uidlist->mbox->box.storage;
        struct stat st;
        uoff_t file_size;
 
@@ -1742,7 +1729,7 @@ int maildir_uidlist_sync_next_uid(struct maildir_uidlist_sync_ctx *ctx,
                return -1;
        for (p = filename; *p != '\0'; p++) {
                if (*p == 13 || *p == 10) {
-                       struct mailbox *box = &uidlist->ibox->box;
+                       struct mailbox *box = &uidlist->mbox->box;
 
                        dir = mailbox_list_get_path(box->list, box->name,
                                                MAILBOX_LIST_PATH_TYPE_MAILBOX);
index 95b527aaabd283c9a464c6a228f0b26c893a6b6e..50f66a50058bf6373c8291aa86898aba11bb28d0 100644 (file)
@@ -7,7 +7,6 @@
 /* how many seconds to wait before overriding uidlist.lock */
 #define MAILDIR_UIDLIST_LOCK_STALE_TIMEOUT (60*2)
 
-struct index_mailbox;
 struct maildir_mailbox;
 struct maildir_uidlist;
 struct maildir_uidlist_sync_ctx;
@@ -55,8 +54,6 @@ void maildir_uidlist_unlock(struct maildir_uidlist *uidlist);
 bool maildir_uidlist_is_locked(struct maildir_uidlist *uidlist);
 
 struct maildir_uidlist *maildir_uidlist_init(struct maildir_mailbox *mbox);
-struct maildir_uidlist *
-maildir_uidlist_init_readonly(struct index_mailbox *ibox);
 void maildir_uidlist_deinit(struct maildir_uidlist **uidlist);
 
 /* Returns -1 if error, 0 if file is broken or lost, 1 if ok. If nfs_flush=TRUE
index 285db42495f9c7af45d3cb8b5594d700219eafda..7ec527ded1971e005a9aaccbd25c3729b20c19ac 100644 (file)
@@ -43,7 +43,7 @@ maildir_filename_guess(struct maildir_mailbox *mbox, uint32_t uid,
        } else {
                *have_flags_r = TRUE;
                kw_ctx = maildir_keywords_sync_init_readonly(mbox->keywords,
-                                                            mbox->ibox.box.index);
+                                                            mbox->box.index);
                fname = maildir_filename_set_flags(kw_ctx, fname,
                                                   flags, &keywords);
                maildir_keywords_sync_deinit(&kw_ctx);
@@ -74,13 +74,13 @@ static int maildir_file_do_try(struct maildir_mailbox *mbox, uint32_t uid,
 
        if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {
                /* probably in new/ dir */
-               path = t_strconcat(mbox->ibox.box.path, "/new/", fname, NULL);
+               path = t_strconcat(mbox->box.path, "/new/", fname, NULL);
                ret = callback(mbox, path, context);
                if (ret != 0)
                        return ret;
        }
 
-       path = t_strconcat(mbox->ibox.box.path, "/cur/", fname, NULL);
+       path = t_strconcat(mbox->box.path, "/cur/", fname, NULL);
        ret = callback(mbox, path, context);
        return ret;
 }
index c50e113fe1da066dd0c25bbc44044e7a92f2f4b6..9aef60cae07b8c3edd5db68a49396abea2004f80 100644 (file)
@@ -21,15 +21,15 @@ int mbox_file_open(struct mbox_mailbox *mbox)
 
        if (mbox->mbox_file_stream != NULL) {
                /* read-only mbox stream */
-               i_assert(mbox->ibox.backend_readonly);
+               i_assert(mbox->box.backend_readonly);
                return 0;
        }
 
-       fd = open(mbox->ibox.box.path,
-                 mbox->ibox.backend_readonly ? O_RDONLY : O_RDWR);
-       if (fd == -1 && errno == EACCES && !mbox->ibox.backend_readonly) {
-                mbox->ibox.backend_readonly = TRUE;
-               fd = open(mbox->ibox.box.path, O_RDONLY);
+       fd = open(mbox->box.path,
+                 mbox->box.backend_readonly ? O_RDONLY : O_RDWR);
+       if (fd == -1 && errno == EACCES && !mbox->box.backend_readonly) {
+                mbox->box.backend_readonly = TRUE;
+               fd = open(mbox->box.path, O_RDONLY);
        }
 
        if (fd == -1) {
@@ -68,7 +68,7 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox)
 
        if (mbox->mbox_file_stream != NULL) {
                /* read-only mbox stream */
-               i_assert(mbox->mbox_fd == -1 && mbox->ibox.backend_readonly);
+               i_assert(mbox->mbox_fd == -1 && mbox->box.backend_readonly);
        } else {
                if (mbox->mbox_fd == -1) {
                        if (mbox_file_open(mbox) < 0)
@@ -89,7 +89,7 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox)
        }
 
        mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream,
-                                                    mbox->ibox.box.path);
+                                                    mbox->box.path);
        if (mbox->mbox_lock_type != F_UNLCK)
                istream_raw_mbox_set_locked(mbox->mbox_stream);
        return 0;
@@ -97,12 +97,13 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox)
 
 static void mbox_file_fix_atime(struct mbox_mailbox *mbox)
 {
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
        struct utimbuf buf;
        struct stat st;
 
-       if (mbox->ibox.recent_flags_count > 0 &&
-           (mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
-           mbox->mbox_fd != -1 && !mbox->ibox.backend_readonly) {
+       if (ibox->recent_flags_count > 0 &&
+           (mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
+           mbox->mbox_fd != -1 && !mbox->box.backend_readonly) {
                /* we've seen recent messages which we want to keep recent.
                   keep file's atime lower than mtime so \Marked status
                   gets shown while listing */
@@ -113,7 +114,7 @@ static void mbox_file_fix_atime(struct mbox_mailbox *mbox)
                if (st.st_atime >= st.st_mtime) {
                        buf.modtime = st.st_mtime;
                        buf.actime = buf.modtime - 1;
-                       if (utime(mbox->ibox.box.path, &buf) < 0) {
+                       if (utime(mbox->box.path, &buf) < 0) {
                                mbox_set_syscall_error(mbox, "utimes()");
                                return;
                        }
@@ -131,7 +132,7 @@ void mbox_file_close_stream(struct mbox_mailbox *mbox)
        if (mbox->mbox_file_stream != NULL) {
                if (mbox->mbox_fd == -1) {
                        /* read-only mbox stream */
-                       i_assert(mbox->ibox.backend_readonly);
+                       i_assert(mbox->box.backend_readonly);
                        i_stream_seek(mbox->mbox_file_stream, 0);
                } else {
                        i_stream_destroy(&mbox->mbox_file_stream);
@@ -153,7 +154,7 @@ int mbox_file_lookup_offset(struct mbox_mailbox *mbox,
        if (data == NULL) {
                mail_storage_set_critical(&mbox->storage->storage,
                        "Cached message offset lost for seq %u in mbox file %s",
-                       seq, mbox->ibox.box.path);
+                       seq, mbox->box.path);
                 mbox->mbox_hdr.dirty_flag = TRUE;
                 mbox->mbox_broken_offsets = TRUE;
                return 0;
@@ -190,7 +191,7 @@ int mbox_file_seek(struct mbox_mailbox *mbox, struct mail_index_view *view,
 
                mail_storage_set_critical(&mbox->storage->storage,
                        "Cached message offset %s is invalid for mbox file %s",
-                       dec2str(offset), mbox->ibox.box.path);
+                       dec2str(offset), mbox->box.path);
                mbox->mbox_hdr.dirty_flag = TRUE;
                mbox->mbox_broken_offsets = TRUE;
                return 0;
index d24a9d5a9dde62c555239c5bd6486159c96da08a..899dd02d1f0dd0cc136fc8ace63897769a5569dd 100644 (file)
@@ -174,9 +174,9 @@ static int mbox_file_open_latest(struct mbox_lock_context *ctx, int lock_type)
                   be sure that the file is latest, but mbox files get rarely
                   deleted and the flushing might cause errors (e.g. EBUSY for
                   trying to flush a /var/mail mountpoint) */
-               if (nfs_safe_stat(mbox->ibox.box.path, &st) < 0) {
+               if (nfs_safe_stat(mbox->box.path, &st) < 0) {
                        if (errno == ENOENT)
-                               mailbox_set_deleted(&mbox->ibox.box);
+                               mailbox_set_deleted(&mbox->box);
                        else
                                mbox_set_syscall_error(mbox, "stat()");
                        return -1;
@@ -233,7 +233,7 @@ static bool dotlock_callback(unsigned int secs_left, bool stale, void *context)
        }
        ctx->dotlock_last_stale = stale;
 
-       index_storage_lock_notify(&ctx->mbox->ibox, stale ?
+       index_storage_lock_notify(&ctx->mbox->box, stale ?
                                  MAILBOX_LOCK_NOTIFY_MAILBOX_OVERRIDE :
                                  MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
                                  secs_left);
@@ -268,12 +268,12 @@ static int mbox_dotlock_privileged_op(struct mbox_mailbox *mbox,
              privileged group
            - DoS other users by dotlocking their mailboxes infinitely
        */
-       fname = strrchr(mbox->ibox.box.path, '/');
+       fname = strrchr(mbox->box.path, '/');
        if (fname == NULL) {
                /* already relative */
-               fname = mbox->ibox.box.path;
+               fname = mbox->box.path;
        } else {
-               dir = t_strdup_until(mbox->ibox.box.path, fname);
+               dir = t_strdup_until(mbox->box.path, fname);
                if (chdir(dir) < 0) {
                        mail_storage_set_critical(&mbox->storage->storage,
                                "chdir(%s) failed: %m", dir);
@@ -285,7 +285,7 @@ static int mbox_dotlock_privileged_op(struct mbox_mailbox *mbox,
        if (op == MBOX_DOTLOCK_OP_LOCK) {
                if (access(fname, R_OK) < 0) {
                        mail_storage_set_critical(&mbox->storage->storage,
-                               "access(%s) failed: %m", mbox->ibox.box.path);
+                               "access(%s) failed: %m", mbox->box.path);
                        return -1;
                }
        }
@@ -348,11 +348,11 @@ mbox_dotlock_log_eacces_error(struct mbox_mailbox *mbox, const char *path)
        errmsg = eacces_error_get_creating("file_dotlock_create", path);
        dir = strrchr(path, '/');
        dir = dir == NULL ? "." : t_strdup_until(path, dir);
-       if (strcmp(mbox->ibox.box.name, "INBOX") != 0) {
+       if (strcmp(mbox->box.name, "INBOX") != 0) {
                mail_storage_set_critical(&mbox->storage->storage,
                        "%s (not INBOX -> no privileged locking)", errmsg);
        } else if (!mbox->mbox_privileged_locking) {
-               dir = mailbox_list_get_path(mbox->ibox.box.list, NULL,
+               dir = mailbox_list_get_path(mbox->box.list, NULL,
                                            MAILBOX_LIST_PATH_TYPE_DIR);
                mail_storage_set_critical(&mbox->storage->storage,
                        "%s (under root dir %s -> no privileged locking)",
@@ -410,7 +410,7 @@ mbox_lock_dotlock_int(struct mbox_lock_context *ctx, int lock_type, bool try)
        set.callback = dotlock_callback;
        set.context = ctx;
 
-       ret = file_dotlock_create(&set, mbox->ibox.box.path, 0,
+       ret = file_dotlock_create(&set, mbox->box.path, 0,
                                  &mbox->mbox_dotlock);
        if (ret >= 0) {
                /* success / timeout */
@@ -420,7 +420,7 @@ mbox_lock_dotlock_int(struct mbox_lock_context *ctx, int lock_type, bool try)
                ret = mbox_dotlock_privileged_op(mbox, &set,
                                                 MBOX_DOTLOCK_OP_LOCK);
        } else if (errno == EACCES)
-               mbox_dotlock_log_eacces_error(mbox, mbox->ibox.box.path);
+               mbox_dotlock_log_eacces_error(mbox, mbox->box.path);
        else
                mbox_set_syscall_error(mbox, "file_dotlock_create()");
 
@@ -510,7 +510,7 @@ static int mbox_lock_flock(struct mbox_lock_context *ctx, int lock_type,
                        next_alarm = 5;
                alarm(next_alarm);
 
-               index_storage_lock_notify(&ctx->mbox->ibox,
+               index_storage_lock_notify(&ctx->mbox->box,
                                          MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
                                          max_wait_time - now);
        }
@@ -574,7 +574,7 @@ static int mbox_lock_lockf(struct mbox_lock_context *ctx, int lock_type,
                        next_alarm = 5;
                alarm(next_alarm);
 
-               index_storage_lock_notify(&ctx->mbox->ibox,
+               index_storage_lock_notify(&ctx->mbox->box,
                                          MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
                                          max_wait_time - now);
        }
@@ -632,7 +632,7 @@ static int mbox_lock_fcntl(struct mbox_lock_context *ctx, int lock_type,
                        mail_storage_set_critical(&ctx->mbox->storage->storage,
                                "fcntl() failed with mbox file %s: "
                                "File is locked by another process (EACCES)",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        return -1;
                }
 
@@ -649,7 +649,7 @@ static int mbox_lock_fcntl(struct mbox_lock_context *ctx, int lock_type,
                        next_alarm = 5;
                alarm(next_alarm);
 
-               index_storage_lock_notify(&ctx->mbox->ibox,
+               index_storage_lock_notify(&ctx->mbox->box,
                                          MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
                                          max_wait_time - now);
        }
@@ -697,14 +697,14 @@ static int mbox_update_locking(struct mbox_mailbox *mbox, int lock_type,
 
        *fcntl_locked_r = FALSE;
 
-        index_storage_lock_notify_reset(&mbox->ibox);
+        index_storage_lock_notify_reset(&mbox->box);
 
        if (!mbox->storage->lock_settings_initialized)
                 mbox_init_lock_settings(mbox->storage);
 
        if (mbox->mbox_fd == -1 && mbox->mbox_file_stream != NULL) {
                /* read-only mbox stream. no need to lock. */
-               i_assert(mbox->ibox.backend_readonly);
+               i_assert(mbox->box.backend_readonly);
                mbox->mbox_lock_type = lock_type;
                return 1;
        }
@@ -767,7 +767,7 @@ static int mbox_update_locking(struct mbox_mailbox *mbox, int lock_type,
 int mbox_lock(struct mbox_mailbox *mbox, int lock_type,
              unsigned int *lock_id_r)
 {
-       const char *path = mbox->ibox.box.path;
+       const char *path = mbox->box.path;
        int mbox_fd = mbox->mbox_fd;
        bool fcntl_locked;
        int ret;
@@ -777,7 +777,7 @@ int mbox_lock(struct mbox_mailbox *mbox, int lock_type,
        i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK);
 
        /* mbox must be locked before index */
-       i_assert(mbox->ibox.box.index->lock_type != F_WRLCK);
+       i_assert(mbox->box.index->lock_type != F_WRLCK);
 
        if (mbox->mbox_lock_type == F_UNLCK) {
                ret = mbox_update_locking(mbox, lock_type, &fcntl_locked);
index a24e5c2dc1fdd60b3982bd172f635f6e85e08ffb..cdb7cbbdfd52a3b47f95f5398c1c8bc3c5bdaf8a 100644 (file)
 #include <unistd.h>
 #include <sys/stat.h>
 
-static void mbox_prepare_resync(struct index_mail *mail)
+static void mbox_prepare_resync(struct mail *mail)
 {
        struct mbox_transaction_context *t =
-               (struct mbox_transaction_context *)mail->trans;
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+               (struct mbox_transaction_context *)mail->transaction;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->box;
 
        if (mbox->mbox_lock_type == F_RDLCK) {
                if (mbox->mbox_lock_id == t->mbox_lock_id)
@@ -34,16 +34,17 @@ static int mbox_mail_seek(struct index_mail *mail)
 {
        struct mbox_transaction_context *t =
                (struct mbox_transaction_context *)mail->trans;
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mail *_mail = &mail->mail.mail;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)_mail->box;
        enum mbox_sync_flags sync_flags = 0;
        int ret, try;
        bool deleted;
 
-       if (mail->mail.mail.expunged || mbox->syncing)
+       if (_mail->expunged || mbox->syncing)
                return -1;
 
-       if (mail->mail.mail.lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
-               return mail_set_aborted(&mail->mail.mail);
+       if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
+               return mail_set_aborted(_mail);
 
        if (mbox->mbox_stream != NULL &&
            istream_raw_mbox_is_corrupted(mbox->mbox_stream)) {
@@ -54,7 +55,7 @@ static int mbox_mail_seek(struct index_mail *mail)
        for (try = 0; try < 2; try++) {
                if ((sync_flags & MBOX_SYNC_FORCE_SYNC) != 0) {
                        /* dirty offsets are broken. make sure we can sync. */
-                       mbox_prepare_resync(mail);
+                       mbox_prepare_resync(_mail);
                }
                if (mbox->mbox_lock_type == F_UNLCK) {
                        sync_flags |= MBOX_SYNC_LOCK_READING;
@@ -65,8 +66,8 @@ static int mbox_mail_seek(struct index_mail *mail)
 
                        /* refresh index file after mbox has been locked to
                           make sure we get only up-to-date mbox offsets. */
-                       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
-                               mail_storage_set_index_error(&mbox->ibox.box);
+                       if (mail_index_refresh(mbox->box.index) < 0) {
+                               mail_storage_set_index_error(&mbox->box);
                                return -1;
                        }
 
@@ -84,14 +85,14 @@ static int mbox_mail_seek(struct index_mail *mail)
                        return -1;
 
                ret = mbox_file_seek(mbox, mail->trans->trans_view,
-                                    mail->mail.mail.seq, &deleted);
+                                    _mail->seq, &deleted);
                if (ret > 0) {
                        /* success */
                        break;
                }
                if (ret < 0) {
                        if (deleted)
-                               mail_set_expunged(&mail->mail.mail);
+                               mail_set_expunged(_mail);
                        return -1;
                }
 
@@ -101,7 +102,7 @@ static int mbox_mail_seek(struct index_mail *mail)
        if (ret == 0) {
                mail_storage_set_critical(&mbox->storage->storage,
                        "Losing sync for mail uid=%u in mbox file %s",
-                       mail->mail.mail.uid, mbox->ibox.box.path);
+                       _mail->uid, mbox->box.path);
        }
        return 0;
 }
@@ -110,7 +111,7 @@ static int mbox_mail_get_received_date(struct mail *_mail, time_t *date_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
        struct index_mail_data *data = &mail->data;
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)_mail->box;
 
        if (index_mail_get_received_date(_mail, date_r) == 0)
                return 0;
@@ -150,7 +151,7 @@ mbox_mail_get_md5_header(struct index_mail *mail, const char **value_r)
 {
        static uint8_t empty_md5[16] =
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box;
        const void *ext_data;
 
        if (mail->data.guid != NULL)
@@ -173,7 +174,7 @@ mbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
                      const char **value_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)_mail->box;
 
        switch (field) {
        case MAIL_FETCH_FROM_ENVELOPE:
@@ -191,7 +192,7 @@ mbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
                   but it's almost guaranteed that it means the MD5 sum is
                   missing. recalculate it. */
                mbox->mbox_save_md5 = TRUE;
-                mbox_prepare_resync(mail);
+                mbox_prepare_resync(_mail);
                if (mbox_sync(mbox, MBOX_SYNC_FORCE_SYNC) < 0)
                        return -1;
 
@@ -211,7 +212,7 @@ mbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
 static bool
 mbox_mail_get_next_offset(struct index_mail *mail, uoff_t *next_offset_r)
 {
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box;
        struct mail_index_view *view;
        const struct mail_index_header *hdr;
        uint32_t seq;
@@ -232,7 +233,7 @@ mbox_mail_get_next_offset(struct index_mail *mail, uoff_t *next_offset_r)
        if (mbox_sync_header_refresh(mbox) < 0)
                return -1;
 
-       view = mail_index_view_open(mail->ibox->box.index);
+       view = mail_index_view_open(mail->mail.mail.box->index);
        hdr = mail_index_get_header(view);
        if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq))
                i_panic("Message unexpectedly expunged from index");
@@ -255,7 +256,7 @@ static int mbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
        struct index_mail_data *data = &mail->data;
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)_mail->box;
        struct istream *input;
        struct message_size hdr_size;
        uoff_t old_offset, body_offset, body_size, next_offset;
@@ -296,7 +297,7 @@ static int mbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
 
 static int mbox_mail_init_stream(struct index_mail *mail)
 {
-       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+       struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box;
        struct istream *raw_stream;
        uoff_t hdr_offset, next_offset;
        int ret;
@@ -312,7 +313,7 @@ static int mbox_mail_init_stream(struct index_mail *mail)
                if (ret < 0) {
                        i_warning("mbox %s: Can't find next message offset "
                                  "for uid=%u",
-                                 mbox->ibox.box.path, mail->mail.mail.uid);
+                                 mbox->box.path, mail->mail.mail.uid);
                }
        }
        if (ret <= 0)
index e0b0cf1cadc7e1767a3332961eb92a3a1a5e4661..9342adcf814e850957bdec6b29c8190f83528cde 100644 (file)
@@ -179,8 +179,8 @@ static void mbox_save_init_sync(struct mailbox_transaction_context *t)
 
        /* open a new view to get the header. this is required if we just
           synced the mailbox so we can get updated next_uid. */
-       (void)mail_index_refresh(mbox->ibox.box.index);
-       view = mail_index_view_open(mbox->ibox.box.index);
+       (void)mail_index_refresh(mbox->box.index);
+       view = mail_index_view_open(mbox->box.index);
        hdr = mail_index_get_header(view);
 
        ctx->next_uid = hdr->next_uid;
@@ -227,7 +227,7 @@ mbox_save_append_keyword_headers(struct mbox_save_context *ctx,
        const char *const *keyword_names;
        unsigned int i, count, keyword_names_count;
 
-       keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.box.index);
+       keyword_names_list = mail_index_get_keywords(ctx->mbox->box.index);
        keyword_names = array_get(keyword_names_list, &keyword_names_count);
 
        str_append(ctx->headers, "X-Keywords:");
@@ -255,14 +255,14 @@ mbox_save_init_file(struct mbox_save_context *ctx,
        bool empty = FALSE;
        int ret;
 
-       if (ctx->mbox->ibox.backend_readonly) {
+       if (ctx->mbox->box.backend_readonly) {
                mail_storage_set_error(storage, MAIL_ERROR_PERM,
                                       "Read-only mbox");
                return -1;
        }
 
-       if (mail_index_is_deleted(mbox->ibox.box.index)) {
-               mailbox_set_deleted(&mbox->ibox.box);
+       if (mail_index_is_deleted(mbox->box.index)) {
+               mailbox_set_deleted(&mbox->box);
                return -1;
        }
 
@@ -778,7 +778,7 @@ int mbox_transaction_save_commit_pre(struct mail_save_context *_ctx)
 
                buf.modtime = st.st_mtime;
                buf.actime = ctx->orig_atime;
-               if (utime(mbox->ibox.box.path, &buf) < 0)
+               if (utime(mbox->box.path, &buf) < 0)
                        mbox_set_syscall_error(mbox, "utime()");
        }
 
index c8e0abed4fbdb445057990dcaa18259f8e032db9..f1e5d1793856e5ac12416421857a63a738c395af 100644 (file)
@@ -83,7 +83,7 @@ int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
        } else {
                mail_storage_set_critical(&mbox->storage->storage,
                                          "%s failed with mbox file %s: %m",
-                                         function, mbox->ibox.box.path);
+                                         function, mbox->box.path);
        }
        return -1;
 }
@@ -338,37 +338,39 @@ mbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                   enum mailbox_flags flags)
 {
        struct mbox_mailbox *mbox;
+       struct index_mailbox_context *ibox;
        pool_t pool;
 
        pool = pool_alloconly_create("mbox mailbox", 1024+512);
        mbox = p_new(pool, struct mbox_mailbox, 1);
-       mbox->ibox.box = mbox_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &mbox_mail_vfuncs;
+       mbox->box = mbox_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &mbox_mail_vfuncs;
 
-       mbox->ibox.save_commit_pre = mbox_transaction_save_commit_pre;
-       mbox->ibox.save_commit_post = mbox_transaction_save_commit_post;
-       mbox->ibox.save_rollback = mbox_transaction_save_rollback;
-
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    MBOX_INDEX_PREFIX);
 
+       ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
+       ibox->save_commit_pre = mbox_transaction_save_commit_pre;
+       ibox->save_commit_post = mbox_transaction_save_commit_post;
+       ibox->save_rollback = mbox_transaction_save_rollback;
+
        mbox->storage = (struct mbox_storage *)storage;
        mbox->mbox_fd = -1;
        mbox->mbox_lock_type = F_UNLCK;
        mbox->mbox_ext_idx =
-               mail_index_ext_register(mbox->ibox.box.index, "mbox",
+               mail_index_ext_register(mbox->box.index, "mbox",
                                        sizeof(mbox->mbox_hdr),
                                        sizeof(uint64_t), sizeof(uint64_t));
        mbox->md5hdr_ext_idx =
-               mail_index_ext_register(mbox->ibox.box.index, "header-md5",
+               mail_index_ext_register(mbox->box.index, "header-md5",
                                        0, 16, 1);
 
        if ((storage->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
                mbox->mbox_save_md5 = TRUE;
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 static int verify_inbox(struct mailbox_list *list)
@@ -418,18 +420,18 @@ static void mbox_lock_touch_timeout(struct mbox_mailbox *mbox)
 
 static int mbox_mailbox_open_existing(struct mbox_mailbox *mbox)
 {
-       struct mailbox *box = &mbox->ibox.box;
+       struct mailbox *box = &mbox->box;
        const char *rootdir;
+       bool move_to_memory;
 
        if (access(box->path, R_OK|W_OK) < 0) {
                if (errno != EACCES) {
                        mbox_set_syscall_error(mbox, "access()");
                        return -1;
                }
-               mbox->ibox.backend_readonly = TRUE;
+               mbox->box.backend_readonly = TRUE;
        }
-       mbox->ibox.move_to_memory =
-               want_memory_indexes(mbox->storage, box->path);
+       move_to_memory = want_memory_indexes(mbox->storage, box->path);
 
        if (strcmp(box->name, "INBOX") == 0) {
                /* if INBOX isn't under the root directory, it's probably in
@@ -449,7 +451,7 @@ static int mbox_mailbox_open_existing(struct mbox_mailbox *mbox)
                                            mbox_lock_touch_timeout, mbox);
                }
        }
-       return index_storage_mailbox_open(box);
+       return index_storage_mailbox_open(box, move_to_memory);
 }
 
 static int mbox_mailbox_open(struct mailbox *box)
@@ -460,7 +462,7 @@ static int mbox_mailbox_open(struct mailbox *box)
 
        if (box->input != NULL) {
                mbox->mbox_file_stream = box->input;
-               mbox->ibox.backend_readonly = TRUE;
+               mbox->box.backend_readonly = TRUE;
                mbox->no_mbox_file = TRUE;
                return 0;
        }
@@ -549,7 +551,7 @@ static void mbox_mailbox_close(struct mailbox *box)
        if (box->view != NULL) {
                hdr = mail_index_get_header(box->view);
                if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
-                   !mbox->ibox.backend_readonly) {
+                   !mbox->box.backend_readonly) {
                        /* we've done changes to mbox which haven't been
                           written yet. do it now. */
                        sync_flags |= MBOX_SYNC_REWRITE;
@@ -588,9 +590,9 @@ static void mbox_notify_changes(struct mailbox *box)
        struct mbox_mailbox *mbox = (struct mbox_mailbox *)box;
 
        if (box->notify_callback == NULL)
-               index_mailbox_check_remove_all(&mbox->ibox);
+               index_mailbox_check_remove_all(&mbox->box);
        else if (!mbox->no_mbox_file)
-               index_mailbox_check_add(&mbox->ibox, mbox->ibox.box.path);
+               index_mailbox_check_add(&mbox->box, mbox->box.path);
 }
 
 static bool
@@ -814,7 +816,7 @@ static void mbox_transaction_unlock(struct mailbox *box, unsigned int lock_id)
        if (lock_id != 0)
                (void)mbox_unlock(mbox, lock_id);
        if (mbox->mbox_global_lock_id == 0) {
-               i_assert(mbox->ibox.box.transaction_count > 0 ||
+               i_assert(mbox->box.transaction_count > 0 ||
                         mbox->mbox_lock_type == F_UNLCK);
        } else {
                /* mailbox opened with MAILBOX_FLAG_KEEP_LOCKED */
index ccf096ff6100245c5a83d2f1aae836a224227c31..f5b05ad38cf5eba07cb3053ca4e63f6b3efebb9e 100644 (file)
@@ -32,7 +32,7 @@ struct mbox_storage {
 };
 
 struct mbox_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct mbox_storage *storage;
 
        int mbox_fd;
index 10ead9d13d7634fdc236a86e828bcd93a37d2ead..07588b3d968a37ebe8821e731a78fafc59c85feb 100644 (file)
@@ -113,7 +113,8 @@ static void
 parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
                          struct message_header_line *hdr, size_t pos)
 {
-       struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->sync_ctx->mbox->box;
+       struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
        const char *keyword, *error;
        size_t keyword_start;
        unsigned int idx, count;
@@ -135,7 +136,7 @@ parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
                /* add it to index's keyword list if it's not there already */
                keyword = t_strndup(hdr->full_value + keyword_start,
                                    pos - keyword_start);
-               if (mailbox_keyword_is_valid(&ctx->sync_ctx->mbox->ibox.box,
+               if (mailbox_keyword_is_valid(&ctx->sync_ctx->mbox->box,
                                             keyword, &error)) {
                        mail_index_keyword_lookup_or_create(box->index,
                                                            keyword, &idx);
@@ -143,7 +144,7 @@ parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
                count++;
        }
 
-       if (count != array_count(ctx->sync_ctx->mbox->ibox.keyword_names)) {
+       if (count != array_count(ibox->keyword_names)) {
                /* need to update this list */
                ctx->imapbase_rewrite = TRUE;
                ctx->need_rewrite = TRUE;
@@ -247,7 +248,7 @@ static bool parse_x_imap(struct mbox_sync_mail_context *ctx,
 static bool parse_x_keywords_real(struct mbox_sync_mail_context *ctx,
                                  struct message_header_line *hdr)
 {
-       struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->sync_ctx->mbox->box;
        ARRAY_TYPE(keyword_indexes) keyword_list;
        const unsigned int *list;
        string_t *keyword;
index 9e42500f8fbfbd41fb7db784ae4cece903db2274..3640b0e5bd56448a089d9ac64548760d3b79936d 100644 (file)
@@ -124,12 +124,14 @@ static void
 keywords_append(struct mbox_sync_context *sync_ctx, string_t *dest,
                const ARRAY_TYPE(keyword_indexes) *keyword_indexes_arr)
 {
+       struct index_mailbox_context *ibox =
+               INDEX_STORAGE_CONTEXT(&sync_ctx->mbox->box);
        const char *const *keyword_names;
        const unsigned int *keyword_indexes;
        unsigned int i, idx_count, keywords_count;
        size_t last_break;
 
-       keyword_names = array_get(sync_ctx->mbox->ibox.keyword_names,
+       keyword_names = array_get(ibox->keyword_names,
                                  &keywords_count);
        keyword_indexes = array_get(keyword_indexes_arr, &idx_count);
 
@@ -152,6 +154,8 @@ static void
 keywords_append_all(struct mbox_sync_mail_context *ctx, string_t *dest,
                    size_t startpos)
 {
+       struct index_mailbox_context *ibox =
+               INDEX_STORAGE_CONTEXT(&ctx->sync_ctx->mbox->box);
        const char *const *names;
        const unsigned char *p;
        unsigned int i, count;
@@ -168,7 +172,7 @@ keywords_append_all(struct mbox_sync_mail_context *ctx, string_t *dest,
                }
        }
 
-       names = array_get(ctx->sync_ctx->mbox->ibox.keyword_names, &count);
+       names = array_get(ibox->keyword_names, &count);
        for (i = 0; i < count; i++) {
                /* wrap the line whenever it gets too long */
                if (str_len(dest) - last_break < KEYWORD_WRAP_LINE_LENGTH)
index 578ffa2233298143c4f45760058f7e90f244a726..6efb86d7d54c80a3cc149a4bfe6dd7367d3665f3 100644 (file)
@@ -73,13 +73,13 @@ void mbox_sync_set_critical(struct mbox_sync_context *sync_ctx,
                mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
                        "mbox file %s was modified while we were syncing, "
                        "check your locking settings",
-                       sync_ctx->mbox->ibox.box.path);
+                       sync_ctx->mbox->box.path);
        }
 
        va_start(va, fmt);
        mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
                                  "Sync failed for mbox file %s: %s",
-                                 sync_ctx->mbox->ibox.box.path,
+                                 sync_ctx->mbox->box.path,
                                  t_strdup_vprintf(fmt, va));
        va_end(va);
 }
@@ -181,7 +181,7 @@ static void mbox_sync_read_index_syncs(struct mbox_sync_context *sync_ctx,
 
        index_sync_changes_read(sync_ctx->sync_changes, uid, sync_expunge_r,
                                expunged_guid_128);
-       if (sync_ctx->mbox->ibox.backend_readonly) {
+       if (sync_ctx->mbox->box.backend_readonly) {
                /* we can't expunge anything from read-only mboxes */
                *sync_expunge_r = FALSE;
        }
@@ -296,7 +296,7 @@ static void
 mbox_sync_update_index_keywords(struct mbox_sync_mail_context *mail_ctx)
 {
        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
-       struct mail_index *index = sync_ctx->mbox->ibox.box.index;
+       struct mail_index *index = sync_ctx->mbox->box.index;
        struct mail_keywords *keywords;
 
        keywords = !array_is_created(&mail_ctx->mail.keywords) ?
@@ -366,7 +366,7 @@ static void mbox_sync_update_flags(struct mbox_sync_mail_context *mail_ctx,
                                   const struct mail_index_record *rec)
 {
        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
-       struct mailbox *box = &sync_ctx->mbox->ibox.box;
+       struct mailbox *box = &sync_ctx->mbox->box;
        struct mbox_sync_mail *mail = &mail_ctx->mail;
        enum mail_index_sync_type sync_type;
        ARRAY_TYPE(keyword_indexes) orig_keywords = ARRAY_INIT;
@@ -594,7 +594,7 @@ static void update_from_offsets(struct mbox_sync_context *sync_ctx)
 static void mbox_sync_handle_expunge(struct mbox_sync_mail_context *mail_ctx)
 {
        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
-       struct mailbox *box = &sync_ctx->mbox->ibox.box;
+       struct mailbox *box = &sync_ctx->mbox->box;
 
        if (box->v.sync_notify != NULL) {
                box->v.sync_notify(box, mail_ctx->mail.uid,
@@ -991,7 +991,7 @@ static bool mbox_sync_imapbase(struct mbox_sync_context *sync_ctx,
                i_warning("UIDVALIDITY changed (%u -> %u) in mbox file %s",
                          sync_ctx->hdr->uid_validity,
                          sync_ctx->base_uid_validity,
-                         sync_ctx->mbox->ibox.box.path);
+                         sync_ctx->mbox->box.path);
                sync_ctx->index_reset = TRUE;
                return TRUE;
        }
@@ -1114,7 +1114,7 @@ static int mbox_sync_loop(struct mbox_sync_context *sync_ctx,
                                        &sync_ctx->mbox->storage->storage,
                                        "Out of UIDs, renumbering them in mbox "
                                        "file %s",
-                                       sync_ctx->mbox->ibox.box.path);
+                                       sync_ctx->mbox->box.path);
                                sync_ctx->renumber_uids = TRUE;
                                return 0;
                        }
@@ -1390,7 +1390,7 @@ mbox_sync_index_update_ext_header(struct mbox_sync_context *sync_ctx)
                mail_generate_guid_128(mbox->mbox_hdr.mailbox_guid);
        }
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
+       mail_index_get_header_ext(mbox->box.view, mbox->mbox_ext_idx,
                                  &data, &data_size);
        if (data_size != sizeof(mbox->mbox_hdr) ||
            memcmp(data, &mbox->mbox_hdr, data_size) != 0) {
@@ -1429,7 +1429,7 @@ static int mbox_sync_update_index_header(struct mbox_sync_context *sync_ctx)
                   quite minimal (an extra logged error message). */
                while (sync_ctx->orig_mtime == st->st_mtime) {
                        usleep(500000);
-                       if (utime(sync_ctx->mbox->ibox.box.path, NULL) < 0) {
+                       if (utime(sync_ctx->mbox->box.path, NULL) < 0) {
                                mbox_set_syscall_error(sync_ctx->mbox,
                                                       "utime()");
                                return -1;
@@ -1483,7 +1483,7 @@ static int mbox_sync_update_index_header(struct mbox_sync_context *sync_ctx)
        view = mail_index_transaction_open_updated_view(sync_ctx->t);
        if (mail_index_lookup_seq_range(view, sync_ctx->last_nonrecent_uid + 1,
                                        (uint32_t)-1, &seq, &seq2)) {
-               index_mailbox_set_recent_seq(&sync_ctx->mbox->ibox,
+               index_mailbox_set_recent_seq(&sync_ctx->mbox->box,
                                             view, seq, seq2);
        }
        mail_index_view_close(&view);
@@ -1515,7 +1515,7 @@ static void mbox_sync_restart(struct mbox_sync_context *sync_ctx)
                mail_index_reset(sync_ctx->t);
                sync_ctx->reset_hdr.next_uid = 1;
                sync_ctx->hdr = &sync_ctx->reset_hdr;
-               index_mailbox_reset_uidvalidity(&sync_ctx->mbox->ibox);
+               index_mailbox_reset_uidvalidity(&sync_ctx->mbox->box);
        }
 
        sync_ctx->prev_msg_uid = 0;
@@ -1590,7 +1590,7 @@ static int mbox_sync_do(struct mbox_sync_context *sync_ctx,
                   b) we ran out of UIDs
                   c) syncing had errors */
                if (sync_ctx->delay_writes &&
-                   !sync_ctx->mbox->ibox.backend_readonly &&
+                   !sync_ctx->mbox->box.backend_readonly &&
                    (sync_ctx->errors || sync_ctx->renumber_uids)) {
                        /* fixing a broken mbox state, be sure to write
                           the changes. */
@@ -1631,16 +1631,16 @@ int mbox_sync_header_refresh(struct mbox_mailbox *mbox)
        const void *data;
        size_t data_size;
 
-       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
-               mail_storage_set_index_error(&mbox->ibox.box);
+       if (mail_index_refresh(mbox->box.index) < 0) {
+               mail_storage_set_index_error(&mbox->box);
                return -1;
        }
 
-       mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
+       mail_index_get_header_ext(mbox->box.view, mbox->mbox_ext_idx,
                                  &data, &data_size);
        if (data_size == 0) {
                /* doesn't exist. FIXME: backwards compatibility copying */
-               hdr = mail_index_get_header(mbox->ibox.box.view);
+               hdr = mail_index_get_header(mbox->box.view);
                mbox->mbox_hdr.sync_mtime = hdr->sync_stamp;
                mbox->mbox_hdr.sync_size = hdr->sync_size;
                return 0;
@@ -1670,16 +1670,16 @@ int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty,
                st = i_stream_stat(mbox->mbox_file_stream, FALSE);
                if (st == NULL) {
                        if (errno == ENOENT) {
-                               mailbox_set_deleted(&mbox->ibox.box);
+                               mailbox_set_deleted(&mbox->box);
                                return 0;
                        }
                        mbox_set_syscall_error(mbox, "i_stream_stat()");
                        return -1;
                }
        } else {
-               if (stat(mbox->ibox.box.path, &statbuf) < 0) {
+               if (stat(mbox->box.path, &statbuf) < 0) {
                        if (errno == ENOENT) {
-                               mailbox_set_deleted(&mbox->ibox.box);
+                               mailbox_set_deleted(&mbox->box);
                                return 0;
                        }
                        mbox_set_syscall_error(mbox, "stat()");
@@ -1732,7 +1732,7 @@ static int mbox_sync_int(struct mbox_mailbox *mbox, enum mbox_sync_flags flags,
        int ret, changed;
        bool delay_writes;
 
-       delay_writes = mbox->ibox.backend_readonly ||
+       delay_writes = mbox->box.backend_readonly ||
                ((flags & MBOX_SYNC_REWRITE) == 0 &&
                 mbox->storage->set->mbox_lazy_writes);
 
@@ -1779,7 +1779,7 @@ again:
                   lock it for writing immediately. the mbox must be locked
                   before index syncing is started to avoid deadlocks, so we
                   don't have much choice either (well, easy ones anyway). */
-               int lock_type = mbox->ibox.backend_readonly ? F_RDLCK : F_WRLCK;
+               int lock_type = mbox->box.backend_readonly ? F_RDLCK : F_WRLCK;
 
                if ((ret = mbox_lock(mbox, lock_type, lock_id)) <= 0) {
                        if (ret == 0 || lock_type == F_RDLCK)
@@ -1788,25 +1788,25 @@ again:
                        /* try as read-only */
                        if (mbox_lock(mbox, F_RDLCK, lock_id) <= 0)
                                return -1;
-                       mbox->ibox.backend_readonly = TRUE;
+                       mbox->box.backend_readonly = TRUE;
                }
        }
 
        sync_flags = 0;
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
        if ((flags & MBOX_SYNC_REWRITE) != 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY;
 
-       ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->box.index, &index_sync_ctx,
                                    &sync_view, &trans, sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                return ret;
        }
 
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) {
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) {
                /* see if we need to drop recent flags */
                sync_ctx.hdr = mail_index_get_header(sync_view);
                if (sync_ctx.hdr->first_recent_uid < sync_ctx.hdr->next_uid)
@@ -1819,7 +1819,7 @@ again:
                /* index may need to do internal syncing though, so commit
                   instead of rollbacking. */
                if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                        return -1;
                }
                return 0;
@@ -1828,7 +1828,7 @@ again:
        memset(&sync_ctx, 0, sizeof(sync_ctx));
        sync_ctx.mbox = mbox;
        sync_ctx.keep_recent =
-               (mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0;
+               (mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0;
 
        sync_ctx.hdr = mail_index_get_header(sync_view);
        sync_ctx.from_line = str_new(default_pool, 256);
@@ -1843,17 +1843,16 @@ again:
                pool_alloconly_create("mbox saved keywords", 4096);
 
        /* make sure we've read the latest keywords in index */
-       (void)mail_index_get_keywords(mbox->ibox.box.index);
+       (void)mail_index_get_keywords(mbox->box.index);
 
        i_array_init(&sync_ctx.mails, 64);
 
        sync_ctx.flags = flags;
        sync_ctx.delay_writes = delay_writes ||
-               sync_ctx.mbox->ibox.backend_readonly;
+               sync_ctx.mbox->box.backend_readonly;
 
        sync_ctx.sync_changes =
-               index_sync_changes_init(&mbox->ibox, index_sync_ctx,
-                                       sync_view, trans,
+               index_sync_changes_init(index_sync_ctx, sync_view, trans,
                                        sync_ctx.delay_writes);
 
        if (!changed && delay_writes) {
@@ -1895,14 +1894,14 @@ again:
        if (ret < 0)
                mail_index_sync_rollback(&index_sync_ctx);
        else if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-               mail_storage_set_index_error(&mbox->ibox.box);
+               mail_storage_set_index_error(&mbox->box);
                ret = -1;
        }
        sync_ctx.t = NULL;
        sync_ctx.index_sync_ctx = NULL;
 
        if (ret == 0 && mbox->mbox_fd != -1 && sync_ctx.keep_recent &&
-           !sync_ctx.mbox->ibox.backend_readonly) {
+           !sync_ctx.mbox->box.backend_readonly) {
                /* try to set atime back to its original value */
                struct utimbuf buf;
                struct stat st;
@@ -1912,7 +1911,7 @@ again:
                else {
                        buf.modtime = st.st_mtime;
                        buf.actime = sync_ctx.orig_atime;
-                       if (utime(mbox->ibox.box.path, &buf) < 0)
+                       if (utime(mbox->box.path, &buf) < 0)
                                mbox_set_syscall_error(mbox, "utime()");
                }
        }
@@ -1960,8 +1959,8 @@ int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags)
                }
        }
 
-       if (mbox->ibox.box.v.sync_notify != NULL)
-               mbox->ibox.box.v.sync_notify(&mbox->ibox.box, 0, 0);
+       if (mbox->box.v.sync_notify != NULL)
+               mbox->box.v.sync_notify(&mbox->box, 0, 0);
        return ret;
 }
 
@@ -1977,7 +1976,7 @@ mbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       if (index_mailbox_want_full_sync(&mbox->ibox, flags) && ret == 0) {
+       if (index_mailbox_want_full_sync(&mbox->box, flags) && ret == 0) {
                if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&
                    !mbox->storage->set->mbox_very_dirty_syncs)
                        mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
index 9b5902d0a1e1cd37e09b59d1aa55f5c2c8f77d2d..e3eb38a4b795a82574f9584035a7f34c0b77eeb5 100644 (file)
@@ -46,13 +46,13 @@ raw_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        pool = pool_alloconly_create("raw mailbox", 1024+512);
        mbox = p_new(pool, struct raw_mailbox, 1);
-       mbox->ibox.box = raw_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &raw_mail_vfuncs;
+       mbox->box = raw_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &raw_mail_vfuncs;
 
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, NULL);
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags, NULL);
 
        mbox->storage = (struct raw_storage *)storage;
 
@@ -63,7 +63,7 @@ raw_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                mbox->have_filename = TRUE;
        }
        mbox->size = (uoff_t)-1;
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 static int raw_mailbox_open(struct mailbox *box)
@@ -71,7 +71,7 @@ static int raw_mailbox_open(struct mailbox *box)
        int fd;
 
        if (box->input != NULL)
-               return index_storage_mailbox_open(box);
+               return index_storage_mailbox_open(box, FALSE);
 
        fd = open(box->path, O_RDONLY);
        if (fd == -1) {
@@ -87,7 +87,7 @@ static int raw_mailbox_open(struct mailbox *box)
        }
        box->input = i_stream_create_fd(fd, MAIL_READ_FULL_BLOCK_SIZE, TRUE);
        i_stream_set_init_buffer_size(box->input, MAIL_READ_FULL_BLOCK_SIZE);
-       return index_storage_mailbox_open(box);
+       return index_storage_mailbox_open(box, FALSE);
 }
 
 static int
index 2dfa14ab2c767d013ec54d8714f6a9c904953afe..a5c2c59d9038a1e447a91ab76b6612c8056405b5 100644 (file)
@@ -13,7 +13,7 @@ struct raw_storage {
 };
 
 struct raw_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct raw_storage *storage;
 
        time_t mtime, ctime;
index 4a9262f8e22a0cc6304b9eceb5d71ba488252033..4c7d88bf6d27cce83e34eaf7c9e3d829e359911d 100644 (file)
@@ -18,14 +18,14 @@ static int raw_sync(struct raw_mailbox *mbox)
 
        sync_flags = MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY |
                MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
-       ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->box.index, &index_sync_ctx,
                                    &sync_view, &trans, sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                return ret;
        }
 
@@ -36,10 +36,10 @@ static int raw_sync(struct raw_mailbox *mbox)
 
        /* add our one and only message */
        mail_index_append(trans, 1, &seq);
-       index_mailbox_set_recent_uid(&mbox->ibox, 1);
+       index_mailbox_set_recent_uid(&mbox->box, 1);
 
        if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-               mail_storage_set_index_error(&mbox->ibox.box);
+               mail_storage_set_index_error(&mbox->box);
                return -1;
        }
        mbox->synced = TRUE;
index 3972738e7885a9a7e9d3ac43818bed1a910d931c..d87131eebba3e7827314e346184cbc5c85717b07 100644 (file)
@@ -87,19 +87,19 @@ int mail_transaction_log_view_next(struct mail_transaction_log_view *view ATTR_U
 
 static void test_index_storage_get_expunges(void)
 {
-       struct index_mailbox *ibox;
+       struct mailbox *box;
        ARRAY_TYPE(seq_range) uids_filter;
        ARRAY_TYPE(mailbox_expunge_rec) expunges;
        const struct mailbox_expunge_rec *exp;
        unsigned int i, count;
        uint64_t modseq;
 
-       ibox = t_new(struct index_mailbox, 1);
-       ibox->box.index = t_new(struct mail_index, 1);
-       ibox->box.view = t_new(struct mail_index_view, 1);
+       box = t_new(struct mailbox, 1);
+       box->index = t_new(struct mail_index, 1);
+       box->view = t_new(struct mail_index_view, 1);
 
-       ibox->box.view->log_file_head_seq = 101;
-       ibox->box.view->log_file_head_offset = 1024;
+       box->view->log_file_head_seq = 101;
+       box->view->log_file_head_offset = 1024;
 
        test_begin("index storage get expunges");
 
@@ -114,7 +114,7 @@ static void test_index_storage_get_expunges(void)
        t_array_init(&expunges, 32);
        modseq = 98ULL << 32;
        for (i = 0; i < 2; i++) {
-               test_assert(index_storage_get_expunges(&ibox->box, modseq, &uids_filter,
+               test_assert(index_storage_get_expunges(box, modseq, &uids_filter,
                                                       &expunges) == i);
 
                exp = array_get(&expunges, &count);
index aa4b76c85d28ab8eebab284fc14aedfd78e24af3..89e730cb855c50e311f97e5e1c9278355dbd2dbb 100644 (file)
@@ -253,6 +253,8 @@ struct mailbox {
        unsigned int opened:1;
        /* Mailbox was deleted while we had it open. */
        unsigned int mailbox_deleted:1;
+       /* we've discovered there aren't enough permissions to modify mailbox */
+       unsigned int backend_readonly:1;
 };
 
 struct mail_vfuncs {
index 26d6faac93c5b19cbaac762f0231a1f3b66d288a..20c7e2be5dc62093b4ead08373c6ac9bcbd3e68b 100644 (file)
@@ -323,16 +323,16 @@ int virtual_config_read(struct virtual_mailbox *mbox)
        i_array_init(&mbox->backend_boxes, 8);
        mbox->search_args_crc32 = (uint32_t)-1;
 
-       path = t_strconcat(mbox->ibox.box.path, "/"VIRTUAL_CONFIG_FNAME, NULL);
+       path = t_strconcat(mbox->box.path, "/"VIRTUAL_CONFIG_FNAME, NULL);
        fd = open(path, O_RDONLY);
        if (fd == -1) {
                if (errno == ENOENT) {
-                       mailbox_list_set_error(mbox->ibox.box.list,
+                       mailbox_list_set_error(mbox->box.list,
                                MAIL_ERROR_NOTPOSSIBLE,
                                "Virtual mailbox missing configuration file");
                        return -1;
                }
-               mailbox_list_set_critical(mbox->ibox.box.list,
+               mailbox_list_set_critical(mbox->box.list,
                                          "open(%s) failed: %m", path);
                return -1;
        }
@@ -340,7 +340,7 @@ int virtual_config_read(struct virtual_mailbox *mbox)
        memset(&ctx, 0, sizeof(ctx));
        ctx.sep = mail_namespaces_get_root_sep(user->namespaces);
        ctx.mbox = mbox;
-       ctx.pool = mbox->ibox.box.pool;
+       ctx.pool = mbox->box.pool;
        ctx.rule = t_str_new(256);
        ctx.input = i_stream_create_fd(fd, (size_t)-1, FALSE);
        i_stream_set_return_partial_line(ctx.input, TRUE);
@@ -353,7 +353,7 @@ int virtual_config_read(struct virtual_mailbox *mbox)
                else
                        ret = virtual_config_parse_line(&ctx, line, &error);
                if (ret < 0) {
-                       mailbox_list_set_critical(mbox->ibox.box.list,
+                       mailbox_list_set_critical(mbox->box.list,
                                                  "%s: Error at line %u: %s",
                                                  path, linenum, error);
                        break;
@@ -362,7 +362,7 @@ int virtual_config_read(struct virtual_mailbox *mbox)
        if (ret == 0) {
                ret = virtual_config_add_rule(&ctx, &error);
                if (ret < 0) {
-                       mailbox_list_set_critical(mbox->ibox.box.list,
+                       mailbox_list_set_critical(mbox->box.list,
                                                  "%s: Error at line %u: %s",
                                                  path, linenum, error);
                }
@@ -373,7 +373,7 @@ int virtual_config_read(struct virtual_mailbox *mbox)
                ret = virtual_config_expand_wildcards(&ctx);
 
        if (ret == 0 && array_count(&mbox->backend_boxes) == 0) {
-               mailbox_list_set_critical(mbox->ibox.box.list,
+               mailbox_list_set_critical(mbox->box.list,
                                          "%s: No mailboxes defined", path);
                ret = -1;
        }
index 06b1dd887c99e0d167c5470657557b5574bbde72..937bb83a3018fce34cf575d5f92b29a7c183d5aa 100644 (file)
@@ -41,7 +41,7 @@ virtual_mail_alloc(struct mailbox_transaction_context *t,
 
        vmail->imail.data_pool =
                pool_alloconly_create("virtual index_mail", 512);
-       vmail->imail.ibox = &mbox->ibox;
+       vmail->imail.ibox = INDEX_STORAGE_CONTEXT(t->box);
        vmail->imail.trans = (struct index_transaction_context *)t;
 
        vmail->wanted_fields = wanted_fields;
index 55a6ea277772925a6006129780356b8da73e1198..4ba8cd9bf07a0f25c02b90d25887607e0a16eff3 100644 (file)
@@ -82,7 +82,7 @@ static void virtual_search_get_records(struct mail_search_context *ctx,
                        seq_range_array_add(&vctx->result, 0, ctx->seq);
                } else {
                        /* possible match, save and check later */
-                       mail_index_lookup_ext(mbox->ibox.box.view, ctx->seq,
+                       mail_index_lookup_ext(mbox->box.view, ctx->seq,
                                              mbox->virtual_ext_id,
                                              &data, &expunged);
                        vrec = data;
index b17fdac6fce0881482625127072c77bece98005f..9739c276050db159d3d68626c320e54e86eab42b 100644 (file)
@@ -144,7 +144,7 @@ static int virtual_backend_box_open(struct virtual_mailbox *mbox,
                        return 0;
                }
                /* copy the error */
-               mail_storage_set_error(mbox->ibox.box.storage, error,
+               mail_storage_set_error(mbox->box.storage, error,
                        t_strdup_printf("%s (%s)", str, mailbox));
                return -1;
        }
@@ -197,23 +197,23 @@ virtual_mailbox_alloc(struct mail_storage *_storage, struct mailbox_list *list,
 
        pool = pool_alloconly_create("virtual mailbox", 1024+512);
        mbox = p_new(pool, struct virtual_mailbox, 1);
-       mbox->ibox.box = virtual_mailbox;
-       mbox->ibox.box.pool = pool;
-       mbox->ibox.box.storage = _storage;
-       mbox->ibox.box.list = list;
-       mbox->ibox.box.mail_vfuncs = &virtual_mail_vfuncs;
+       mbox->box = virtual_mailbox;
+       mbox->box.pool = pool;
+       mbox->box.storage = _storage;
+       mbox->box.list = list;
+       mbox->box.mail_vfuncs = &virtual_mail_vfuncs;
 
-       index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
+       index_storage_mailbox_alloc(&mbox->box, name, input, flags,
                                    VIRTUAL_INDEX_PREFIX);
 
        mbox->storage = storage;
        mbox->vseq_lookup_prev_mailbox = i_strdup("");
 
        mbox->virtual_ext_id =
-               mail_index_ext_register(mbox->ibox.box.index, "virtual", 0,
+               mail_index_ext_register(mbox->box.index, "virtual", 0,
                        sizeof(struct virtual_mail_index_record),
                        sizeof(uint32_t));
-       return &mbox->ibox.box;
+       return &mbox->box;
 }
 
 static int virtual_mailbox_open(struct mailbox *box)
@@ -255,7 +255,7 @@ static int virtual_mailbox_open(struct mailbox *box)
                virtual_mailboxes_open(mbox, box->flags) < 0;
        array_delete(&mbox->storage->open_stack,
                     array_count(&mbox->storage->open_stack)-1, 1);
-       return failed ? -1 : index_storage_mailbox_open(box);
+       return failed ? -1 : index_storage_mailbox_open(box, FALSE);
 }
 
 static void virtual_mailbox_close(struct mailbox *box)
index 4f8e3348fca1e3c20633db327e920f30b859b954..b6a87b097f0126d1442e5563e08b8e5137d3f55e 100644 (file)
@@ -99,7 +99,7 @@ struct virtual_backend_box {
 ARRAY_DEFINE_TYPE(virtual_backend_box, struct virtual_backend_box *);
 
 struct virtual_mailbox {
-       struct index_mailbox ibox;
+       struct mailbox box;
        struct virtual_storage *storage;
 
        uint32_t virtual_ext_id;
index 511406f99c73347625200a86baf550ec14a420f1..08d2d1b16ec99dd0dd51d99707df044c8484ada1 100644 (file)
@@ -140,7 +140,7 @@ virtual_sync_get_backend_box(struct virtual_sync_context *ctx, const char *name,
        /* another process just added a new mailbox.
           we can't handle this currently. */
        ctx->mbox->inconsistent = TRUE;
-       mail_storage_set_error(ctx->mbox->ibox.box.storage, MAIL_ERROR_TEMP,
+       mail_storage_set_error(ctx->mbox->box.storage, MAIL_ERROR_TEMP,
                "Backend mailbox added by another session. "
                "Reopen the virtual mailbox.");
        return -1;
@@ -184,7 +184,7 @@ static int virtual_sync_ext_header_read(struct virtual_sync_context *ctx)
                if (ext_name_offset >= ext_size ||
                    ext_hdr->mailbox_count > INT_MAX/sizeof(*mailboxes)) {
                        i_error("virtual index %s: Broken mailbox_count header",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        ctx->index_broken = TRUE;
                        ext_mailbox_count = 0;
                        ret = 0;
@@ -199,18 +199,18 @@ static int virtual_sync_ext_header_read(struct virtual_sync_context *ctx)
                if (mailboxes[i].id > ext_hdr->highest_mailbox_id ||
                    mailboxes[i].id <= prev_mailbox_id) {
                        i_error("virtual index %s: Broken mailbox id",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        break;
                }
                if (mailboxes[i].name_len == 0 ||
                    mailboxes[i].name_len > ext_size) {
                        i_error("virtual index %s: Broken mailbox name_len",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        break;
                }
                if (ext_name_offset + mailboxes[i].name_len > ext_size) {
                        i_error("virtual index %s: Broken mailbox list",
-                               ctx->mbox->ibox.box.path);
+                               ctx->mbox->box.path);
                        break;
                }
                T_BEGIN {
@@ -433,7 +433,7 @@ static void virtual_sync_index_changes(struct virtual_sync_context *ctx)
 
 static void virtual_sync_index_finish(struct virtual_sync_context *ctx)
 {
-       struct mailbox *box = &ctx->mbox->ibox.box;
+       struct mailbox *box = &ctx->mbox->box;
        const struct mail_index_header *hdr;
        uint32_t seq1, seq2;
 
@@ -446,7 +446,7 @@ static void virtual_sync_index_finish(struct virtual_sync_context *ctx)
        /* mark the newly seen messages as recent */
        if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
                                        hdr->next_uid, &seq1, &seq2)) {
-               index_mailbox_set_recent_seq(&ctx->mbox->ibox, ctx->sync_view,
+               index_mailbox_set_recent_seq(&ctx->mbox->box, ctx->sync_view,
                                             seq1, seq2);
        }
        if (ctx->ext_header_rewrite) {
@@ -1319,7 +1319,7 @@ virtual_sync_apply_existing_appends(struct virtual_sync_context *ctx)
                                                          vrec->mailbox_id);
                        if (bbox == NULL) {
                                mail_storage_set_critical(
-                                       ctx->mbox->ibox.box.storage,
+                                       ctx->mbox->box.storage,
                                        "Mailbox ID %u unexpectedly lost",
                                        vrec->mailbox_id);
                                return -1;
@@ -1352,7 +1352,7 @@ virtual_sync_apply_existing_expunges(struct virtual_mailbox *mbox,
 
        seq_range_array_iter_init(&iter, isync_ctx->expunges);
        while (seq_range_array_iter_nth(&iter, n++, &seq)) {
-               mail_index_lookup_ext(mbox->ibox.box.view, seq,
+               mail_index_lookup_ext(mbox->box.view, seq,
                                      mbox->virtual_ext_id, &data, &expunged);
                vrec = data;
 
@@ -1380,7 +1380,7 @@ static int virtual_sync_backend_boxes(struct virtual_sync_context *ctx)
        for (i = 0; i < count; i++) {
                if (virtual_sync_backend_box(ctx, bboxes[i]) < 0) {
                        /* backend failed, copy the error */
-                       virtual_box_copy_error(&ctx->mbox->ibox.box,
+                       virtual_box_copy_error(&ctx->mbox->box,
                                               bboxes[i]->box);
                        return -1;
                }
@@ -1414,7 +1414,7 @@ static int virtual_sync_finish(struct virtual_sync_context *ctx, bool success)
        virtual_sync_backend_boxes_finish(ctx);
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
+                       mail_storage_set_index_error(&ctx->mbox->box);
                        ret = -1;
                }
        } else {
@@ -1424,7 +1424,7 @@ static int virtual_sync_finish(struct virtual_sync_context *ctx, bool success)
                        if (mail_index_unlink(ctx->index) < 0) {
                                i_error("virtual index %s: Failed to unlink() "
                                        "broken indexes: %m",
-                                       ctx->mbox->ibox.box.path);
+                                       ctx->mbox->box.path);
                        }
                }
                mail_index_sync_rollback(&ctx->index_sync_ctx);
@@ -1443,7 +1443,7 @@ static int virtual_sync(struct virtual_mailbox *mbox,
        ctx = i_new(struct virtual_sync_context, 1);
        ctx->mbox = mbox;
        ctx->flags = flags;
-       ctx->index = mbox->ibox.box.index;
+       ctx->index = mbox->box.index;
        /* Removed messages are expunged when
           a) EXPUNGE is used
           b) Mailbox is being opened (FIX_INCONSISTENT is set) */
@@ -1453,7 +1453,7 @@ static int virtual_sync(struct virtual_mailbox *mbox,
 
        index_sync_flags = MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY |
                MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
+       if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                index_sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
        ret = mail_index_sync_begin(ctx->index, &ctx->index_sync_ctx,
@@ -1461,7 +1461,7 @@ static int virtual_sync(struct virtual_mailbox *mbox,
                                    index_sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox.box);
+                       mail_storage_set_index_error(&mbox->box);
                i_free(ctx);
                return ret;
        }
@@ -1493,7 +1493,7 @@ virtual_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       if (index_mailbox_want_full_sync(&mbox->ibox, flags) && ret == 0)
+       if (index_mailbox_want_full_sync(&mbox->box, flags) && ret == 0)
                ret = virtual_sync(mbox, flags);
 
        sync_ctx = index_mailbox_sync_init(box, flags, ret < 0);