From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E24ED414B99 for ; Mon, 9 Apr 2012 04:17:23 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sPq+F+Txzq6B for ; Mon, 9 Apr 2012 04:17:22 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id A8E0A414B96 for ; Mon, 9 Apr 2012 04:17:22 -0700 (PDT) Received: by pbcuo1 with SMTP id uo1so5664086pbc.26 for ; Mon, 09 Apr 2012 04:17:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=E+XhC5NXOKVzDJcPVfP59TOgg4Ulya0BCUPpoIzpbPo=; b=kRWJRVqNH/Z/gP2XTu4t4E2ze92asyFc1PZkORF5CeQqQUia1FOma/wyAwTapeEwFC 9+Gl4nHpCI3tjML9P/10jbtuqWYeeRTQpvgIjZV4i2mGLKp1OlZaADHcsfYx3kAG7gM1 8gpw6dWkI32xveQZb5Gr5B8ZHSz41wqlQQnpmSNpE2vcAFxkr63bmqeF8bqdNnBP/EPD 9TnkkOg7zxLSQmhM/ycmQ59f56gneSAb+QfA6FaXXZFY66MoVGIX2a4HmOy+ERi+h5cy uxlcScnCg3uY2Iu39PVU2WvSteytNLkIqtEKuCj1en+dHmSRVm2PAjQJREuf1BKO36C6 eM+w== MIME-Version: 1.0 Received: by 10.68.223.36 with SMTP id qr4mr6141349pbc.54.1333970241762; Mon, 09 Apr 2012 04:17:21 -0700 (PDT) Received: by 10.68.241.234 with HTTP; Mon, 9 Apr 2012 04:17:21 -0700 (PDT) Received: by 10.68.241.234 with HTTP; Mon, 9 Apr 2012 04:17:21 -0700 (PDT) In-Reply-To: <1333966665-10469-3-git-send-email-Vladimir.Marek@oracle.com> References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com> <1333966665-10469-3-git-send-email-Vladimir.Marek@oracle.com> Date: Mon, 9 Apr 2012 14:17:21 +0300 Message-ID: Subject: Re: [PATCH 2/4] dirent->d_type not available on Soalris From: Jani Nikula To: Vladimir.Marek@oracle.com Content-Type: multipart/alternative; boundary=047d7b2e09bd66b3a104bd3d2610 X-Gm-Message-State: ALoCoQn/5FrY6tb5qa1fPucNshwvazO+3HkQ/jO3eKVmUcZIlXykxJPu43ANXX0rrAOxqspGSz9s Cc: Notmuch Mail , Vladimir Marek X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2012 11:17:24 -0000 --047d7b2e09bd66b3a104bd3d2610 Content-Type: text/plain; charset=UTF-8 On Apr 9, 2012 1:18 PM, wrote: > > From: Vladimir Marek > > 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 > --- > 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 > +#include > > 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 --047d7b2e09bd66b3a104bd3d2610 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Apr 9, 2012 1:18 PM, <Vl= adimir.Marek@oracle.com> wrote:
>
> From: Vladimir Marek <vlmarek@v= olny.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>
> ---
> =C2=A0notmuch-new.c | =C2=A0 19 +++++++++++++------
> =C2=A01 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 @@
> =C2=A0#include "notmuch-client.h"
>
> =C2=A0#include <unistd.h>
> +#include <sys/types.h>
>
> =C2=A0typedef struct _filename_node {
> =C2=A0 =C2=A0 char *filename;
> @@ -165,9 +166,12 @@ static int
> =C2=A0_entries_resemble_maildir (struct dirent **entries, int count) > =C2=A0{
> =C2=A0 =C2=A0 int i, found =3D 0;
> + =C2=A0 =C2=A0struct stat statbuf;
>
> =C2=A0 =C2=A0 for (i =3D 0; i < count; i++) {
> - =C2=A0 =C2=A0 =C2=A0 if (entries[i]->d_type !=3D DT_DIR &&= ; entries[i]->d_type !=3D DT_UNKNOWN)
> + =C2=A0 =C2=A0 =C2=A0 if (stat(entries[i]->d_name, &statbuf) = =3D=3D -1)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue;
> + =C2=A0 =C2=A0 =C2=A0 if (! S_ISDIR(statbuf.st_mode))

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

BR,
Jani.

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

--047d7b2e09bd66b3a104bd3d2610--