Skip to content

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

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()?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions