From e628a7eecd63ad08f10b79ad3b7372ea2f5f7660 Mon Sep 17 00:00:00 2001 From: "Vladimir.Marek" Date: Mon, 9 Apr 2012 18:32:07 +0200 Subject: [PATCH] [PATCH 2/4] dirent->d_type not available on Soalris --- ae/19d03b6033281eab9a8001e6d51e9d2ccb85bb | 160 ++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 ae/19d03b6033281eab9a8001e6d51e9d2ccb85bb diff --git a/ae/19d03b6033281eab9a8001e6d51e9d2ccb85bb b/ae/19d03b6033281eab9a8001e6d51e9d2ccb85bb new file mode 100644 index 000000000..1f823e8bc --- /dev/null +++ b/ae/19d03b6033281eab9a8001e6d51e9d2ccb85bb @@ -0,0 +1,160 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id CFC2A414B9A + for ; Mon, 9 Apr 2012 09:32:49 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -4.999 +X-Spam-Level: +X-Spam-Status: No, score=-4.999 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_HI=-5, UNPARSEABLE_RELAY=0.001] + 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 wdaL3BgPyLhz for ; + Mon, 9 Apr 2012 09:32:48 -0700 (PDT) +X-Greylist: delayed 22445 seconds by postgrey-1.32 at olra; + Mon, 09 Apr 2012 09:32:48 PDT +Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D188C414B96 + for ; Mon, 9 Apr 2012 09:32:48 -0700 (PDT) +Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) + by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with + ESMTP id q39GWkbT015218 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Mon, 9 Apr 2012 16:32:47 GMT +Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) + by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + q39GWjGr020006 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Mon, 9 Apr 2012 16:32:45 GMT +Received: from abhmt106.oracle.com (abhmt106.oracle.com [141.146.116.58]) + by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id + q39GWiHW028104; Mon, 9 Apr 2012 11:32:44 -0500 +Received: from pub.czech.sun.com (/10.163.20.32) + by default (Oracle Beehive Gateway v4.0) + with ESMTP ; Mon, 09 Apr 2012 09:32:44 -0700 +From: Vladimir.Marek@oracle.com +To: notmuch@notmuchmail.org +Subject: [PATCH 2/4] dirent->d_type not available on Soalris +Date: Mon, 9 Apr 2012 18:32:07 +0200 +Message-Id: <1333989127-21523-1-git-send-email-Vladimir.Marek@oracle.com> +X-Mailer: git-send-email 1.7.3.2 +In-Reply-To: + +References: + +X-Source-IP: acsinet22.oracle.com [141.146.126.238] +X-CT-RefId: str=0001.0A090203.4F830F30.0012,ss=1,re=0.000,fgs=0 +Cc: 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 16:32:50 -0000 + +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 | 28 ++++++++++++++++++++++++++++ + 1 files changed, 28 insertions(+), 0 deletions(-) + +diff --git a/notmuch-new.c b/notmuch-new.c +index 4f13535..3d265bd 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -21,6 +21,9 @@ + #include "notmuch-client.h" + + #include ++#ifndef _DIRENT_HAVE_D_TYPE ++#include ++#endif + + typedef struct _filename_node { + char *filename; +@@ -167,7 +170,14 @@ _entries_resemble_maildir (struct dirent **entries, int count) + int i, found = 0; + + for (i = 0; i < count; i++) { ++#ifdef _DIRENT_HAVE_D_TYPE + if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN) ++#else ++ struct stat statbuf; ++ if (stat(entries[i]->d_name, &statbuf) == -1) ++ continue; ++ if (! S_ISDIR(statbuf.st_mode)) ++#endif + continue; + + if (strcmp(entries[i]->d_name, "new") == 0 || +@@ -258,6 +268,9 @@ add_files_recursive (notmuch_database_t *notmuch, + struct stat st; + notmuch_bool_t is_maildir, new_directory; + const char **tag; ++#ifndef _DIRENT_HAVE_D_TYPE ++ struct stat statbuf; ++#endif + + if (stat (path, &st)) { + fprintf (stderr, "Error reading directory %s: %s\n", +@@ -328,9 +341,16 @@ 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). */ ++#ifdef _DIRENT_HAVE_D_TYPE + if (entry->d_type != DT_DIR && + entry->d_type != DT_LNK && + entry->d_type != DT_UNKNOWN) ++#else ++ if (stat(entry->d_name, &statbuf) == -1) ++ continue; ++ if (!(statbuf.st_mode & S_IFDIR) && ++ !(statbuf.st_mode & S_IFLNK)) ++#endif + { + continue; + } +@@ -427,7 +447,11 @@ add_files_recursive (notmuch_database_t *notmuch, + * + * In either case, a stat does the trick. + */ ++#ifdef _DIRENT_HAVE_D_TYPE + if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) { ++#else ++ if (stat(entry->d_name, &statbuf) == -1 || statbuf.st_mode & S_IFLNK) { ++#endif + int err; + + next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); +@@ -443,7 +467,11 @@ add_files_recursive (notmuch_database_t *notmuch, + + if (! S_ISREG (st.st_mode)) + continue; ++#ifdef _DIRENT_HAVE_D_TYPE + } else if (entry->d_type != DT_REG) { ++#else ++ } else if (statbuf.st_mode & S_IFREG) { ++#endif + continue; + } + +-- +1.7.3.2 + -- 2.26.2