diff --git a/notmuch-new.c b/notmuch-new.c
index 490101d..d8ac4ba 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -119,6 +119,37 @@ is_maildir (struct dirent **entries, int count)
     return 0;
 }
 
+/*
+  add entry->d_type
+ */
+
+ 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;
+ }
+
+
 /* Examine 'path' recursively as follows:
  *
  *   o Ask the filesystem for the mtime of 'path' (fs_mtime)
@@ -186,6 +217,11 @@ add_files_recursive (notmuch_database_t *notmuch,
 	    break;
 
         entry= namelist[i++];
+        /* handle FSs that don't support entry->d_type */
+        if (entry->d_type == DT_UNKNOWN)
+            _set_dtype (path, entry);
+
+
 
 	/* If this directory hasn't been modified since the last
 	 * add_files, then we only need to look further for
