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 B4266431FBF for ; Sun, 20 Dec 2009 05:21:00 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 qA9biFmWPwnb for ; Sun, 20 Dec 2009 05:21:00 -0800 (PST) Received: from mout.perfora.net (mout.perfora.net [74.208.4.195]) by olra.theworths.org (Postfix) with ESMTP id 1ED25431FAE for ; Sun, 20 Dec 2009 05:21:00 -0800 (PST) Received: from hobbes.caurea.org (gw.ptr-62-65-144-46.customer.ch.netstream.com [62.65.144.46]) by mx.perfora.net (node=mxus2) with ESMTP (Nemesis) id 0M2s0s-1OBhS03LEc-00sbho for notmuch@notmuchmail.org; Sun, 20 Dec 2009 08:20:59 -0500 Received: by hobbes.caurea.org (Postfix, from userid 101) id 5FF4A448B7; Sun, 20 Dec 2009 14:20:53 +0100 (CET) From: Tomas Carnecky To: notmuch@notmuchmail.org Date: Sun, 20 Dec 2009 14:20:32 +0100 Message-Id: <1261315232-21494-1-git-send-email-tom@dbservice.com> X-Mailer: git-send-email 1.6.6.rc1.39.g9a42 Subject: [notmuch] [PATCH] Solaris doesn't have 'struct dirent::d_type' X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Sun, 20 Dec 2009 13:21:00 -0000 Use stat(2) instead. Signed-off-by: Tomas Carnecky --- There is a second issue that prevents notmuch from working on Solaris: the getpwuid_r() prototype doesn't have the last argument. But that can be easily worked around by setting -D_POSIX_PTHREAD_SEMANTICS on the compiler commandline. Do you want to use uname to detect the platform and define platform-specific code or can I unconditionally add that define to CFLAGS? notmuch-new.c | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 9d20616..837ae4f 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -90,12 +90,18 @@ static int ino_cmp(const struct dirent **a, const struct dirent **b) * Return 1 if the directory looks like a Maildir and 0 otherwise. */ static int -is_maildir (struct dirent **entries, int count) +is_maildir (const char *path, struct dirent **entries, int count) { int i, found = 0; for (i = 0; i < count; i++) { - if (entries[i]->d_type != DT_DIR) continue; + char pbuf[PATH_MAX]; + snprintf(pbuf, PATH_MAX, "%s/%s", path, entries[i]->d_name); + + struct stat buf; + if (stat(pbuf, &buf) == -1 || !S_ISDIR(buf.st_mode)) + continue; + if (strcmp(entries[i]->d_name, "new") == 0 || strcmp(entries[i]->d_name, "cur") == 0 || strcmp(entries[i]->d_name, "tmp") == 0) @@ -178,7 +184,13 @@ add_files_recursive (notmuch_database_t *notmuch, /* If this directory hasn't been modified since the last * add_files, then we only need to look further for * sub-directories. */ - if (path_mtime <= path_dbtime && entry->d_type == DT_REG) + struct stat buf; + char pbuf[PATH_MAX]; + snprintf(pbuf, PATH_MAX, "%s/%s", path, entry->d_name); + if (stat(pbuf, &buf) == -1) + continue; + + if (path_mtime <= path_dbtime && S_ISREG(buf.st_mode)) continue; /* Ignore special directories to avoid infinite recursion. @@ -188,9 +200,9 @@ add_files_recursive (notmuch_database_t *notmuch, * user specify files to be ignored. */ if (strcmp (entry->d_name, ".") == 0 || strcmp (entry->d_name, "..") == 0 || - (entry->d_type == DT_DIR && + (S_ISDIR(buf.st_mode) && (strcmp (entry->d_name, "tmp") == 0) && - is_maildir (namelist, num_entries)) || + is_maildir (path, namelist, num_entries)) || strcmp (entry->d_name, ".notmuch") ==0) { continue; -- 1.6.6.rc1.39.g9a42