-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: NsecToTimeval does not handle times before 1970 #12777
Comments
This breaks setting of file timestamps in go-fuse, downstream bug: hanwen/go-fuse#58 |
What do you think should happen? It seems to me that having the kernel return EINVAL is correct. |
|
Testcase: https://gist.github.com/rfjakob/6d3359a97d22f32083bc
tv.Sec and tv.Usec are both wrong. It should be:
|
nsectotimeval should do if (tv.usec < 0) { |
the same holds for NsecToTimeSpec. func main() {
} |
I can prepare a patch if you want. |
@hanwen I think the rounding should also be the other way round if nsec is negative I noticed that the Linux kernel rounds DOWN while we round UP, check out http://lxr.free-electrons.com/source/kernel/time/time.c#L422 . This is unrelated, but it may be an opportunity to fix this as well. |
syscall.NsecToTimespec does not work properly for times before 1970, see golang/go#12777 This caused xfstests generic/258 to fail. Fixes issue hanwen#58.
syscall.NsecToTimespec does not work properly for times before 1970, see golang/go#12777 This caused xfstests generic/258 to fail. Fixes issue hanwen#58.
syscall.NsecToTimespec does not work properly for times before 1970, see golang/go#12777 This caused xfstests generic/258 to fail. Fixes issue hanwen#58.
Ping? NsecToTimeval is still broken. |
For dates before 1970, syscall.NsecToTimespec() incorrectly returns negative nanoseconds. Ticket: golang/go#12777 Handle that case by zeroing out Nsec if it is negative, but otherwise keep the value. This makes nanoseconds work for the vast majority of use cases.
CL https://golang.org/cl/30705 mentions this issue. |
Fixed by 6c517df |
Passing a time before 1970 means that
nsec
is negative.This means that the rounding will not work properly, and the returned
tv.Usec
will be negative.A negative
tv.Usec
is invalid and rejected by the Linux kernel withEINVAL
.Source code for reference: https://github.com/golang/go/blob/master/src/syscall/syscall_linux_amd64.go#L96
The text was updated successfully, but these errors were encountered: