Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/unix: file type information from dirents inaccessible #14856

Open
dbentley opened this issue Mar 18, 2016 · 2 comments
Open

x/sys/unix: file type information from dirents inaccessible #14856

dbentley opened this issue Mar 18, 2016 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@dbentley
Copy link

golang.org/x/sys/unix.ReadDirent reads a Dirent that includes the filename and the file type. golang.org/x/sys/unix.ParseDirent parses out the filename.

Linux and OSX include the file type in the Dirent. Go should make this information accessible. This info would let programs skip stat'ing files of the wrong type.

It would not be feasible to change ParseDirent to do so because it would require a type signature change.

If we can agree on a plan, I can (try to) make the code change.

Here's my proposal, but I've never made a change to Go so it may be off-base.

The package unix could offer a func like "ParseDirentFully" that returned a struct or interface that offered all dirent members available. ParseDirent could call ParseDirentFully to return just the name. (The naming could be better, e.g. ParseDirent and ParseNameFromDirent, but that would break existing code) The code in syscall_*.go already casts to the dirent type from the underlying FS, so it could access another member.

(I am using go 1.5.1 on darwin/amd64. I have inspected code on tip and believe this issue still applies)

@minux
Copy link
Member

minux commented Mar 18, 2016 via email

@bradfitz bradfitz modified the milestone: Unreleased Apr 7, 2016
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
Status: Triage Backlog
Development

No branches or pull requests

5 participants