mbox-storage.c revision f81f4bc282cd1944cec187bae89c0701a416ed2a
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen/* Copyright (C) 2002-2003 Timo Sirainen */
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen#define CREATE_MODE 0770 /* umask() should limit it more */
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen/* How often to touch the dotlock file when using KEEP_LOCKED flag */
0a00890f8ec34ee08d0d391441fca36ed42d7a0cTimo Sirainen/* Assume that if atime < mtime, there are new mails. If it's good enough for
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen UW-IMAP, it's good enough for us. */
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen (st).st_atime < (st).st_mtime ? MAILBOX_MARKED : MAILBOX_UNMARKED)
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen/* NOTE: must be sorted for istream-header-filter. Note that it's not such
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen a good idea to change this list, as the messages will then change from
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen client's point of view. So if you do it, change all mailboxes' UIDVALIDITY
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen so all caches are reset. */
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainenconst char *mbox_hide_headers[] = {
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen "Content-Length",
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen "X-IMAPbase",
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen "X-Keywords",
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen sizeof(mbox_hide_headers) / sizeof(mbox_hide_headers[0]);
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen/* A bit ugly duplification of the above list. It's safe to modify this list
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen without bad side effects, just keep the list sorted. */
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen "Content-Length",
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainen "X-Delivery-ID"
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen "X-IMAPbase",
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen "X-Keywords",
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen sizeof(mbox_save_drop_headers) / sizeof(mbox_save_drop_headers[0]);
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainenstatic MODULE_CONTEXT_DEFINE_INIT(mbox_mailbox_list_module,
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenstatic int mbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainenstatic int mbox_list_delete_mailbox(struct mailbox_list *list,
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainen const char *name);
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenint mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen mail_storage_set_error(&mbox->storage->storage,
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen "Not enough disk space");
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen mail_storage_set_critical(&mbox->storage->storage,
965ed6ea3fc8f7637bd0d159d2fdb283a191ce34Timo Sirainen "%s failed with mbox file %s: %m",
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstatic bool mbox_is_file(const char *path, const char *name, bool debug)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen i_info("mbox autodetect: %s: stat(%s) failed: %m",
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen i_info("mbox autodetect: %s: is a directory (%s)",
70cb37c37e4dce8f57cd3f882f7444e76b918befTimo Sirainen i_info("mbox autodetect: %s: no R/W access (%s)",
08aea01ef9a9d20703e0fcf8618e6195c0037a44Timo Sirainen i_info("mbox autodetect: %s: yes (%s)", name, path);
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstatic bool mbox_is_dir(const char *path, const char *name, bool debug)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen i_info("mbox autodetect: %s: stat(%s) failed: %m",
return FALSE;
if (debug) {
return FALSE;
if (debug)
return TRUE;
const char *path;
if (debug) {
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return FALSE;
if (debug)
return path;
if (debug)
if (debug)
return path;
if (debug)
if (debug)
if (debug)
return NULL;
if (debug)
return path;
if (debug)
if (debug)
return path;
if (debug)
if (debug)
return path;
return NULL;
return NULL;
if (debug)
return path;
const char **layout_r)
bool autodetect;
if (autodetect) {
if (debug)
if (p == NULL) {
} while (p != NULL);
const char *path, *p;
if (p == NULL)
return path;
const char *name)
const char *index_dir;
const char *inbox_path;
int fd;
const char *env;
unsigned int min_size;
return FALSE;
if (min_size == 0)
return FALSE;
return FALSE;
static struct mbox_mailbox *
return NULL;
return mbox;
static struct mailbox *
static struct mailbox *
return NULL;
static struct mailbox *
return NULL;
return NULL;
path);
return NULL;
bool directory)
int fd;
if (p != NULL) {
if (directory) {
int ret = 0;
return ret;
const char *inbox_path;
return FALSE;
t_push();
ret = 0;
t_pop();
return ret;
const char *name)
name));
static void mbox_class_init(void)
static void mbox_class_deinit(void)
NULL,