maildir-util.c revision f7ad1162969feff6b08f0e640a928db1783daae9
/* Copyright (c) 2004-2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "str.h"
#include "mkdir-parents.h"
#include "maildir-storage.h"
#include "maildir-uidlist.h"
#include "maildir-sync.h"
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <utime.h>
#define MAILDIR_RESYNC_RETRY_COUNT 10
{
int ret;
return -2; /* expunged */
t_push();
if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {
/* probably in new/ dir */
if (ret != 0) {
t_pop();
return ret;
}
}
t_pop();
return ret;
}
void *context ATTR_UNUSED)
{
/* most likely a symlink pointing to a non-existing file */
"Maildir: Symlink destination doesn't exist: %s", path);
return -2;
} else {
"maildir_file_do(%s): Filename keeps changing", path);
return -1;
}
}
{
int i, ret;
for (i = 0; i < MAILDIR_RESYNC_RETRY_COUNT && ret == 0; i++) {
/* file is either renamed or deleted. sync the maildir and
see which one. if file appears to be renamed constantly,
don't try to open it more than 10 times. */
return -1;
}
if (i == MAILDIR_RESYNC_RETRY_COUNT)
}
{
struct dirent *d;
unsigned int dir_len;
"opendir(%s) failed: %m", dir);
}
return;
}
t_push();
if (d->d_name[0] == '.' &&
/* skip . and .. */
continue;
}
}
}
}
}
t_pop();
#ifdef HAVE_DIRFD
"fstat(%s) failed: %m", dir);
}
#else
"stat(%s) failed: %m", dir);
}
#endif
/* mounted with noatime. update it ourself. */
"utime(%s) failed: %m", dir);
}
}
"closedir(%s) failed: %m", dir);
}
}
{
const char *path;
unsigned int i;
t_push();
/* @UNSAFE: get a list of directories we want to create */
for (i = 0; i < N_ELEMENTS(subdirs); i++)
for (i = 0; i < N_ELEMENTS(dirs); i++) {
continue;
"stat(%s) failed: %m", path);
break;
}
/* mailbox was being deleted just now */
break;
}
"mkdir(%s) failed: %m", path);
break;
}
}
t_pop();
}
{
else {
}
return TRUE;
}
/* maildir itself exists. create all of its subdirectories in case
they got lost. */
}