Skip to content

[project] Switch most syscalls to golang.org/x/sys#33399

Merged
estesp merged 1 commit intomoby:masterfrom
tophj-ibm:move-all-of-pkg-to-syscall
Jul 11, 2017
Merged

[project] Switch most syscalls to golang.org/x/sys#33399
estesp merged 1 commit intomoby:masterfrom
tophj-ibm:move-all-of-pkg-to-syscall

Conversation

@tophj-ibm
Copy link
Copy Markdown
Contributor

@tophj-ibm tophj-ibm commented May 25, 2017

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

gopher

img src=http://gopherholemuseum.ca

Comment thread pkg/archive/time_unsupported.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally duplicated ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've still got a lot to do, but thanks for the review!

Comment thread pkg/system/events_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Comment thread pkg/system/events_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't be better to just return avoiding the named return? most people are not comfortable with it and it decreases readability

Comment thread pkg/system/syscall_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unmount windows? Wrong replacement?

Comment thread pkg/system/syscall_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong replacement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh sed fail :(

@fntlnz
Copy link
Copy Markdown
Contributor

fntlnz commented May 25, 2017

@tophj-ibm just did some early "macro" review, will try this asap.
Also this needs some gofmt love

14:37:54 These files are not properly gofmt'd:
14:37:54  - pkg/archive/archive_unix.go
14:37:54  - pkg/archive/archive_windows.go

@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch 10 times, most recently from b5091f1 to 630d687 Compare June 2, 2017 18:05
@tophj-ibm
Copy link
Copy Markdown
Contributor Author

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.

@tophj-ibm tophj-ibm changed the title [WIP] Switch all syscalls to golang.org/x/sys [project] Switch most syscalls to golang.org/x/sys Jun 2, 2017
@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch 2 times, most recently from 07d2aec to 92980a8 Compare June 2, 2017 21:26
@thaJeztah
Copy link
Copy Markdown
Member

Thanks @tophj-ibm - I moved this to code review 👍

@cpuguy83
Copy link
Copy Markdown
Member

Looks ok, but needs a rebase.

@GordonTheTurtle
Copy link
Copy Markdown

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ 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 -f

Amending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jun 22, 2017
@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from 7580892 to 165558f Compare June 22, 2017 17:05
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jun 22, 2017
@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from 165558f to 355b367 Compare June 23, 2017 12:29
@tophj-ibm
Copy link
Copy Markdown
Contributor Author

thanks for the review, rebased.

@justincormack
Copy link
Copy Markdown
Contributor

justincormack commented Jun 26, 2017 via email

@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from 519954d to 5bf9143 Compare June 26, 2017 18:34
@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from 5bf9143 to 3035b58 Compare July 6, 2017 13:11
@tophj-ibm
Copy link
Copy Markdown
Contributor Author

rebased again and finally green 😎

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions (but perhaps it's for a reason 😄)

Also needs a minor rebase again 😢

Comment thread daemon/graphdriver/aufs/aufs.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra blank line here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra blank line here (I see there's some other blank lines above as well)

Comment thread pkg/archive/archive_unix_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason syscall.Stat_t is still being used in this file (instead of unix.Stat_t)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. 🤷‍♂️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread pkg/archive/changes_linux.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question (syscall.Stat_t)

Comment thread pkg/archive/changes_unix.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question for this file

@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from 3035b58 to a32ca69 Compare July 10, 2017 13:42
thaJeztah
thaJeztah previously approved these changes Jul 11, 2017
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM see below 😅

@thaJeztah
Copy link
Copy Markdown
Member

oh, oops, looks like it needs a gofmt;

13:55:02 These files are not properly gofmt'd:
13:55:02  - daemon/graphdriver/aufs/aufs.go
13:55:02  - daemon/graphdriver/devmapper/deviceset.go
13:55:02 
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"
 )

@thaJeztah thaJeztah dismissed their stale review July 11, 2017 04:00

missed the gofmt

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]>
@tophj-ibm tophj-ibm force-pushed the move-all-of-pkg-to-syscall branch from a32ca69 to 069fdc8 Compare July 11, 2017 12:00
@tophj-ibm
Copy link
Copy Markdown
Contributor Author

@thaJeztah updated, and back to green

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoop! LGTM

Copy link
Copy Markdown
Contributor

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@estesp estesp merged commit 54251b5 into moby:master Jul 11, 2017
@tiborvass
Copy link
Copy Markdown
Contributor

LGTM

@tiborvass
Copy link
Copy Markdown
Contributor

Lol @estesp was faster <3

@tophj-ibm tophj-ibm deleted the move-all-of-pkg-to-syscall branch July 12, 2017 11:57
tklauser added a commit to tklauser/moby that referenced this pull request Jul 27, 2017
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]>
k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Aug 3, 2017
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
```
@thaJeztah
Copy link
Copy Markdown
Member

@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! 👍

wgliang pushed a commit to wgliang/utils that referenced this pull request Jun 11, 2018
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
```
tamalsaha pushed a commit to kmodules/shared-informer that referenced this pull request Aug 13, 2020
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
tamalsaha pushed a commit to gomodules/jsonpath that referenced this pull request Apr 21, 2021
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
tamalsaha pushed a commit to gomodules/jsonpath that referenced this pull request Apr 21, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants