unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Vladimir.Marek@oracle.com
Cc: Notmuch Mail <notmuch@notmuchmail.org>,
	Vladimir Marek <vlmarek@volny.cz>
Subject: Re: [PATCH 2/4] dirent->d_type not available on Soalris
Date: Mon, 9 Apr 2012 14:17:21 +0300	[thread overview]
Message-ID: <CAB+hUn_gFp+bspNFa-4e6hnH077Sx3to8jZGo1MSwt82QFwxwQ@mail.gmail.com> (raw)
In-Reply-To: <1333966665-10469-3-git-send-email-Vladimir.Marek@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 3305 bytes --]

On Apr 9, 2012 1:18 PM, <Vladimir.Marek@oracle.com> wrote:
>
> From: Vladimir Marek <vlmarek@volny.cz>
>
> The inspiration was taken from similar issue in mutt:
> http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html
>
> Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
> ---
>  notmuch-new.c |   19 +++++++++++++------
>  1 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 4f13535..20bc580 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -21,6 +21,7 @@
>  #include "notmuch-client.h"
>
>  #include <unistd.h>
> +#include <sys/types.h>
>
>  typedef struct _filename_node {
>     char *filename;
> @@ -165,9 +166,12 @@ static int
>  _entries_resemble_maildir (struct dirent **entries, int count)
>  {
>     int i, found = 0;
> +    struct stat statbuf;
>
>     for (i = 0; i < count; i++) {
> -       if (entries[i]->d_type != DT_DIR && entries[i]->d_type !=
DT_UNKNOWN)
> +       if (stat(entries[i]->d_name, &statbuf) == -1)
> +               continue;
> +       if (! S_ISDIR(statbuf.st_mode))

Notmuch new is possibly one of the most performance critical bits for
people with, uh, much mail. The performance impact of the new syscalls
should be measured. (Can't do this myself atm.)

BR,
Jani.

>            continue;
>
>        if (strcmp(entries[i]->d_name, "new") == 0 ||
> @@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,
>     struct stat st;
>     notmuch_bool_t is_maildir, new_directory;
>     const char **tag;
> +    struct stat statbuf;
>
>     if (stat (path, &st)) {
>        fprintf (stderr, "Error reading directory %s: %s\n",
> @@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,
>
>        entry = fs_entries[i];
>
> +       if (stat(entry->d_name, &statbuf) == -1)
> +               continue;
> +
>        /* We only want to descend into directories.
>         * But symlinks can be to directories too, of course.
>         *
> @@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,
>         * scandir results, then it might be a directory (and if not,
>         * then we'll stat and return immediately in the next level of
>         * recursion). */
> -       if (entry->d_type != DT_DIR &&
> -           entry->d_type != DT_LNK &&
> -           entry->d_type != DT_UNKNOWN)
> +       if (!(statbuf.st_mode & S_IFDIR) &&
> +           !(statbuf.st_mode & S_IFLNK))
>        {
>            continue;
>        }
> @@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,
>         *
>         * In either case, a stat does the trick.
>         */
> -       if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
> +       if (stat(entry->d_name, &statbuf) == -1 || statbuf.st_mode &
S_IFLNK) {
>            int err;
>
>            next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
> @@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,
>
>            if (! S_ISREG (st.st_mode))
>                continue;
> -       } else if (entry->d_type != DT_REG) {
> +       } else if ( statbuf.st_mode & S_IFREG) {
>            continue;
>        }
>
> --
> 1.7.3.2
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

[-- Attachment #2: Type: text/html, Size: 4767 bytes --]

  reply	other threads:[~2012-04-09 11:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09 10:17 notmuch on Solaris Vladimir.Marek
2012-04-09 10:17 ` [PATCH 1/4] Make configure use /bin/bash instead of /bin/sh Vladimir.Marek
2012-04-09 11:10   ` Jani Nikula
2012-04-09 12:19     ` Vladimir Marek
2012-04-10 17:26       ` Tomi Ollila
2012-04-11  8:43         ` Vladimir Marek
2012-04-11 18:47           ` Tomi Ollila
2012-04-30 11:58   ` David Bremner
2012-04-30 12:09     ` Tomi Ollila
2012-04-09 10:17 ` [PATCH 2/4] dirent->d_type not available on Soalris Vladimir.Marek
2012-04-09 11:17   ` Jani Nikula [this message]
2012-04-09 15:12     ` Vladimir Marek
2012-04-09 15:46       ` Adam Wolfe Gordon
2012-04-09 16:32         ` Vladimir.Marek
2012-04-11 18:57           ` Tomi Ollila
2012-04-11 19:36           ` Austin Clements
2012-04-09 10:17 ` [PATCH 3/4] Private strsep implementation Vladimir.Marek
2012-10-15  5:05   ` Ethan Glasser-Camp
2012-04-09 10:17 ` [PATCH 4/4] Explicitly type void* pointers Vladimir.Marek
2012-04-09 11:04   ` Jani Nikula
2012-04-09 18:15     ` Vladimir Marek
2012-04-09 21:31       ` Jani Nikula
2012-04-10  6:53         ` Vladimir Marek
2012-04-11 21:11         ` Austin Clements
2012-04-12  8:02           ` Jani Nikula
2012-04-12 17:57             ` Austin Clements
2012-04-15 21:05   ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAB+hUn_gFp+bspNFa-4e6hnH077Sx3to8jZGo1MSwt82QFwxwQ@mail.gmail.com \
    --to=jani@nikula.org \
    --cc=Vladimir.Marek@oracle.com \
    --cc=notmuch@notmuchmail.org \
    --cc=vlmarek@volny.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).