[project] Switch most syscalls to golang.org/x/sys#33399
Conversation
There was a problem hiding this comment.
Is this intentionally duplicated ?
There was a problem hiding this comment.
Yeah, this will cover the freebsd / solaris case. It's not ideal because I only really need 2 files instead of 3, but these already existed and seemed like a good place for them anyway.
There was a problem hiding this comment.
I've still got a lot to do, but thanks for the review!
There was a problem hiding this comment.
wouldn't be better to just return avoiding the named return? most people are not comfortable with it and it decreases readability
There was a problem hiding this comment.
the unmount windows? Wrong replacement?
|
@tophj-ibm just did some early "macro" review, will try this asap. |
b5091f1 to
630d687
Compare
|
Okay the tests appear to be going, and all the work should be done here, I'm going to move this out of WIP. cc @thaJeztah because this touches the pkg directory, @vieux @dnephin you might want to take a look. |
07d2aec to
92980a8
Compare
|
Thanks @tophj-ibm - I moved this to code review 👍 |
|
Looks ok, but needs a rebase. |
|
Please sign your commits following these rules: $ git clone -b "move-all-of-pkg-to-syscall" [email protected]:tophj-ibm/moby.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353877392
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
7580892 to
165558f
Compare
165558f to
355b367
Compare
|
thanks for the review, rebased. |
|
The casting rules are different if you assign to a variable first, weirdly.
An extra cast seems ok.
…On 26 Jun 2017 15:55, "Christopher Jones" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/system/utimes_linux.go
<#33399 (comment)>:
> if err != nil {
return err
}
- if _, _, err := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(atSymLinkNoFollow), 0, 0); err != 0 && err != syscall.ENOSYS {
+ if _, _, err := unix.Syscall6(unix.SYS_UTIMENSAT, uintptr(unix.AT_FDCWD), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(unix.AT_SYMLINK_NOFOLLOW), 0, 0); err != 0 && err != unix.ENOSYS {
@cpuguy83 <https://github.com/cpuguy83> go question: do you have any idea
why both unix.AT_FDCWD and the old atFdCwd would both reflect as type int,
but only the former throws an error here?
I can get this to work if I cast unix.AT_FDCWD to an int beforehand, but
I'm pretty sure that's just because it's bypassing the type checker.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#33399 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAdcPCTXz83AZ3yOypLyynFwZwUoX3T2ks5sH8ZjgaJpZM4Nmc11>
.
|
519954d to
5bf9143
Compare
5bf9143 to
3035b58
Compare
|
rebased again and finally green 😎 |
thaJeztah
left a comment
There was a problem hiding this comment.
Some questions (but perhaps it's for a reason 😄)
Also needs a minor rebase again 😢
There was a problem hiding this comment.
nit: extra blank line here (I see there's some other blank lines above as well)
There was a problem hiding this comment.
Any reason syscall.Stat_t is still being used in this file (instead of unix.Stat_t)?
There was a problem hiding this comment.
Yes, it's because os.Stat().Sys() implements type syscall.Stat_t and not unix.Stat_t. The difference is unix.Stat_t doesn't have additional padding at the end. There are multiple asserts to make sure it's of type syscall.Stat_t, so those fail.
I could probably remove all of the type assertions looking for syscall.Stat_t, but I wasn't sure if that would mess up anything else and this seemed fine. I can look more into changing it if you think that's better. 🤷♂️
There was a problem hiding this comment.
difference is unix.Stat_t doesn't have additional padding at the end
Oh, I see it now, they looked so similar 😊
I could probably remove all of the type assertions looking for syscall.Stat_t
It's fine to keep it as-is for this PR. Thanks for explaining!
There was a problem hiding this comment.
same question (syscall.Stat_t)
3035b58 to
a32ca69
Compare
|
oh, oops, looks like it needs a gofmt; diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go
index b04aede71..c68c98cf8 100644
--- a/daemon/graphdriver/aufs/aufs.go
+++ b/daemon/graphdriver/aufs/aufs.go
@@ -36,7 +36,6 @@ import (
"time"
"github.com/Sirupsen/logrus"
- "github.com/vbatts/tar-split/tar/storage"
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/chrootarchive"
@@ -47,6 +46,7 @@ import (
"github.com/docker/docker/pkg/system"
rsystem "github.com/opencontainers/runc/libcontainer/system"
"github.com/opencontainers/selinux/go-selinux/label"
+ "github.com/vbatts/tar-split/tar/storage"
"golang.org/x/sys/unix"
)
diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go
index ca9e67906..522277936 100644
--- a/daemon/graphdriver/devmapper/deviceset.go
+++ b/daemon/graphdriver/devmapper/deviceset.go
@@ -28,8 +28,8 @@ import (
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/parsers"
units "github.com/docker/go-units"
- "github.com/pkg/errors"
"github.com/opencontainers/selinux/go-selinux/label"
+ "github.com/pkg/errors"
"golang.org/x/sys/unix"
) |
Changes most references of syscall to golang.org/x/sys/ Ones aren't changes include, Errno, Signal and SysProcAttr as they haven't been implemented in /x/sys/. Signed-off-by: Christopher Jones <[email protected]> [s390x] switch utsname from unsigned to signed per golang/sys@33267e0 char in s390x in the /x/sys/unix package is now signed, so change the buildtags Signed-off-by: Christopher Jones <[email protected]>
a32ca69 to
069fdc8
Compare
|
@thaJeztah updated, and back to green |
|
LGTM |
|
Lol @estesp was faster <3 |
Switch some more usage of the Stat function and the Stat_t type from the syscall package to golang.org/x/sys. Those were missing in PR moby#33399. Signed-off-by: Tobias Klauser <[email protected]>
Automatic merge from submit-queue Switch from package syscall to golang.org/x/sys/unix **What this PR does / why we need it**: The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes without having to use a new go version. In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function. **Special notes for your reviewer**: This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588 **Release note**: ```release-note NONE ```
|
@bcmills don't know if there was a specific reason, other than that the "freebsd" code was contributed 3 .. 4 years ago, but never reached completion. If you're interested to help out on making those changes, please do! 👍 |
Automatic merge from submit-queue Switch from package syscall to golang.org/x/sys/unix **What this PR does / why we need it**: The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes without having to use a new go version. In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function. **Special notes for your reviewer**: This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588 **Release note**: ```release-note NONE ```
Automatic merge from submit-queue Switch from package syscall to golang.org/x/sys/unix **What this PR does / why we need it**: The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes without having to use a new go version. In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function. **Special notes for your reviewer**: This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588 **Release note**: ```release-note NONE ``` Kubernetes-commit: 5d24a2c19923d6da46110b827619f4b21cf689ac
Automatic merge from submit-queue Switch from package syscall to golang.org/x/sys/unix **What this PR does / why we need it**: The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes without having to use a new go version. In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function. **Special notes for your reviewer**: This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588 **Release note**: ```release-note NONE ``` Kubernetes-commit: 5d24a2c19923d6da46110b827619f4b21cf689ac
Automatic merge from submit-queue Switch from package syscall to golang.org/x/sys/unix **What this PR does / why we need it**: The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes without having to use a new go version. In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function. **Special notes for your reviewer**: This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588 **Release note**: ```release-note NONE ``` Kubernetes-commit: 5d24a2c19923d6da46110b827619f4b21cf689ac
The go syscall package has been frozen since go1.4. Any new features, and most updates for syscall are implemented in the golang.org/x/sys package instead. This is a WIP to change over all syscall references to /x/sys. This is called "most" syscall because of three exclusions that haven't been implemented yet are syscall.Errno, Signal, and SysProcAttr For more info see #31925
The original plan was to convert just pkg (which I've already done here) but the unit tests won't pass until I change most of everything so I'm going to do it all at the same time here.
While most of the code is more or less find and replace, some sections will have to be split. Where syscall would work on both windows + unix, /x/sys does not, so windows and unix logic will have to split.
Some other differences I've found that need to be addressed here:
1.) s390x forces signed char in /x/sys/unix, so change the buildtags for s390x in /pkg/platform/utsname per golang/sys@33267e0
img src=http://gopherholemuseum.ca