8000 [project] change syscall to /x/sys/unix|windows · thaJeztah/docker@069fdc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 069fdc8

8000 Browse files
committed
[project] change syscall to /x/sys/unix|windows
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 <tophj@linux.vnet.ibm.com> [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 <tophj@linux.vnet.ibm.com>
1 parent 6978a6e commit 069fdc8

File tree

93 files changed

+499
-474
lines changed

Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"net"
88
"os"
99
"path/filepath"
10-
"syscall"
1110

1211
"github.com/docker/docker/libcontainerd"
1312
"github.com/docker/docker/pkg/system"
13+
"golang.org/x/sys/unix"
1414
)
1515

1616
const defaultDaemonConfigFile = ""
@@ -30,8 +30,8 @@ func currentUserIsOwner(f string) bool {
3030
// caused by custom umask
3131
func setDefaultUmask() error {
3232
desiredUmask := 0022
33-
syscall.Umask(desiredUmask)
34-
if umask := syscall.Umask(desiredUmask); umask != desiredUmask {
33+
unix.Umask(desiredUmask)
34+
if umask := unix.Umask(desiredUmask); umask != desiredUmask {
3535
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask)
3636
}
3737

Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
"os/signal"
1010
"path/filepath"
1111
"strconv"
12-
"syscall"
1312

1413
"github.com/docker/docker/cmd/dockerd/hack"
1514
"github.com/docker/docker/daemon"
1615
"github.com/docker/docker/libcontainerd"
1716
"github.com/docker/libnetwork/portallocator"
17+
"golang.org/x/sys/unix"
1818
)
1919

2020
const defaultDaemonConfigFile = "/etc/docker/daemon.json"
@@ -23,8 +23,8 @@ const defaultDaemonConfigFile = "/etc/docker/daemon.json"
2323
// caused by custom umask
2424
func setDefaultUmask() error {
2525
desiredUmask := 0022
26-
syscall.Umask(desiredUmask)
27-
if umask := syscall.Umask(desiredUmask); umask != desiredUmask {
26+
unix.Umask(desiredUmask)
27+
if umask := unix.Umask(desiredUmask); umask != desiredUmask {
2828
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask)
2929
}
3030

@@ -38,7 +38,7 @@ func getDaemonConfDir(_ string) string {
3838
// setupConfigReloadTrap configures the USR2 signal to reload the configuration.
3939
func (cli *DaemonCli) setupConfigReloadTrap() {
4040
c := make(chan os.Signal, 1)
41-
signal.Notify(c, syscall.SIGHUP)
41+
signal.Notify(c, unix.SIGHUP)
4242
go func() {
4343
for range c {
4444
cli.reloadConfig()

Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"net"
66
"os"
77
"path/filepath"
8-
"syscall"
98

109
"github.com/Sirupsen/logrus"
1110
"github.com/docker/docker/libcontainerd"
1211
"github.com/docker/docker/pkg/system"
12+
"golang.org/x/sys/windows"
1313
)
1414

1515
var defaultDaemonConfigFile = ""
@@ -58,14 +58,14 @@ func notifyShutdown(err error) {
5858
// setupConfigReloadTrap configures a Win32 event to reload the configuration.
5959
func (cli *DaemonCli) setupConfigReloadTrap() {
6060
go func() {
61-
sa := syscall.SecurityAttributes{
61+
sa := windows.SecurityAttributes{
6262
Length: 0,
6363
}
6464
ev := "Global\\docker-daemon-config-" + fmt.Sprint(os.Getpid())
6565
if h, _ := system.CreateEvent(&sa, false, false, ev); h != 0 {
6666
logrus.Debugf("Config reload - waiting signal at %s", ev)
6767
for {
68-
syscall.WaitForSingleObject(h, syscall.INFINITE)
68+
windows.WaitForSingleObject(h, windows.INFINITE)
6969
cli.reloadConfig()
7070
}
7171
}

Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os"
1010
"os/exec"
1111
"path/filepath"
12-
"syscall"
1312
"time"
1413
"unsafe"
1514

@@ -30,7 +29,7 @@ var (
3029
flRunService *bool
3130

3231
setStdHandle = windows.NewLazySystemDLL("kernel32.dll").NewProc("SetStdHandle")
33-
oldStderr syscall.Handle
32+
oldStderr windows.Handle
3433
panicFile *os.File
3534

3635
service *handler
@@ -131,14 +130,14 @@ func (h *etwHook) Fire(e *logrus.Entry) error {
131130
err error
132131
)
133132

134-
ss[0], err = syscall.UTF16PtrFromString(e.Message)
133+
ss[0], err = windows.UTF16PtrFromString(e.Message)
135134
if err != nil {
136135
return err
137136
}
138137

139138
count := uint16(1)
140139
if exts != "" {
141-
ss[1], err = syscall.UTF16PtrFromString(exts)
140+
ss[1], err = windows.UTF16PtrFromString(exts)
142141
if err != nil {
143142
return err
144143
}
@@ -397,8 +396,8 @@ func initPanicFile(path string) error {
397396
// Update STD_ERROR_HANDLE to point to the panic file so that Go writes to
398397
// it when it panics. Remember the old stderr to restore it before removing
399398
// the panic file.
400-
sh := syscall.STD_ERROR_HANDLE
401-
h, err := syscall.GetStdHandle(sh)
399+
sh := windows.STD_ERROR_HANDLE
400+
h, err := windows.GetStdHandle(sh)
402401
if err != nil {
403402
return err
404403
}
@@ -422,7 +421,7 @@ func initPanicFile(path string) error {
422421
func removePanicFile() {
423422
if st, err := panicFile.Stat(); err == nil {
424423
if st.Size() == 0 {
425-
sh := syscall.STD_ERROR_HANDLE
424+
sh := windows.STD_ERROR_HANDLE
426425
setStdHandle.Call(uintptr(sh), uintptr(oldStderr))
427426
panicFile.Close()
428427
os.Remove(panicFile.Name())

Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os"
1010
"path/filepath"
1111
"strconv"
12-
"syscall"
1312
"time"
1413

1514
"github.com/Sirupsen/logrus"
@@ -22,6 +21,7 @@ import (
2221
"github.com/docker/libnetwork"
2322
"github.com/opencontainers/selinux/go-selinux/label"
2423
"github.com/pkg/errors"
24+
"golang.org/x/sys/unix"
2525
)
2626

2727
func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
@@ -125,7 +125,7 @@ func (daemon *Daemon) setupIpcDirs(c *container.Container) error {
125125
shmSize = c.HostConfig.ShmSize
126126
}
127127
shmproperty := "mode=1777,size=" + strconv.FormatInt(shmSize, 10)
128-
if err := syscall.Mount("shm", shmPath, "tmpfs", uintptr(syscall.MS_NOEXEC|syscall.MS_NOSUID|syscall.MS_NODEV), label.FormatMountLabel(shmproperty, c.GetMountLabel())); err != nil {
128+
if err := unix.Mount("shm", shmPath, "tmpfs", uintptr(unix.MS_NOEXEC|unix.MS_NOSUID|unix.MS_NODEV), label.FormatMountLabel(shmproperty, c.GetMountLabel())); err != nil {
129129
return fmt.Errorf("mounting shm tmpfs: %s", err)
130130
}
131131
if err := os.Chown(shmPath, rootIDs.UID, rootIDs.GID); err != nil {
@@ -301,8 +301,8 @@ func killProcessDirectly(cntr *container.Container) error {
301301
// Ensure that we don't kill ourselves
302302
if pid := cntr.GetPID(); pid != 0 {
303303
logrus.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", stringid.TruncateID(cntr.ID))
304-
if err := syscall.Kill(pid, 9); err != nil {
305-
if err != syscall.ESRCH {
304+
if err := unix.Kill(pid, 9); err != nil {
305+
if err != unix.ESRCH {
306306
return err
307307
}
308308
e := errNoSuchProcess{pid, 9}
@@ -315,7 +315,7 @@ func killProcessDirectly(cntr *container.Container) error {
315315
}
316316

317317
func detachMounted(path string) error {
318-
return syscall.Unmount(path, syscall.MNT_DETACH)
318+
return unix.Unmount(path, unix.MNT_DETACH)
319319
}
320320

321321
func isLinkable(child *container.Container) bool {

Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ package daemon
55
import (
66
"os"
77
"os/signal"
8-
"syscall"
98

109
"github.com/Sirupsen/logrus"
1110
stackdump "github.com/docker/docker/pkg/signal"
11+
"golang.org/x/sys/unix"
1212
)
1313

1414
func (d *Daemon) setupDumpStackTrap(root string) {
1515
c := make(chan os.Signal, 1)
16-
signal.Notify(c, syscall.SIGUSR1)
16+
signal.Notify(c, unix.SIGUSR1)
1717
go func() {
1818
for range c {
1919
path, err := stackdump.DumpStacks(root)

Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package daemon
33
import (
44
"fmt"
55
"os"
6-
"syscall"
76
"unsafe"
87

98
winio "github.com/Microsoft/go-winio"
109
"github.com/Sirupsen/logrus"
1110
"github.com/docker/docker/pkg/signal"
1211
"github.com/docker/docker/pkg/system"
12+
"golang.org/x/sys/windows"
1313
)
1414

1515
func (d *Daemon) setupDumpStackTrap(root string) {
@@ -22,7 +22,7 @@ func (d *Daemon) setupDumpStackTrap(root string) {
2222
logrus.Errorf("failed to get security descriptor for debug stackdump event %s: %s", ev, err.Error())
2323
return
2424
}
25-
var sa syscall.SecurityAttributes
25+
var sa windows.SecurityAttributes
2626
sa.Length = uint32(unsafe.Sizeof(sa))
2727
sa.InheritHandle = 1
2828
sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0]))
@@ -34,7 +34,7 @@ func (d *Daemon) setupDumpStackTrap(root string) {
3434
go func() {
3535
logrus.Debugf("Stackdump - waiting signal at %s", ev)
3636
for {
37-
syscall.WaitForSingleObject(h, syscall.INFINITE)
37+
windows.WaitForSingleObject(h, windows.INFINITE)
3838
path, err := signal.DumpStacks(root)
3939
if err != nil {
4040
logrus.WithError(err).Error("failed to write goroutines dump")

Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ import (
3333
"path/filepath"
3434
"strings"
3535
"sync"
36-
"syscall"
3736
"time"
3837

3938
"github.com/Sirupsen/logrus"
40-
"github.com/vbatts/tar-split/tar/storage"
41-
4239
"github.com/docker/docker/daemon/graphdriver"
4340
"github.com/docker/docker/pkg/archive"
4441
"github.com/docker/docker/pkg/chrootarchive"
@@ -47,9 +44,10 @@ import (
4744
"github.com/docker/docker/pkg/locker"
4845
mountpk "github.com/docker/docker/pkg/mount"
4946
"github.com/docker/docker/pkg/system"
50-
5147
rsystem "github.com/opencontainers/runc/libcontainer/system"
5248
"github.com/opencontainers/selinux/go-selinux/label"
49+
"github.com/vbatts/tar-split/tar/storage"
50+
"golang.org/x/sys/unix"
5351
)
5452

5553
var (
@@ -295,7 +293,7 @@ func (a *Driver) Remove(id string) error {
295293
}
296294

297295
if err := a.unmount(mountpoint); err != nil {
298-
if err != syscall.EBUSY {
296+
if err != unix.EBUSY {
299297
return fmt.Errorf("aufs: unmount error: %s: %v", mountpoint, err)
300298
}
301299
if retries >= 5 {
@@ -315,7 +313,7 @@ func (a *Driver) Remove(id string) error {
315313
// the whole tree.
316314
tmpMntPath := path.Join(a.mntPath(), fmt.Sprintf("%s-removing", id))
317315
if err := os.Rename(mountpoint, tmpMntPath); err != nil && !os.IsNotExist(err) {
318-
if err == syscall.EBUSY {
316+
if err == unix.EBUSY {
319317
logrus.Warn("os.Rename err due to EBUSY")
320318
}
321319
return err
@@ -575,7 +573,7 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro
575573
if useDirperm() {
576574
offset += len(",dirperm1")
577575
}
578-
b := make([]byte, syscall.Getpagesize()-len(mountLabel)-offset) // room for xino & mountLabel
576+
b := make([]byte, unix.Getpagesize()-len(mountLabel)-offset) // room for xino & mountLabel
579577
bp := copy(b, fmt.Sprintf("br:%s=rw", rw))
580578

581579
index := 0
@@ -599,7 +597,7 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro
599597
for ; index < len(ro); index++ {
600598
layer := fmt.Sprintf(":%s=ro+wh", ro[index])
601599
data := label.FormatMountLabel(fmt.Sprintf("append%s", layer), mountLabel)
602-
if err = mount("none", target, "aufs", syscall.MS_REMOUNT, data); err != nil {
600+
if err = mount("none", target, "aufs", unix.MS_REMOUNT, data); err != nil {
603601
return
604602
}
605603
}

Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ package aufs
44

55
import (
66
"os/exec"
7-
"syscall"
87

98
"github.com/Sirupsen/logrus"
9+
"golang.org/x/sys/unix"
1010
)
1111

1212
// Unmount the target specified.
1313
func Unmount(target string) error {
1414
if err := exec.Command("auplink", target, "flush").Run(); err != nil {
1515
logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err)
1616
}
17-
if err := syscall.Unmount(target, 0); err != nil {
17+
if err := unix.Unmount(target, 0); err != nil {
1818
return err
1919
}
2020
return nil
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package aufs
22

3-
import "syscall"
3+
import "golang.org/x/sys/unix"
44

55
func mount(source string, target string, fstype string, flags uintptr, data string) error {
6-
return syscall.Mount(source, target, fstype, flags, data)
6+
return unix.Mount(source, target, fstype, flags, data)
77
}