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
syscall: linux F_SETLK constant is wrong #7059
Labels
Milestone
Comments
It would break anybody on 32-bit platforms using F_SETLK incorrectly where they had meant F_SETLK64. For instance, this bad program would start breaking: k := struct { Type uint32 Whence uint32 Start uint64 Len uint64 Pid uint32 }{ Type: syscall.F_WRLCK, Whence: uint32(os.SEEK_SET), Start: 0, Len: 0, // whole file Pid: uint32(os.Getpid()), } _, _, errno := syscall.Syscall(syscall.SYS_FCNTL64, f.Fd(), uintptr(syscall.F_SETLK), // <--- whoops. User meant F_SETLK64. uintptr(unsafe.Pointer(&k))) |
On GNU/Linux F_GETLK vs. F_GETLK64 depends not on the system call number, but on the version of the flock struct that is used. That struct has Start and Len fields that (on a 32 bit system) are either 32 bit (for F_GETLK) or 64 bit (for F_GETLK64). So I think the right thing to do is to implement Flock in the syscall package, and define it to match the version of F_GETLK. That should happen automatically if we add Flock to pkg/syscall/types_linux.go. |
https://golang.org/cl/53350043 Labels changed: added repo-main, release-go1.3. Owner changed to @bradfitz. Status changed to Started. |
This issue was updated by revision 055b588. R=golang-codereviews, dave, iant CC=golang-codereviews https://golang.org/cl/53350043 |
Sent https://golang.org/cl/53470043 after looking at this with Ian. If we're going to have a 64-bit Go syscall.Lock_t type for all POSIX platforms, it would be nice to have a syscall number name that we could use to use it. Unfortunately, the correct syscall name varies by system... either FCNTL or FCNTL64. So we should have a func or method to do a fcntl lock. The CL above adds a method to Lock_t. |
This issue was closed by revision 5d3033c. Status changed to Fixed. |
This issue was updated by revision 367ad45. R=rsc CC=golang-codereviews https://golang.org/cl/55370043 |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: