dbox-storage.c revision dd645357a6b851a3a9527d16e2bced731e46dcaa
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "path-util.h"
#include "ioloop.h"
#include "fs-api.h"
#include "mkdir-parents.h"
#include "unlink-old-files.h"
#include "mailbox-uidvalidity.h"
#include "mailbox-list-private.h"
#include "index-storage.h"
#include "dbox-storage.h"
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
struct mailbox_list_settings *set)
{
}
static bool
const char *alt_path2, const char *alt_symlink_path)
{
return FALSE;
}
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
/* FIXME: for backwards compatibility. old versions
created the symlink to mailboxes/ directory, which
was fine with sdbox, but didn't even exist with
mdbox. we'll silently replace the symlink. */
return TRUE;
}
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
}
return FALSE;
}
{
&alt_path);
&alt_path2);
return;
i_error("symlink(%s, %s) failed: %m",
}
}
}
struct mail_namespace *ns,
const char **error_r)
{
const char *error;
args = "";
} else {
}
/* FIXME: the deduplication part doesn't work, because
sdbox renames the files.. */
*error_r = "mail_attachment_fs: "
"sis-queue not currently supported by sdbox";
return -1;
}
error);
return -1;
}
}
return 0;
}
{
}
{
const char *path;
}
{
else {
&dir) <= 0)
return;
}
}
static bool
{
return FALSE;
/* check once in a while if there are temp files to clean up */
if (interval == 0) {
/* disabled */
/* there haven't been any changes to this directory since we
last checked it. */
/* time to scan */
const char *prefix =
}
return TRUE;
}
{
;
return -1;
return -1;
} else {
"stat(%s) failed: %m", box_path);
return -1;
}
return -1;
return 0;
}
{
struct dirent *d;
int ret = 1;
return 1;
}
path);
return -1;
}
if (*d->d_name == '.')
continue;
ret = 0;
break;
}
path);
ret = -1;
}
return ret;
}
{
const char *alt_path;
int ret;
return ret;
if (mailbox_open(box) < 0)
return -1;
"Mailbox already exists");
return -1;
}
/* if alt path already exists and contains files, rebuild storage so
that we don't start overwriting files. */
if (ret < 0)
return -1;
if (ret == 0) {
"Mailbox %s has existing files in alt path, "
"rebuilding storage to avoid losing messages",
return -1;
}
/* dir is empty, ignore it */
}
}
const struct mailbox_update *update)
{
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
int ret;
/* use syncing as a lock */
if (ret <= 0) {
return -1;
}
return -1;
}
}
return mail_index_sync_commit(&sync_ctx);
}
{
const char *alt_path;
&alt_path))
return 0;
/* make sure alt storage is mounted. if it's not, abort the rebuild. */
return 0;
return -1;
}
/* try to create the alt directory. if it fails, it means alt
storage isn't mounted. */
return -1;
return 0;
}
{
const void *data;
if (flags_offset < data_size)
}