File kdump-DT_UNKNOWN-fallback-to-stat.patch of Package kdump
From: Petr Tesarik <ptesarik@suse.com>
Subject: Fall back to stat() if file type is DT_UNKNOWN
References: bsc#964206
Patch-mainline: v0.8.16
Git-commit: 479c69b527d70c94e3183836da84be72baa31246
Some file systems (most notably XFS with default options) do not set
the file type in struct dirent.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
kdumptool/fileutil.cc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
--- a/kdumptool/fileutil.cc
+++ b/kdumptool/fileutil.cc
@@ -18,6 +18,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>
@@ -449,7 +450,17 @@ bool FilterDots::test(int dirfd, const s
// -----------------------------------------------------------------------------
bool FilterDotsAndNondirs::test(int dirfd, const struct dirent *d) const
{
- return FilterDots::test(dirfd, d) && d->d_type == DT_DIR;
+ if (!FilterDots::test(dirfd, d))
+ return false;
+ if (d->d_type == DT_DIR)
+ return true;
+ if (d->d_type != DT_UNKNOWN)
+ return false;
+
+ struct stat mystat;
+ if (fstatat(dirfd, d->d_name, &mystat, AT_SYMLINK_NOFOLLOW) != 0)
+ return false;
+ return S_ISDIR(mystat.st_mode);
}
//}}}