cydir-storage.c revision 17ad2164c747cedbf81dae1893063e71a3df0356
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen MODULE_CONTEXT(obj, cydir_mailbox_list_module)
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainenstatic MODULE_CONTEXT_DEFINE_INIT(cydir_mailbox_list_module,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainenstatic struct mail_storage *cydir_storage_alloc(void)
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen pool = pool_alloconly_create("cydir storage", 512+256);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen storage = p_new(pool, struct cydir_storage, 1);
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainencydir_storage_get_list_settings(const struct mail_namespace *ns ATTR_UNUSED,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen set->subscription_fname = CYDIR_SUBSCRIPTION_FILE_NAME;
d97f081a3de44852197ced772e21560c108895a6Timo Sirainenstatic int create_cydir(struct mail_storage *storage, struct mailbox_list *list,
d97f081a3de44852197ced772e21560c108895a6Timo Sirainen mailbox_list_get_dir_permissions(list, NULL, &mode, &gid);
d97f081a3de44852197ced772e21560c108895a6Timo Sirainen if (mkdir_parents_chown(path, mode, (uid_t)-1, gid) < 0 &&
d97f081a3de44852197ced772e21560c108895a6Timo Sirainen if (!mail_storage_set_error_from_errno(storage)) {
d97f081a3de44852197ced772e21560c108895a6Timo Sirainenstatic struct mailbox *
d97f081a3de44852197ced772e21560c108895a6Timo Sirainencydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* cydir can't work without index files */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen pool = pool_alloconly_create("cydir mailbox", 1024+512);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi mail_index_set_fsync_types(mbox->ibox.index,
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen mbox->storage = (struct cydir_storage *)storage;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenstatic int cydir_mailbox_open(struct mailbox *box)
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen "cydir doesn't support streamed mailboxes");
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* exists, open it */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen } else if (errno == ENOENT && strcmp(box->name, "INBOX") == 0) {
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* INBOX always exists, create it */
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen if (create_cydir(box->storage, box->list, box->path) < 0)
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen mail_storage_set_critical(box->storage, "stat(%s) failed: %m",
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainencydir_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen struct cydir_mailbox *mbox = (struct cydir_mailbox *)box;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen trans = mail_index_transaction_begin(mbox->ibox.view, 0);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen offsetof(struct mail_index_header, uid_validity),
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen &update->uid_validity, sizeof(update->uid_validity),
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* FIXME: update next_uid, highestmodseq. guid is also missing.. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen if (mail_index_transaction_commit(&trans) < 0) {
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen mail_storage_set_internal_error(box->storage);
bool directory)
const char *path;
const char *name)
struct dirent *d;
unsigned int dir_len;
errno = 0;
path);
if (!unlinked_something) {
const char *src;
const char *mail_path;
ret = 0;
return ret;
static void cydir_class_init(void)
static void cydir_class_deinit(void)
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,