dbox-storage.c revision 94f84d1c3f786d1b92dd2a1507f83a2dad887c56
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
#include "lib.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
dbox_alt_path_has_changed(const char *root_dir,
const char *alt_path, const char *alt_symlink_path)
{
if (ret < 0) {
return FALSE;
}
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
}
return FALSE;
}
{
return;
i_error("symlink(%s, %s) failed: %m",
}
}
}
struct mail_namespace *ns,
const char **error_r)
{
struct fs_settings fs_set;
const char *error;
args = "";
} else {
}
&error) < 0) {
error);
return -1;
}
}
return 0;
}
{
}
{
const char *path;
}
{
else {
}
}
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;
}
{
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
const char *alt_path;
int ret;
return ret;
if (mailbox_open(box) < 0)
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 */
}
/* use syncing as a lock */
if (ret <= 0) {
return -1;
}
return -1;
}
}
return mail_index_sync_commit(&sync_ctx);
}
{
const char *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;
}