From 4d213b31b890011f120146f0d760d7ffd70f75b9 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 8 Oct 2015 16:39:49 +0200 Subject: nlplug-findfs: fix recursing dirs on isofs the dirent d_type is not supported on isofs apparently. Use lstat instead. --- nlplug-findfs.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'nlplug-findfs.c') diff --git a/nlplug-findfs.c b/nlplug-findfs.c index d4ef606..9d68cfa 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -274,7 +274,17 @@ void recurse_dir(const char *dir, struct recurse_opts *opts) while ((entry = readdir(d)) != NULL) { char path[PATH_MAX]; - if (entry->d_type & DT_DIR) { + struct stat st; + + /* d_type is not supported by all filesystems so we need + lstat */ + snprintf(path, sizeof(path), "%s/%s", dir, entry->d_name); + if (lstat(path, &st) < 0) { + dbg("%s: %s", path, strerror(errno)); + continue; + } + + if (S_ISDIR(st.st_mode)) { if (entry->d_name[0] == '.') continue; } else if (opts->searchname @@ -282,8 +292,7 @@ void recurse_dir(const char *dir, struct recurse_opts *opts) continue; } - snprintf(path, sizeof(path), "%s/%s", dir, entry->d_name); - if (entry->d_type & DT_DIR) + if (S_ISDIR(st.st_mode)) recurse_dir(path, opts); else opts->callback(path, opts->userdata); -- cgit v1.2.3