1 Return-Path: <tomc@caurea.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id B4266431FBF
\r
6 for <notmuch@notmuchmail.org>; Sun, 20 Dec 2009 05:21:00 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id qA9biFmWPwnb for <notmuch@notmuchmail.org>;
\r
11 Sun, 20 Dec 2009 05:21:00 -0800 (PST)
\r
12 Received: from mout.perfora.net (mout.perfora.net [74.208.4.195])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 1ED25431FAE
\r
14 for <notmuch@notmuchmail.org>; Sun, 20 Dec 2009 05:21:00 -0800 (PST)
\r
15 Received: from hobbes.caurea.org
\r
16 (gw.ptr-62-65-144-46.customer.ch.netstream.com [62.65.144.46])
\r
17 by mx.perfora.net (node=mxus2) with ESMTP (Nemesis)
\r
18 id 0M2s0s-1OBhS03LEc-00sbho for notmuch@notmuchmail.org;
\r
19 Sun, 20 Dec 2009 08:20:59 -0500
\r
20 Received: by hobbes.caurea.org (Postfix, from userid 101)
\r
21 id 5FF4A448B7; Sun, 20 Dec 2009 14:20:53 +0100 (CET)
\r
22 From: Tomas Carnecky <tom@dbservice.com>
\r
23 To: notmuch@notmuchmail.org
\r
24 Date: Sun, 20 Dec 2009 14:20:32 +0100
\r
25 Message-Id: <1261315232-21494-1-git-send-email-tom@dbservice.com>
\r
26 X-Mailer: git-send-email 1.6.6.rc1.39.g9a42
\r
27 Subject: [notmuch] [PATCH] Solaris doesn't have 'struct dirent::d_type'
\r
28 X-BeenThere: notmuch@notmuchmail.org
\r
29 X-Mailman-Version: 2.1.12
\r
31 List-Id: "Use and development of the notmuch mail system."
\r
32 <notmuch.notmuchmail.org>
\r
33 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
34 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
35 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
36 List-Post: <mailto:notmuch@notmuchmail.org>
\r
37 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
38 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
40 X-List-Received-Date: Sun, 20 Dec 2009 13:21:00 -0000
\r
42 Use stat(2) instead.
\r
44 Signed-off-by: Tomas Carnecky <tom@dbservice.com>
\r
47 There is a second issue that prevents notmuch from working on Solaris:
\r
48 the getpwuid_r() prototype doesn't have the last argument. But that can
\r
49 be easily worked around by setting -D_POSIX_PTHREAD_SEMANTICS on the
\r
50 compiler commandline. Do you want to use uname to detect the platform
\r
51 and define platform-specific code or can I unconditionally add that
\r
54 notmuch-new.c | 22 +++++++++++++++++-----
\r
55 1 files changed, 17 insertions(+), 5 deletions(-)
\r
57 diff --git a/notmuch-new.c b/notmuch-new.c
\r
58 index 9d20616..837ae4f 100644
\r
61 @@ -90,12 +90,18 @@ static int ino_cmp(const struct dirent **a, const struct dirent **b)
\r
62 * Return 1 if the directory looks like a Maildir and 0 otherwise.
\r
65 -is_maildir (struct dirent **entries, int count)
\r
66 +is_maildir (const char *path, struct dirent **entries, int count)
\r
70 for (i = 0; i < count; i++) {
\r
71 - if (entries[i]->d_type != DT_DIR) continue;
\r
72 + char pbuf[PATH_MAX];
\r
73 + snprintf(pbuf, PATH_MAX, "%s/%s", path, entries[i]->d_name);
\r
76 + if (stat(pbuf, &buf) == -1 || !S_ISDIR(buf.st_mode))
\r
79 if (strcmp(entries[i]->d_name, "new") == 0 ||
\r
80 strcmp(entries[i]->d_name, "cur") == 0 ||
\r
81 strcmp(entries[i]->d_name, "tmp") == 0)
\r
82 @@ -178,7 +184,13 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
83 /* If this directory hasn't been modified since the last
\r
84 * add_files, then we only need to look further for
\r
85 * sub-directories. */
\r
86 - if (path_mtime <= path_dbtime && entry->d_type == DT_REG)
\r
88 + char pbuf[PATH_MAX];
\r
89 + snprintf(pbuf, PATH_MAX, "%s/%s", path, entry->d_name);
\r
90 + if (stat(pbuf, &buf) == -1)
\r
93 + if (path_mtime <= path_dbtime && S_ISREG(buf.st_mode))
\r
96 /* Ignore special directories to avoid infinite recursion.
\r
97 @@ -188,9 +200,9 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
98 * user specify files to be ignored. */
\r
99 if (strcmp (entry->d_name, ".") == 0 ||
\r
100 strcmp (entry->d_name, "..") == 0 ||
\r
101 - (entry->d_type == DT_DIR &&
\r
102 + (S_ISDIR(buf.st_mode) &&
\r
103 (strcmp (entry->d_name, "tmp") == 0) &&
\r
104 - is_maildir (namelist, num_entries)) ||
\r
105 + is_maildir (path, namelist, num_entries)) ||
\r
106 strcmp (entry->d_name, ".notmuch") ==0)
\r