runtime: Directory.EnumerateDirectories doesn't return directory list on rhel7.2
From @jainaashish on April 7, 2018 0:18
I’ve created a simple application to demonstrate the issue where Directory.EnumerateDirectories
api doesn’t return the list of child directories on rhel 7.2, although it works fine on Windows or Ubuntu.
Sample Project - https://github.com/jainaashish/CoreClrIssue/tree/master/EnumerateDirectoriesIssue/EnumerateDirectoriesIssue
Copied from original issue: dotnet/coreclr#17465
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (24 by maintainers)
@anipik I think we can set this issue aside now. It is fully understood and fixed.
For future reference, this only reproes on XFS if ftype=0, eg in my case:
This is set at the time the volume is created with mkfs.
The problem is we are seeing directories as files. We call readdir and check whether the d_type is DT_DIR.
The issue is that these machines have XFS file system, on which readdir returns a d_type of DT_UNKNOWN for both files and directories.
In 2.0 encountering DT_UNKNOWN we then fell back to calling lstat to find out whether it’s a directory - as the docs for readdir say we should. https://github.com/dotnet/corefx/blob/release/2.0.0/src/System.IO.FileSystem/src/System/IO/UnixFileSystem.cs#L614-L630
In 2.1 we only do this for DT_LNK. https://github.com/dotnet/corefx/blob/AddAlpine3.8/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.Unix.cs#L47
@Anipik can you please make this your first priority as we need to know whether there is a 2.1 bug.