sdbox-storage.c revision 08e9fd42eb8007e1f9db62c088eef74f906114a5
/* Copyright (c) 2007-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "fs-api.h"
#include "master-service.h"
#include "mail-index-modseq.h"
#include "mail-search-build.h"
#include "mailbox-list-private.h"
#include "index-pop3-uidl.h"
#include "dbox-mail.h"
#include "dbox-save.h"
#include "sdbox-file.h"
#include "sdbox-sync.h"
#include "sdbox-storage.h"
extern struct mailbox sdbox_mailbox;
extern struct dbox_storage_vfuncs sdbox_dbox_storage_vfuncs;
static struct mail_storage *sdbox_storage_alloc(void)
{
struct sdbox_storage *storage;
}
struct mail_namespace *ns,
const char **error_r)
{
enum fs_properties props;
return -1;
if ((props & FS_PROPERTY_RENAME) == 0) {
*error_r = "mail_attachment_fs: "
"Backend doesn't support renaming";
return -1;
}
}
return 0;
}
static const char *
{
if (debug)
return path;
}
if (debug)
}
return NULL;
}
struct mailbox_list_settings *set)
{
else {
if (debug)
i_debug("sdbox: couldn't find root dir");
return FALSE;
}
}
/* NOTE: this check works for mdbox as well. we'll rely on the
autodetect ordering to catch mdbox before we get here. */
if (debug)
return FALSE;
}
if (debug)
return FALSE;
}
return TRUE;
}
static struct mailbox *
{
struct sdbox_mailbox *mbox;
struct index_mailbox_context *ibox;
/* dbox can't work without index files */
}
bool *need_resize_r)
{
struct mail_index_view *view;
const void *data;
int ret = 0;
if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
if (log_error) {
"sdbox %s: Invalid dbox header size",
}
ret = -1;
} else {
ret = -1;
else {
/* data is valid. remember it in case mailbox
is being reset */
}
}
return ret;
}
struct mail_index_transaction *trans,
const struct mailbox_update *update)
{
bool need_resize;
need_resize = TRUE;
}
sizeof(new_hdr.mailbox_guid));
}
if (need_resize) {
sizeof(new_hdr));
}
}
sizeof(mbox->mailbox_guid));
}
const struct mailbox_update *update,
struct mail_index_transaction *trans)
{
const struct mail_index_header *hdr;
}
else if (hdr->uid_validity != 0)
else {
/* set uidvalidity */
}
}
}
}
}
/* initialize pop3-uidl header when creating mailbox
(not on mailbox_update()) */
}
if (mail_index_transaction_commit(&new_trans) < 0) {
return -1;
}
}
return 0;
}
static const char *
{
return t_strdup_printf("-%s-%u",
}
{
struct sdbox_index_header hdr;
bool need_resize;
hdr.rebuild_count == 0)
else
}
{
}
{
struct sdbox_index_header hdr;
return -1;
mbox->hdr_ext_id =
sizeof(struct sdbox_index_header), 0, 0);
/* set the initialization data in case the mailbox is created */
return 0;
}
{
struct sdbox_index_header hdr;
bool need_resize;
if (sdbox_mailbox_alloc_index(mbox) < 0)
return -1;
if (dbox_mailbox_open(box) < 0)
return -1;
/* wait for mailbox creation to initialize the index */
return 0;
}
/* looks like the mailbox is corrupted */
}
/* regenerate it */
return -1;
}
sizeof(mbox->mailbox_guid));
return 0;
}
{
if (mbox->corrupted_rebuild_count != 0)
(void)sdbox_sync(mbox, 0);
}
static int
enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r)
{
return -1;
if ((items & MAILBOX_METADATA_GUID) != 0) {
sizeof(metadata_r->guid));
}
return 0;
}
static int
{
if (mailbox_open(box) < 0)
return -1;
}
return -1;
}
struct mail_storage sdbox_storage = {
.v = {
NULL,
NULL,
}
};
struct mail_storage dbox_storage = {
.v = {
NULL,
NULL,
}
};
struct mailbox sdbox_mailbox = {
.v = {
NULL,
NULL,
}
};
struct dbox_storage_vfuncs sdbox_dbox_storage_vfuncs = {
};