Skip to content

GetFileSystemEntries() causes each file to be stat'd even if the only thing we need are the paths #31301

@antiufo

Description

@antiufo

Original issue: PowerShell/PowerShell#10816.
It seems like the root cause is that string[] IO.Directory.GetFileSystemEntries() calls stat() on each entry to retrieve additional metadata, even though the only thing that method is requesting is the path, which should readily be available in the data provided by readdir().

This can be observed by running strace -f -tt -o trace.txt pwsh -noprofile -c '$a = [IO.Directory]::GetFileSystemEntries("/usr/bin")'

I quickly looked at the code and it seems like additional metadata should be retrieved lazily in FileSystemEntry.Unix.cs/FileStatus.Unix.cs (which is a reasonable thing to do), but I could be wrong. Is there something that is unexpectedly triggering stat()?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions