diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-08 16:39:49 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-08 16:39:49 +0200 |
commit | 4d213b31b890011f120146f0d760d7ffd70f75b9 (patch) | |
tree | 0a45b7762f017147089ee949f3e99e849e32e7ed /nlplug-findfs.c | |
parent | 17b72a447b7524e66729d31d598ba473bbda7324 (diff) | |
download | mkinitfs-4d213b31b890011f120146f0d760d7ffd70f75b9.tar.bz2 mkinitfs-4d213b31b890011f120146f0d760d7ffd70f75b9.tar.xz |
nlplug-findfs: fix recursing dirs on isofs
the dirent d_type is not supported on isofs apparently. Use lstat
instead.
Diffstat (limited to 'nlplug-findfs.c')
-rw-r--r-- | nlplug-findfs.c | 15 |
1 files changed, 12 insertions, 3 deletions
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); |