# HG changeset patch # User Timo Sirainen # Date 1175258641 -10800 # Node ID 78eaf595359ce358c56f2fb0a29766aa4a25fecb # Parent daca7ed634c0446579196f57dac9996a4beaa437 Removed struct index_storage abstraction. It's pointless. diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/cydir/cydir-save.c --- a/src/lib-storage/index/cydir/cydir-save.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/cydir/cydir-save.c Fri Mar 30 15:44:01 2007 +0300 @@ -48,7 +48,7 @@ { const char *dir; - dir = mailbox_list_get_path(STORAGE(ctx->mbox->storage)->list, + dir = mailbox_list_get_path(ctx->mbox->storage->storage.list, ctx->mbox->ibox.box.name, MAILBOX_LIST_PATH_TYPE_MAILBOX); return t_strdup_printf("%s/%s.%u", dir, ctx->tmp_basename, num); @@ -134,10 +134,10 @@ if (o_stream_send_istream(ctx->output, ctx->input) < 0) { if (ENOSPACE(ctx->output->stream_errno)) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Not enough disk space"); } else { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "o_stream_send_istream(%s) failed: %m", cydir_get_save_path(ctx, ctx->mail_count)); } @@ -187,7 +187,7 @@ uid = hdr->next_uid; mail_index_append_assign_uids(ctx->trans, uid, &next_uid); - dir = mailbox_list_get_path(STORAGE(ctx->mbox->storage)->list, + dir = mailbox_list_get_path(ctx->mbox->storage->storage.list, ctx->mbox->ibox.box.name, MAILBOX_LIST_PATH_TYPE_MAILBOX); @@ -207,7 +207,7 @@ str_printfa(dest_path, "%u.", uid); if (rename(str_c(src_path), str_c(dest_path)) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "rename(%s, %s) failed: %m", str_c(src_path), str_c(dest_path)); ctx->failed = TRUE; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/cydir/cydir-storage.c --- a/src/lib-storage/index/cydir/cydir-storage.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/cydir/cydir-storage.c Fri Mar 30 15:44:01 2007 +0300 @@ -88,7 +88,6 @@ enum file_lock_method lock_method) { struct cydir_storage *storage; - struct index_storage *istorage; struct mailbox_list_settings list_set; struct mailbox_list *list; const char *error; @@ -133,22 +132,18 @@ MODULE_CONTEXT_SET_FULL(list, cydir_mailbox_list_module, storage, &storage->list_module_ctx); - istorage = INDEX_STORAGE(storage); - istorage->storage = cydir_storage; - istorage->storage.pool = pool; + storage->storage = cydir_storage; + storage->storage.pool = pool; + storage->storage.user = p_strdup(pool, user); + index_storage_init(&storage->storage, list, flags, lock_method); - istorage->user = p_strdup(pool, user); - index_storage_init(istorage, list, flags, lock_method); - - return STORAGE(storage); + return &storage->storage; } -static void cydir_free(struct mail_storage *_storage) +static void cydir_free(struct mail_storage *storage) { - struct index_storage *storage = (struct index_storage *) _storage; - index_storage_deinit(storage); - pool_unref(storage->storage.pool); + pool_unref(storage->pool); } static bool cydir_autodetect(const char *data __attr_unused__, @@ -204,8 +199,7 @@ cydir_open(struct cydir_storage *storage, const char *name, enum mailbox_open_flags flags) { - struct index_storage *istorage = INDEX_STORAGE(storage); - struct mail_storage *_storage = STORAGE(storage); + struct mail_storage *_storage = &storage->storage; struct cydir_mailbox *mbox; struct mail_index *index; const char *path, *index_dir; @@ -227,7 +221,7 @@ mbox = p_new(pool, struct cydir_mailbox, 1); mbox->ibox.box = cydir_mailbox; mbox->ibox.box.pool = pool; - mbox->ibox.storage = istorage; + mbox->ibox.storage = &storage->storage; mbox->ibox.mail_vfuncs = &cydir_mail_vfuncs; mbox->ibox.is_recent = cydir_is_recent; mbox->ibox.index = index; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/cydir/cydir-storage.h --- a/src/lib-storage/index/cydir/cydir-storage.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/cydir/cydir-storage.h Fri Mar 30 15:44:01 2007 +0300 @@ -14,7 +14,7 @@ (&(mbox_storage)->storage) struct cydir_storage { - struct index_storage storage; + struct mail_storage storage; union mailbox_list_module_context list_module_ctx; }; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/cydir/cydir-sync.c --- a/src/lib-storage/index/cydir/cydir-sync.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/cydir/cydir-sync.c Fri Mar 30 15:44:01 2007 +0300 @@ -30,7 +30,7 @@ string_t *path = t_str_new(256); const char *dir; - dir = mailbox_list_get_path(STORAGE(mbox->storage)->list, + dir = mailbox_list_get_path(mbox->storage->storage.list, mbox->ibox.box.name, MAILBOX_LIST_PATH_TYPE_MAILBOX); str_append(path, dir); @@ -86,7 +86,7 @@ str_printfa(path, "%u.", uid); if (unlink(str_c(path)) < 0 && errno != ENOENT) { mail_storage_set_critical( - STORAGE(ctx->mbox->storage), + &ctx->mbox->storage->storage, "unlink(%s) failed: %m", str_c(path)); /* continue anyway */ } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-file.c --- a/src/lib-storage/index/dbox/dbox-file.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-file.c Fri Mar 30 15:44:01 2007 +0300 @@ -73,7 +73,7 @@ return 0; errno = file->input->stream_errno; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "read(%s) failed: %m", file->path); return -1; } @@ -93,7 +93,7 @@ if (memcmp(hdr->magic, DBOX_MAIL_HEADER_MAGIC, sizeof(hdr->magic)) != 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Corrupted mail header at %"PRIuUOFF_T " in dbox file %s", offset, file->path); return -1; @@ -126,7 +126,7 @@ if (mbox->file->fd == -1) { if (errno == ENOENT) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "open(%s) failed: %m", mbox->file->path); return -1; } @@ -233,7 +233,7 @@ file->mail_header_size < sizeof(struct dbox_mail_header) || file->keyword_count > file->mail_header_size - sizeof(struct dbox_mail_header)) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "dbox %s: broken file header", file->path); return -1; } @@ -256,12 +256,12 @@ if (size < sizeof(hdr)) { if (file->input->stream_errno != 0) { errno = file->input->stream_errno; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "read(%s) failed: %m", file->path); return -1; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "dbox %s: unexpected end of file", file->path); return -1; } @@ -292,7 +292,7 @@ /* write header + LF to mark end-of-keywords list */ if (o_stream_send(file->output, &hdr, sizeof(hdr)) < 0 || o_stream_send_str(file->output, "\n") < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "write(%s) failed: %m", file->path); return -1; } @@ -304,7 +304,7 @@ file->output->offset); if (o_stream_send(file->output, buf, size) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "write(%s) failed: %m", file->path); return -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-keywords.c --- a/src/lib-storage/index/dbox/dbox-keywords.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-keywords.c Fri Mar 30 15:44:01 2007 +0300 @@ -75,7 +75,7 @@ if (line == NULL || file->input->v_offset > file->header_size) { /* unexpected end of list, or list continues outside its allocated area */ - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Corrupted keyword list offset in dbox file %s", file->path); array_clear(&file->idx_file_keywords); @@ -200,7 +200,7 @@ if (pwrite_full(file->fd, str_data(keyword_str) + new_pos, str_len(keyword_str) - new_pos, file->keyword_list_offset + new_pos) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "pwrite_full(%s) failed: %m", file->path); } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-mail.c --- a/src/lib-storage/index/dbox/dbox-mail.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-mail.c Fri Mar 30 15:44:01 2007 +0300 @@ -23,7 +23,7 @@ uint32_t hdr_uid = hex2dec(hdr->uid_hex, sizeof(hdr->uid_hex)); if (hdr_uid != mail->mail.mail.uid) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "dbox %s: Cached file offset broken", mbox->file->path); @@ -68,7 +68,7 @@ return -1; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Cached message offset lost for uid %u in " "dbox %s", uid, mbox->path); @@ -135,7 +135,7 @@ prev_offset = *offset_r; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Cached message offset (%u, %"PRIuUOFF_T") " "broken for uid %u in dbox %s", file_seq, *offset_r, mail->mail.mail.uid, diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-save.c --- a/src/lib-storage/index/dbox/dbox-save.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-save.c Fri Mar 30 15:44:01 2007 +0300 @@ -258,10 +258,10 @@ if (o_stream_send_istream(ctx->file->output, ctx->input) < 0) { if (ENOSPACE(ctx->file->output->stream_errno)) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Not enough disk space"); } else { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "o_stream_send_istream(%s) failed: %m", ctx->file->path); } @@ -284,7 +284,7 @@ file to the size before writing. */ if (ftruncate(ctx->file->fd, ctx->failed ? ctx->hdr_offset : ctx->file->output->offset) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "ftruncate(%s) failed: %m", ctx->file->path); ctx->failed = TRUE; @@ -300,7 +300,7 @@ sizeof(hdr.mail_size_hex), ctx->hdr_offset + offsetof(struct dbox_mail_header, mail_size_hex)) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "pwrite_full(%s) failed: %m", ctx->file->path); ctx->failed = TRUE; @@ -360,7 +360,7 @@ sizeof(hdr.uid_hex), offset + offsetof(struct dbox_mail_header, uid_hex)) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "pwrite_full(%s) failed: %m", file->path); ctx->failed = TRUE; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-storage.c --- a/src/lib-storage/index/dbox/dbox-storage.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-storage.c Fri Mar 30 15:44:01 2007 +0300 @@ -168,7 +168,6 @@ enum file_lock_method lock_method) { struct dbox_storage *storage; - struct index_storage *istorage; struct mailbox_list_settings list_set; struct mailbox_list *list; const char *error; @@ -224,22 +223,18 @@ storage->new_file_dotlock_set.use_excl_lock = TRUE; } - istorage = INDEX_STORAGE(storage); - istorage->storage = dbox_storage; - istorage->storage.pool = pool; + storage->storage = dbox_storage; + storage->storage.pool = pool; + storage->storage.user = p_strdup(pool, user); + index_storage_init(&storage->storage, list, flags, lock_method); - istorage->user = p_strdup(pool, user); - index_storage_init(istorage, list, flags, lock_method); - - return STORAGE(storage); + return &storage->storage; } -static void dbox_free(struct mail_storage *_storage) +static void dbox_free(struct mail_storage *storage) { - struct index_storage *storage = (struct index_storage *) _storage; - index_storage_deinit(storage); - pool_unref(storage->storage.pool); + pool_unref(storage->pool); } static bool dbox_autodetect(const char *data, enum mail_storage_flags flags) @@ -317,8 +312,7 @@ dbox_open(struct dbox_storage *storage, const char *name, enum mailbox_open_flags flags) { - struct index_storage *istorage = INDEX_STORAGE(storage); - struct mail_storage *_storage = STORAGE(storage); + struct mail_storage *_storage = &storage->storage; struct dbox_mailbox *mbox; struct mail_index *index; const char *path, *index_dir, *value; @@ -340,7 +334,7 @@ mbox = p_new(pool, struct dbox_mailbox, 1); mbox->ibox.box = dbox_mailbox; mbox->ibox.box.pool = pool; - mbox->ibox.storage = istorage; + mbox->ibox.storage = &storage->storage; mbox->ibox.mail_vfuncs = &dbox_mail_vfuncs; mbox->ibox.is_recent = dbox_is_recent; mbox->ibox.index = index; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-storage.h --- a/src/lib-storage/index/dbox/dbox-storage.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-storage.h Fri Mar 30 15:44:01 2007 +0300 @@ -14,7 +14,7 @@ struct dbox_uidlist; struct dbox_storage { - struct index_storage storage; + struct mail_storage storage; union mailbox_list_module_context list_module_ctx; struct dotlock_settings uidlist_dotlock_set; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-sync-expunge.c --- a/src/lib-storage/index/dbox/dbox-sync-expunge.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync-expunge.c Fri Mar 30 15:44:01 2007 +0300 @@ -64,7 +64,7 @@ uoff_t orig_offset) { struct dbox_mailbox *mbox = ctx->mbox; - struct mail_storage *storage = STORAGE(mbox->storage); + struct mail_storage *storage = &mbox->storage->storage; struct dotlock *dotlock; struct istream *input; struct ostream *output; @@ -354,7 +354,7 @@ path = t_strdup_printf("%s/"DBOX_MAIL_FILE_FORMAT, mbox->path, entry->file_seq); if (unlink(path) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "unlink(%s) failed: %m", path); return -1; } @@ -376,13 +376,13 @@ if (pwrite_full(mbox->file->fd, "00000000EFFFFFFF", 16, offsetof(struct dbox_file_header, append_offset_hex)) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "pwrite_full(%s) failed: %m", mbox->path); return -1; } if (ftruncate(mbox->file->fd, offset) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "ftruncate(%s) failed: %m", mbox->file->path); return -1; } @@ -393,7 +393,7 @@ offsetof(struct dbox_file_header, have_expunged_mails)) < 0) { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "pwrite_full(%s) failed: %m", mbox->path); return -1; @@ -473,7 +473,7 @@ path, DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock); if (ret < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "file_dotlock_create(%s) failed: %m", path); return -1; } @@ -503,7 +503,7 @@ if (pwrite_full(mbox->file->fd, "1", 1, offsetof(struct dbox_file_header, have_expunged_mails)) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "pwrite(%s) failed: %m", mbox->file->path); return -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-sync-full.c --- a/src/lib-storage/index/dbox/dbox-sync-full.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync-full.c Fri Mar 30 15:44:01 2007 +0300 @@ -64,7 +64,7 @@ } if (seq == 0) { /* not found. it should have been there. */ - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "dbox %s sync: " "UID %u inserted in the middle of mailbox", mbox->path, mbox->file->seeked_uid); @@ -120,7 +120,7 @@ if (ret == 0) { /* broken file, but without any useful data in it */ if (unlink(mbox->file->path) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "unlink(%s) failed: %m", mbox->file->path); return -1; } @@ -154,7 +154,7 @@ if (ret == 0 && array_count(&entry.uid_list) == 0) { /* all mails expunged in the file */ if (unlink(mbox->file->path) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "unlink(%s) failed: %m", mbox->file->path); return -1; } @@ -202,7 +202,7 @@ write dbox's index file */ dirp = opendir(mbox->path); if (dirp == NULL) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "opendir(%s) failed: %m", mbox->path); return -1; } @@ -228,7 +228,7 @@ break; } if (closedir(dirp) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "closedir(%s) failed: %m", mbox->path); ret = -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-sync.c --- a/src/lib-storage/index/dbox/dbox-sync.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync.c Fri Mar 30 15:44:01 2007 +0300 @@ -23,14 +23,14 @@ file_seq_r, offset_r); if (ret <= 0) { if (ret == 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "Unexpectedly lost seq %u in " "dbox %s", seq, ctx->mbox->path); } return -1; } if (*file_seq_r == 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "Cached message offset lost for seq %u in " "dbox %s", seq, ctx->mbox->path); return -1; @@ -190,7 +190,7 @@ offset + first_flag_offset + start); if (ret < 0) { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "pwrite(%s) failed: %m", mbox->file->path); return -1; @@ -573,7 +573,7 @@ return ret; if (force) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "dbox_sync_full(%s) didn't work", mbox->path); diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/dbox/dbox-uidlist.c --- a/src/lib-storage/index/dbox/dbox-uidlist.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-uidlist.c Fri Mar 30 15:44:01 2007 +0300 @@ -193,7 +193,7 @@ for (i = 0; i < count; i++) { if (!uidlist_merge(&dest_entry->uid_list, &range[i])) { mail_storage_set_critical( - STORAGE(uidlist->mbox->storage), + &uidlist->mbox->storage->storage, "%s: UIDs not ordered (file_seq=%u)", uidlist->path, src_entry->file_seq); return FALSE; @@ -265,7 +265,7 @@ } if (error != NULL) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "%s: Corrupted entry: %s", uidlist->path, error); t_pop(); return FALSE; @@ -282,7 +282,7 @@ entry->create_time = entry->create_time * 10 + *line-'0'; if (*line != ' ') { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "%s: Corrupted entry: Expecting space after timestamp", uidlist->path); @@ -300,7 +300,7 @@ static int dbox_uidlist_read(struct dbox_uidlist *uidlist) { - struct mail_storage *storage = STORAGE(uidlist->mbox->storage); + struct mail_storage *storage = &uidlist->mbox->storage->storage; const char *line; unsigned int uid_validity, last_uid, last_file_seq; struct istream *input; @@ -438,12 +438,12 @@ uidlist->path, 0, &uidlist->dotlock); if (uidlist->lock_fd == -1) { if (errno == EAGAIN) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Timeout while waiting for lock"); - STORAGE(mbox->storage)->temporary_error = TRUE; + mbox->storage->storage.temporary_error = TRUE; return 0; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "file_dotlock_open(%s) failed: %m", uidlist->path); return -1; } @@ -603,7 +603,7 @@ t_pop(); if (output->stream_errno != 0) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "write(%s) failed: %m", uidlist->path); ret = -1; } @@ -617,14 +617,14 @@ if (stat(uidlist->path, &st) < 0) { if (errno != ENOENT) { mail_storage_set_critical( - STORAGE(uidlist->mbox->storage), + &uidlist->mbox->storage->storage, "stat(%s) failed: %m", uidlist->path); return -1; } st.st_mtime = 0; } if (fstat(uidlist->lock_fd, &st2) < 0) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "fstat(%s) failed: %m", lock_path); return -1; } @@ -638,7 +638,7 @@ if (utime(lock_path, &ut) < 0) { mail_storage_set_critical( - STORAGE(uidlist->mbox->storage), + &uidlist->mbox->storage->storage, "utime(%s) failed: %m", lock_path); return -1; } @@ -725,7 +725,7 @@ i_assert(ctx->uidlist->lock_fd != -1); if (fstat(ctx->uidlist->fd, &st) < 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "fstat(%s) failed: %m", ctx->uidlist->path); return -1; } @@ -736,7 +736,7 @@ } if (lseek(ctx->uidlist->fd, 0, SEEK_END) < 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "lseek(%s) failed: %m", ctx->uidlist->path); return -1; } @@ -759,7 +759,7 @@ t_pop(); if (output->stream_errno != 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "write(%s) failed: %m", ctx->uidlist->path); ret = -1; } @@ -770,7 +770,7 @@ /* grow mtime by one to make sure the last write is noticed */ if (fstat(ctx->uidlist->fd, &st) < 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "fstat(%s) failed: %m", ctx->uidlist->path); return -1; } @@ -778,7 +778,7 @@ ut.actime = ioloop_time; ut.modtime = st.st_mtime + 1; if (utime(ctx->uidlist->path, &ut) < 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "utime(%s) failed: %m", ctx->uidlist->path); return -1; } @@ -791,7 +791,7 @@ static int dbox_uidlist_write_append_offsets(struct dbox_uidlist_append_ctx *ctx) { - struct mail_storage *storage = STORAGE(ctx->uidlist->mbox->storage); + struct mail_storage *storage = &ctx->uidlist->mbox->storage->storage; struct dbox_save_file *const *files; struct dbox_file_header hdr; unsigned int i, count; @@ -894,20 +894,20 @@ since we have it locked */ file->fd = open(file->path, O_RDWR); if (file->fd == -1) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "open(%s) failed: %m", file->path); return -1; } if (fstat(file->fd, &st) < 0) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "fstat(%s) failed: %m", file->path); return -1; } if (st.st_ino != save_file->ino || !CMP_DEV_T(st.st_dev, save_file->dev)) { - mail_storage_set_critical(STORAGE(ctx->uidlist->mbox->storage), + mail_storage_set_critical(&ctx->uidlist->mbox->storage->storage, "Appended file changed unexpectedly: %s", file->path); return -1; } @@ -952,13 +952,13 @@ entry->file_size = (uoff_t)-1; return 0; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "open(%s) failed: %m", path); return -1; } if (fstat(fd, st) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fstat(%s) failed: %m", path); (void)close(fd); return -1; @@ -1006,7 +1006,7 @@ if (stat(path, &st) == 0) return 0; if (errno != ENOENT) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "stat(%s) failed: %m", path); return -1; } @@ -1088,7 +1088,7 @@ if (ret < 0) return -1; } else if (ret < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "file_dotlock_create(%s) failed: %m", str_c(path)); return -1; @@ -1391,7 +1391,7 @@ if (stat(uidlist->path, &st) < 0) { if (errno != ENOENT) { mail_storage_set_critical( - STORAGE(uidlist->mbox->storage), + &uidlist->mbox->storage->storage, "stat(%s) failed: %m", uidlist->path); return -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/index-storage.c Fri Mar 30 15:44:01 2007 +0300 @@ -40,27 +40,27 @@ static struct timeout *to_index = NULL; static int index_storage_refcount = 0; -void index_storage_init(struct index_storage *storage, +void index_storage_init(struct mail_storage *storage, struct mailbox_list *list, enum mail_storage_flags flags, enum file_lock_method lock_method) { - storage->storage.list = list; - storage->storage.flags = flags; - storage->storage.lock_method = lock_method; + storage->list = list; + storage->flags = flags; + storage->lock_method = lock_method; - storage->storage.callbacks = - p_new(storage->storage.pool, struct mail_storage_callbacks, 1); + storage->callbacks = + p_new(storage->pool, struct mail_storage_callbacks, 1); - array_create(&storage->storage.module_contexts, - storage->storage.pool, sizeof(void *), 5); + array_create(&storage->module_contexts, + storage->pool, sizeof(void *), 5); index_storage_refcount++; } -void index_storage_deinit(struct index_storage *storage) +void index_storage_deinit(struct mail_storage *storage) { - mailbox_list_deinit(storage->storage.list); - i_free(storage->storage.error); + mailbox_list_deinit(storage->list); + i_free(storage->error); if (--index_storage_refcount > 0) return; @@ -322,7 +322,7 @@ void index_storage_mailbox_open(struct index_mailbox *ibox) { - struct mail_storage *storage = &ibox->storage->storage; + struct mail_storage *storage = ibox->storage; enum mail_index_open_flags index_flags = 0; int ret; @@ -369,7 +369,7 @@ enum mailbox_open_flags flags, bool move_to_memory) { - struct mail_storage *storage = &ibox->storage->storage; + struct mail_storage *storage = ibox->storage; i_assert(name != NULL); @@ -437,14 +437,12 @@ return mail_index_view_is_inconsistent(ibox->view); } -void index_storage_set_callbacks(struct mail_storage *_storage, +void index_storage_set_callbacks(struct mail_storage *storage, struct mail_storage_callbacks *callbacks, void *context) { - struct index_storage *storage = (struct index_storage *) _storage; - - *storage->storage.callbacks = *callbacks; - storage->storage.callback_context = context; + *storage->callbacks = *callbacks; + storage->callback_context = context; } const char *index_storage_get_last_error(struct mail_storage *storage, diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/index-storage.h Fri Mar 30 15:44:01 2007 +0300 @@ -21,17 +21,11 @@ MAILBOX_LOCK_NOTIFY_MAILBOX_OVERRIDE }; -struct index_storage { - struct mail_storage storage; - - const char *user; /* name of user accessing the storage */ -}; - struct index_mailbox { struct mailbox box; union mail_index_module_context index_module_ctx; - struct index_storage *storage; + struct mail_storage *storage; enum mailbox_open_flags open_flags; struct mail_index *index; @@ -107,11 +101,11 @@ void index_storage_unref(struct mail_index *index); void index_storage_destroy_unrefed(void); -void index_storage_init(struct index_storage *storage, +void index_storage_init(struct mail_storage *storage, struct mailbox_list *list, enum mail_storage_flags flags, enum file_lock_method lock_method); -void index_storage_deinit(struct index_storage *storage); +void index_storage_deinit(struct mail_storage *storage); void index_storage_mailbox_init(struct index_mailbox *ibox, const char *name, enum mailbox_open_flags flags, diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-copy.c --- a/src/lib-storage/index/maildir/maildir-copy.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-copy.c Fri Mar 30 15:44:01 2007 +0300 @@ -40,7 +40,7 @@ if (stat(path, &st) < 0) { if (errno == ENOENT) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "stat(%s) failed: %m", path); return -1; } @@ -71,7 +71,7 @@ return 0; if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Not enough disk space"); return -1; } @@ -82,7 +82,7 @@ if (errno == EACCES || ECANTLINK(errno) || errno == EEXIST) return 1; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "link(%s, %s) failed: %m", path, str_c(ctx->dest_path)); return -1; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-keywords.c --- a/src/lib-storage/index/maildir/maildir-keywords.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-keywords.c Fri Mar 30 15:44:01 2007 +0300 @@ -61,7 +61,7 @@ strcase_hash, (hash_cmp_callback_t *)strcasecmp); mk->dotlock_settings.use_excl_lock = - (STORAGE(mbox->storage)->flags & + (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; mk->dotlock_settings.timeout = KEYWORDS_LOCK_STALE_TIMEOUT + 2; mk->dotlock_settings.stale_timeout = KEYWORDS_LOCK_STALE_TIMEOUT; @@ -103,7 +103,7 @@ mk->synced = TRUE; return 0; } - mail_storage_set_critical(STORAGE(mk->mbox->storage), + mail_storage_set_critical(&mk->mbox->storage->storage, "stat(%s) failed: %m", mk->path); return -1; } @@ -122,7 +122,7 @@ mk->synced = TRUE; return 0; } - mail_storage_set_critical(STORAGE(mk->mbox->storage), + mail_storage_set_critical(&mk->mbox->storage->storage, "open(%s) failed: %m", mk->path); return -1; } @@ -154,7 +154,7 @@ i_stream_destroy(&input); if (close(fd) < 0) { - mail_storage_set_critical(STORAGE(mk->mbox->storage), + mail_storage_set_critical(&mk->mbox->storage->storage, "close(%s) failed: %m", mk->path); return -1; } @@ -270,13 +270,13 @@ str_printfa(str, "%u %s\n", i, keywords[i]); } if (write_full(fd, str_data(str), str_len(str)) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "write_full(%s) failed: %m", path); return -1; } if (fstat(fd, &st) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fstat(%s) failed: %m", path); return -1; } @@ -284,7 +284,7 @@ if (st.st_gid != mbox->mail_create_gid && mbox->mail_create_gid != (gid_t)-1) { if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fchown(%s) failed: %m", path); } } @@ -298,14 +298,14 @@ ut.actime = ioloop_time; ut.modtime = mk->synced_mtime; if (utime(path, &ut) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "utime(%s) failed: %m", path); return -1; } } if (fsync(fd) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fsync(%s) failed: %m", path); return -1; } @@ -334,7 +334,7 @@ DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock); umask(old_mask); if (fd == -1) { - mail_storage_set_critical(STORAGE(mk->mbox->storage), + mail_storage_set_critical(&mk->mbox->storage->storage, "file_dotlock_open(%s) failed: %m", mk->path); return -1; } @@ -345,7 +345,7 @@ } if (file_dotlock_replace(&dotlock, 0) < 0) { - mail_storage_set_critical(STORAGE(mk->mbox->storage), + mail_storage_set_critical(&mk->mbox->storage->storage, "file_dotlock_replace(%s) failed: %m", mk->path); return -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Fri Mar 30 15:44:01 2007 +0300 @@ -19,7 +19,7 @@ if (errno == ENOENT) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "open(%s) failed: %m", path); return -1; } @@ -32,7 +32,7 @@ if (errno == ENOENT) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "stat(%s) failed: %m", path); return -1; } @@ -81,7 +81,7 @@ i_assert(fd != -1); if (fstat(fd, st) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fstat(maildir) failed: %m"); return -1; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-save.c --- a/src/lib-storage/index/maildir/maildir-save.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Fri Mar 30 15:44:01 2007 +0300 @@ -63,7 +63,7 @@ const char *tmpname, const char *destname, bool newdir) { - struct mail_storage *storage = STORAGE(ctx->mbox->storage); + struct mail_storage *storage = &ctx->mbox->storage->storage; const char *tmp_path, *new_path; int ret; @@ -361,7 +361,7 @@ ctx->input = input; output = o_stream_create_file(ctx->fd, system_pool, 0, FALSE); - ctx->output = (STORAGE(ctx->mbox->storage)->flags & + ctx->output = (ctx->mbox->storage->storage.flags & MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ? o_stream_create_crlf(default_pool, output) : o_stream_create_lf(default_pool, output); @@ -390,10 +390,10 @@ if (o_stream_send_istream(ctx->output, ctx->input) < 0) { if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Not enough disk space"); } else { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "o_stream_send_istream(%s/%s) failed: %m", ctx->tmpdir, ctx->file_last->basename); } @@ -435,7 +435,7 @@ if (utime(path, &buf) < 0) { ctx->failed = TRUE; - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "utime(%s) failed: %m", path); } } @@ -445,13 +445,13 @@ if (!ctx->mbox->ibox.fsync_disable) { if (fsync(ctx->fd) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "fsync(%s) failed: %m", path); ctx->failed = TRUE; } } if (close(ctx->fd) < 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "close(%s) failed: %m", path); ctx->failed = TRUE; } @@ -462,16 +462,16 @@ /* delete the tmp file */ if (unlink(path) < 0 && errno != ENOENT) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "unlink(%s) failed: %m", path); } errno = output_errno; if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Not enough disk space"); } else if (errno != 0) { - mail_storage_set_critical(STORAGE(ctx->mbox->storage), + mail_storage_set_critical(&ctx->mbox->storage->storage, "write(%s) failed: %m", ctx->mbox->path); } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 30 15:44:01 2007 +0300 @@ -216,7 +216,6 @@ enum file_lock_method lock_method) { struct maildir_storage *storage; - struct index_storage *istorage; struct mailbox_list_settings list_set; struct mailbox_list *list; enum mailbox_open_flags open_flags; @@ -279,24 +278,20 @@ p_strconcat(pool, "tmp/", storage->temp_prefix, NULL); } - istorage = INDEX_STORAGE(storage); - istorage->storage = maildir_storage; - istorage->storage.pool = pool; - - istorage->user = p_strdup(pool, user); - index_storage_init(istorage, list, flags, lock_method); + storage->storage = maildir_storage; + storage->storage.pool = pool; + storage->storage.user = p_strdup(pool, user); + index_storage_init(&storage->storage, list, flags, lock_method); open_flags = 0; - (void)verify_inbox(STORAGE(storage), &open_flags); - return STORAGE(storage); + (void)verify_inbox(&storage->storage, &open_flags); + return &storage->storage; } -static void maildir_free(struct mail_storage *_storage) +static void maildir_free(struct mail_storage *storage) { - struct index_storage *storage = (struct index_storage *) _storage; - index_storage_deinit(storage); - pool_unref(storage->storage.pool); + pool_unref(storage->pool); } static bool maildir_autodetect(const char *data, enum mail_storage_flags flags) @@ -469,7 +464,6 @@ maildir_open(struct maildir_storage *storage, const char *name, enum mailbox_open_flags flags) { - struct index_storage *istorage = INDEX_STORAGE(storage); struct maildir_mailbox *mbox; struct mail_index *index; const char *path, *index_dir, *control_dir; @@ -477,11 +471,11 @@ int shared; pool_t pool; - path = mailbox_list_get_path(istorage->storage.list, name, + path = mailbox_list_get_path(storage->storage.list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX); - index_dir = mailbox_list_get_path(istorage->storage.list, name, + index_dir = mailbox_list_get_path(storage->storage.list, name, MAILBOX_LIST_PATH_TYPE_INDEX); - control_dir = mailbox_list_get_path(istorage->storage.list, name, + control_dir = mailbox_list_get_path(storage->storage.list, name, MAILBOX_LIST_PATH_TYPE_CONTROL); if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) != 0) @@ -500,7 +494,7 @@ mbox = p_new(pool, struct maildir_mailbox, 1); mbox->ibox.box = maildir_mailbox; mbox->ibox.box.pool = pool; - mbox->ibox.storage = istorage; + mbox->ibox.storage = &storage->storage; mbox->ibox.mail_vfuncs = &maildir_mail_vfuncs; mbox->ibox.is_recent = maildir_is_recent; mbox->ibox.index = index; @@ -980,7 +974,7 @@ enum mailbox_info_flags *flags_r) { struct maildir_storage *storage = MAILDIR_LIST_CONTEXT(ctx->list); - struct mail_storage *_storage = &storage->storage.storage; + struct mail_storage *_storage = &storage->storage; int ret; if (fname[1] == mailbox_list_get_hierarchy_sep(_storage->list) && diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-storage.h --- a/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 30 15:44:01 2007 +0300 @@ -46,8 +46,6 @@ #include "mailbox-list-private.h" #define STORAGE(maildir_storage) \ - (&(maildir_storage)->storage.storage) -#define INDEX_STORAGE(maildir_storage) \ (&(maildir_storage)->storage) struct timeval; @@ -55,7 +53,7 @@ struct maildir_copy_context; struct maildir_storage { - struct index_storage storage; + struct mail_storage storage; union mailbox_list_module_context list_module_ctx; const char *temp_prefix; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Fri Mar 30 15:44:01 2007 +0300 @@ -406,7 +406,7 @@ if (errno == ENOENT) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "unlink(%s) failed: %m", path); return -1; } @@ -474,7 +474,7 @@ return 1; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "rename(%s, %s) failed: %m", path, newpath); return -1; } @@ -736,7 +736,7 @@ old_fname); } else { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "unlink(%s) failed: %m", old_path); } } @@ -750,7 +750,7 @@ if (rename(old_path, new_path) == 0) i_warning("Fixed a duplicate: %s -> %s", old_fname, new_fname); else if (errno != ENOENT) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "rename(%s, %s) failed: %m", old_path, new_path); ret = -1; } @@ -761,7 +761,7 @@ static int maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir) { - struct mail_storage *storage = STORAGE(ctx->mbox->storage); + struct mail_storage *storage = &ctx->mbox->storage->storage; const char *dir; DIR *dirp; string_t *src, *dest; @@ -906,14 +906,14 @@ *new_changed_r = *cur_changed_r = FALSE; if (stat(new_dir, &st) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "stat(%s) failed: %m", new_dir); return -1; } new_mtime = st.st_mtime; if (stat(cur_dir, &st) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "stat(%s) failed: %m", cur_dir); return -1; } @@ -1072,7 +1072,7 @@ uid_validity != 0 && hdr->uid_validity != 0) { /* uidvalidity changed and mailbox isn't being initialized, reset mailbox so we can add all messages as new */ - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Maildir %s sync: UIDVALIDITY changed (%u -> %u)", mbox->path, hdr->uid_validity, uid_validity); @@ -1127,7 +1127,7 @@ if ((uflags & MAILDIR_UIDLIST_REC_FLAG_RACING) != 0) { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "Maildir %s sync: " "UID < next_uid " "(%u < %u, file = %s)", @@ -1189,7 +1189,7 @@ } if ((uflags & MAILDIR_UIDLIST_REC_FLAG_RACING) != 0) { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "Maildir %s sync: " "UID inserted in the middle of mailbox " "(%u > %u, file = %s)", diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Fri Mar 30 15:44:01 2007 +0300 @@ -102,12 +102,12 @@ umask(old_mask); if (fd == -1) { if (errno == EAGAIN) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Timeout while waiting for lock"); - STORAGE(mbox->storage)->temporary_error = TRUE; + mbox->storage->storage.temporary_error = TRUE; return 0; } - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "file_dotlock_open(%s) failed: %m", path); return -1; } @@ -115,7 +115,7 @@ if (mbox->mail_create_gid != (gid_t)-1) { if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fchown(%s) failed: %m", path); } } @@ -166,7 +166,7 @@ db_path = t_strconcat(uidlist->mbox->control_dir, "/" MAILDIR_UIDLIST_NAME, NULL); mail_storage_set_critical( - STORAGE(uidlist->mbox->storage), + &uidlist->mbox->storage->storage, "file_dotlock_replace(%s) failed: %m", db_path); } uidlist->delayed_rewrite = FALSE; @@ -189,7 +189,7 @@ uidlist->next_uid = 1; uidlist->dotlock_settings.use_excl_lock = - (STORAGE(mbox->storage)->flags & + (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; uidlist->dotlock_settings.timeout = UIDLIST_LOCK_STALE_TIMEOUT + 2; uidlist->dotlock_settings.stale_timeout = UIDLIST_LOCK_STALE_TIMEOUT; @@ -233,12 +233,12 @@ if (uid == 0 || *line != ' ') { /* invalid file */ - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "Invalid data in file %s", uidlist->fname); return 0; } if (uid <= uidlist->prev_read_uid) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "UIDs not ordered in file %s (%u > %u)", uidlist->fname, uid, uidlist->prev_read_uid); return 0; @@ -252,7 +252,7 @@ uidlist->last_seen_uid = uid; if (uid >= uidlist->next_uid) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "UID larger than next_uid in file %s (%u >= %u)", uidlist->fname, uid, uidlist->next_uid); return 0; @@ -267,7 +267,7 @@ } if (hash_lookup_full(uidlist->files, line, NULL, NULL)) { - mail_storage_set_critical(STORAGE(uidlist->mbox->storage), + mail_storage_set_critical(&uidlist->mbox->storage->storage, "Duplicate file in uidlist file %s: %s", uidlist->fname, line); return 0; @@ -286,7 +286,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, bool *retry_r, bool try_retry) { - struct mail_storage *storage = STORAGE(uidlist->mbox->storage); + struct mail_storage *storage = &uidlist->mbox->storage->storage; const char *line; unsigned int uid_validity, next_uid; struct istream *input; @@ -387,7 +387,7 @@ int maildir_uidlist_update(struct maildir_uidlist *uidlist) { - struct mail_storage *storage = STORAGE(uidlist->mbox->storage); + struct mail_storage *storage = &uidlist->mbox->storage->storage; struct stat st; unsigned int i; bool retry; @@ -555,7 +555,7 @@ static int maildir_uidlist_rewrite_fd(struct maildir_uidlist *uidlist, const char *temp_path) { - struct mail_storage *storage = STORAGE(uidlist->mbox->storage); + struct mail_storage *storage = &uidlist->mbox->storage->storage; struct maildir_uidlist_iter_ctx *iter; struct utimbuf ut; string_t *str; @@ -661,7 +661,7 @@ "/" MAILDIR_UIDLIST_NAME, NULL); if (file_dotlock_replace(&uidlist->dotlock, 0) <= 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "file_dotlock_replace(%s) failed: %m", db_path); (void)unlink(temp_path); ret = -1; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/maildir/maildir-util.c --- a/src/lib-storage/index/maildir/maildir-util.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-util.c Fri Mar 30 15:44:01 2007 +0300 @@ -62,7 +62,7 @@ if (i == 10) { ret = -1; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "maildir_file_do(%s) racing", mbox->path); } @@ -126,15 +126,15 @@ *fname_r = t_strdup(path); if (fd == -1) { if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Not enough disk space"); } else { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "open(%s) failed: %m", path); } } else if (mbox->mail_create_gid != (gid_t)-1) { if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "fchown(%s) failed: %m", path); } } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-file.c --- a/src/lib-storage/index/mbox/mbox-file.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-file.c Fri Mar 30 15:44:01 2007 +0300 @@ -160,7 +160,7 @@ } if (data == NULL) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Cached message offset lost for seq %u in mbox file %s", seq, mbox->path); mbox->mbox_sync_dirty = TRUE; @@ -170,7 +170,7 @@ offset = *((const uint64_t *)data); if (istream_raw_mbox_seek(mbox->mbox_stream, offset) < 0) { if (offset == 0) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Mailbox isn't a valid mbox file"); return -1; } @@ -178,7 +178,7 @@ if (mbox->mbox_sync_dirty) return 0; - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Cached message offset %s is invalid for mbox file %s", dec2str(offset), mbox->path); mbox->mbox_sync_dirty = TRUE; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.c Fri Mar 30 15:44:01 2007 +0300 @@ -249,7 +249,7 @@ ctx->dotlock_last_stale = -1; memset(&set, 0, sizeof(set)); - set.use_excl_lock = (STORAGE(mbox->storage)->flags & + set.use_excl_lock = (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; set.timeout = lock_timeout; set.stale_timeout = dotlock_change_timeout; @@ -262,9 +262,9 @@ return -1; } if (ret == 0) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Timeout while waiting for lock"); - STORAGE(mbox->storage)->temporary_error = TRUE; + mbox->storage->storage.temporary_error = TRUE; return 0; } mbox->mbox_dotlocked = TRUE; @@ -494,9 +494,9 @@ if (!drop_locks) (void)mbox_unlock_files(&ctx); if (ret == 0) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Timeout while waiting for lock"); - STORAGE(mbox->storage)->temporary_error = TRUE; + mbox->storage->storage.temporary_error = TRUE; } return ret; } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Fri Mar 30 15:44:01 2007 +0300 @@ -86,7 +86,7 @@ sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC; } if (ret == 0) { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "Losing sync for mail uid=%u in mbox file %s", mail->mail.mail.uid, mbox->path); } diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-save.c --- a/src/lib-storage/index/mbox/mbox-save.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Fri Mar 30 15:44:01 2007 +0300 @@ -59,7 +59,7 @@ static int write_error(struct mbox_save_context *ctx) { if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Not enough disk space"); } else { mbox_set_syscall_error(ctx->mbox, "write()"); @@ -134,7 +134,7 @@ t_push(); if (from_envelope == NULL) { from_envelope = - t_strconcat(INDEX_STORAGE(ctx->mbox->storage)->user, + t_strconcat(ctx->mbox->storage->storage.user, "@", my_hostdomain, NULL); } @@ -267,7 +267,7 @@ int ret; if (ctx->mbox->mbox_readonly) { - mail_storage_set_error(STORAGE(ctx->mbox->storage), + mail_storage_set_error(&ctx->mbox->storage->storage, "Read-only mbox"); return -1; } @@ -280,7 +280,7 @@ a locking issue that should be possible to fix.. */ mail_storage_set_error( - STORAGE(ctx->mbox->storage), + &ctx->mbox->storage->storage, "Can't copy mails inside same mailbox"); return -1; } @@ -415,7 +415,7 @@ str_printfa(ctx->headers, "X-IMAPbase: %u %010u\n", ctx->uid_validity, ctx->next_uid); } - if ((STORAGE(mbox->storage)->flags & + if ((mbox->storage->storage.flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0) { /* we're using MD5 sums to generate POP3 UIDLs. clients don't like it much if there are duplicates, @@ -473,7 +473,7 @@ mbox_save_drop_headers_count, save_header_callback, ctx); ctx->body_output = - (STORAGE(mbox->storage)->flags & + (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ? o_stream_create_crlf(default_pool, ctx->output) : o_stream_create_lf(default_pool, ctx->output); diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Fri Mar 30 15:44:01 2007 +0300 @@ -83,10 +83,10 @@ i_assert(function != NULL); if (ENOSPACE(errno)) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Not enough disk space"); } else { - mail_storage_set_critical(STORAGE(mbox->storage), + mail_storage_set_critical(&mbox->storage->storage, "%s failed with mbox file %s: %m", function, mbox->path); } @@ -405,7 +405,6 @@ enum file_lock_method lock_method) { struct mbox_storage *storage; - struct index_storage *istorage; struct mailbox_list_settings list_set; struct mailbox_list *list; const char *layout, *error; @@ -437,21 +436,17 @@ MODULE_CONTEXT_SET_FULL(list, mbox_mailbox_list_module, storage, &storage->list_module_ctx); - istorage = INDEX_STORAGE(storage); - istorage->storage = mbox_storage; - istorage->storage.pool = pool; - - istorage->user = p_strdup(pool, user); - index_storage_init(istorage, list, flags, lock_method); - return &storage->storage.storage; + storage->storage = mbox_storage; + storage->storage.pool = pool; + storage->storage.user = p_strdup(pool, user); + index_storage_init(&storage->storage, list, flags, lock_method); + return &storage->storage; } -static void mbox_free(struct mail_storage *_storage) +static void mbox_free(struct mail_storage *storage) { - struct index_storage *storage = (struct index_storage *)_storage; - index_storage_deinit(storage); - pool_unref(storage->storage.pool); + pool_unref(storage->pool); } static int create_mbox_index_dirs(struct mail_storage *storage, @@ -519,7 +514,7 @@ if (errno == ENOENT) st.st_size = 0; else { - mail_storage_set_critical(STORAGE(storage), + mail_storage_set_critical(&storage->storage, "stat(%s) failed: %m", path); return FALSE; } @@ -543,7 +538,7 @@ mbox = p_new(pool, struct mbox_mailbox, 1); mbox->ibox.box = mbox_mailbox; mbox->ibox.box.pool = pool; - mbox->ibox.storage = INDEX_STORAGE(storage); + mbox->ibox.storage = &storage->storage; mbox->ibox.mail_vfuncs = &mbox_mail_vfuncs; mbox->ibox.is_recent = mbox_mail_is_recent; mbox->ibox.index = index; @@ -560,7 +555,7 @@ mbox->mbox_do_dirty_syncs = mbox->mbox_very_dirty_syncs || getenv("MBOX_DIRTY_SYNCS") != NULL; - if ((STORAGE(storage)->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0) + if ((storage->storage.flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0) mbox->mbox_save_md5 = TRUE; if ((flags & MAILBOX_OPEN_KEEP_LOCKED) != 0) { @@ -587,7 +582,7 @@ mbox_open(struct mbox_storage *storage, const char *name, enum mailbox_open_flags flags) { - struct mail_storage *_storage = STORAGE(storage); + struct mail_storage *_storage = &storage->storage; struct mbox_mailbox *mbox; struct mail_index *index; const char *path, *index_dir; @@ -625,7 +620,7 @@ mbox_mailbox_open_stream(struct mbox_storage *storage, const char *name, struct istream *input, enum mailbox_open_flags flags) { - struct mail_storage *_storage = STORAGE(storage); + struct mail_storage *_storage = &storage->storage; struct mail_index *index; struct mbox_mailbox *mbox; const char *path, *index_dir; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-storage.h --- a/src/lib-storage/index/mbox/mbox-storage.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.h Fri Mar 30 15:44:01 2007 +0300 @@ -20,7 +20,7 @@ (&(mbox_storage)->storage) struct mbox_storage { - struct index_storage storage; + struct mail_storage storage; union mailbox_list_module_context list_module_ctx; }; diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-sync-rewrite.c --- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c Fri Mar 30 15:44:01 2007 +0300 @@ -44,7 +44,7 @@ if (ret == (off_t)size) ret = 0; else if (ret >= 0) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "mbox_move(%"PRIuUOFF_T", %"PRIuUOFF_T", %"PRIuUOFF_T ") moved only %"PRIuUOFF_T" bytes in mbox file %s", dest, source, size, (uoff_t)ret, sync_ctx->mbox->path); diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Fri Mar 30 15:44:01 2007 +0300 @@ -65,7 +65,7 @@ int mbox_sync_seek(struct mbox_sync_context *sync_ctx, uoff_t from_offset) { if (istream_raw_mbox_seek(sync_ctx->input, from_offset) < 0) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "Unexpectedly lost From-line at offset %"PRIuUOFF_T " from mbox file %s", from_offset, sync_ctx->mbox->path); @@ -92,7 +92,7 @@ || st.st_mtim.tv_nsec != sync_ctx->last_stat.st_mtim.tv_nsec #endif ))) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + 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->path); return TRUE; @@ -337,7 +337,7 @@ if (rec == NULL && uid < sync_ctx->idx_next_uid) { /* this UID was already in index and it was expunged */ - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "mbox sync: Expunged message reappeared in mailbox %s " "(UID %u < %u, seq=%u, idx_msgs=%u)", sync_ctx->mbox->path, uid, sync_ctx->idx_next_uid, @@ -345,7 +345,7 @@ ret = 0; rec = NULL; } else if (rec != NULL && rec->uid != uid) { /* new UID in the middle of the mailbox - shouldn't happen */ - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "mbox sync: UID inserted in the middle of mailbox %s " "(%u > %u, seq=%u, idx_msgs=%u)", sync_ctx->mbox->path, rec->uid, uid, sync_ctx->seq, messages_count); @@ -633,7 +633,7 @@ return -1; } if (ret == 0) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "X-IMAPbase uid-last unexpectedly points outside " "mbox file %s", sync_ctx->mbox->path); return -1; @@ -648,7 +648,7 @@ } if (uid_last != sync_ctx->base_uid_last) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "X-IMAPbase uid-last unexpectedly lost in mbox file %s", sync_ctx->mbox->path); return -1; @@ -921,7 +921,7 @@ if (seq == 0) { if (istream_raw_mbox_seek(mbox->mbox_stream, 0) < 0) { - mail_storage_set_error(STORAGE(mbox->storage), + mail_storage_set_error(&mbox->storage->storage, "Mailbox isn't a valid mbox file"); return -1; } @@ -937,7 +937,7 @@ if (istream_raw_mbox_seek(mbox->mbox_stream, old_offset) < 0) { mail_storage_set_critical( - STORAGE(mbox->storage), + &mbox->storage->storage, "Error seeking back to original " "offset %s in mbox file %s", dec2str(old_offset), mbox->path); @@ -995,7 +995,7 @@ if (istream_raw_mbox_seek(sync_ctx->mbox->mbox_stream, st->st_size) < 0) { mail_storage_set_critical( - STORAGE(sync_ctx->mbox->storage), + &sync_ctx->mbox->storage->storage, "Error seeking to end of mbox file %s", sync_ctx->mbox->path); return -1; @@ -1090,7 +1090,7 @@ sync_ctx->base_uid_validity != sync_ctx->hdr->uid_validity) { mail_storage_set_critical( - STORAGE(sync_ctx->mbox->storage), + &sync_ctx->mbox->storage->storage, "UIDVALIDITY changed (%u -> %u) " "in mbox file %s", sync_ctx->hdr->uid_validity, @@ -1108,7 +1108,7 @@ return 0; mail_storage_set_critical( - STORAGE(sync_ctx->mbox->storage), + &sync_ctx->mbox->storage->storage, "UIDs broken with partial sync in mbox file %s", sync_ctx->mbox->path); @@ -1181,7 +1181,7 @@ happen normally, so just try to get it fixed without crashing. */ mail_storage_set_critical( - STORAGE(sync_ctx->mbox->storage), + &sync_ctx->mbox->storage->storage, "Out of UIDs, renumbering them in mbox " "file %s", sync_ctx->mbox->path); sync_ctx->renumber_uids = TRUE; @@ -1330,7 +1330,7 @@ } file_size = st->st_size; if (file_size < sync_ctx->file_input->v_offset) { - mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + mail_storage_set_critical(&sync_ctx->mbox->storage->storage, "file size unexpectedly shrinked in mbox file %s " "(%"PRIuUOFF_T" vs %"PRIuUOFF_T")", sync_ctx->mbox->path, file_size, diff -r daca7ed634c0 -r 78eaf595359c src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Fri Mar 30 15:08:59 2007 +0300 +++ b/src/lib-storage/mail-storage-private.h Fri Mar 30 15:44:01 2007 +0300 @@ -64,6 +64,8 @@ char *error; struct mailbox_list *list; + + const char *user; /* name of user accessing the storage */ enum mail_storage_flags flags; enum file_lock_method lock_method;