>>>>> "Olly" == Olly Betts <o...@survex.com> writes:

    Olly> On 2010-01-14, Carl Worth wrote:
    >> On Thu, 14 Jan 2010 18:38:54 +0100, Adrian Perez de Castro 
<ape...@igalia.com> wrote:
    >>> I am using XFS, which always returns DT_UNKNOWN. Taking into account 
that
    >>> there is a good deal of people using filesystems other than the ones you
    >>> mention, and that other non-linux filesystems may also return 
DT_UNKNOWN,
    >>> in my opinion there should be a fall-back. I will try to post a patch
    >>> Anytime Soon=E2=84=A2.
    >> 
    >> We definitely want the fallback. I can attempt to code it, but I don't
    >> have ready access to an afflicted filesystem, so I'd need help testing
    >> anyway.
    >> 
    >> I'd love to see a patch for this bug soon. Be sure to CC me when the
    >> patch is sent and that will help me commit it sooner.

    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

I take a slighly different approach in mu:

/* if the file system does not support entry->d_type, we add it ourselves
 * this is slower (extra stat) but at least it works
 */
static gboolean
_set_dtype (const char* path, struct dirent *entry)
{
        struct stat statbuf;
        char fullpath[4096];
        
        snprintf (fullpath, sizeof(fullpath), "%s%c%s",
                  path, G_DIR_SEPARATOR, entry->d_name);

        if (stat (fullpath, &statbuf) != 0) {
                g_warning ("stat failed on %s: %s", fullpath,
                           strerror(errno));
                return FALSE;
        }

        /* 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;
        
        return TRUE;
}


and then in some other places:

/* handle FSs that don't support entry->d_type */
if (entry->d_type == DT_UNKNOWN) 
        _set_dtype (dirname, entry);

        
Note, that is untested as of yet.

Best wishes,
Dirk.

-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:d...@djcbsoftware.nl           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to