-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
$ go version devel go1.22-98bacdeafe Mon Aug 14 12:51:16 2023 +0000
Does this issue reproduce with the latest release?
Yes.
What did you do?
- Use
os.Opento open anos.Filefor a relative directory. - Call
os.Chdirto change the current working directory. - Call
ReadDirorReaddiron theFileopened in step (1). - Inspect the resulting
FileInfos.
(https://go.dev/play/p/bLLMvUJGu_u?v=gotip)
What did you expect to see?
The FileInfos should correspond to the directory entries relative to the File.
What did you see instead?
On Linux:
ReadDirproduces the directory contents relative to the current directory instead of the opened file.ReaddirproducesDirEntrycontents relative to the opened file, but calling theInfomethod on those entries attempts to open the wrong paths (compare os: File.Stat on Windows doesn't use file handle for directories #52747).
It isn't clear to me how this can be fixed in general — it is possible to use fdopendir to read the correct entries while the parent file is still open, but if the parent file is closed before the Info method is called on the returned DirEntry, I don't see a standard API to reliably open the correct path.
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.