]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added maildir_stat_dirs option.
authorTimo Sirainen <tss@iki.fi>
Sat, 29 May 2004 22:21:39 +0000 (01:21 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 29 May 2004 22:21:39 +0000 (01:21 +0300)
--HG--
branch : HEAD

configure.in
dovecot-example.conf
src/lib-storage/index/maildir/maildir-list.c
src/master/mail-process.c
src/master/master-settings.c
src/master/master-settings.h

index 3d0ff5dacf7ea12801d5952175c279d6b89e9911..03400b450e0d538541805fe4695272d2794409db 100644 (file)
@@ -448,6 +448,16 @@ case "$typeof_off_t" in
     ;;
 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>
index 11407c0121e523c2e0afd05865ef2629b42a0097..f1e7921ad08540d4f03bbbf0f0aff910a001e9bb 100644 (file)
 # 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
index d554f6297bd60128c78d1f83d442dde3efb36b57..313aeae0d82a57e22006a7698b9393345252b86e 100644 (file)
@@ -10,6 +10,7 @@
 #include "maildir-storage.h"
 #include "mailbox-tree.h"
 
+#include <stdlib.h>
 #include <dirent.h>
 #include <sys/stat.h>
 
@@ -53,11 +54,12 @@ static int maildir_fill_readdir(struct maildir_list_context *ctx,
 {
        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) {
@@ -75,6 +77,8 @@ static int maildir_fill_readdir(struct maildir_list_context *ctx,
                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;
@@ -87,10 +91,22 @@ static int maildir_fill_readdir(struct maildir_list_context *ctx,
                    (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,
@@ -99,8 +115,6 @@ static int maildir_fill_readdir(struct maildir_list_context *ctx,
                           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 &&
index 20f85c72d3a0ed8012c7d42375989c9579cbc602..cbf1ae5a058e527c144c8be57b7e34b3c62c6221 100644 (file)
@@ -314,6 +314,8 @@ int create_mail_process(struct login_group *group, int socket,
                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)
index 2264639e0731b1f63fc5b06731ead984a85a4e0c..1be9b89568fac0ff2cd23f34ebf7c6462ba4d5a8 100644 (file)
@@ -93,6 +93,7 @@ static struct setting_def setting_defs[] = {
        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),
@@ -226,6 +227,7 @@ struct settings default_settings = {
        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",
index b82d3d8e1e71883841fd3b2d609a9b7af482d59d..588bf486e285c807b9d22dea9ffe209c13a865e5 100644 (file)
@@ -68,6 +68,7 @@ struct settings {
        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;