[notmuch] indexing mail?
Olly Betts
olly at survex.com
Thu Jan 14 23:30:04 PST 2010
On 2010-01-15, Dirk-Jan C Binnema wrote:
>>>>>> "Olly" == Olly Betts <olly at survex.com> writes:
> Olly> Not a full patch, but I already posted what this code should look like
> Olly> to handle both systems without d_type, and those which return DT_UNKNOWN:
>
> Olly> http://article.gmane.org/gmane.mail.notmuch.general/1044
> static gboolean
> _set_dtype (const char* path, struct dirent *entry)
Underscore prefixed identifiers are reserved by ISO C at file-scope; using them
yourself is undefined behaviour...
> /* we only care about dirs, regular files and links */
> if (S_ISREG (statbuf.st_mode))
> entry->d_type = DT_REG;
> else if (S_ISDIR (statbuf.st_mode))
> entry->d_type = DT_DIR;
> else if (S_ISLNK (statbuf.st_mode))
> entry->d_type = DT_LNK;
This addresses the case where the FS returns DT_UNKNOWN for d_type, but doesn't
deal with the case of platforms where struct dirent has no d_type member - from
the Linux readdir man page:
The only fields in the dirent structure that are mandated by POSIX.1 are:
d_name[], of unspecified size, with at most NAME_MAX characters preceding
the terminating null byte; and (as an XSI extension) d_ino. The other fields
are unstandardized, and not present on all systems; see NOTES below for some
further details.
And in NOTES:
Other than Linux, the d_type field is available mainly only on BSD systems.
Cheers,
Olly
More information about the notmuch
mailing list