raw-storage.c revision 61b0637759146621cbb7edcbd0b03a71cfd66dfe
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainenstatic struct mail_storage *raw_storage_alloc(void)
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen pool = pool_alloconly_create("raw storage", 512+256);
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainenraw_storage_get_list_settings(const struct mail_namespace *ns ATTR_UNUSED,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen set->subscription_fname = RAW_SUBSCRIPTION_FILE_NAME;
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainenstatic struct mailbox *
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainenraw_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen flags |= MAILBOX_FLAG_READONLY | MAILBOX_FLAG_NO_INDEX_FILES;
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen pool = pool_alloconly_create("raw mailbox", 1024+512);
d22301419109ed4a38351715e6760011421dadecTimo Sirainen index_storage_mailbox_alloc(&mbox->box, name, input, flags, NULL);
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen mbox->storage = (struct raw_storage *)storage;
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainenstatic int raw_mailbox_open(struct mailbox *box)
d22301419109ed4a38351715e6760011421dadecTimo Sirainen return index_storage_mailbox_open(box, FALSE);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen } else if (!mail_storage_set_error_from_errno(box->storage)) {
573f0491a5733fe21fa062a455acb4790b4e0499Timo Sirainen box->input = i_stream_create_fd(fd, MAIL_READ_FULL_BLOCK_SIZE, TRUE);
573f0491a5733fe21fa062a455acb4790b4e0499Timo Sirainen i_stream_set_init_buffer_size(box->input, MAIL_READ_FULL_BLOCK_SIZE);
d22301419109ed4a38351715e6760011421dadecTimo Sirainen return index_storage_mailbox_open(box, FALSE);
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen const struct mailbox_update *update ATTR_UNUSED,
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen "Raw mailbox creation isn't supported");
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen const struct mailbox_update *update ATTR_UNUSED)
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen "Raw mailbox update isn't supported");
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainenstatic void raw_notify_changes(struct mailbox *box ATTR_UNUSED)
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainenstatic int raw_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen /* try to avoid stat() with these checks */
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen *flags_r = MAILBOX_NOSELECT | MAILBOX_CHILDREN;
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen (ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) != 0) {
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen /* need to stat() then */
4146f38412c650f4d0e100cf22d7b32e7d24b2b6Timo Sirainen *flags_r = MAILBOX_NOSELECT | MAILBOX_CHILDREN;
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen } else if (errno == EACCES || errno == ELOOP) {
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen mailbox_list_set_critical(ctx->list, "stat(%s) failed: %m",
563273bdac80393af63b9520cbf4d24cc0efd028Timo Sirainenstatic void raw_storage_add_list(struct mail_storage *storage ATTR_UNUSED,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen list->v.iter_is_mailbox = raw_list_iter_is_mailbox;