-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: O_PATH & O_TMPFILE aren't defined on Linux #7830
Labels
Milestone
Comments
mikioh
changed the title
go.sys/unix: O_PATH & O_TMPFILE aren't defined on Linux
unix: O_PATH & O_TMPFILE aren't defined on Linux
Jan 7, 2015
rsc
changed the title
unix: O_PATH & O_TMPFILE aren't defined on Linux
x/sys/unix: O_PATH & O_TMPFILE aren't defined on Linux
Apr 14, 2015
wking
added a commit
to ipfs/kubo
that referenced
this issue
Jun 24, 2015
On Linux, open() will follow symlinks unless you use the O_NOFOLLOW flag (added in Linux 2.1.126). Then it will error out with ELOOP unless you've set O_PATH. Unfortunately, Go doesn't define O_PATH and has no plans to do so [1]. The other tricky bit here is extracting the errno [2] from the *PathError [3] returned by os.Open [4]. The new files.Errno tries to cast the error instance to an *os.PathError. If that succeeds, it looks at the *os.PathError's Err attribute and tries to cast that to an Errno. If that succeeds it returns the extracted errno. With this commit, we now have File object for the symlinks with the correct filename and mode. I've also created a string-based reader to pass along the link target, so the adder will have it available when it gains support for these types of files. [1]: golang/go#7830 [2]: https://golang.org/pkg/syscall/#Errno [3]: https://golang.org/pkg/os/#PathError [4]: https://golang.org/pkg/os/#Open License: MIT Signed-off-by: W. Trevor King <wking@tremily.us>
O_PATH is already exported. I've made a CL for O_TMPFILE: https://go-review.googlesource.com/#/c/21003/ |
CL https://golang.org/cl/21003 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by joejob357:
The text was updated successfully, but these errors were encountered: