[PATCH 2/4] dirent->d_type not available on Soalris
authorVladimir.Marek <Vladimir.Marek@oracle.com>
Mon, 9 Apr 2012 10:17:43 +0000 (12:17 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:10 +0000 (09:46 -0800)
88/60ffd87608b53d7cba0ef2af0cbc2090e62720 [new file with mode: 0644]

diff --git a/88/60ffd87608b53d7cba0ef2af0cbc2090e62720 b/88/60ffd87608b53d7cba0ef2af0cbc2090e62720
new file mode 100644 (file)
index 0000000..6f73aee
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <Vladimir.Marek@oracle.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 878D6416467\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 03:18:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.299\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id rBOA6stHhMgT for <notmuch@notmuchmail.org>;\r
+       Mon,  9 Apr 2012 03:18:44 -0700 (PDT)\r
+Received: from rcsinet14.oracle.com (rcsinet14.oracle.com [148.87.113.126])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 745E5416464\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 03:18:44 -0700 (PDT)\r
+Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117])\r
+       by rcsinet14.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with\r
+       ESMTP id q39AGbrP026349\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)\r
+       for <notmuch@notmuchmail.org>; Mon, 9 Apr 2012 10:16:37 GMT\r
+Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93])\r
+       by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with\r
+       ESMTP id q39AIfQn010126\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
+       Mon, 9 Apr 2012 10:18:42 GMT\r
+Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156])\r
+       by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+       q39AIe1q015673\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\r
+       Mon, 9 Apr 2012 10:18:41 GMT\r
+Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72])\r
+       by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id\r
+       q39AIeta008108; Mon, 9 Apr 2012 05:18:40 -0500\r
+Received: from pub.czech.sun.com (/10.163.20.32)\r
+       by default (Oracle Beehive Gateway v4.0)\r
+       with ESMTP ; Mon, 09 Apr 2012 03:18:40 -0700\r
+From: Vladimir.Marek@oracle.com\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] dirent->d_type not available on Soalris\r
+Date: Mon,  9 Apr 2012 12:17:43 +0200\r
+Message-Id: <1333966665-10469-3-git-send-email-Vladimir.Marek@oracle.com>\r
+X-Mailer: git-send-email 1.7.3.2\r
+In-Reply-To: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>\r
+References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>\r
+X-Source-IP: ucsinet21.oracle.com [156.151.31.93]\r
+X-CT-RefId: str=0001.0A090201.4F82B782.00BB,ss=1,re=0.000,fgs=0\r
+Cc: Vladimir Marek <vlmarek@volny.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 09 Apr 2012 10:18:45 -0000\r
+\r
+From: Vladimir Marek <vlmarek@volny.cz>\r
+\r
+The inspiration was taken from similar issue in mutt:\r
+http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html\r
+\r
+Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
+---\r
+ notmuch-new.c |   19 +++++++++++++------\r
+ 1 files changed, 13 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 4f13535..20bc580 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -21,6 +21,7 @@\r
+ #include "notmuch-client.h"\r
\r
+ #include <unistd.h>\r
++#include <sys/types.h>\r
\r
+ typedef struct _filename_node {\r
+     char *filename;\r
+@@ -165,9 +166,12 @@ static int\r
+ _entries_resemble_maildir (struct dirent **entries, int count)\r
+ {\r
+     int i, found = 0;\r
++    struct stat statbuf;\r
\r
+     for (i = 0; i < count; i++) {\r
+-      if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)\r
++      if (stat(entries[i]->d_name, &statbuf) == -1)\r
++              continue;\r
++      if (! S_ISDIR(statbuf.st_mode))\r
+           continue;\r
\r
+       if (strcmp(entries[i]->d_name, "new") == 0 ||\r
+@@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+     struct stat st;\r
+     notmuch_bool_t is_maildir, new_directory;\r
+     const char **tag;\r
++    struct stat statbuf;\r
\r
+     if (stat (path, &st)) {\r
+       fprintf (stderr, "Error reading directory %s: %s\n",\r
+@@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,\r
\r
+       entry = fs_entries[i];\r
\r
++      if (stat(entry->d_name, &statbuf) == -1)\r
++              continue;\r
++\r
+       /* We only want to descend into directories.\r
+        * But symlinks can be to directories too, of course.\r
+        *\r
+@@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+        * scandir results, then it might be a directory (and if not,\r
+        * then we'll stat and return immediately in the next level of\r
+        * recursion). */\r
+-      if (entry->d_type != DT_DIR &&\r
+-          entry->d_type != DT_LNK &&\r
+-          entry->d_type != DT_UNKNOWN)\r
++      if (!(statbuf.st_mode & S_IFDIR) &&\r
++          !(statbuf.st_mode & S_IFLNK))\r
+       {\r
+           continue;\r
+       }\r
+@@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+        *\r
+        * In either case, a stat does the trick.\r
+        */\r
+-      if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {\r
++      if (stat(entry->d_name, &statbuf) == -1 || statbuf.st_mode & S_IFLNK) {\r
+           int err;\r
\r
+           next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
+@@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
\r
+           if (! S_ISREG (st.st_mode))\r
+               continue;\r
+-      } else if (entry->d_type != DT_REG) {\r
++      } else if ( statbuf.st_mode & S_IFREG) {\r
+           continue;\r
+       }\r
\r
+-- \r
+1.7.3.2\r
+\r