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 C6542431FBD for ; Thu, 21 Jan 2010 12:16:56 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 tests=[BAYES_50=0.001] autolearn=ham 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 gd4UzekXOLka for ; Thu, 21 Jan 2010 12:16:56 -0800 (PST) X-Greylist: delayed 400 seconds by postgrey-1.32 at olra; Thu, 21 Jan 2010 12:16:55 PST Received: from proxy.dmvnoc.com (proxy.dmvnoc.com [216.169.144.254]) by olra.theworths.org (Postfix) with ESMTP id E6EAC431FAE for ; Thu, 21 Jan 2010 12:16:55 -0800 (PST) Received: (qmail 11079 invoked from network); 21 Jan 2010 20:10:14 +0000 Received: from unknown (HELO ?192.168.1.19?) (192.168.1.19) by mail.internetconnection.net with SMTP; 21 Jan 2010 20:10:14 +0000 From: Geo Carncross To: notmuch@notmuchmail.org Content-Type: multipart/mixed; boundary="=-M4CpZ46nwdpaYw2E2ppA" Date: Thu, 21 Jan 2010 15:10:18 -0500 Message-ID: <1264104618.3941.108.camel@dwarf> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Subject: [PATCH] d_type fix 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: Thu, 21 Jan 2010 20:16:57 -0000 --=-M4CpZ46nwdpaYw2E2ppA Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit A review of notmuch-new.c shows three uses of ->d_type: Near line 153, in _entries_resemble_maildir() we can simply allow for DT_UNKNOWN. This would fail if people have MH-style folders which have three folders called "new" "cur" and "tmp", but that seems unlikely, in which case the "tmp" folder would simply not be scanned. Near line 273 in add_files_recursive() we have another check. If DT_UNKNOWN, we fall through, then add_files_recursive() does a stat almost immediately, returning with success if the path isn't a directory. Thus, the fallback is already written. Finally, near line 343, in add_files_recursive() (a long function) we have another check. Here we can simply treat DT_UNKNOWN as DT_LNK, since the logic for the stat() results are the same. Attached is a patch which was tested with reiserfs. It should also work with xfs. --=-M4CpZ46nwdpaYw2E2ppA Content-Disposition: attachment; filename="notmuch_new_d_type_fix.patch" Content-Type: text/x-patch; name="notmuch_new_d_type_fix.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit diff --git a/notmuch-new.c b/notmuch-new.c index b740ee2..3e6b96a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -153,7 +153,7 @@ _entries_resemble_maildir (struct dirent **entries, int count) int i, found = 0; for (i = 0; i < count; i++) { - if (entries[i]->d_type != DT_DIR) + if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN) continue; if (strcmp(entries[i]->d_name, "new") == 0 || @@ -273,7 +273,8 @@ add_files_recursive (notmuch_database_t *notmuch, entry = fs_entries[i]; - if (entry->d_type != DT_DIR && entry->d_type != DT_LNK) + if (entry->d_type != DT_DIR && entry->d_type != DT_LNK + && entry->d_type != DT_UNKNOWN) continue; /* Ignore special directories to avoid infinite recursion. @@ -343,7 +344,7 @@ add_files_recursive (notmuch_database_t *notmuch, /* If we're looking at a symlink, we only want to add it if it * links to a regular file, (and not to a directory, say). */ - if (entry->d_type == DT_LNK) { + if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) { int err; next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); --=-M4CpZ46nwdpaYw2E2ppA--