maildir-storage.c revision c9205d09549222e0654471a85f7231890bf50318
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (C) 2002-2006 Timo Sirainen */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen#define CREATE_MODE 0777 /* umask() should limit it more */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen#define MAILDIR_PLUSPLUS_DRIVER_NAME "maildir++"
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen#define MAILDIR_SUBFOLDER_FILENAME "maildirfolder"
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainenstatic int verify_inbox(struct mail_storage *storage);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstatic const char *strip_tail_slash(const char *path)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstatic const char *strip_tail_slash_and_cut(const char *path)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmaildir_get_list_settings(struct mailbox_list_settings *list_set,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *data, enum mail_storage_flags flags)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen bool debug = (flags & MAIL_STORAGE_FLAG_DEBUG) != 0;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen list_set->subscription_fname = MAILDIR_SUBSCRIPTION_FILE_NAME;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen if ((flags & MAIL_STORAGE_FLAG_NO_AUTODETECTION) != 0) {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* we'll need to figure out the maildir location ourself.
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen It's $HOME/Maildir unless we are chrooted. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen i_info("maildir: /cur exists, assuming chroot");
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* <Maildir> [:INBOX=<dir>] [:INDEX=<dir>] [:CONTROL=<dir>] */
c49a19168dab6fda80aee16ad799a8a56d3bc18fTimo Sirainen } while (p != NULL);
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen list_set->root_dir = strip_tail_slash(list_set->root_dir);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmaildir_create(const char *data, const char *user,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen if (maildir_get_list_settings(&list_set, data, flags) < 0)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* normally the maildir is created in verify_inbox() */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen if ((flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) != 0) {
a75907609d7c410c9e17beedfafbf28b4439fa8aTimo Sirainen pool = pool_alloconly_create("storage", 512+256);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen storage = p_new(pool, struct maildir_storage, 1);
caea325346da6fb1cf503b35a619467a997acbfaTimo Sirainen getenv("MAILDIR_COPY_WITH_HARDLINKS") != NULL;
caea325346da6fb1cf503b35a619467a997acbfaTimo Sirainen getenv("MAILDIR_COPY_PRESERVE_FILENAME") != NULL;
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen storage->stat_dirs = getenv("MAILDIR_STAT_DIRS") != NULL;
const char *path;
if (debug)
return FALSE;
if (debug)
return FALSE;
return TRUE;
const char *root_dir;
return NULL;
MAILDIR_PLUSPLUS_DRIVER_NAME) != 0) {
return NULL;
if (verify) {
if (!verify)
const char *path;
name);
name);
const char *path;
static struct mailbox *
int shared;
if (shared)
if (!shared) {
return NULL;
mbox);
static struct mailbox *
const char *path;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
path);
return NULL;
const char *path;
int fd;
const char *name,
int fd;
const char *name)
int count;
count = 0;
name);
dest);
count++;
const char *const *names;
unsigned int i, count;
int ret;
ret = 0;
const char *name;
for (i = 0; i < count; i++) {
t_push();
t_pop();
t_pop();
return ret;
int ret;
bool found;
if (ret < 0)
int ret = 0;
return ret;
int ret;
MAILDIR_PLUSPLUS_DRIVER_NAME) == 0) {
const char *path;
t_push();
t_pop();
switch (type) {
const char *path;
t_push();
t_pop();
if (ret == 0)
return ret;
static void maildir_class_init(void)
static void maildir_class_deinit(void)