[notmuch] [PATCH] Add post-add and post-tag hooks

Olly Betts olly at survex.com
Wed Dec 23 00:29:56 PST 2009


[Sorry, I seemed to manage to attach my reply to the wrong thread...]

On Wed, Dec 23, 2009 at 07:57:21AM +0100, Tomas Carnecky wrote:
> On 12/23/09 12:02 AM, Olly Betts wrote:
>> Rather than a platform-specific check, it would be better to check if DT_DIR
>> is defined.
>>
>> Beware that even on Linux (where the d_type field is present), it may always
>> contain DT_UNKNOWN for some filesystems, so you really should check for that
>> case and fall back to using stat() instead.
>
> Currently configure is a simple shell script and not some autoconf  
> magic. And I don't know how eager Carl is to use autoconf, scons, cmake  
> or similar.

No autoconf magic required (or desirable here that I can see) - here's what
I'm suggesting (untested as written, but Xapian's omega indexer uses an
approach much like this):

#ifdef DT_UNKNOWN
    /* If d_type is available and supported by the FS, avoid a call to stat. */
    if (entries[i]->d_type == DT_UNKNOWN) {
	/* Fall back to calling stat. */
#endif
    {
	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;
    }
#ifdef DT_UNKNOWN
    } else if (entries[i]->d_type != DT_DIR) continue;
#endif


Cheers,
    Olly


More information about the notmuch mailing list