From b3e55b246d16e2a9f0ea67a814c1e3566a8e36ab Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 23 Jul 2018 22:58:46 +0000 Subject: [PATCH] Handle DT_UNKNOWN correctly during directory iteration. Unlike stat and lstat, where unknown really means we know it's something weird, during directory iteration DT_UNKNOWN simply means that the underlying FS doesn't support the dirent::dt_type field. This patch fixes libc++ to correctly set the cache to empty when DT_UNKNOWN is reported. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337768 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/experimental/filesystem/directory_iterator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/experimental/filesystem/directory_iterator.cpp b/src/experimental/filesystem/directory_iterator.cpp index c95ebc8ac..7a1ab2573 100644 --- a/src/experimental/filesystem/directory_iterator.cpp +++ b/src/experimental/filesystem/directory_iterator.cpp @@ -42,8 +42,11 @@ static file_type get_file_type(DirEntT *ent, int) { return file_type::regular; case DT_SOCK: return file_type::socket; + // Unlike in lstat, hitting "unknown" here simply means that the underlying + // filesystem doesn't support d_type. Report is as 'none' so we correctly + // set the cache to empty. case DT_UNKNOWN: - return file_type::unknown; + break; } return file_type::none; }