;;
esac
+dnl * Do we have struct dirent->d_type
+AC_TRY_COMPILE([
+ #include <dirent.h>
+], [
+ struct dirent d;
+ d.d_type = DT_DIR;
+], [
+ AC_DEFINE(HAVE_DIRENT_D_TYPE,, Define if you have struct dirent->d_type)
+])
+
dnl * Do we have OFF_T_MAX?
AC_TRY_COMPILE([
#include <limits.h>
# which may be slower. Required for NFS.
#fcntl_locks_disable = no
+# By default LIST command returns all entries in maildir beginning with dot.
+# Enabling this option makes Dovecot return only entries which are directories.
+# This is done by stat()ing each entry, so it causes more disk I/O.
+# (For systems setting struct dirent->d_type, this check is free and it's
+# done always regardless of this setting)
+#maildir_stat_dirs = no
+
# Copy mail to another folders using hard links. This is much faster than
# actually copying the file. This is problematic only if something modifies
# the mail in one folder but doesn't want it modified in the others. I don't
#include "maildir-storage.h"
#include "mailbox-tree.h"
+#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
{
DIR *dirp;
struct dirent *d;
+ struct stat st;
const char *path, *p, *mailbox_c;
string_t *mailbox;
enum imap_match_result match;
struct mailbox_node *node;
- int created;
+ int stat_dirs, created, hide;
dirp = opendir(ctx->dir);
if (dirp == NULL) {
node->flags &= ~(MAILBOX_PLACEHOLDER | MAILBOX_NONEXISTENT);
}
+ stat_dirs = getenv("MAILDIR_STAT_DIRS") != NULL;
+
mailbox = t_str_new(PATH_MAX);
while ((d = readdir(dirp)) != NULL) {
const char *fname = d->d_name;
(fname[1] == '\0' || (fname[1] == '.' && fname[2] == '\0')))
continue;
- /* FIXME: kludges. these files must be renamed later */
- if (strcmp(fname, ".customflags") == 0 ||
- strcmp(fname, ".subscriptions") == 0)
+#ifdef HAVE_DIRENT_D_TYPE
+ /* check the type always since there's no extra cost */
+ if (d->d_type == DT_DIR)
+ ;
+ else if (d->d_type != DT_UNKNOWN)
continue;
+ else
+#endif
+ if (stat_dirs) {
+ t_push();
+ path = t_strdup_printf("%s/%s", ctx->dir, fname);
+ hide = stat(path, &st) < 0 || !S_ISDIR(st.st_mode);
+ t_pop();
+ if (hide)
+ continue;
+ }
if (fname[1] == MAILDIR_FS_SEP) {
/* this mailbox is in the middle of being deleted,
delete it ourself if it's been there longer than
one hour. don't touch it if it's outside our
mail root dir. */
- struct stat st;
-
t_push();
path = t_strdup_printf("%s/%s", ctx->dir, fname);
if (stat(path, &st) == 0 &&
env_put("MMAP_NO_WRITE=1");
if (set->fcntl_locks_disable)
env_put("FCNTL_LOCKS_DISABLE=1");
+ if (set->maildir_stat_dirs)
+ env_put("MAILDIR_STAT_DIRS=1");
if (set->maildir_copy_with_hardlinks)
env_put("MAILDIR_COPY_WITH_HARDLINKS=1");
if (set->maildir_check_content_changes)
DEF(SET_BOOL, mmap_disable),
DEF(SET_BOOL, mmap_no_write),
DEF(SET_BOOL, fcntl_locks_disable),
+ DEF(SET_BOOL, maildir_stat_dirs),
DEF(SET_BOOL, maildir_copy_with_hardlinks),
DEF(SET_BOOL, maildir_check_content_changes),
DEF(SET_STR, mbox_locks),
MEMBER(mmap_no_write) FALSE,
#endif
MEMBER(fcntl_locks_disable) FALSE,
+ MEMBER(maildir_stat_dirs) FALSE,
MEMBER(maildir_copy_with_hardlinks) FALSE,
MEMBER(maildir_check_content_changes) FALSE,
MEMBER(mbox_locks) "dotlock fcntl",
int mmap_disable;
int mmap_no_write;
int fcntl_locks_disable;
+ int maildir_stat_dirs;
int maildir_copy_with_hardlinks;
int maildir_check_content_changes;
const char *mbox_locks;