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 https://github.com/golang/sys/commit/33267e036fd93fcd26ea95b7bdaf2d8306cb743c
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>
... | ... |
@@ -7,10 +7,10 @@ import ( |
7 | 7 |
"net" |
8 | 8 |
"os" |
9 | 9 |
"path/filepath" |
10 |
- "syscall" |
|
11 | 10 |
|
12 | 11 |
"github.com/docker/docker/libcontainerd" |
13 | 12 |
"github.com/docker/docker/pkg/system" |
13 |
+ "golang.org/x/sys/unix" |
|
14 | 14 |
) |
15 | 15 |
|
16 | 16 |
const defaultDaemonConfigFile = "" |
... | ... |
@@ -30,8 +30,8 @@ func currentUserIsOwner(f string) bool { |
30 | 30 |
// caused by custom umask |
31 | 31 |
func setDefaultUmask() error { |
32 | 32 |
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 { |
|
35 | 35 |
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask) |
36 | 36 |
} |
37 | 37 |
|
... | ... |
@@ -9,12 +9,12 @@ import ( |
9 | 9 |
"os/signal" |
10 | 10 |
"path/filepath" |
11 | 11 |
"strconv" |
12 |
- "syscall" |
|
13 | 12 |
|
14 | 13 |
"github.com/docker/docker/cmd/dockerd/hack" |
15 | 14 |
"github.com/docker/docker/daemon" |
16 | 15 |
"github.com/docker/docker/libcontainerd" |
17 | 16 |
"github.com/docker/libnetwork/portallocator" |
17 |
+ "golang.org/x/sys/unix" |
|
18 | 18 |
) |
19 | 19 |
|
20 | 20 |
const defaultDaemonConfigFile = "/etc/docker/daemon.json" |
... | ... |
@@ -23,8 +23,8 @@ const defaultDaemonConfigFile = "/etc/docker/daemon.json" |
23 | 23 |
// caused by custom umask |
24 | 24 |
func setDefaultUmask() error { |
25 | 25 |
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 { |
|
28 | 28 |
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask) |
29 | 29 |
} |
30 | 30 |
|
... | ... |
@@ -38,7 +38,7 @@ func getDaemonConfDir(_ string) string { |
38 | 38 |
// setupConfigReloadTrap configures the USR2 signal to reload the configuration. |
39 | 39 |
func (cli *DaemonCli) setupConfigReloadTrap() { |
40 | 40 |
c := make(chan os.Signal, 1) |
41 |
- signal.Notify(c, syscall.SIGHUP) |
|
41 |
+ signal.Notify(c, unix.SIGHUP) |
|
42 | 42 |
go func() { |
43 | 43 |
for range c { |
44 | 44 |
cli.reloadConfig() |
... | ... |
@@ -5,11 +5,11 @@ import ( |
5 | 5 |
"net" |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 |
- "syscall" |
|
9 | 8 |
|
10 | 9 |
"github.com/Sirupsen/logrus" |
11 | 10 |
"github.com/docker/docker/libcontainerd" |
12 | 11 |
"github.com/docker/docker/pkg/system" |
12 |
+ "golang.org/x/sys/windows" |
|
13 | 13 |
) |
14 | 14 |
|
15 | 15 |
var defaultDaemonConfigFile = "" |
... | ... |
@@ -58,14 +58,14 @@ func notifyShutdown(err error) { |
58 | 58 |
// setupConfigReloadTrap configures a Win32 event to reload the configuration. |
59 | 59 |
func (cli *DaemonCli) setupConfigReloadTrap() { |
60 | 60 |
go func() { |
61 |
- sa := syscall.SecurityAttributes{ |
|
61 |
+ sa := windows.SecurityAttributes{ |
|
62 | 62 |
Length: 0, |
63 | 63 |
} |
64 | 64 |
ev := "Global\\docker-daemon-config-" + fmt.Sprint(os.Getpid()) |
65 | 65 |
if h, _ := system.CreateEvent(&sa, false, false, ev); h != 0 { |
66 | 66 |
logrus.Debugf("Config reload - waiting signal at %s", ev) |
67 | 67 |
for { |
68 |
- syscall.WaitForSingleObject(h, syscall.INFINITE) |
|
68 |
+ windows.WaitForSingleObject(h, windows.INFINITE) |
|
69 | 69 |
cli.reloadConfig() |
70 | 70 |
} |
71 | 71 |
} |
... | ... |
@@ -9,7 +9,6 @@ import ( |
9 | 9 |
"os" |
10 | 10 |
"os/exec" |
11 | 11 |
"path/filepath" |
12 |
- "syscall" |
|
13 | 12 |
"time" |
14 | 13 |
"unsafe" |
15 | 14 |
|
... | ... |
@@ -30,7 +29,7 @@ var ( |
30 | 30 |
flRunService *bool |
31 | 31 |
|
32 | 32 |
setStdHandle = windows.NewLazySystemDLL("kernel32.dll").NewProc("SetStdHandle") |
33 |
- oldStderr syscall.Handle |
|
33 |
+ oldStderr windows.Handle |
|
34 | 34 |
panicFile *os.File |
35 | 35 |
|
36 | 36 |
service *handler |
... | ... |
@@ -131,14 +130,14 @@ func (h *etwHook) Fire(e *logrus.Entry) error { |
131 | 131 |
err error |
132 | 132 |
) |
133 | 133 |
|
134 |
- ss[0], err = syscall.UTF16PtrFromString(e.Message) |
|
134 |
+ ss[0], err = windows.UTF16PtrFromString(e.Message) |
|
135 | 135 |
if err != nil { |
136 | 136 |
return err |
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
count := uint16(1) |
140 | 140 |
if exts != "" { |
141 |
- ss[1], err = syscall.UTF16PtrFromString(exts) |
|
141 |
+ ss[1], err = windows.UTF16PtrFromString(exts) |
|
142 | 142 |
if err != nil { |
143 | 143 |
return err |
144 | 144 |
} |
... | ... |
@@ -397,8 +396,8 @@ func initPanicFile(path string) error { |
397 | 397 |
// Update STD_ERROR_HANDLE to point to the panic file so that Go writes to |
398 | 398 |
// it when it panics. Remember the old stderr to restore it before removing |
399 | 399 |
// the panic file. |
400 |
- sh := syscall.STD_ERROR_HANDLE |
|
401 |
- h, err := syscall.GetStdHandle(sh) |
|
400 |
+ sh := windows.STD_ERROR_HANDLE |
|
401 |
+ h, err := windows.GetStdHandle(sh) |
|
402 | 402 |
if err != nil { |
403 | 403 |
return err |
404 | 404 |
} |
... | ... |
@@ -422,7 +421,7 @@ func initPanicFile(path string) error { |
422 | 422 |
func removePanicFile() { |
423 | 423 |
if st, err := panicFile.Stat(); err == nil { |
424 | 424 |
if st.Size() == 0 { |
425 |
- sh := syscall.STD_ERROR_HANDLE |
|
425 |
+ sh := windows.STD_ERROR_HANDLE |
|
426 | 426 |
setStdHandle.Call(uintptr(sh), uintptr(oldStderr)) |
427 | 427 |
panicFile.Close() |
428 | 428 |
os.Remove(panicFile.Name()) |
... | ... |
@@ -9,7 +9,6 @@ import ( |
9 | 9 |
"os" |
10 | 10 |
"path/filepath" |
11 | 11 |
"strconv" |
12 |
- "syscall" |
|
13 | 12 |
"time" |
14 | 13 |
|
15 | 14 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -22,6 +21,7 @@ import ( |
22 | 22 |
"github.com/docker/libnetwork" |
23 | 23 |
"github.com/opencontainers/selinux/go-selinux/label" |
24 | 24 |
"github.com/pkg/errors" |
25 |
+ "golang.org/x/sys/unix" |
|
25 | 26 |
) |
26 | 27 |
|
27 | 28 |
func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) { |
... | ... |
@@ -125,7 +125,7 @@ func (daemon *Daemon) setupIpcDirs(c *container.Container) error { |
125 | 125 |
shmSize = c.HostConfig.ShmSize |
126 | 126 |
} |
127 | 127 |
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 { |
|
129 | 129 |
return fmt.Errorf("mounting shm tmpfs: %s", err) |
130 | 130 |
} |
131 | 131 |
if err := os.Chown(shmPath, rootIDs.UID, rootIDs.GID); err != nil { |
... | ... |
@@ -301,8 +301,8 @@ func killProcessDirectly(cntr *container.Container) error { |
301 | 301 |
// Ensure that we don't kill ourselves |
302 | 302 |
if pid := cntr.GetPID(); pid != 0 { |
303 | 303 |
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 { |
|
306 | 306 |
return err |
307 | 307 |
} |
308 | 308 |
e := errNoSuchProcess{pid, 9} |
... | ... |
@@ -315,7 +315,7 @@ func killProcessDirectly(cntr *container.Container) error { |
315 | 315 |
} |
316 | 316 |
|
317 | 317 |
func detachMounted(path string) error { |
318 |
- return syscall.Unmount(path, syscall.MNT_DETACH) |
|
318 |
+ return unix.Unmount(path, unix.MNT_DETACH) |
|
319 | 319 |
} |
320 | 320 |
|
321 | 321 |
func isLinkable(child *container.Container) bool { |
... | ... |
@@ -5,15 +5,15 @@ package daemon |
5 | 5 |
import ( |
6 | 6 |
"os" |
7 | 7 |
"os/signal" |
8 |
- "syscall" |
|
9 | 8 |
|
10 | 9 |
"github.com/Sirupsen/logrus" |
11 | 10 |
stackdump "github.com/docker/docker/pkg/signal" |
11 |
+ "golang.org/x/sys/unix" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
func (d *Daemon) setupDumpStackTrap(root string) { |
15 | 15 |
c := make(chan os.Signal, 1) |
16 |
- signal.Notify(c, syscall.SIGUSR1) |
|
16 |
+ signal.Notify(c, unix.SIGUSR1) |
|
17 | 17 |
go func() { |
18 | 18 |
for range c { |
19 | 19 |
path, err := stackdump.DumpStacks(root) |
... | ... |
@@ -3,13 +3,13 @@ package daemon |
3 | 3 |
import ( |
4 | 4 |
"fmt" |
5 | 5 |
"os" |
6 |
- "syscall" |
|
7 | 6 |
"unsafe" |
8 | 7 |
|
9 | 8 |
winio "github.com/Microsoft/go-winio" |
10 | 9 |
"github.com/Sirupsen/logrus" |
11 | 10 |
"github.com/docker/docker/pkg/signal" |
12 | 11 |
"github.com/docker/docker/pkg/system" |
12 |
+ "golang.org/x/sys/windows" |
|
13 | 13 |
) |
14 | 14 |
|
15 | 15 |
func (d *Daemon) setupDumpStackTrap(root string) { |
... | ... |
@@ -22,7 +22,7 @@ func (d *Daemon) setupDumpStackTrap(root string) { |
22 | 22 |
logrus.Errorf("failed to get security descriptor for debug stackdump event %s: %s", ev, err.Error()) |
23 | 23 |
return |
24 | 24 |
} |
25 |
- var sa syscall.SecurityAttributes |
|
25 |
+ var sa windows.SecurityAttributes |
|
26 | 26 |
sa.Length = uint32(unsafe.Sizeof(sa)) |
27 | 27 |
sa.InheritHandle = 1 |
28 | 28 |
sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) |
... | ... |
@@ -34,7 +34,7 @@ func (d *Daemon) setupDumpStackTrap(root string) { |
34 | 34 |
go func() { |
35 | 35 |
logrus.Debugf("Stackdump - waiting signal at %s", ev) |
36 | 36 |
for { |
37 |
- syscall.WaitForSingleObject(h, syscall.INFINITE) |
|
37 |
+ windows.WaitForSingleObject(h, windows.INFINITE) |
|
38 | 38 |
path, err := signal.DumpStacks(root) |
39 | 39 |
if err != nil { |
40 | 40 |
logrus.WithError(err).Error("failed to write goroutines dump") |
... | ... |
@@ -33,12 +33,9 @@ import ( |
33 | 33 |
"path/filepath" |
34 | 34 |
"strings" |
35 | 35 |
"sync" |
36 |
- "syscall" |
|
37 | 36 |
"time" |
38 | 37 |
|
39 | 38 |
"github.com/Sirupsen/logrus" |
40 |
- "github.com/vbatts/tar-split/tar/storage" |
|
41 |
- |
|
42 | 39 |
"github.com/docker/docker/daemon/graphdriver" |
43 | 40 |
"github.com/docker/docker/pkg/archive" |
44 | 41 |
"github.com/docker/docker/pkg/chrootarchive" |
... | ... |
@@ -47,9 +44,10 @@ import ( |
47 | 47 |
"github.com/docker/docker/pkg/locker" |
48 | 48 |
mountpk "github.com/docker/docker/pkg/mount" |
49 | 49 |
"github.com/docker/docker/pkg/system" |
50 |
- |
|
51 | 50 |
rsystem "github.com/opencontainers/runc/libcontainer/system" |
52 | 51 |
"github.com/opencontainers/selinux/go-selinux/label" |
52 |
+ "github.com/vbatts/tar-split/tar/storage" |
|
53 |
+ "golang.org/x/sys/unix" |
|
53 | 54 |
) |
54 | 55 |
|
55 | 56 |
var ( |
... | ... |
@@ -295,7 +293,7 @@ func (a *Driver) Remove(id string) error { |
295 | 295 |
} |
296 | 296 |
|
297 | 297 |
if err := a.unmount(mountpoint); err != nil { |
298 |
- if err != syscall.EBUSY { |
|
298 |
+ if err != unix.EBUSY { |
|
299 | 299 |
return fmt.Errorf("aufs: unmount error: %s: %v", mountpoint, err) |
300 | 300 |
} |
301 | 301 |
if retries >= 5 { |
... | ... |
@@ -315,7 +313,7 @@ func (a *Driver) Remove(id string) error { |
315 | 315 |
// the whole tree. |
316 | 316 |
tmpMntPath := path.Join(a.mntPath(), fmt.Sprintf("%s-removing", id)) |
317 | 317 |
if err := os.Rename(mountpoint, tmpMntPath); err != nil && !os.IsNotExist(err) { |
318 |
- if err == syscall.EBUSY { |
|
318 |
+ if err == unix.EBUSY { |
|
319 | 319 |
logrus.Warn("os.Rename err due to EBUSY") |
320 | 320 |
} |
321 | 321 |
return err |
... | ... |
@@ -575,7 +573,7 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro |
575 | 575 |
if useDirperm() { |
576 | 576 |
offset += len(",dirperm1") |
577 | 577 |
} |
578 |
- b := make([]byte, syscall.Getpagesize()-len(mountLabel)-offset) // room for xino & mountLabel |
|
578 |
+ b := make([]byte, unix.Getpagesize()-len(mountLabel)-offset) // room for xino & mountLabel |
|
579 | 579 |
bp := copy(b, fmt.Sprintf("br:%s=rw", rw)) |
580 | 580 |
|
581 | 581 |
index := 0 |
... | ... |
@@ -599,7 +597,7 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro |
599 | 599 |
for ; index < len(ro); index++ { |
600 | 600 |
layer := fmt.Sprintf(":%s=ro+wh", ro[index]) |
601 | 601 |
data := label.FormatMountLabel(fmt.Sprintf("append%s", layer), mountLabel) |
602 |
- if err = mount("none", target, "aufs", syscall.MS_REMOUNT, data); err != nil { |
|
602 |
+ if err = mount("none", target, "aufs", unix.MS_REMOUNT, data); err != nil { |
|
603 | 603 |
return |
604 | 604 |
} |
605 | 605 |
} |
... | ... |
@@ -4,9 +4,9 @@ package aufs |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"os/exec" |
7 |
- "syscall" |
|
8 | 7 |
|
9 | 8 |
"github.com/Sirupsen/logrus" |
9 |
+ "golang.org/x/sys/unix" |
|
10 | 10 |
) |
11 | 11 |
|
12 | 12 |
// Unmount the target specified. |
... | ... |
@@ -14,7 +14,7 @@ func Unmount(target string) error { |
14 | 14 |
if err := exec.Command("auplink", target, "flush").Run(); err != nil { |
15 | 15 |
logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err) |
16 | 16 |
} |
17 |
- if err := syscall.Unmount(target, 0); err != nil { |
|
17 |
+ if err := unix.Unmount(target, 0); err != nil { |
|
18 | 18 |
return err |
19 | 19 |
} |
20 | 20 |
return nil |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
package aufs |
2 | 2 |
|
3 |
-import "syscall" |
|
3 |
+import "golang.org/x/sys/unix" |
|
4 | 4 |
|
5 | 5 |
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) |
|
7 | 7 |
} |
... | ... |
@@ -24,7 +24,6 @@ import ( |
24 | 24 |
"strconv" |
25 | 25 |
"strings" |
26 | 26 |
"sync" |
27 |
- "syscall" |
|
28 | 27 |
"unsafe" |
29 | 28 |
|
30 | 29 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -35,6 +34,7 @@ import ( |
35 | 35 |
"github.com/docker/docker/pkg/system" |
36 | 36 |
"github.com/docker/go-units" |
37 | 37 |
"github.com/opencontainers/selinux/go-selinux/label" |
38 |
+ "golang.org/x/sys/unix" |
|
38 | 39 |
) |
39 | 40 |
|
40 | 41 |
func init() { |
... | ... |
@@ -197,7 +197,7 @@ func subvolCreate(path, name string) error { |
197 | 197 |
args.name[i] = C.char(c) |
198 | 198 |
} |
199 | 199 |
|
200 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_SUBVOL_CREATE, |
|
200 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_SUBVOL_CREATE, |
|
201 | 201 |
uintptr(unsafe.Pointer(&args))) |
202 | 202 |
if errno != 0 { |
203 | 203 |
return fmt.Errorf("Failed to create btrfs subvolume: %v", errno.Error()) |
... | ... |
@@ -225,7 +225,7 @@ func subvolSnapshot(src, dest, name string) error { |
225 | 225 |
C.set_name_btrfs_ioctl_vol_args_v2(&args, cs) |
226 | 226 |
C.free(unsafe.Pointer(cs)) |
227 | 227 |
|
228 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(destDir), C.BTRFS_IOC_SNAP_CREATE_V2, |
|
228 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(destDir), C.BTRFS_IOC_SNAP_CREATE_V2, |
|
229 | 229 |
uintptr(unsafe.Pointer(&args))) |
230 | 230 |
if errno != 0 { |
231 | 231 |
return fmt.Errorf("Failed to create btrfs snapshot: %v", errno.Error()) |
... | ... |
@@ -234,8 +234,8 @@ func subvolSnapshot(src, dest, name string) error { |
234 | 234 |
} |
235 | 235 |
|
236 | 236 |
func isSubvolume(p string) (bool, error) { |
237 |
- var bufStat syscall.Stat_t |
|
238 |
- if err := syscall.Lstat(p, &bufStat); err != nil { |
|
237 |
+ var bufStat unix.Stat_t |
|
238 |
+ if err := unix.Lstat(p, &bufStat); err != nil { |
|
239 | 239 |
return false, err |
240 | 240 |
} |
241 | 241 |
|
... | ... |
@@ -287,7 +287,7 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error { |
287 | 287 |
var args C.struct_btrfs_ioctl_qgroup_create_args |
288 | 288 |
args.qgroupid = C.__u64(qgroupid) |
289 | 289 |
|
290 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QGROUP_CREATE, |
|
290 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QGROUP_CREATE, |
|
291 | 291 |
uintptr(unsafe.Pointer(&args))) |
292 | 292 |
if errno != 0 { |
293 | 293 |
logrus.Errorf("Failed to delete btrfs qgroup %v for %s: %v", qgroupid, fullPath, errno.Error()) |
... | ... |
@@ -302,7 +302,7 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error { |
302 | 302 |
for i, c := range []byte(name) { |
303 | 303 |
args.name[i] = C.char(c) |
304 | 304 |
} |
305 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_SNAP_DESTROY, |
|
305 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_SNAP_DESTROY, |
|
306 | 306 |
uintptr(unsafe.Pointer(&args))) |
307 | 307 |
if errno != 0 { |
308 | 308 |
return fmt.Errorf("Failed to destroy btrfs snapshot %s for %s: %v", dirpath, name, errno.Error()) |
... | ... |
@@ -338,7 +338,7 @@ func (d *Driver) subvolEnableQuota() error { |
338 | 338 |
|
339 | 339 |
var args C.struct_btrfs_ioctl_quota_ctl_args |
340 | 340 |
args.cmd = C.BTRFS_QUOTA_CTL_ENABLE |
341 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_CTL, |
|
341 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_CTL, |
|
342 | 342 |
uintptr(unsafe.Pointer(&args))) |
343 | 343 |
if errno != 0 { |
344 | 344 |
return fmt.Errorf("Failed to enable btrfs quota for %s: %v", dir, errno.Error()) |
... | ... |
@@ -364,7 +364,7 @@ func (d *Driver) subvolDisableQuota() error { |
364 | 364 |
|
365 | 365 |
var args C.struct_btrfs_ioctl_quota_ctl_args |
366 | 366 |
args.cmd = C.BTRFS_QUOTA_CTL_DISABLE |
367 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_CTL, |
|
367 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_CTL, |
|
368 | 368 |
uintptr(unsafe.Pointer(&args))) |
369 | 369 |
if errno != 0 { |
370 | 370 |
return fmt.Errorf("Failed to disable btrfs quota for %s: %v", dir, errno.Error()) |
... | ... |
@@ -389,7 +389,7 @@ func (d *Driver) subvolRescanQuota() error { |
389 | 389 |
defer closeDir(dir) |
390 | 390 |
|
391 | 391 |
var args C.struct_btrfs_ioctl_quota_rescan_args |
392 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_RESCAN_WAIT, |
|
392 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_RESCAN_WAIT, |
|
393 | 393 |
uintptr(unsafe.Pointer(&args))) |
394 | 394 |
if errno != 0 { |
395 | 395 |
return fmt.Errorf("Failed to rescan btrfs quota for %s: %v", dir, errno.Error()) |
... | ... |
@@ -408,7 +408,7 @@ func subvolLimitQgroup(path string, size uint64) error { |
408 | 408 |
var args C.struct_btrfs_ioctl_qgroup_limit_args |
409 | 409 |
args.lim.max_referenced = C.__u64(size) |
410 | 410 |
args.lim.flags = C.BTRFS_QGROUP_LIMIT_MAX_RFER |
411 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QGROUP_LIMIT, |
|
411 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QGROUP_LIMIT, |
|
412 | 412 |
uintptr(unsafe.Pointer(&args))) |
413 | 413 |
if errno != 0 { |
414 | 414 |
return fmt.Errorf("Failed to limit qgroup for %s: %v", dir, errno.Error()) |
... | ... |
@@ -437,7 +437,7 @@ func subvolQgroupStatus(path string) error { |
437 | 437 |
args.key.max_transid = C.__u64(math.MaxUint64) |
438 | 438 |
args.key.nr_items = 4096 |
439 | 439 |
|
440 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_TREE_SEARCH, |
|
440 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_TREE_SEARCH, |
|
441 | 441 |
uintptr(unsafe.Pointer(&args))) |
442 | 442 |
if errno != 0 { |
443 | 443 |
return fmt.Errorf("Failed to search qgroup for %s: %v", path, errno.Error()) |
... | ... |
@@ -459,7 +459,7 @@ func subvolLookupQgroup(path string) (uint64, error) { |
459 | 459 |
var args C.struct_btrfs_ioctl_ino_lookup_args |
460 | 460 |
args.objectid = C.BTRFS_FIRST_FREE_OBJECTID |
461 | 461 |
|
462 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_INO_LOOKUP, |
|
462 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_INO_LOOKUP, |
|
463 | 463 |
uintptr(unsafe.Pointer(&args))) |
464 | 464 |
if errno != 0 { |
465 | 465 |
return 0, fmt.Errorf("Failed to lookup qgroup for %s: %v", dir, errno.Error()) |
... | ... |
@@ -20,7 +20,6 @@ import ( |
20 | 20 |
"time" |
21 | 21 |
|
22 | 22 |
"github.com/Sirupsen/logrus" |
23 |
- |
|
24 | 23 |
"github.com/docker/docker/daemon/graphdriver" |
25 | 24 |
"github.com/docker/docker/dockerversion" |
26 | 25 |
"github.com/docker/docker/pkg/devicemapper" |
... | ... |
@@ -29,9 +28,9 @@ import ( |
29 | 29 |
"github.com/docker/docker/pkg/mount" |
30 | 30 |
"github.com/docker/docker/pkg/parsers" |
31 | 31 |
units "github.com/docker/go-units" |
32 |
- "github.com/pkg/errors" |
|
33 |
- |
|
34 | 32 |
"github.com/opencontainers/selinux/go-selinux/label" |
33 |
+ "github.com/pkg/errors" |
|
34 |
+ "golang.org/x/sys/unix" |
|
35 | 35 |
) |
36 | 36 |
|
37 | 37 |
var ( |
... | ... |
@@ -1197,7 +1196,7 @@ func (devices *DeviceSet) growFS(info *devInfo) error { |
1197 | 1197 |
return fmt.Errorf("Error mounting '%s' on '%s': %s", info.DevName(), fsMountPoint, err) |
1198 | 1198 |
} |
1199 | 1199 |
|
1200 |
- defer syscall.Unmount(fsMountPoint, syscall.MNT_DETACH) |
|
1200 |
+ defer unix.Unmount(fsMountPoint, unix.MNT_DETACH) |
|
1201 | 1201 |
|
1202 | 1202 |
switch devices.BaseDeviceFilesystem { |
1203 | 1203 |
case "ext4": |
... | ... |
@@ -1266,7 +1265,7 @@ func setCloseOnExec(name string) { |
1266 | 1266 |
if link == name { |
1267 | 1267 |
fd, err := strconv.Atoi(i.Name()) |
1268 | 1268 |
if err == nil { |
1269 |
- syscall.CloseOnExec(fd) |
|
1269 |
+ unix.CloseOnExec(fd) |
|
1270 | 1270 |
} |
1271 | 1271 |
} |
1272 | 1272 |
} |
... | ... |
@@ -2287,7 +2286,7 @@ func (devices *DeviceSet) Shutdown(home string) error { |
2287 | 2287 |
// We use MNT_DETACH here in case it is still busy in some running |
2288 | 2288 |
// container. This means it'll go away from the global scope directly, |
2289 | 2289 |
// and the device will be released when that container dies. |
2290 |
- if err := syscall.Unmount(p, syscall.MNT_DETACH); err != nil { |
|
2290 |
+ if err := unix.Unmount(p, unix.MNT_DETACH); err != nil { |
|
2291 | 2291 |
logrus.Debugf("devmapper: Shutdown unmounting %s, error: %s", p, err) |
2292 | 2292 |
} |
2293 | 2293 |
} |
... | ... |
@@ -2400,7 +2399,7 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error { |
2400 | 2400 |
|
2401 | 2401 |
if fstype == "xfs" && devices.xfsNospaceRetries != "" { |
2402 | 2402 |
if err := devices.xfsSetNospaceRetries(info); err != nil { |
2403 |
- syscall.Unmount(path, syscall.MNT_DETACH) |
|
2403 |
+ unix.Unmount(path, unix.MNT_DETACH) |
|
2404 | 2404 |
devices.deactivateDevice(info) |
2405 | 2405 |
return err |
2406 | 2406 |
} |
... | ... |
@@ -2426,7 +2425,7 @@ func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error { |
2426 | 2426 |
defer devices.Unlock() |
2427 | 2427 |
|
2428 | 2428 |
logrus.Debugf("devmapper: Unmount(%s)", mountPath) |
2429 |
- if err := syscall.Unmount(mountPath, syscall.MNT_DETACH); err != nil { |
|
2429 |
+ if err := unix.Unmount(mountPath, unix.MNT_DETACH); err != nil { |
|
2430 | 2430 |
return err |
2431 | 2431 |
} |
2432 | 2432 |
logrus.Debug("devmapper: Unmount done") |
... | ... |
@@ -2523,8 +2522,8 @@ func (devices *DeviceSet) MetadataDevicePath() string { |
2523 | 2523 |
} |
2524 | 2524 |
|
2525 | 2525 |
func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64, error) { |
2526 |
- buf := new(syscall.Statfs_t) |
|
2527 |
- if err := syscall.Statfs(loopFile, buf); err != nil { |
|
2526 |
+ buf := new(unix.Statfs_t) |
|
2527 |
+ if err := unix.Statfs(loopFile, buf); err != nil { |
|
2528 | 2528 |
logrus.Warnf("devmapper: Couldn't stat loopfile filesystem %v: %v", loopFile, err) |
2529 | 2529 |
return 0, err |
2530 | 2530 |
} |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
package graphdriver |
2 | 2 |
|
3 |
-import "syscall" |
|
3 |
+import "golang.org/x/sys/unix" |
|
4 | 4 |
|
5 | 5 |
var ( |
6 | 6 |
// Slice of drivers that should be used in an order |
... | ... |
@@ -11,7 +11,7 @@ var ( |
11 | 11 |
|
12 | 12 |
// Mounted checks if the given path is mounted as the fs type |
13 | 13 |
func Mounted(fsType FsMagic, mountPath string) (bool, error) { |
14 |
- var buf syscall.Statfs_t |
|
14 |
+ var buf unix.Statfs_t |
|
15 | 15 |
if err := syscall.Statfs(mountPath, &buf); err != nil { |
16 | 16 |
return false, err |
17 | 17 |
} |
... | ... |
@@ -4,9 +4,9 @@ package graphdriver |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"path/filepath" |
7 |
- "syscall" |
|
8 | 7 |
|
9 | 8 |
"github.com/docker/docker/pkg/mount" |
9 |
+ "golang.org/x/sys/unix" |
|
10 | 10 |
) |
11 | 11 |
|
12 | 12 |
const ( |
... | ... |
@@ -88,8 +88,8 @@ var ( |
88 | 88 |
|
89 | 89 |
// GetFSMagic returns the filesystem id given the path. |
90 | 90 |
func GetFSMagic(rootpath string) (FsMagic, error) { |
91 |
- var buf syscall.Statfs_t |
|
92 |
- if err := syscall.Statfs(filepath.Dir(rootpath), &buf); err != nil { |
|
91 |
+ var buf unix.Statfs_t |
|
92 |
+ if err := unix.Statfs(filepath.Dir(rootpath), &buf); err != nil { |
|
93 | 93 |
return 0, err |
94 | 94 |
} |
95 | 95 |
return FsMagic(buf.Type), nil |
... | ... |
@@ -127,8 +127,8 @@ func (c *defaultChecker) IsMounted(path string) bool { |
127 | 127 |
|
128 | 128 |
// Mounted checks if the given path is mounted as the fs type |
129 | 129 |
func Mounted(fsType FsMagic, mountPath string) (bool, error) { |
130 |
- var buf syscall.Statfs_t |
|
131 |
- if err := syscall.Statfs(mountPath, &buf); err != nil { |
|
130 |
+ var buf unix.Statfs_t |
|
131 |
+ if err := unix.Statfs(mountPath, &buf); err != nil { |
|
132 | 132 |
return false, err |
133 | 133 |
} |
134 | 134 |
return FsMagic(buf.Type) == fsType, nil |
... | ... |
@@ -9,7 +9,6 @@ import ( |
9 | 9 |
"os" |
10 | 10 |
"path" |
11 | 11 |
"reflect" |
12 |
- "syscall" |
|
13 | 12 |
"testing" |
14 | 13 |
"unsafe" |
15 | 14 |
|
... | ... |
@@ -18,6 +17,7 @@ import ( |
18 | 18 |
"github.com/docker/go-units" |
19 | 19 |
"github.com/stretchr/testify/assert" |
20 | 20 |
"github.com/stretchr/testify/require" |
21 |
+ "golang.org/x/sys/unix" |
|
21 | 22 |
) |
22 | 23 |
|
23 | 24 |
var ( |
... | ... |
@@ -329,8 +329,8 @@ func DriverTestSetQuota(t *testing.T, drivername string) { |
329 | 329 |
|
330 | 330 |
quota := uint64(50 * units.MiB) |
331 | 331 |
err = writeRandomFile(path.Join(mountPath, "file"), quota*2) |
332 |
- if pathError, ok := err.(*os.PathError); ok && pathError.Err != syscall.EDQUOT { |
|
333 |
- t.Fatalf("expect write() to fail with %v, got %v", syscall.EDQUOT, err) |
|
332 |
+ if pathError, ok := err.(*os.PathError); ok && pathError.Err != unix.EDQUOT { |
|
333 |
+ t.Fatalf("expect write() to fail with %v, got %v", unix.EDQUOT, err) |
|
334 | 334 |
} |
335 | 335 |
|
336 | 336 |
} |
... | ... |
@@ -12,6 +12,7 @@ import ( |
12 | 12 |
"github.com/docker/docker/daemon/graphdriver" |
13 | 13 |
"github.com/stretchr/testify/assert" |
14 | 14 |
"github.com/stretchr/testify/require" |
15 |
+ "golang.org/x/sys/unix" |
|
15 | 16 |
) |
16 | 17 |
|
17 | 18 |
func verifyFile(t testing.TB, path string, mode os.FileMode, uid, gid uint32) { |
... | ... |
@@ -33,8 +34,8 @@ func verifyFile(t testing.TB, path string, mode os.FileMode, uid, gid uint32) { |
33 | 33 |
|
34 | 34 |
func createBase(t testing.TB, driver graphdriver.Driver, name string) { |
35 | 35 |
// We need to be able to set any perms |
36 |
- oldmask := syscall.Umask(0) |
|
37 |
- defer syscall.Umask(oldmask) |
|
36 |
+ oldmask := unix.Umask(0) |
|
37 |
+ defer unix.Umask(oldmask) |
|
38 | 38 |
|
39 | 39 |
err := driver.CreateReadWrite(name, "", nil) |
40 | 40 |
require.NoError(t, err) |
... | ... |
@@ -12,6 +12,7 @@ import ( |
12 | 12 |
"github.com/docker/docker/pkg/pools" |
13 | 13 |
"github.com/docker/docker/pkg/system" |
14 | 14 |
rsystem "github.com/opencontainers/runc/libcontainer/system" |
15 |
+ "golang.org/x/sys/unix" |
|
15 | 16 |
) |
16 | 17 |
|
17 | 18 |
type copyFlags int |
... | ... |
@@ -110,12 +111,12 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error { |
110 | 110 |
// cannot create a device if running in user namespace |
111 | 111 |
return nil |
112 | 112 |
} |
113 |
- if err := syscall.Mkfifo(dstPath, stat.Mode); err != nil { |
|
113 |
+ if err := unix.Mkfifo(dstPath, stat.Mode); err != nil { |
|
114 | 114 |
return err |
115 | 115 |
} |
116 | 116 |
|
117 | 117 |
case os.ModeDevice: |
118 |
- if err := syscall.Mknod(dstPath, stat.Mode, int(stat.Rdev)); err != nil { |
|
118 |
+ if err := unix.Mknod(dstPath, stat.Mode, int(stat.Rdev)); err != nil { |
|
119 | 119 |
return err |
120 | 120 |
} |
121 | 121 |
|
... | ... |
@@ -11,7 +11,6 @@ import ( |
11 | 11 |
"os/exec" |
12 | 12 |
"path" |
13 | 13 |
"strconv" |
14 |
- "syscall" |
|
15 | 14 |
|
16 | 15 |
"github.com/Sirupsen/logrus" |
17 | 16 |
"github.com/docker/docker/daemon/graphdriver" |
... | ... |
@@ -23,6 +22,7 @@ import ( |
23 | 23 |
"github.com/docker/docker/pkg/mount" |
24 | 24 |
"github.com/docker/docker/pkg/system" |
25 | 25 |
"github.com/opencontainers/selinux/go-selinux/label" |
26 |
+ "golang.org/x/sys/unix" |
|
26 | 27 |
) |
27 | 28 |
|
28 | 29 |
// This is a small wrapper over the NaiveDiffWriter that lets us have a custom |
... | ... |
@@ -363,7 +363,7 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { |
363 | 363 |
defer func() { |
364 | 364 |
if err != nil { |
365 | 365 |
if c := d.ctr.Decrement(mergedDir); c <= 0 { |
366 |
- syscall.Unmount(mergedDir, 0) |
|
366 |
+ unix.Unmount(mergedDir, 0) |
|
367 | 367 |
} |
368 | 368 |
} |
369 | 369 |
}() |
... | ... |
@@ -377,7 +377,7 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { |
377 | 377 |
workDir = path.Join(dir, "work") |
378 | 378 |
opts = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerDir, upperDir, workDir) |
379 | 379 |
) |
380 |
- if err := syscall.Mount("overlay", mergedDir, "overlay", 0, label.FormatMountLabel(opts, mountLabel)); err != nil { |
|
380 |
+ if err := unix.Mount("overlay", mergedDir, "overlay", 0, label.FormatMountLabel(opts, mountLabel)); err != nil { |
|
381 | 381 |
return "", fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err) |
382 | 382 |
} |
383 | 383 |
// chown "workdir/work" to the remapped root UID/GID. Overlay fs inside a |
... | ... |
@@ -404,7 +404,7 @@ func (d *Driver) Put(id string) error { |
404 | 404 |
if count := d.ctr.Decrement(mountpoint); count > 0 { |
405 | 405 |
return nil |
406 | 406 |
} |
407 |
- if err := syscall.Unmount(mountpoint, syscall.MNT_DETACH); err != nil { |
|
407 |
+ if err := unix.Unmount(mountpoint, unix.MNT_DETACH); err != nil { |
|
408 | 408 |
logrus.Debugf("Failed to unmount %s overlay: %v", id, err) |
409 | 409 |
} |
410 | 410 |
return nil |
... | ... |
@@ -8,11 +8,11 @@ import ( |
8 | 8 |
"os" |
9 | 9 |
"path" |
10 | 10 |
"path/filepath" |
11 |
- "syscall" |
|
12 | 11 |
|
13 | 12 |
"github.com/Sirupsen/logrus" |
14 | 13 |
"github.com/docker/docker/pkg/system" |
15 | 14 |
"github.com/pkg/errors" |
15 |
+ "golang.org/x/sys/unix" |
|
16 | 16 |
) |
17 | 17 |
|
18 | 18 |
// hasOpaqueCopyUpBug checks whether the filesystem has a bug |
... | ... |
@@ -52,11 +52,11 @@ func hasOpaqueCopyUpBug(d string) error { |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
opts := fmt.Sprintf("lowerdir=%s:%s,upperdir=%s,workdir=%s", path.Join(td, "l2"), path.Join(td, "l1"), path.Join(td, "l3"), path.Join(td, "work")) |
55 |
- if err := syscall.Mount("overlay", filepath.Join(td, "merged"), "overlay", 0, opts); err != nil { |
|
55 |
+ if err := unix.Mount("overlay", filepath.Join(td, "merged"), "overlay", 0, opts); err != nil { |
|
56 | 56 |
return errors.Wrap(err, "failed to mount overlay") |
57 | 57 |
} |
58 | 58 |
defer func() { |
59 |
- if err := syscall.Unmount(filepath.Join(td, "merged"), 0); err != nil { |
|
59 |
+ if err := unix.Unmount(filepath.Join(td, "merged"), 0); err != nil { |
|
60 | 60 |
logrus.Warnf("Failed to unmount check directory %v: %v", filepath.Join(td, "merged"), err) |
61 | 61 |
} |
62 | 62 |
}() |
... | ... |
@@ -9,9 +9,9 @@ import ( |
9 | 9 |
"fmt" |
10 | 10 |
"os" |
11 | 11 |
"runtime" |
12 |
- "syscall" |
|
13 | 12 |
|
14 | 13 |
"github.com/docker/docker/pkg/reexec" |
14 |
+ "golang.org/x/sys/unix" |
|
15 | 15 |
) |
16 | 16 |
|
17 | 17 |
func init() { |
... | ... |
@@ -80,7 +80,7 @@ func mountFromMain() { |
80 | 80 |
fatal(err) |
81 | 81 |
} |
82 | 82 |
|
83 |
- if err := syscall.Mount(options.Device, options.Target, options.Type, uintptr(options.Flag), options.Label); err != nil { |
|
83 |
+ if err := unix.Mount(options.Device, options.Target, options.Type, uintptr(options.Flag), options.Label); err != nil { |
|
84 | 84 |
fatal(err) |
85 | 85 |
} |
86 | 86 |
|
... | ... |
@@ -15,7 +15,6 @@ import ( |
15 | 15 |
"strconv" |
16 | 16 |
"strings" |
17 | 17 |
"sync" |
18 |
- "syscall" |
|
19 | 18 |
|
20 | 19 |
"github.com/Sirupsen/logrus" |
21 | 20 |
|
... | ... |
@@ -35,6 +34,7 @@ import ( |
35 | 35 |
units "github.com/docker/go-units" |
36 | 36 |
|
37 | 37 |
"github.com/opencontainers/selinux/go-selinux/label" |
38 |
+ "golang.org/x/sys/unix" |
|
38 | 39 |
) |
39 | 40 |
|
40 | 41 |
var ( |
... | ... |
@@ -539,7 +539,7 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { |
539 | 539 |
defer func() { |
540 | 540 |
if err != nil { |
541 | 541 |
if c := d.ctr.Decrement(mergedDir); c <= 0 { |
542 |
- syscall.Unmount(mergedDir, 0) |
|
542 |
+ unix.Unmount(mergedDir, 0) |
|
543 | 543 |
} |
544 | 544 |
} |
545 | 545 |
}() |
... | ... |
@@ -552,10 +552,10 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { |
552 | 552 |
} |
553 | 553 |
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", strings.Join(absLowers, ":"), path.Join(dir, "diff"), path.Join(dir, "work")) |
554 | 554 |
mountData := label.FormatMountLabel(opts, mountLabel) |
555 |
- mount := syscall.Mount |
|
555 |
+ mount := unix.Mount |
|
556 | 556 |
mountTarget := mergedDir |
557 | 557 |
|
558 |
- pageSize := syscall.Getpagesize() |
|
558 |
+ pageSize := unix.Getpagesize() |
|
559 | 559 |
|
560 | 560 |
// Go can return a larger page size than supported by the system |
561 | 561 |
// as of go 1.7. This will be fixed in 1.8 and this block can be |
... | ... |
@@ -619,7 +619,7 @@ func (d *Driver) Put(id string) error { |
619 | 619 |
if count := d.ctr.Decrement(mountpoint); count > 0 { |
620 | 620 |
return nil |
621 | 621 |
} |
622 |
- if err := syscall.Unmount(mountpoint, syscall.MNT_DETACH); err != nil { |
|
622 |
+ if err := unix.Unmount(mountpoint, unix.MNT_DETACH); err != nil { |
|
623 | 623 |
logrus.Debugf("Failed to unmount %s overlay: %s - %v", id, mountpoint, err) |
624 | 624 |
} |
625 | 625 |
return nil |
... | ... |
@@ -5,13 +5,13 @@ package overlay2 |
5 | 5 |
import ( |
6 | 6 |
"io/ioutil" |
7 | 7 |
"os" |
8 |
- "syscall" |
|
9 | 8 |
"testing" |
10 | 9 |
|
11 | 10 |
"github.com/docker/docker/daemon/graphdriver" |
12 | 11 |
"github.com/docker/docker/daemon/graphdriver/graphtest" |
13 | 12 |
"github.com/docker/docker/pkg/archive" |
14 | 13 |
"github.com/docker/docker/pkg/reexec" |
14 |
+ "golang.org/x/sys/unix" |
|
15 | 15 |
) |
16 | 16 |
|
17 | 17 |
func init() { |
... | ... |
@@ -31,7 +31,7 @@ func cdMountFrom(dir, device, target, mType, label string) error { |
31 | 31 |
os.Chdir(dir) |
32 | 32 |
defer os.Chdir(wd) |
33 | 33 |
|
34 |
- return syscall.Mount(device, target, mType, 0, label) |
|
34 |
+ return unix.Mount(device, target, mType, 0, label) |
|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
func skipIfNaive(t *testing.T) { |
... | ... |
@@ -12,6 +12,7 @@ import ( |
12 | 12 |
"time" |
13 | 13 |
|
14 | 14 |
"github.com/Sirupsen/logrus" |
15 |
+ "golang.org/x/sys/unix" |
|
15 | 16 |
) |
16 | 17 |
|
17 | 18 |
// generateID creates a new random string identifier with the given length |
... | ... |
@@ -69,7 +70,7 @@ func retryOnError(err error) bool { |
69 | 69 |
case *os.PathError: |
70 | 70 |
return retryOnError(err.Err) // unpack the target error |
71 | 71 |
case syscall.Errno: |
72 |
- if err == syscall.EPERM { |
|
72 |
+ if err == unix.EPERM { |
|
73 | 73 |
// EPERM represents an entropy pool exhaustion, a condition under |
74 | 74 |
// which we backoff and retry. |
75 | 75 |
return true |
... | ... |
@@ -59,6 +59,7 @@ import ( |
59 | 59 |
"unsafe" |
60 | 60 |
|
61 | 61 |
"github.com/Sirupsen/logrus" |
62 |
+ "golang.org/x/sys/unix" |
|
62 | 63 |
) |
63 | 64 |
|
64 | 65 |
// Quota limit params - currently we only control blocks hard limit |
... | ... |
@@ -184,7 +185,7 @@ func setProjectQuota(backingFsBlockDev string, projectID uint32, quota Quota) er |
184 | 184 |
var cs = C.CString(backingFsBlockDev) |
185 | 185 |
defer C.free(unsafe.Pointer(cs)) |
186 | 186 |
|
187 |
- _, _, errno := syscall.Syscall6(syscall.SYS_QUOTACTL, C.Q_XSETPQLIM, |
|
187 |
+ _, _, errno := unix.Syscall6(unix.SYS_QUOTACTL, C.Q_XSETPQLIM, |
|
188 | 188 |
uintptr(unsafe.Pointer(cs)), uintptr(d.d_id), |
189 | 189 |
uintptr(unsafe.Pointer(&d)), 0, 0) |
190 | 190 |
if errno != 0 { |
... | ... |
@@ -211,7 +212,7 @@ func (q *Control) GetQuota(targetPath string, quota *Quota) error { |
211 | 211 |
var cs = C.CString(q.backingFsBlockDev) |
212 | 212 |
defer C.free(unsafe.Pointer(cs)) |
213 | 213 |
|
214 |
- _, _, errno := syscall.Syscall6(syscall.SYS_QUOTACTL, C.Q_XGETPQUOTA, |
|
214 |
+ _, _, errno := unix.Syscall6(unix.SYS_QUOTACTL, C.Q_XGETPQUOTA, |
|
215 | 215 |
uintptr(unsafe.Pointer(cs)), uintptr(C.__u32(projectID)), |
216 | 216 |
uintptr(unsafe.Pointer(&d)), 0, 0) |
217 | 217 |
if errno != 0 { |
... | ... |
@@ -232,7 +233,7 @@ func getProjectID(targetPath string) (uint32, error) { |
232 | 232 |
defer closeDir(dir) |
233 | 233 |
|
234 | 234 |
var fsx C.struct_fsxattr |
235 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR, |
|
235 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR, |
|
236 | 236 |
uintptr(unsafe.Pointer(&fsx))) |
237 | 237 |
if errno != 0 { |
238 | 238 |
return 0, fmt.Errorf("Failed to get projid for %s: %v", targetPath, errno.Error()) |
... | ... |
@@ -250,14 +251,14 @@ func setProjectID(targetPath string, projectID uint32) error { |
250 | 250 |
defer closeDir(dir) |
251 | 251 |
|
252 | 252 |
var fsx C.struct_fsxattr |
253 |
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR, |
|
253 |
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR, |
|
254 | 254 |
uintptr(unsafe.Pointer(&fsx))) |
255 | 255 |
if errno != 0 { |
256 | 256 |
return fmt.Errorf("Failed to get projid for %s: %v", targetPath, errno.Error()) |
257 | 257 |
} |
258 | 258 |
fsx.fsx_projid = C.__u32(projectID) |
259 | 259 |
fsx.fsx_xflags |= C.FS_XFLAG_PROJINHERIT |
260 |
- _, _, errno = syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSSETXATTR, |
|
260 |
+ _, _, errno = unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSSETXATTR, |
|
261 | 261 |
uintptr(unsafe.Pointer(&fsx))) |
262 | 262 |
if errno != 0 { |
263 | 263 |
return fmt.Errorf("Failed to set projid for %s: %v", targetPath, errno.Error()) |
... | ... |
@@ -329,9 +330,9 @@ func makeBackingFsDev(home string) (string, error) { |
329 | 329 |
|
330 | 330 |
backingFsBlockDev := path.Join(home, "backingFsBlockDev") |
331 | 331 |
// Re-create just in case someone copied the home directory over to a new device |
332 |
- syscall.Unlink(backingFsBlockDev) |
|
332 |
+ unix.Unlink(backingFsBlockDev) |
|
333 | 333 |
stat := fileinfo.Sys().(*syscall.Stat_t) |
334 |
- if err := syscall.Mknod(backingFsBlockDev, syscall.S_IFBLK|0600, int(stat.Dev)); err != nil { |
|
334 |
+ if err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { |
|
335 | 335 |
return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDev, err) |
336 | 336 |
} |
337 | 337 |
|
... | ... |
@@ -124,7 +124,7 @@ func getFileSystemType(drive string) (fsType string, hr error) { |
124 | 124 |
modkernel32 = windows.NewLazySystemDLL("kernel32.dll") |
125 | 125 |
procGetVolumeInformation = modkernel32.NewProc("GetVolumeInformationW") |
126 | 126 |
buf = make([]uint16, 255) |
127 |
- size = syscall.MAX_PATH + 1 |
|
127 |
+ size = windows.MAX_PATH + 1 |
|
128 | 128 |
) |
129 | 129 |
if len(drive) != 1 { |
130 | 130 |
hr = errors.New("getFileSystemType must be called with a drive letter") |
... | ... |
@@ -132,11 +132,11 @@ func getFileSystemType(drive string) (fsType string, hr error) { |
132 | 132 |
} |
133 | 133 |
drive += `:\` |
134 | 134 |
n := uintptr(unsafe.Pointer(nil)) |
135 |
- r0, _, _ := syscall.Syscall9(procGetVolumeInformation.Addr(), 8, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(drive))), n, n, n, n, n, uintptr(unsafe.Pointer(&buf[0])), uintptr(size), 0) |
|
135 |
+ r0, _, _ := syscall.Syscall9(procGetVolumeInformation.Addr(), 8, uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(drive))), n, n, n, n, n, uintptr(unsafe.Pointer(&buf[0])), uintptr(size), 0) |
|
136 | 136 |
if int32(r0) < 0 { |
137 | 137 |
hr = syscall.Errno(win32FromHresult(r0)) |
138 | 138 |
} |
139 |
- fsType = syscall.UTF16ToString(buf) |
|
139 |
+ fsType = windows.UTF16ToString(buf) |
|
140 | 140 |
return |
141 | 141 |
} |
142 | 142 |
|
... | ... |
@@ -904,12 +904,12 @@ func (fg *fileGetCloserWithBackupPrivileges) Get(filename string) (io.ReadCloser |
904 | 904 |
// standby list - Microsoft VSO Bug Tracker #9900466 |
905 | 905 |
err := winio.RunWithPrivilege(winio.SeBackupPrivilege, func() error { |
906 | 906 |
path := longpath.AddPrefix(filepath.Join(fg.path, filename)) |
907 |
- p, err := syscall.UTF16FromString(path) |
|
907 |
+ p, err := windows.UTF16FromString(path) |
|
908 | 908 |
if err != nil { |
909 | 909 |
return err |
910 | 910 |
} |
911 | 911 |
const fileFlagSequentialScan = 0x08000000 // FILE_FLAG_SEQUENTIAL_SCAN |
912 |
- h, err := syscall.CreateFile(&p[0], syscall.GENERIC_READ, syscall.FILE_SHARE_READ, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS|fileFlagSequentialScan, 0) |
|
912 |
+ h, err := windows.CreateFile(&p[0], windows.GENERIC_READ, windows.FILE_SHARE_READ, nil, windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS|fileFlagSequentialScan, 0) |
|
913 | 913 |
if err != nil { |
914 | 914 |
return &os.PathError{Op: "open", Path: path, Err: err} |
915 | 915 |
} |
... | ... |
@@ -10,7 +10,6 @@ import ( |
10 | 10 |
"strconv" |
11 | 11 |
"strings" |
12 | 12 |
"sync" |
13 |
- "syscall" |
|
14 | 13 |
"time" |
15 | 14 |
|
16 | 15 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -20,6 +19,7 @@ import ( |
20 | 20 |
"github.com/docker/docker/pkg/parsers" |
21 | 21 |
zfs "github.com/mistifyio/go-zfs" |
22 | 22 |
"github.com/opencontainers/selinux/go-selinux/label" |
23 |
+ "golang.org/x/sys/unix" |
|
23 | 24 |
) |
24 | 25 |
|
25 | 26 |
type zfsOptions struct { |
... | ... |
@@ -141,8 +141,8 @@ func parseOptions(opt []string) (zfsOptions, error) { |
141 | 141 |
} |
142 | 142 |
|
143 | 143 |
func lookupZfsDataset(rootdir string) (string, error) { |
144 |
- var stat syscall.Stat_t |
|
145 |
- if err := syscall.Stat(rootdir, &stat); err != nil { |
|
144 |
+ var stat unix.Stat_t |
|
145 |
+ if err := unix.Stat(rootdir, &stat); err != nil { |
|
146 | 146 |
return "", fmt.Errorf("Failed to access '%s': %s", rootdir, err) |
147 | 147 |
} |
148 | 148 |
wantedDev := stat.Dev |
... | ... |
@@ -152,7 +152,7 @@ func lookupZfsDataset(rootdir string) (string, error) { |
152 | 152 |
return "", err |
153 | 153 |
} |
154 | 154 |
for _, m := range mounts { |
155 |
- if err := syscall.Stat(m.Mountpoint, &stat); err != nil { |
|
155 |
+ if err := unix.Stat(m.Mountpoint, &stat); err != nil { |
|
156 | 156 |
logrus.Debugf("[zfs] failed to stat '%s' while scanning for zfs mount: %v", m.Mountpoint, err) |
157 | 157 |
continue // may fail on fuse file systems |
158 | 158 |
} |
... | ... |
@@ -3,15 +3,15 @@ package zfs |
3 | 3 |
import ( |
4 | 4 |
"fmt" |
5 | 5 |
"strings" |
6 |
- "syscall" |
|
7 | 6 |
|
8 | 7 |
"github.com/Sirupsen/logrus" |
9 | 8 |
"github.com/docker/docker/daemon/graphdriver" |
9 |
+ "golang.org/x/sys/unix" |
|
10 | 10 |
) |
11 | 11 |
|
12 | 12 |
func checkRootdirFs(rootdir string) error { |
13 |
- var buf syscall.Statfs_t |
|
14 |
- if err := syscall.Statfs(rootdir, &buf); err != nil { |
|
13 |
+ var buf unix.Statfs_t |
|
14 |
+ if err := unix.Statfs(rootdir, &buf); err != nil { |
|
15 | 15 |
return fmt.Errorf("Failed to access '%s': %s", rootdir, err) |
16 | 16 |
} |
17 | 17 |
|
... | ... |
@@ -2,15 +2,15 @@ package zfs |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"fmt" |
5 |
- "syscall" |
|
6 | 5 |
|
7 | 6 |
"github.com/Sirupsen/logrus" |
8 | 7 |
"github.com/docker/docker/daemon/graphdriver" |
8 |
+ "golang.org/x/sys/unix" |
|
9 | 9 |
) |
10 | 10 |
|
11 | 11 |
func checkRootdirFs(rootdir string) error { |
12 |
- var buf syscall.Statfs_t |
|
13 |
- if err := syscall.Statfs(rootdir, &buf); err != nil { |
|
12 |
+ var buf unix.Statfs_t |
|
13 |
+ if err := unix.Statfs(rootdir, &buf); err != nil { |
|
14 | 14 |
return fmt.Errorf("Failed to access '%s': %s", rootdir, err) |
15 | 15 |
} |
16 | 16 |
|
... | ... |
@@ -6,9 +6,9 @@ import ( |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 | 8 |
"strings" |
9 |
- "syscall" |
|
10 | 9 |
|
11 | 10 |
"github.com/docker/docker/pkg/idtools" |
11 |
+ "golang.org/x/sys/unix" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
// Setup populates a directory with mountpoints suitable |
... | ... |
@@ -33,7 +33,7 @@ func Setup(initLayer string, rootIDs idtools.IDPair) error { |
33 | 33 |
prev := "/" |
34 | 34 |
for _, p := range parts[1:] { |
35 | 35 |
prev = filepath.Join(prev, p) |
36 |
- syscall.Unlink(filepath.Join(initLayer, prev)) |
|
36 |
+ unix.Unlink(filepath.Join(initLayer, prev)) |
|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
if _, err := os.Stat(filepath.Join(initLayer, pth)); err != nil { |
... | ... |
@@ -16,7 +16,6 @@ import ( |
16 | 16 |
"errors" |
17 | 17 |
"fmt" |
18 | 18 |
"sync" |
19 |
- "syscall" |
|
20 | 19 |
"unsafe" |
21 | 20 |
|
22 | 21 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -42,12 +41,12 @@ var ( |
42 | 42 |
procEventWriteString = modAdvapi32.NewProc("EventWriteString") |
43 | 43 |
procEventUnregister = modAdvapi32.NewProc("EventUnregister") |
44 | 44 |
) |
45 |
-var providerHandle syscall.Handle |
|
45 |
+var providerHandle windows.Handle |
|
46 | 46 |
var refCount int |
47 | 47 |
var mu sync.Mutex |
48 | 48 |
|
49 | 49 |
func init() { |
50 |
- providerHandle = syscall.InvalidHandle |
|
50 |
+ providerHandle = windows.InvalidHandle |
|
51 | 51 |
if err := logger.RegisterLogDriver(name, New); err != nil { |
52 | 52 |
logrus.Fatal(err) |
53 | 53 |
} |
... | ... |
@@ -70,7 +69,7 @@ func New(info logger.Info) (logger.Logger, error) { |
70 | 70 |
|
71 | 71 |
// Log logs the message to the ETW stream. |
72 | 72 |
func (etwLogger *etwLogs) Log(msg *logger.Message) error { |
73 |
- if providerHandle == syscall.InvalidHandle { |
|
73 |
+ if providerHandle == windows.InvalidHandle { |
|
74 | 74 |
// This should never be hit, if it is, it indicates a programming error. |
75 | 75 |
errorMessage := "ETWLogs cannot log the message, because the event provider has not been registered." |
76 | 76 |
logrus.Error(errorMessage) |
... | ... |
@@ -121,7 +120,7 @@ func unregisterETWProvider() { |
121 | 121 |
if refCount == 1 { |
122 | 122 |
if callEventUnregister() { |
123 | 123 |
refCount-- |
124 |
- providerHandle = syscall.InvalidHandle |
|
124 |
+ providerHandle = windows.InvalidHandle |
|
125 | 125 |
} |
126 | 126 |
// Not returning an error if EventUnregister fails, because etwLogs will continue to work |
127 | 127 |
} else { |
... | ... |
@@ -131,7 +130,7 @@ func unregisterETWProvider() { |
131 | 131 |
|
132 | 132 |
func callEventRegister() error { |
133 | 133 |
// The provider's GUID is {a3693192-9ed6-46d2-a981-f8226c8363bd} |
134 |
- guid := syscall.GUID{ |
|
134 |
+ guid := windows.GUID{ |
|
135 | 135 |
Data1: 0xa3693192, |
136 | 136 |
Data2: 0x9ed6, |
137 | 137 |
Data3: 0x46d2, |
... | ... |
@@ -148,7 +147,7 @@ func callEventRegister() error { |
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
func callEventWriteString(message string) error { |
151 |
- utf16message, err := syscall.UTF16FromString(message) |
|
151 |
+ utf16message, err := windows.UTF16FromString(message) |
|
152 | 152 |
|
153 | 153 |
if err != nil { |
154 | 154 |
return err |
... | ... |
@@ -7,7 +7,6 @@ import ( |
7 | 7 |
"net/http" |
8 | 8 |
"os" |
9 | 9 |
"path/filepath" |
10 |
- "syscall" |
|
11 | 10 |
|
12 | 11 |
"github.com/Sirupsen/logrus" |
13 | 12 |
"github.com/docker/docker/pkg/mount" |
... | ... |
@@ -15,11 +14,12 @@ import ( |
15 | 15 |
"github.com/docker/docker/pkg/plugins" |
16 | 16 |
metrics "github.com/docker/go-metrics" |
17 | 17 |
"github.com/pkg/errors" |
18 |
+ "golang.org/x/sys/unix" |
|
18 | 19 |
) |
19 | 20 |
|
20 | 21 |
func (daemon *Daemon) listenMetricsSock() (string, error) { |
21 | 22 |
path := filepath.Join(daemon.configStore.ExecRoot, "metrics.sock") |
22 |
- syscall.Unlink(path) |
|
23 |
+ unix.Unlink(path) |
|
23 | 24 |
l, err := net.Listen("unix", path) |
24 | 25 |
if err != nil { |
25 | 26 |
return "", errors.Wrap(err, "error setting up metrics plugin listener") |
... | ... |
@@ -1,14 +1,13 @@ |
1 | 1 |
package daemon |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
5 |
- |
|
6 | 4 |
containertypes "github.com/docker/docker/api/types/container" |
7 | 5 |
"github.com/docker/docker/container" |
8 | 6 |
"github.com/docker/docker/oci" |
9 | 7 |
"github.com/docker/docker/pkg/sysinfo" |
10 | 8 |
"github.com/docker/docker/pkg/system" |
11 | 9 |
"github.com/opencontainers/runtime-spec/specs-go" |
10 |
+ "golang.org/x/sys/windows" |
|
12 | 11 |
) |
13 | 12 |
|
14 | 13 |
func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { |
... | ... |
@@ -196,7 +195,7 @@ func (daemon *Daemon) createSpecLinuxFields(c *container.Container, s *specs.Spe |
196 | 196 |
func escapeArgs(args []string) []string { |
197 | 197 |
escapedArgs := make([]string, len(args)) |
198 | 198 |
for i, a := range args { |
199 |
- escapedArgs[i] = syscall.EscapeArg(a) |
|
199 |
+ escapedArgs[i] = windows.EscapeArg(a) |
|
200 | 200 |
} |
201 | 201 |
return escapedArgs |
202 | 202 |
} |
... | ... |
@@ -113,7 +113,7 @@ func continueOnError(err error) bool { |
113 | 113 |
case ImageConfigPullError: |
114 | 114 |
return false |
115 | 115 |
case error: |
116 |
- return !strings.Contains(err.Error(), strings.ToLower(syscall.ENOSPC.Error())) |
|
116 |
+ return !strings.Contains(err.Error(), strings.ToLower(syscall.ESRCH.Error())) |
|
117 | 117 |
} |
118 | 118 |
// let's be nice and fallback if the error is a completely |
119 | 119 |
// unexpected one. |
... | ... |
@@ -5,9 +5,9 @@ package daemon |
5 | 5 |
import ( |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 |
- "syscall" |
|
9 | 8 |
|
10 | 9 |
"github.com/go-check/check" |
10 |
+ "golang.org/x/sys/unix" |
|
11 | 11 |
) |
12 | 12 |
|
13 | 13 |
func cleanupExecRoot(c *check.C, execRoot string) { |
... | ... |
@@ -18,7 +18,7 @@ func cleanupExecRoot(c *check.C, execRoot string) { |
18 | 18 |
// new exec root. |
19 | 19 |
netnsPath := filepath.Join(execRoot, "netns") |
20 | 20 |
filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error { |
21 |
- if err := syscall.Unmount(path, syscall.MNT_FORCE); err != nil { |
|
21 |
+ if err := unix.Unmount(path, unix.MNT_FORCE); err != nil { |
|
22 | 22 |
c.Logf("unmount of %s failed: %v", path, err) |
23 | 23 |
} |
24 | 24 |
os.Remove(path) |
... | ... |
@@ -28,9 +28,9 @@ func cleanupExecRoot(c *check.C, execRoot string) { |
28 | 28 |
|
29 | 29 |
// SignalDaemonDump sends a signal to the daemon to write a dump file |
30 | 30 |
func SignalDaemonDump(pid int) { |
31 |
- syscall.Kill(pid, syscall.SIGQUIT) |
|
31 |
+ unix.Kill(pid, unix.SIGQUIT) |
|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
func signalDaemonReload(pid int) error { |
35 |
- return syscall.Kill(pid, syscall.SIGHUP) |
|
35 |
+ return unix.Kill(pid, unix.SIGHUP) |
|
36 | 36 |
} |
... | ... |
@@ -10,21 +10,21 @@ import ( |
10 | 10 |
"golang.org/x/sys/windows" |
11 | 11 |
) |
12 | 12 |
|
13 |
-func openEvent(desiredAccess uint32, inheritHandle bool, name string, proc *windows.LazyProc) (handle syscall.Handle, err error) { |
|
14 |
- namep, _ := syscall.UTF16PtrFromString(name) |
|
13 |
+func openEvent(desiredAccess uint32, inheritHandle bool, name string, proc *windows.LazyProc) (handle windows.Handle, err error) { |
|
14 |
+ namep, _ := windows.UTF16PtrFromString(name) |
|
15 | 15 |
var _p2 uint32 |
16 | 16 |
if inheritHandle { |
17 | 17 |
_p2 = 1 |
18 | 18 |
} |
19 | 19 |
r0, _, e1 := proc.Call(uintptr(desiredAccess), uintptr(_p2), uintptr(unsafe.Pointer(namep))) |
20 |
- handle = syscall.Handle(r0) |
|
21 |
- if handle == syscall.InvalidHandle { |
|
20 |
+ handle = windows.Handle(r0) |
|
21 |
+ if handle == windows.InvalidHandle { |
|
22 | 22 |
err = e1 |
23 | 23 |
} |
24 | 24 |
return |
25 | 25 |
} |
26 | 26 |
|
27 |
-func pulseEvent(handle syscall.Handle, proc *windows.LazyProc) (err error) { |
|
27 |
+func pulseEvent(handle windows.Handle, proc *windows.LazyProc) (err error) { |
|
28 | 28 |
r0, _, _ := proc.Call(uintptr(handle)) |
29 | 29 |
if r0 != 0 { |
30 | 30 |
err = syscall.Errno(r0) |
... | ... |
@@ -7,7 +7,6 @@ import ( |
7 | 7 |
"path" |
8 | 8 |
"strconv" |
9 | 9 |
"strings" |
10 |
- "syscall" |
|
11 | 10 |
"time" |
12 | 11 |
|
13 | 12 |
"github.com/docker/docker/api/types/swarm" |
... | ... |
@@ -17,6 +16,7 @@ import ( |
17 | 17 |
"github.com/docker/docker/integration-cli/fixtures/plugin" |
18 | 18 |
"github.com/go-check/check" |
19 | 19 |
"golang.org/x/net/context" |
20 |
+ "golang.org/x/sys/unix" |
|
20 | 21 |
) |
21 | 22 |
|
22 | 23 |
func setPortConfig(portConfig []swarm.PortConfig) daemon.ServiceConstructor { |
... | ... |
@@ -584,7 +584,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesStateReporting(c *check.C) { |
584 | 584 |
c.Assert(err, checker.IsNil) |
585 | 585 |
pid, err := strconv.Atoi(strings.TrimSpace(pidStr)) |
586 | 586 |
c.Assert(err, checker.IsNil) |
587 |
- c.Assert(syscall.Kill(pid, syscall.SIGKILL), checker.IsNil) |
|
587 |
+ c.Assert(unix.Kill(pid, unix.SIGKILL), checker.IsNil) |
|
588 | 588 |
|
589 | 589 |
time.Sleep(time.Second) // give some time to handle the signal |
590 | 590 |
|
... | ... |
@@ -6,12 +6,12 @@ import ( |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 | 8 |
"strings" |
9 |
- "syscall" |
|
10 | 9 |
|
11 | 10 |
"github.com/docker/docker/integration-cli/checker" |
12 | 11 |
"github.com/docker/docker/pkg/mount" |
13 | 12 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
14 | 13 |
"github.com/go-check/check" |
14 |
+ "golang.org/x/sys/unix" |
|
15 | 15 |
) |
16 | 16 |
|
17 | 17 |
// TestDaemonRestartWithPluginEnabled tests state restore for an enabled plugin |
... | ... |
@@ -145,7 +145,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) { |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
for { |
148 |
- if err := syscall.Kill(s.d.Pid(), 0); err == syscall.ESRCH { |
|
148 |
+ if err := unix.Kill(s.d.Pid(), 0); err == unix.ESRCH { |
|
149 | 149 |
break |
150 | 150 |
} |
151 | 151 |
} |
... | ... |
@@ -19,7 +19,6 @@ import ( |
19 | 19 |
"strconv" |
20 | 20 |
"strings" |
21 | 21 |
"sync" |
22 |
- "syscall" |
|
23 | 22 |
"time" |
24 | 23 |
|
25 | 24 |
"crypto/tls" |
... | ... |
@@ -42,6 +41,7 @@ import ( |
42 | 42 |
"github.com/docker/libtrust" |
43 | 43 |
"github.com/go-check/check" |
44 | 44 |
"github.com/kr/pty" |
45 |
+ "golang.org/x/sys/unix" |
|
45 | 46 |
) |
46 | 47 |
|
47 | 48 |
// TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon |
... | ... |
@@ -2309,8 +2309,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *check.C) { |
2309 | 2309 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
2310 | 2310 |
configFile.Close() |
2311 | 2311 |
|
2312 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2313 |
- // syscall.Kill(s.d.cmd.Process.Pid, syscall.SIGHUP) |
|
2312 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2313 |
+ // unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP) |
|
2314 | 2314 |
|
2315 | 2315 |
time.Sleep(3 * time.Second) |
2316 | 2316 |
|
... | ... |
@@ -2350,8 +2350,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec |
2350 | 2350 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
2351 | 2351 |
configFile.Close() |
2352 | 2352 |
|
2353 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2354 |
- // syscall.Kill(s.d.cmd.Process.Pid, syscall.SIGHUP) |
|
2353 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2354 |
+ // unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP) |
|
2355 | 2355 |
|
2356 | 2356 |
time.Sleep(3 * time.Second) |
2357 | 2357 |
|
... | ... |
@@ -2368,7 +2368,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec |
2368 | 2368 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
2369 | 2369 |
configFile.Close() |
2370 | 2370 |
|
2371 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2371 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2372 | 2372 |
|
2373 | 2373 |
time.Sleep(3 * time.Second) |
2374 | 2374 |
|
... | ... |
@@ -2455,7 +2455,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) { |
2455 | 2455 |
} |
2456 | 2456 |
` |
2457 | 2457 |
ioutil.WriteFile(configName, []byte(config), 0644) |
2458 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2458 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2459 | 2459 |
// Give daemon time to reload config |
2460 | 2460 |
<-time.After(1 * time.Second) |
2461 | 2461 |
|
... | ... |
@@ -2484,7 +2484,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) { |
2484 | 2484 |
} |
2485 | 2485 |
` |
2486 | 2486 |
ioutil.WriteFile(configName, []byte(config), 0644) |
2487 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2487 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2488 | 2488 |
// Give daemon time to reload config |
2489 | 2489 |
<-time.After(1 * time.Second) |
2490 | 2490 |
|
... | ... |
@@ -2510,7 +2510,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) { |
2510 | 2510 |
} |
2511 | 2511 |
` |
2512 | 2512 |
ioutil.WriteFile(configName, []byte(config), 0644) |
2513 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2513 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2514 | 2514 |
// Give daemon time to reload config |
2515 | 2515 |
<-time.After(1 * time.Second) |
2516 | 2516 |
|
... | ... |
@@ -2762,7 +2762,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) { |
2762 | 2762 |
_, err := s.d.Cmd("run", "-d", "busybox", "top") |
2763 | 2763 |
c.Assert(err, check.IsNil) |
2764 | 2764 |
|
2765 |
- c.Assert(s.d.Signal(syscall.SIGINT), checker.IsNil) |
|
2765 |
+ c.Assert(s.d.Signal(unix.SIGINT), checker.IsNil) |
|
2766 | 2766 |
|
2767 | 2767 |
select { |
2768 | 2768 |
case <-s.d.Wait: |
... | ... |
@@ -2796,7 +2796,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C) |
2796 | 2796 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
2797 | 2797 |
configFile.Close() |
2798 | 2798 |
|
2799 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
2799 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
2800 | 2800 |
|
2801 | 2801 |
select { |
2802 | 2802 |
case <-s.d.Wait: |
... | ... |
@@ -2897,7 +2897,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *check.C) { |
2897 | 2897 |
pidint, err := strconv.Atoi(strings.TrimSpace(pid)) |
2898 | 2898 |
c.Assert(err, check.IsNil) |
2899 | 2899 |
c.Assert(pidint, checker.GreaterThan, 0) |
2900 |
- c.Assert(syscall.Kill(pidint, syscall.SIGKILL), check.IsNil) |
|
2900 |
+ c.Assert(unix.Kill(pidint, unix.SIGKILL), check.IsNil) |
|
2901 | 2901 |
|
2902 | 2902 |
ticker := time.NewTicker(50 * time.Millisecond) |
2903 | 2903 |
timeout := time.After(10 * time.Second) |
... | ... |
@@ -10,7 +10,6 @@ import ( |
10 | 10 |
"os" |
11 | 11 |
"os/exec" |
12 | 12 |
"strings" |
13 |
- "syscall" |
|
14 | 13 |
"time" |
15 | 14 |
"unicode" |
16 | 15 |
|
... | ... |
@@ -18,6 +17,7 @@ import ( |
18 | 18 |
"github.com/docker/docker/integration-cli/cli/build" |
19 | 19 |
"github.com/go-check/check" |
20 | 20 |
"github.com/kr/pty" |
21 |
+ "golang.org/x/sys/unix" |
|
21 | 22 |
) |
22 | 23 |
|
23 | 24 |
// #5979 |
... | ... |
@@ -421,7 +421,7 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) { |
421 | 421 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
422 | 422 |
configFile.Close() |
423 | 423 |
|
424 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
424 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
425 | 425 |
|
426 | 426 |
time.Sleep(3 * time.Second) |
427 | 427 |
|
... | ... |
@@ -459,7 +459,7 @@ func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) { |
459 | 459 |
} |
460 | 460 |
c.Assert(daemonID, checker.Not(checker.Equals), "") |
461 | 461 |
|
462 |
- c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil) |
|
462 |
+ c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil) |
|
463 | 463 |
|
464 | 464 |
time.Sleep(3 * time.Second) |
465 | 465 |
|
... | ... |
@@ -12,7 +12,6 @@ import ( |
12 | 12 |
"os" |
13 | 13 |
"path/filepath" |
14 | 14 |
"strings" |
15 |
- "syscall" |
|
16 | 15 |
"time" |
17 | 16 |
|
18 | 17 |
"github.com/docker/docker/api/types" |
... | ... |
@@ -30,6 +29,7 @@ import ( |
30 | 30 |
"github.com/docker/libnetwork/netlabel" |
31 | 31 |
"github.com/go-check/check" |
32 | 32 |
"github.com/vishvananda/netlink" |
33 |
+ "golang.org/x/sys/unix" |
|
33 | 34 |
) |
34 | 35 |
|
35 | 36 |
const dummyNetworkDriver = "dummy-network-driver" |
... | ... |
@@ -1810,12 +1810,12 @@ func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) { |
1810 | 1810 |
cli.DockerCmd(c, "run", "-d", "--name", "client", "--net=host", "appropriate/nc", "sh", "-c", cmd) |
1811 | 1811 |
|
1812 | 1812 |
// Get all the flows using netlink |
1813 |
- flows, err := netlink.ConntrackTableList(netlink.ConntrackTable, syscall.AF_INET) |
|
1813 |
+ flows, err := netlink.ConntrackTableList(netlink.ConntrackTable, unix.AF_INET) |
|
1814 | 1814 |
c.Assert(err, check.IsNil) |
1815 | 1815 |
var flowMatch int |
1816 | 1816 |
for _, flow := range flows { |
1817 | 1817 |
// count only the flows that we are interested in, skipping others that can be laying around the host |
1818 |
- if flow.Forward.Protocol == syscall.IPPROTO_UDP && |
|
1818 |
+ if flow.Forward.Protocol == unix.IPPROTO_UDP && |
|
1819 | 1819 |
flow.Forward.DstIP.Equal(net.ParseIP("192.168.10.1")) && |
1820 | 1820 |
flow.Forward.DstPort == 8080 { |
1821 | 1821 |
flowMatch++ |
... | ... |
@@ -1828,11 +1828,11 @@ func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) { |
1828 | 1828 |
cli.DockerCmd(c, "rm", "-fv", "server") |
1829 | 1829 |
|
1830 | 1830 |
// Fetch again all the flows and validate that there is no server flow in the conntrack laying around |
1831 |
- flows, err = netlink.ConntrackTableList(netlink.ConntrackTable, syscall.AF_INET) |
|
1831 |
+ flows, err = netlink.ConntrackTableList(netlink.ConntrackTable, unix.AF_INET) |
|
1832 | 1832 |
c.Assert(err, check.IsNil) |
1833 | 1833 |
flowMatch = 0 |
1834 | 1834 |
for _, flow := range flows { |
1835 |
- if flow.Forward.Protocol == syscall.IPPROTO_UDP && |
|
1835 |
+ if flow.Forward.Protocol == unix.IPPROTO_UDP && |
|
1836 | 1836 |
flow.Forward.DstIP.Equal(net.ParseIP("192.168.10.1")) && |
1837 | 1837 |
flow.Forward.DstPort == 8080 { |
1838 | 1838 |
flowMatch++ |
... | ... |
@@ -5,7 +5,6 @@ import ( |
5 | 5 |
"os" |
6 | 6 |
"strings" |
7 | 7 |
"sync" |
8 |
- "syscall" |
|
9 | 8 |
"time" |
10 | 9 |
|
11 | 10 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -17,6 +16,7 @@ import ( |
17 | 17 |
"github.com/golang/protobuf/ptypes/timestamp" |
18 | 18 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
19 | 19 |
"golang.org/x/net/context" |
20 |
+ "golang.org/x/sys/unix" |
|
20 | 21 |
) |
21 | 22 |
|
22 | 23 |
type client struct { |
... | ... |
@@ -95,9 +95,9 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly |
95 | 95 |
AdditionalGids: sp.User.AdditionalGids, |
96 | 96 |
}, |
97 | 97 |
Pid: processFriendlyName, |
98 |
- Stdin: p.fifo(syscall.Stdin), |
|
99 |
- Stdout: p.fifo(syscall.Stdout), |
|
100 |
- Stderr: p.fifo(syscall.Stderr), |
|
98 |
+ Stdin: p.fifo(unix.Stdin), |
|
99 |
+ Stdout: p.fifo(unix.Stdout), |
|
100 |
+ Stderr: p.fifo(unix.Stderr), |
|
101 | 101 |
Capabilities: sp.Capabilities.Effective, |
102 | 102 |
ApparmorProfile: sp.ApparmorProfile, |
103 | 103 |
SelinuxLabel: sp.SelinuxLabel, |
... | ... |
@@ -226,7 +226,7 @@ func (clnt *client) cleanupOldRootfs(containerID string) { |
226 | 226 |
if mts, err := mount.GetMounts(); err == nil { |
227 | 227 |
for _, mts := range mts { |
228 | 228 |
if strings.HasSuffix(mts.Mountpoint, containerID+"/rootfs") { |
229 |
- if err := syscall.Unmount(mts.Mountpoint, syscall.MNT_DETACH); err == nil { |
|
229 |
+ if err := unix.Unmount(mts.Mountpoint, unix.MNT_DETACH); err == nil { |
|
230 | 230 |
os.RemoveAll(strings.TrimSuffix(mts.Mountpoint, "/rootfs")) |
231 | 231 |
} |
232 | 232 |
break |
... | ... |
@@ -524,7 +524,7 @@ func (clnt *client) Restore(containerID string, attachStdio StdioCallback, optio |
524 | 524 |
|
525 | 525 |
container.discardFifos() |
526 | 526 |
|
527 |
- if err := clnt.Signal(containerID, int(syscall.SIGTERM)); err != nil { |
|
527 |
+ if err := clnt.Signal(containerID, int(unix.SIGTERM)); err != nil { |
|
528 | 528 |
logrus.Errorf("libcontainerd: error sending sigterm to %v: %v", containerID, err) |
529 | 529 |
} |
530 | 530 |
|
... | ... |
@@ -541,7 +541,7 @@ func (clnt *client) Restore(containerID string, attachStdio StdioCallback, optio |
541 | 541 |
|
542 | 542 |
select { |
543 | 543 |
case <-time.After(10 * time.Second): |
544 |
- if err := clnt.Signal(containerID, int(syscall.SIGKILL)); err != nil { |
|
544 |
+ if err := clnt.Signal(containerID, int(unix.SIGKILL)); err != nil { |
|
545 | 545 |
logrus.Errorf("libcontainerd: error sending sigkill to %v: %v", containerID, err) |
546 | 546 |
} |
547 | 547 |
select { |
... | ... |
@@ -9,7 +9,6 @@ import ( |
9 | 9 |
"os" |
10 | 10 |
"path/filepath" |
11 | 11 |
"sync" |
12 |
- "syscall" |
|
13 | 12 |
"time" |
14 | 13 |
|
15 | 14 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -18,6 +17,7 @@ import ( |
18 | 18 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
19 | 19 |
"github.com/tonistiigi/fifo" |
20 | 20 |
"golang.org/x/net/context" |
21 |
+ "golang.org/x/sys/unix" |
|
21 | 22 |
) |
22 | 23 |
|
23 | 24 |
type container struct { |
... | ... |
@@ -69,7 +69,7 @@ func (ctr *container) clean() error { |
69 | 69 |
// Caller needs to lock container ID before calling this method. |
70 | 70 |
func (ctr *container) cleanProcess(id string) { |
71 | 71 |
if p, ok := ctr.processes[id]; ok { |
72 |
- for _, i := range []int{syscall.Stdin, syscall.Stdout, syscall.Stderr} { |
|
72 |
+ for _, i := range []int{unix.Stdin, unix.Stdout, unix.Stderr} { |
|
73 | 73 |
if err := os.Remove(p.fifo(i)); err != nil && !os.IsNotExist(err) { |
74 | 74 |
logrus.Warnf("libcontainerd: failed to remove %v for process %v: %v", p.fifo(i), id, err) |
75 | 75 |
} |
... | ... |
@@ -137,9 +137,9 @@ func (ctr *container) start(spec *specs.Spec, checkpoint, checkpointDir string, |
137 | 137 |
r := &containerd.CreateContainerRequest{ |
138 | 138 |
Id: ctr.containerID, |
139 | 139 |
BundlePath: ctr.dir, |
140 |
- Stdin: ctr.fifo(syscall.Stdin), |
|
141 |
- Stdout: ctr.fifo(syscall.Stdout), |
|
142 |
- Stderr: ctr.fifo(syscall.Stderr), |
|
140 |
+ Stdin: ctr.fifo(unix.Stdin), |
|
141 |
+ Stdout: ctr.fifo(unix.Stdout), |
|
142 |
+ Stderr: ctr.fifo(unix.Stderr), |
|
143 | 143 |
Checkpoint: checkpoint, |
144 | 144 |
CheckpointDir: checkpointDir, |
145 | 145 |
// check to see if we are running in ramdisk to disable pivot root |
... | ... |
@@ -233,8 +233,8 @@ func (ctr *container) handleEvent(e *containerd.Event) error { |
233 | 233 |
// that may be blocked on the writer side. |
234 | 234 |
func (ctr *container) discardFifos() { |
235 | 235 |
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) |
236 |
- for _, i := range []int{syscall.Stdout, syscall.Stderr} { |
|
237 |
- f, err := fifo.OpenFifo(ctx, ctr.fifo(i), syscall.O_RDONLY|syscall.O_NONBLOCK, 0) |
|
236 |
+ for _, i := range []int{unix.Stdout, unix.Stderr} { |
|
237 |
+ f, err := fifo.OpenFifo(ctx, ctr.fifo(i), unix.O_RDONLY|unix.O_NONBLOCK, 0) |
|
238 | 238 |
if err != nil { |
239 | 239 |
logrus.Warnf("error opening fifo %v for discarding: %+v", f, err) |
240 | 240 |
continue |
... | ... |
@@ -6,13 +6,13 @@ import ( |
6 | 6 |
"io" |
7 | 7 |
"io/ioutil" |
8 | 8 |
"strings" |
9 |
- "syscall" |
|
10 | 9 |
"time" |
11 | 10 |
|
12 | 11 |
"github.com/Microsoft/hcsshim" |
13 | 12 |
"github.com/Sirupsen/logrus" |
14 | 13 |
"github.com/docker/docker/pkg/system" |
15 | 14 |
"github.com/opencontainers/runtime-spec/specs-go" |
15 |
+ "golang.org/x/sys/windows" |
|
16 | 16 |
) |
17 | 17 |
|
18 | 18 |
type container struct { |
... | ... |
@@ -185,7 +185,7 @@ func (ctr *container) waitProcessExitCode(process *process) int { |
185 | 185 |
// Block indefinitely for the process to exit. |
186 | 186 |
err := process.hcsProcess.Wait() |
187 | 187 |
if err != nil { |
188 |
- if herr, ok := err.(*hcsshim.ProcessError); ok && herr.Err != syscall.ERROR_BROKEN_PIPE { |
|
188 |
+ if herr, ok := err.(*hcsshim.ProcessError); ok && herr.Err != windows.ERROR_BROKEN_PIPE { |
|
189 | 189 |
logrus.Warnf("libcontainerd: Wait() failed (container may have been killed): %s", err) |
190 | 190 |
} |
191 | 191 |
// Fall through here, do not return. This ensures we attempt to continue the |
... | ... |
@@ -195,7 +195,7 @@ func (ctr *container) waitProcessExitCode(process *process) int { |
195 | 195 |
|
196 | 196 |
exitCode, err := process.hcsProcess.ExitCode() |
197 | 197 |
if err != nil { |
198 |
- if herr, ok := err.(*hcsshim.ProcessError); ok && herr.Err != syscall.ERROR_BROKEN_PIPE { |
|
198 |
+ if herr, ok := err.(*hcsshim.ProcessError); ok && herr.Err != windows.ERROR_BROKEN_PIPE { |
|
199 | 199 |
logrus.Warnf("libcontainerd: unable to get exit code from container %s", ctr.containerID) |
200 | 200 |
} |
201 | 201 |
// Since we got an error retrieving the exit code, make sure that the code we return |
... | ... |
@@ -15,7 +15,6 @@ import ( |
15 | 15 |
"strconv" |
16 | 16 |
"strings" |
17 | 17 |
"sync" |
18 |
- "syscall" |
|
19 | 18 |
"time" |
20 | 19 |
|
21 | 20 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -25,6 +24,7 @@ import ( |
25 | 25 |
"github.com/golang/protobuf/ptypes" |
26 | 26 |
"github.com/golang/protobuf/ptypes/timestamp" |
27 | 27 |
"golang.org/x/net/context" |
28 |
+ "golang.org/x/sys/unix" |
|
28 | 29 |
"google.golang.org/grpc" |
29 | 30 |
"google.golang.org/grpc/grpclog" |
30 | 31 |
"google.golang.org/grpc/health/grpc_health_v1" |
... | ... |
@@ -185,7 +185,7 @@ func (r *remote) Cleanup() { |
185 | 185 |
r.closedManually = true |
186 | 186 |
r.rpcConn.Close() |
187 | 187 |
// Ask the daemon to quit |
188 |
- syscall.Kill(r.daemonPid, syscall.SIGTERM) |
|
188 |
+ unix.Kill(r.daemonPid, unix.SIGTERM) |
|
189 | 189 |
|
190 | 190 |
// Wait up to 15secs for it to stop |
191 | 191 |
for i := time.Duration(0); i < containerdShutdownTimeout; i += time.Second { |
... | ... |
@@ -197,7 +197,7 @@ func (r *remote) Cleanup() { |
197 | 197 |
|
198 | 198 |
if system.IsProcessAlive(r.daemonPid) { |
199 | 199 |
logrus.Warnf("libcontainerd: containerd (%d) didn't stop within 15 secs, killing it\n", r.daemonPid) |
200 |
- syscall.Kill(r.daemonPid, syscall.SIGKILL) |
|
200 |
+ unix.Kill(r.daemonPid, unix.SIGKILL) |
|
201 | 201 |
} |
202 | 202 |
|
203 | 203 |
// cleanup some files |
... | ... |
@@ -224,7 +224,7 @@ func (r *remote) Client(b Backend) (Client, error) { |
224 | 224 |
} |
225 | 225 |
|
226 | 226 |
func (r *remote) updateEventTimestamp(t time.Time) { |
227 |
- f, err := os.OpenFile(r.eventTsPath, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600) |
|
227 |
+ f, err := os.OpenFile(r.eventTsPath, unix.O_CREAT|unix.O_WRONLY|unix.O_TRUNC, 0600) |
|
228 | 228 |
if err != nil { |
229 | 229 |
logrus.Warnf("libcontainerd: failed to open event timestamp file: %v", err) |
230 | 230 |
return |
... | ... |
@@ -5,6 +5,7 @@ import ( |
5 | 5 |
|
6 | 6 |
containerd "github.com/containerd/containerd/api/grpc/types" |
7 | 7 |
"github.com/opencontainers/runtime-spec/specs-go" |
8 |
+ "golang.org/x/sys/unix" |
|
8 | 9 |
) |
9 | 10 |
|
10 | 11 |
func getRootIDs(s specs.Spec) (int, int, error) { |
... | ... |
@@ -57,6 +58,6 @@ func convertRlimits(sr []specs.LinuxRlimit) (cr []*containerd.Rlimit) { |
57 | 57 |
func setSysProcAttr(sid bool) *syscall.SysProcAttr { |
58 | 58 |
return &syscall.SysProcAttr{ |
59 | 59 |
Setsid: sid, |
60 |
- Pdeathsig: syscall.SIGKILL, |
|
60 |
+ Pdeathsig: unix.SIGKILL, |
|
61 | 61 |
} |
62 | 62 |
} |
... | ... |
@@ -5,9 +5,9 @@ import ( |
5 | 5 |
"os" |
6 | 6 |
"path/filepath" |
7 | 7 |
"strings" |
8 |
- "syscall" |
|
9 | 8 |
|
10 | 9 |
"github.com/docker/docker/pkg/system" |
10 |
+ "golang.org/x/sys/unix" |
|
11 | 11 |
) |
12 | 12 |
|
13 | 13 |
func getWhiteoutConverter(format WhiteoutFormat) tarWhiteoutConverter { |
... | ... |
@@ -67,7 +67,7 @@ func (overlayWhiteoutConverter) ConvertRead(hdr *tar.Header, path string) (bool, |
67 | 67 |
|
68 | 68 |
// if a directory is marked as opaque by the AUFS special file, we need to translate that to overlay |
69 | 69 |
if base == WhiteoutOpaqueDir { |
70 |
- err := syscall.Setxattr(dir, "trusted.overlay.opaque", []byte{'y'}, 0) |
|
70 |
+ err := unix.Setxattr(dir, "trusted.overlay.opaque", []byte{'y'}, 0) |
|
71 | 71 |
// don't write the file itself |
72 | 72 |
return false, err |
73 | 73 |
} |
... | ... |
@@ -77,7 +77,7 @@ func (overlayWhiteoutConverter) ConvertRead(hdr *tar.Header, path string) (bool, |
77 | 77 |
originalBase := base[len(WhiteoutPrefix):] |
78 | 78 |
originalPath := filepath.Join(dir, originalBase) |
79 | 79 |
|
80 |
- if err := syscall.Mknod(originalPath, syscall.S_IFCHR, 0); err != nil { |
|
80 |
+ if err := unix.Mknod(originalPath, unix.S_IFCHR, 0); err != nil { |
|
81 | 81 |
return false, err |
82 | 82 |
} |
83 | 83 |
if err := os.Chown(originalPath, hdr.Uid, hdr.Gid); err != nil { |
... | ... |
@@ -8,6 +8,7 @@ import ( |
8 | 8 |
"testing" |
9 | 9 |
|
10 | 10 |
"github.com/docker/docker/pkg/system" |
11 |
+ "golang.org/x/sys/unix" |
|
11 | 12 |
) |
12 | 13 |
|
13 | 14 |
// setupOverlayTestDir creates files in a directory with overlay whiteouts |
... | ... |
@@ -51,7 +52,7 @@ func setupOverlayTestDir(t *testing.T, src string) { |
51 | 51 |
t.Fatal(err) |
52 | 52 |
} |
53 | 53 |
|
54 |
- if err := system.Mknod(filepath.Join(src, "d3", "f1"), syscall.S_IFCHR, 0); err != nil { |
|
54 |
+ if err := system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0); err != nil { |
|
55 | 55 |
t.Fatal(err) |
56 | 56 |
} |
57 | 57 |
} |
... | ... |
@@ -12,6 +12,7 @@ import ( |
12 | 12 |
"github.com/docker/docker/pkg/idtools" |
13 | 13 |
"github.com/docker/docker/pkg/system" |
14 | 14 |
rsystem "github.com/opencontainers/runc/libcontainer/system" |
15 |
+ "golang.org/x/sys/unix" |
|
15 | 16 |
) |
16 | 17 |
|
17 | 18 |
// fixVolumePathPrefix does platform specific processing to ensure that if |
... | ... |
@@ -47,8 +48,8 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) ( |
47 | 47 |
|
48 | 48 |
if ok { |
49 | 49 |
// Currently go does not fill in the major/minors |
50 |
- if s.Mode&syscall.S_IFBLK != 0 || |
|
51 |
- s.Mode&syscall.S_IFCHR != 0 { |
|
50 |
+ if s.Mode&unix.S_IFBLK != 0 || |
|
51 |
+ s.Mode&unix.S_IFCHR != 0 { |
|
52 | 52 |
hdr.Devmajor = int64(major(uint64(s.Rdev))) |
53 | 53 |
hdr.Devminor = int64(minor(uint64(s.Rdev))) |
54 | 54 |
} |
... | ... |
@@ -95,11 +96,11 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { |
95 | 95 |
mode := uint32(hdr.Mode & 07777) |
96 | 96 |
switch hdr.Typeflag { |
97 | 97 |
case tar.TypeBlock: |
98 |
- mode |= syscall.S_IFBLK |
|
98 |
+ mode |= unix.S_IFBLK |
|
99 | 99 |
case tar.TypeChar: |
100 |
- mode |= syscall.S_IFCHR |
|
100 |
+ mode |= unix.S_IFCHR |
|
101 | 101 |
case tar.TypeFifo: |
102 |
- mode |= syscall.S_IFIFO |
|
102 |
+ mode |= unix.S_IFIFO |
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))) |
... | ... |
@@ -13,6 +13,7 @@ import ( |
13 | 13 |
"testing" |
14 | 14 |
|
15 | 15 |
"github.com/docker/docker/pkg/system" |
16 |
+ "golang.org/x/sys/unix" |
|
16 | 17 |
) |
17 | 18 |
|
18 | 19 |
func TestCanonicalTarNameForPath(t *testing.T) { |
... | ... |
@@ -159,13 +160,13 @@ func TestTarWithBlockCharFifo(t *testing.T) { |
159 | 159 |
if err := ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil { |
160 | 160 |
t.Fatal(err) |
161 | 161 |
} |
162 |
- if err := system.Mknod(filepath.Join(origin, "2"), syscall.S_IFBLK, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
162 |
+ if err := system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
163 | 163 |
t.Fatal(err) |
164 | 164 |
} |
165 |
- if err := system.Mknod(filepath.Join(origin, "3"), syscall.S_IFCHR, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
165 |
+ if err := system.Mknod(filepath.Join(origin, "3"), unix.S_IFCHR, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
166 | 166 |
t.Fatal(err) |
167 | 167 |
} |
168 |
- if err := system.Mknod(filepath.Join(origin, "4"), syscall.S_IFIFO, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
168 |
+ if err := system.Mknod(filepath.Join(origin, "4"), unix.S_IFIFO, int(system.Mkdev(int64(12), int64(5)))); err != nil { |
|
169 | 169 |
t.Fatal(err) |
170 | 170 |
} |
171 | 171 |
|
... | ... |
@@ -10,6 +10,7 @@ import ( |
10 | 10 |
"unsafe" |
11 | 11 |
|
12 | 12 |
"github.com/docker/docker/pkg/system" |
13 |
+ "golang.org/x/sys/unix" |
|
13 | 14 |
) |
14 | 15 |
|
15 | 16 |
// walker is used to implement collectFileInfoForChanges on linux. Where this |
... | ... |
@@ -233,7 +234,7 @@ func readdirnames(dirname string) (names []nameIno, err error) { |
233 | 233 |
// Refill the buffer if necessary |
234 | 234 |
if bufp >= nbuf { |
235 | 235 |
bufp = 0 |
236 |
- nbuf, err = syscall.ReadDirent(int(f.Fd()), buf) // getdents on linux |
|
236 |
+ nbuf, err = unix.ReadDirent(int(f.Fd()), buf) // getdents on linux |
|
237 | 237 |
if nbuf < 0 { |
238 | 238 |
nbuf = 0 |
239 | 239 |
} |
... | ... |
@@ -255,12 +256,12 @@ func readdirnames(dirname string) (names []nameIno, err error) { |
255 | 255 |
return sl, nil |
256 | 256 |
} |
257 | 257 |
|
258 |
-// parseDirent is a minor modification of syscall.ParseDirent (linux version) |
|
258 |
+// parseDirent is a minor modification of unix.ParseDirent (linux version) |
|
259 | 259 |
// which returns {name,inode} pairs instead of just names. |
260 | 260 |
func parseDirent(buf []byte, names []nameIno) (consumed int, newnames []nameIno) { |
261 | 261 |
origlen := len(buf) |
262 | 262 |
for len(buf) > 0 { |
263 |
- dirent := (*syscall.Dirent)(unsafe.Pointer(&buf[0])) |
|
263 |
+ dirent := (*unix.Dirent)(unsafe.Pointer(&buf[0])) |
|
264 | 264 |
buf = buf[dirent.Reclen:] |
265 | 265 |
if dirent.Ino == 0 { // File absent in directory. |
266 | 266 |
continue |
... | ... |
@@ -7,6 +7,7 @@ import ( |
7 | 7 |
"syscall" |
8 | 8 |
|
9 | 9 |
"github.com/docker/docker/pkg/system" |
10 |
+ "golang.org/x/sys/unix" |
|
10 | 11 |
) |
11 | 12 |
|
12 | 13 |
func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { |
... | ... |
@@ -16,7 +17,7 @@ func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { |
16 | 16 |
oldStat.GID() != newStat.GID() || |
17 | 17 |
oldStat.Rdev() != newStat.Rdev() || |
18 | 18 |
// Don't look at size for dirs, its not a good measure of change |
19 |
- (oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR && |
|
19 |
+ (oldStat.Mode()&unix.S_IFDIR != unix.S_IFDIR && |
|
20 | 20 |
(!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) || (oldStat.Size() != newStat.Size()))) { |
21 | 21 |
return true |
22 | 22 |
} |
... | ... |
@@ -24,7 +25,7 @@ func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { |
24 | 24 |
} |
25 | 25 |
|
26 | 26 |
func (info *FileInfo) isDir() bool { |
27 |
- return info.parent == nil || info.stat.Mode()&syscall.S_IFDIR != 0 |
|
27 |
+ return info.parent == nil || info.stat.Mode()&unix.S_IFDIR != 0 |
|
28 | 28 |
} |
29 | 29 |
|
30 | 30 |
func getIno(fi os.FileInfo) uint64 { |
... | ... |
@@ -5,10 +5,10 @@ import ( |
5 | 5 |
"io/ioutil" |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 |
- "syscall" |
|
9 | 8 |
|
10 | 9 |
"github.com/docker/docker/pkg/mount" |
11 | 10 |
rsystem "github.com/opencontainers/runc/libcontainer/system" |
11 |
+ "golang.org/x/sys/unix" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
// chroot on linux uses pivot_root instead of chroot |
... | ... |
@@ -22,7 +22,7 @@ func chroot(path string) (err error) { |
22 | 22 |
if rsystem.RunningInUserNS() { |
23 | 23 |
return realChroot(path) |
24 | 24 |
} |
25 |
- if err := syscall.Unshare(syscall.CLONE_NEWNS); err != nil { |
|
25 |
+ if err := unix.Unshare(unix.CLONE_NEWNS); err != nil { |
|
26 | 26 |
return fmt.Errorf("Error creating mount namespace before pivot: %v", err) |
27 | 27 |
} |
28 | 28 |
|
... | ... |
@@ -47,7 +47,7 @@ func chroot(path string) (err error) { |
47 | 47 |
defer func() { |
48 | 48 |
if mounted { |
49 | 49 |
// make sure pivotDir is not mounted before we try to remove it |
50 |
- if errCleanup := syscall.Unmount(pivotDir, syscall.MNT_DETACH); errCleanup != nil { |
|
50 |
+ if errCleanup := unix.Unmount(pivotDir, unix.MNT_DETACH); errCleanup != nil { |
|
51 | 51 |
if err == nil { |
52 | 52 |
err = errCleanup |
53 | 53 |
} |
... | ... |
@@ -66,7 +66,7 @@ func chroot(path string) (err error) { |
66 | 66 |
} |
67 | 67 |
}() |
68 | 68 |
|
69 |
- if err := syscall.PivotRoot(path, pivotDir); err != nil { |
|
69 |
+ if err := unix.PivotRoot(path, pivotDir); err != nil { |
|
70 | 70 |
// If pivot fails, fall back to the normal chroot after cleaning up temp dir |
71 | 71 |
if err := os.Remove(pivotDir); err != nil { |
72 | 72 |
return fmt.Errorf("Error cleaning up after failed pivot: %v", err) |
... | ... |
@@ -79,17 +79,17 @@ func chroot(path string) (err error) { |
79 | 79 |
// This dir contains the rootfs of the caller, which we need to remove so it is not visible during extraction |
80 | 80 |
pivotDir = filepath.Join("/", filepath.Base(pivotDir)) |
81 | 81 |
|
82 |
- if err := syscall.Chdir("/"); err != nil { |
|
82 |
+ if err := unix.Chdir("/"); err != nil { |
|
83 | 83 |
return fmt.Errorf("Error changing to new root: %v", err) |
84 | 84 |
} |
85 | 85 |
|
86 | 86 |
// Make the pivotDir (where the old root lives) private so it can be unmounted without propagating to the host |
87 |
- if err := syscall.Mount("", pivotDir, "", syscall.MS_PRIVATE|syscall.MS_REC, ""); err != nil { |
|
87 |
+ if err := unix.Mount("", pivotDir, "", unix.MS_PRIVATE|unix.MS_REC, ""); err != nil { |
|
88 | 88 |
return fmt.Errorf("Error making old root private after pivot: %v", err) |
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
// Now unmount the old root so it's no longer visible from the new root |
92 |
- if err := syscall.Unmount(pivotDir, syscall.MNT_DETACH); err != nil { |
|
92 |
+ if err := unix.Unmount(pivotDir, unix.MNT_DETACH); err != nil { |
|
93 | 93 |
return fmt.Errorf("Error while unmounting old root after pivot: %v", err) |
94 | 94 |
} |
95 | 95 |
mounted = false |
... | ... |
@@ -98,10 +98,10 @@ func chroot(path string) (err error) { |
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
func realChroot(path string) error { |
101 |
- if err := syscall.Chroot(path); err != nil { |
|
101 |
+ if err := unix.Chroot(path); err != nil { |
|
102 | 102 |
return fmt.Errorf("Error after fallback to chroot: %v", err) |
103 | 103 |
} |
104 |
- if err := syscall.Chdir("/"); err != nil { |
|
104 |
+ if err := unix.Chdir("/"); err != nil { |
|
105 | 105 |
return fmt.Errorf("Error changing to new root after chroot: %v", err) |
106 | 106 |
} |
107 | 107 |
return nil |
... | ... |
@@ -2,11 +2,11 @@ |
2 | 2 |
|
3 | 3 |
package chrootarchive |
4 | 4 |
|
5 |
-import "syscall" |
|
5 |
+import "golang.org/x/sys/unix" |
|
6 | 6 |
|
7 | 7 |
func chroot(path string) error { |
8 |
- if err := syscall.Chroot(path); err != nil { |
|
8 |
+ if err := unix.Chroot(path); err != nil { |
|
9 | 9 |
return err |
10 | 10 |
} |
11 |
- return syscall.Chdir("/") |
|
11 |
+ return unix.Chdir("/") |
|
12 | 12 |
} |
... | ... |
@@ -7,10 +7,10 @@ import ( |
7 | 7 |
"fmt" |
8 | 8 |
"os" |
9 | 9 |
"runtime" |
10 |
- "syscall" |
|
11 | 10 |
"unsafe" |
12 | 11 |
|
13 | 12 |
"github.com/Sirupsen/logrus" |
13 |
+ "golang.org/x/sys/unix" |
|
14 | 14 |
) |
15 | 15 |
|
16 | 16 |
// DevmapperLogger defines methods for logging with devicemapper. |
... | ... |
@@ -449,7 +449,7 @@ func BlockDeviceDiscard(path string) error { |
449 | 449 |
|
450 | 450 |
// Without this sometimes the remove of the device that happens after |
451 | 451 |
// discard fails with EBUSY. |
452 |
- syscall.Sync() |
|
452 |
+ unix.Sync() |
|
453 | 453 |
|
454 | 454 |
return nil |
455 | 455 |
} |
... | ... |
@@ -3,13 +3,14 @@ |
3 | 3 |
package devicemapper |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
7 | 6 |
"unsafe" |
7 |
+ |
|
8 |
+ "golang.org/x/sys/unix" |
|
8 | 9 |
) |
9 | 10 |
|
10 | 11 |
func ioctlBlkGetSize64(fd uintptr) (int64, error) { |
11 | 12 |
var size int64 |
12 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkGetSize64, uintptr(unsafe.Pointer(&size))); err != 0 { |
|
13 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, BlkGetSize64, uintptr(unsafe.Pointer(&size))); err != 0 { |
|
13 | 14 |
return 0, err |
14 | 15 |
} |
15 | 16 |
return size, nil |
... | ... |
@@ -20,7 +21,7 @@ func ioctlBlkDiscard(fd uintptr, offset, length uint64) error { |
20 | 20 |
r[0] = offset |
21 | 21 |
r[1] = length |
22 | 22 |
|
23 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkDiscard, uintptr(unsafe.Pointer(&r[0]))); err != 0 { |
|
23 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, BlkDiscard, uintptr(unsafe.Pointer(&r[0]))); err != 0 { |
|
24 | 24 |
return err |
25 | 25 |
} |
26 | 26 |
return nil |
... | ... |
@@ -6,8 +6,9 @@ import ( |
6 | 6 |
"fmt" |
7 | 7 |
"io/ioutil" |
8 | 8 |
"os" |
9 |
- "syscall" |
|
10 | 9 |
"unsafe" |
10 |
+ |
|
11 |
+ "golang.org/x/sys/unix" |
|
11 | 12 |
) |
12 | 13 |
|
13 | 14 |
func locateDummyIfEmpty(path string) (string, error) { |
... | ... |
@@ -40,9 +41,9 @@ func SupportsDType(path string) (bool, error) { |
40 | 40 |
|
41 | 41 |
visited := 0 |
42 | 42 |
supportsDType := true |
43 |
- fn := func(ent *syscall.Dirent) bool { |
|
43 |
+ fn := func(ent *unix.Dirent) bool { |
|
44 | 44 |
visited++ |
45 |
- if ent.Type == syscall.DT_UNKNOWN { |
|
45 |
+ if ent.Type == unix.DT_UNKNOWN { |
|
46 | 46 |
supportsDType = false |
47 | 47 |
// stop iteration |
48 | 48 |
return true |
... | ... |
@@ -59,7 +60,7 @@ func SupportsDType(path string) (bool, error) { |
59 | 59 |
return supportsDType, nil |
60 | 60 |
} |
61 | 61 |
|
62 |
-func iterateReadDir(path string, fn func(*syscall.Dirent) bool) error { |
|
62 |
+func iterateReadDir(path string, fn func(*unix.Dirent) bool) error { |
|
63 | 63 |
d, err := os.Open(path) |
64 | 64 |
if err != nil { |
65 | 65 |
return err |
... | ... |
@@ -68,7 +69,7 @@ func iterateReadDir(path string, fn func(*syscall.Dirent) bool) error { |
68 | 68 |
fd := int(d.Fd()) |
69 | 69 |
buf := make([]byte, 4096) |
70 | 70 |
for { |
71 |
- nbytes, err := syscall.ReadDirent(fd, buf) |
|
71 |
+ nbytes, err := unix.ReadDirent(fd, buf) |
|
72 | 72 |
if err != nil { |
73 | 73 |
return err |
74 | 74 |
} |
... | ... |
@@ -76,7 +77,7 @@ func iterateReadDir(path string, fn func(*syscall.Dirent) bool) error { |
76 | 76 |
break |
77 | 77 |
} |
78 | 78 |
for off := 0; off < nbytes; { |
79 |
- ent := (*syscall.Dirent)(unsafe.Pointer(&buf[off])) |
|
79 |
+ ent := (*unix.Dirent)(unsafe.Pointer(&buf[off])) |
|
80 | 80 |
if stop := fn(ent); stop { |
81 | 81 |
return nil |
82 | 82 |
} |
... | ... |
@@ -6,8 +6,9 @@ import ( |
6 | 6 |
"io/ioutil" |
7 | 7 |
"os" |
8 | 8 |
"os/exec" |
9 |
- "syscall" |
|
10 | 9 |
"testing" |
10 |
+ |
|
11 |
+ "golang.org/x/sys/unix" |
|
11 | 12 |
) |
12 | 13 |
|
13 | 14 |
func testSupportsDType(t *testing.T, expected bool, mkfsCommand string, mkfsArg ...string) { |
... | ... |
@@ -53,7 +54,7 @@ func testSupportsDType(t *testing.T, expected bool, mkfsCommand string, mkfsArg |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
// loopback-mount the image. |
56 |
- // for ease of setting up loopback device, we use os/exec rather than syscall.Mount |
|
56 |
+ // for ease of setting up loopback device, we use os/exec rather than unix.Mount |
|
57 | 57 |
out, err = exec.Command("mount", "-o", "loop", imageFileName, mountpoint).CombinedOutput() |
58 | 58 |
if len(out) > 0 { |
59 | 59 |
t.Log(string(out)) |
... | ... |
@@ -62,7 +63,7 @@ func testSupportsDType(t *testing.T, expected bool, mkfsCommand string, mkfsArg |
62 | 62 |
t.Skip("skipping the test because mount failed") |
63 | 63 |
} |
64 | 64 |
defer func() { |
65 |
- if err := syscall.Unmount(mountpoint, 0); err != nil { |
|
65 |
+ if err := unix.Unmount(mountpoint, 0); err != nil { |
|
66 | 66 |
t.Fatal(err) |
67 | 67 |
} |
68 | 68 |
}() |
... | ... |
@@ -6,9 +6,9 @@ import ( |
6 | 6 |
"errors" |
7 | 7 |
"fmt" |
8 | 8 |
"os" |
9 |
- "syscall" |
|
10 | 9 |
|
11 | 10 |
"github.com/Sirupsen/logrus" |
11 |
+ "golang.org/x/sys/unix" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
// Loopback related errors |
... | ... |
@@ -69,7 +69,7 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil |
69 | 69 |
loopFile.Close() |
70 | 70 |
|
71 | 71 |
// If the error is EBUSY, then try the next loopback |
72 |
- if err != syscall.EBUSY { |
|
72 |
+ if err != unix.EBUSY { |
|
73 | 73 |
logrus.Errorf("Cannot set up loopback device %s: %s", target, err) |
74 | 74 |
return nil, ErrAttachLoopbackDevice |
75 | 75 |
} |
... | ... |
@@ -3,12 +3,13 @@ |
3 | 3 |
package loopback |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
7 | 6 |
"unsafe" |
7 |
+ |
|
8 |
+ "golang.org/x/sys/unix" |
|
8 | 9 |
) |
9 | 10 |
|
10 | 11 |
func ioctlLoopCtlGetFree(fd uintptr) (int, error) { |
11 |
- index, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, LoopCtlGetFree, 0) |
|
12 |
+ index, _, err := unix.Syscall(unix.SYS_IOCTL, fd, LoopCtlGetFree, 0) |
|
12 | 13 |
if err != 0 { |
13 | 14 |
return 0, err |
14 | 15 |
} |
... | ... |
@@ -16,21 +17,21 @@ func ioctlLoopCtlGetFree(fd uintptr) (int, error) { |
16 | 16 |
} |
17 | 17 |
|
18 | 18 |
func ioctlLoopSetFd(loopFd, sparseFd uintptr) error { |
19 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetFd, sparseFd); err != 0 { |
|
19 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetFd, sparseFd); err != 0 { |
|
20 | 20 |
return err |
21 | 21 |
} |
22 | 22 |
return nil |
23 | 23 |
} |
24 | 24 |
|
25 | 25 |
func ioctlLoopSetStatus64(loopFd uintptr, loopInfo *loopInfo64) error { |
26 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
26 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
27 | 27 |
return err |
28 | 28 |
} |
29 | 29 |
return nil |
30 | 30 |
} |
31 | 31 |
|
32 | 32 |
func ioctlLoopClrFd(loopFd uintptr) error { |
33 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopClrFd, 0); err != 0 { |
|
33 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopClrFd, 0); err != 0 { |
|
34 | 34 |
return err |
35 | 35 |
} |
36 | 36 |
return nil |
... | ... |
@@ -39,14 +40,14 @@ func ioctlLoopClrFd(loopFd uintptr) error { |
39 | 39 |
func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) { |
40 | 40 |
loopInfo := &loopInfo64{} |
41 | 41 |
|
42 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopGetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
42 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopGetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
43 | 43 |
return nil, err |
44 | 44 |
} |
45 | 45 |
return loopInfo, nil |
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
func ioctlLoopSetCapacity(loopFd uintptr, value int) error { |
49 |
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetCapacity, uintptr(value)); err != 0 { |
|
49 |
+ if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetCapacity, uintptr(value)); err != 0 { |
|
50 | 50 |
return err |
51 | 51 |
} |
52 | 52 |
return nil |
... | ... |
@@ -1,87 +1,87 @@ |
1 | 1 |
package mount |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
4 |
+ "golang.org/x/sys/unix" |
|
5 | 5 |
) |
6 | 6 |
|
7 | 7 |
const ( |
8 | 8 |
// RDONLY will mount the file system read-only. |
9 |
- RDONLY = syscall.MS_RDONLY |
|
9 |
+ RDONLY = unix.MS_RDONLY |
|
10 | 10 |
|
11 | 11 |
// NOSUID will not allow set-user-identifier or set-group-identifier bits to |
12 | 12 |
// take effect. |
13 |
- NOSUID = syscall.MS_NOSUID |
|
13 |
+ NOSUID = unix.MS_NOSUID |
|
14 | 14 |
|
15 | 15 |
// NODEV will not interpret character or block special devices on the file |
16 | 16 |
// system. |
17 |
- NODEV = syscall.MS_NODEV |
|
17 |
+ NODEV = unix.MS_NODEV |
|
18 | 18 |
|
19 | 19 |
// NOEXEC will not allow execution of any binaries on the mounted file system. |
20 |
- NOEXEC = syscall.MS_NOEXEC |
|
20 |
+ NOEXEC = unix.MS_NOEXEC |
|
21 | 21 |
|
22 | 22 |
// SYNCHRONOUS will allow I/O to the file system to be done synchronously. |
23 |
- SYNCHRONOUS = syscall.MS_SYNCHRONOUS |
|
23 |
+ SYNCHRONOUS = unix.MS_SYNCHRONOUS |
|
24 | 24 |
|
25 | 25 |
// DIRSYNC will force all directory updates within the file system to be done |
26 | 26 |
// synchronously. This affects the following system calls: create, link, |
27 | 27 |
// unlink, symlink, mkdir, rmdir, mknod and rename. |
28 |
- DIRSYNC = syscall.MS_DIRSYNC |
|
28 |
+ DIRSYNC = unix.MS_DIRSYNC |
|
29 | 29 |
|
30 | 30 |
// REMOUNT will attempt to remount an already-mounted file system. This is |
31 | 31 |
// commonly used to change the mount flags for a file system, especially to |
32 | 32 |
// make a readonly file system writeable. It does not change device or mount |
33 | 33 |
// point. |
34 |
- REMOUNT = syscall.MS_REMOUNT |
|
34 |
+ REMOUNT = unix.MS_REMOUNT |
|
35 | 35 |
|
36 | 36 |
// MANDLOCK will force mandatory locks on a filesystem. |
37 |
- MANDLOCK = syscall.MS_MANDLOCK |
|
37 |
+ MANDLOCK = unix.MS_MANDLOCK |
|
38 | 38 |
|
39 | 39 |
// NOATIME will not update the file access time when reading from a file. |
40 |
- NOATIME = syscall.MS_NOATIME |
|
40 |
+ NOATIME = unix.MS_NOATIME |
|
41 | 41 |
|
42 | 42 |
// NODIRATIME will not update the directory access time. |
43 |
- NODIRATIME = syscall.MS_NODIRATIME |
|
43 |
+ NODIRATIME = unix.MS_NODIRATIME |
|
44 | 44 |
|
45 | 45 |
// BIND remounts a subtree somewhere else. |
46 |
- BIND = syscall.MS_BIND |
|
46 |
+ BIND = unix.MS_BIND |
|
47 | 47 |
|
48 | 48 |
// RBIND remounts a subtree and all possible submounts somewhere else. |
49 |
- RBIND = syscall.MS_BIND | syscall.MS_REC |
|
49 |
+ RBIND = unix.MS_BIND | unix.MS_REC |
|
50 | 50 |
|
51 | 51 |
// UNBINDABLE creates a mount which cannot be cloned through a bind operation. |
52 |
- UNBINDABLE = syscall.MS_UNBINDABLE |
|
52 |
+ UNBINDABLE = unix.MS_UNBINDABLE |
|
53 | 53 |
|
54 | 54 |
// RUNBINDABLE marks the entire mount tree as UNBINDABLE. |
55 |
- RUNBINDABLE = syscall.MS_UNBINDABLE | syscall.MS_REC |
|
55 |
+ RUNBINDABLE = unix.MS_UNBINDABLE | unix.MS_REC |
|
56 | 56 |
|
57 | 57 |
// PRIVATE creates a mount which carries no propagation abilities. |
58 |
- PRIVATE = syscall.MS_PRIVATE |
|
58 |
+ PRIVATE = unix.MS_PRIVATE |
|
59 | 59 |
|
60 | 60 |
// RPRIVATE marks the entire mount tree as PRIVATE. |
61 |
- RPRIVATE = syscall.MS_PRIVATE | syscall.MS_REC |
|
61 |
+ RPRIVATE = unix.MS_PRIVATE | unix.MS_REC |
|
62 | 62 |
|
63 | 63 |
// SLAVE creates a mount which receives propagation from its master, but not |
64 | 64 |
// vice versa. |
65 |
- SLAVE = syscall.MS_SLAVE |
|
65 |
+ SLAVE = unix.MS_SLAVE |
|
66 | 66 |
|
67 | 67 |
// RSLAVE marks the entire mount tree as SLAVE. |
68 |
- RSLAVE = syscall.MS_SLAVE | syscall.MS_REC |
|
68 |
+ RSLAVE = unix.MS_SLAVE | unix.MS_REC |
|
69 | 69 |
|
70 | 70 |
// SHARED creates a mount which provides the ability to create mirrors of |
71 | 71 |
// that mount such that mounts and unmounts within any of the mirrors |
72 | 72 |
// propagate to the other mirrors. |
73 |
- SHARED = syscall.MS_SHARED |
|
73 |
+ SHARED = unix.MS_SHARED |
|
74 | 74 |
|
75 | 75 |
// RSHARED marks the entire mount tree as SHARED. |
76 |
- RSHARED = syscall.MS_SHARED | syscall.MS_REC |
|
76 |
+ RSHARED = unix.MS_SHARED | unix.MS_REC |
|
77 | 77 |
|
78 | 78 |
// RELATIME updates inode access times relative to modify or change time. |
79 |
- RELATIME = syscall.MS_RELATIME |
|
79 |
+ RELATIME = unix.MS_RELATIME |
|
80 | 80 |
|
81 | 81 |
// STRICTATIME allows to explicitly request full atime updates. This makes |
82 | 82 |
// it possible for the kernel to default to relatime or noatime but still |
83 | 83 |
// allow userspace to override it. |
84 |
- STRICTATIME = syscall.MS_STRICTATIME |
|
84 |
+ STRICTATIME = unix.MS_STRICTATIME |
|
85 | 85 |
|
86 |
- mntDetach = syscall.MNT_DETACH |
|
86 |
+ mntDetach = unix.MNT_DETACH |
|
87 | 87 |
) |
... | ... |
@@ -13,8 +13,9 @@ import "C" |
13 | 13 |
import ( |
14 | 14 |
"fmt" |
15 | 15 |
"strings" |
16 |
- "syscall" |
|
17 | 16 |
"unsafe" |
17 |
+ |
|
18 |
+ "golang.org/x/sys/unix" |
|
18 | 19 |
) |
19 | 20 |
|
20 | 21 |
func allocateIOVecs(options []string) []C.struct_iovec { |
... | ... |
@@ -55,5 +56,5 @@ func mount(device, target, mType string, flag uintptr, data string) error { |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
func unmount(target string, flag int) error { |
58 |
- return syscall.Unmount(target, flag) |
|
58 |
+ return unix.Unmount(target, flag) |
|
59 | 59 |
} |
... | ... |
@@ -1,18 +1,18 @@ |
1 | 1 |
package mount |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
4 |
+ "golang.org/x/sys/unix" |
|
5 | 5 |
) |
6 | 6 |
|
7 | 7 |
const ( |
8 | 8 |
// ptypes is the set propagation types. |
9 |
- ptypes = syscall.MS_SHARED | syscall.MS_PRIVATE | syscall.MS_SLAVE | syscall.MS_UNBINDABLE |
|
9 |
+ ptypes = unix.MS_SHARED | unix.MS_PRIVATE | unix.MS_SLAVE | unix.MS_UNBINDABLE |
|
10 | 10 |
|
11 | 11 |
// pflags is the full set valid flags for a change propagation call. |
12 |
- pflags = ptypes | syscall.MS_REC | syscall.MS_SILENT |
|
12 |
+ pflags = ptypes | unix.MS_REC | unix.MS_SILENT |
|
13 | 13 |
|
14 | 14 |
// broflags is the combination of bind and read only |
15 |
- broflags = syscall.MS_BIND | syscall.MS_RDONLY |
|
15 |
+ broflags = unix.MS_BIND | unix.MS_RDONLY |
|
16 | 16 |
) |
17 | 17 |
|
18 | 18 |
// isremount returns true if either device name or flags identify a remount request, false otherwise. |
... | ... |
@@ -20,7 +20,7 @@ func isremount(device string, flags uintptr) bool { |
20 | 20 |
switch { |
21 | 21 |
// We treat device "" and "none" as a remount request to provide compatibility with |
22 | 22 |
// requests that don't explicitly set MS_REMOUNT such as those manipulating bind mounts. |
23 |
- case flags&syscall.MS_REMOUNT != 0, device == "", device == "none": |
|
23 |
+ case flags&unix.MS_REMOUNT != 0, device == "", device == "none": |
|
24 | 24 |
return true |
25 | 25 |
default: |
26 | 26 |
return false |
... | ... |
@@ -31,26 +31,26 @@ func mount(device, target, mType string, flags uintptr, data string) error { |
31 | 31 |
oflags := flags &^ ptypes |
32 | 32 |
if !isremount(device, flags) { |
33 | 33 |
// Initial call applying all non-propagation flags. |
34 |
- if err := syscall.Mount(device, target, mType, oflags, data); err != nil { |
|
34 |
+ if err := unix.Mount(device, target, mType, oflags, data); err != nil { |
|
35 | 35 |
return err |
36 | 36 |
} |
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
if flags&ptypes != 0 { |
40 | 40 |
// Change the propagation type. |
41 |
- if err := syscall.Mount("", target, "", flags&pflags, ""); err != nil { |
|
41 |
+ if err := unix.Mount("", target, "", flags&pflags, ""); err != nil { |
|
42 | 42 |
return err |
43 | 43 |
} |
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
if oflags&broflags == broflags { |
47 | 47 |
// Remount the bind to apply read only. |
48 |
- return syscall.Mount("", target, "", oflags|syscall.MS_REMOUNT, "") |
|
48 |
+ return unix.Mount("", target, "", oflags|unix.MS_REMOUNT, "") |
|
49 | 49 |
} |
50 | 50 |
|
51 | 51 |
return nil |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
func unmount(target string, flag int) error { |
55 |
- return syscall.Unmount(target, flag) |
|
55 |
+ return unix.Unmount(target, flag) |
|
56 | 56 |
} |
... | ... |
@@ -5,8 +5,9 @@ package mount |
5 | 5 |
import ( |
6 | 6 |
"os" |
7 | 7 |
"path" |
8 |
- "syscall" |
|
9 | 8 |
"testing" |
9 |
+ |
|
10 |
+ "golang.org/x/sys/unix" |
|
10 | 11 |
) |
11 | 12 |
|
12 | 13 |
// nothing is propagated in or out |
... | ... |
@@ -309,7 +310,7 @@ func TestSubtreeUnbindable(t *testing.T) { |
309 | 309 |
}() |
310 | 310 |
|
311 | 311 |
// then attempt to mount it to target. It should fail |
312 |
- if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil && err != syscall.EINVAL { |
|
312 |
+ if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil && err != unix.EINVAL { |
|
313 | 313 |
t.Fatal(err) |
314 | 314 |
} else if err == nil { |
315 | 315 |
t.Fatalf("%q should not have been bindable", sourceDir) |
... | ... |
@@ -4,8 +4,9 @@ package kernel |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"fmt" |
7 |
- "syscall" |
|
8 | 7 |
"unsafe" |
8 |
+ |
|
9 |
+ "golang.org/x/sys/windows" |
|
9 | 10 |
) |
10 | 11 |
|
11 | 12 |
// VersionInfo holds information about the kernel. |
... | ... |
@@ -24,28 +25,28 @@ func (k *VersionInfo) String() string { |
24 | 24 |
func GetKernelVersion() (*VersionInfo, error) { |
25 | 25 |
|
26 | 26 |
var ( |
27 |
- h syscall.Handle |
|
27 |
+ h windows.Handle |
|
28 | 28 |
dwVersion uint32 |
29 | 29 |
err error |
30 | 30 |
) |
31 | 31 |
|
32 | 32 |
KVI := &VersionInfo{"Unknown", 0, 0, 0} |
33 | 33 |
|
34 |
- if err = syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE, |
|
35 |
- syscall.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`), |
|
34 |
+ if err = windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, |
|
35 |
+ windows.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`), |
|
36 | 36 |
0, |
37 |
- syscall.KEY_READ, |
|
37 |
+ windows.KEY_READ, |
|
38 | 38 |
&h); err != nil { |
39 | 39 |
return KVI, err |
40 | 40 |
} |
41 |
- defer syscall.RegCloseKey(h) |
|
41 |
+ defer windows.RegCloseKey(h) |
|
42 | 42 |
|
43 | 43 |
var buf [1 << 10]uint16 |
44 | 44 |
var typ uint32 |
45 | 45 |
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16 |
46 | 46 |
|
47 |
- if err = syscall.RegQueryValueEx(h, |
|
48 |
- syscall.StringToUTF16Ptr("BuildLabEx"), |
|
47 |
+ if err = windows.RegQueryValueEx(h, |
|
48 |
+ windows.StringToUTF16Ptr("BuildLabEx"), |
|
49 | 49 |
nil, |
50 | 50 |
&typ, |
51 | 51 |
(*byte)(unsafe.Pointer(&buf[0])), |
... | ... |
@@ -53,11 +54,11 @@ func GetKernelVersion() (*VersionInfo, error) { |
53 | 53 |
return KVI, err |
54 | 54 |
} |
55 | 55 |
|
56 |
- KVI.kvi = syscall.UTF16ToString(buf[:]) |
|
56 |
+ KVI.kvi = windows.UTF16ToString(buf[:]) |
|
57 | 57 |
|
58 | 58 |
// Important - docker.exe MUST be manifested for this API to return |
59 | 59 |
// the correct information. |
60 |
- if dwVersion, err = syscall.GetVersion(); err != nil { |
|
60 |
+ if dwVersion, err = windows.GetVersion(); err != nil { |
|
61 | 61 |
return KVI, err |
62 | 62 |
} |
63 | 63 |
|
... | ... |
@@ -1,18 +1,16 @@ |
1 | 1 |
package kernel |
2 | 2 |
|
3 |
-import ( |
|
4 |
- "syscall" |
|
5 |
-) |
|
3 |
+import "golang.org/x/sys/unix" |
|
6 | 4 |
|
7 | 5 |
// Utsname represents the system name structure. |
8 |
-// It is passthrough for syscall.Utsname in order to make it portable with |
|
6 |
+// It is passthrough for unix.Utsname in order to make it portable with |
|
9 | 7 |
// other platforms where it is not available. |
10 |
-type Utsname syscall.Utsname |
|
8 |
+type Utsname unix.Utsname |
|
11 | 9 |
|
12 |
-func uname() (*syscall.Utsname, error) { |
|
13 |
- uts := &syscall.Utsname{} |
|
10 |
+func uname() (*unix.Utsname, error) { |
|
11 |
+ uts := &unix.Utsname{} |
|
14 | 12 |
|
15 |
- if err := syscall.Uname(uts); err != nil { |
|
13 |
+ if err := unix.Uname(uts); err != nil { |
|
16 | 14 |
return nil, err |
17 | 15 |
} |
18 | 16 |
return uts, nil |
... | ... |
@@ -1,8 +1,9 @@ |
1 | 1 |
package operatingsystem |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
5 | 4 |
"unsafe" |
5 |
+ |
|
6 |
+ "golang.org/x/sys/windows" |
|
6 | 7 |
) |
7 | 8 |
|
8 | 9 |
// See https://code.google.com/p/go/source/browse/src/pkg/mime/type_windows.go?r=d14520ac25bf6940785aabb71f5be453a286f58c |
... | ... |
@@ -11,33 +12,33 @@ import ( |
11 | 11 |
// GetOperatingSystem gets the name of the current operating system. |
12 | 12 |
func GetOperatingSystem() (string, error) { |
13 | 13 |
|
14 |
- var h syscall.Handle |
|
14 |
+ var h windows.Handle |
|
15 | 15 |
|
16 | 16 |
// Default return value |
17 | 17 |
ret := "Unknown Operating System" |
18 | 18 |
|
19 |
- if err := syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE, |
|
20 |
- syscall.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`), |
|
19 |
+ if err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, |
|
20 |
+ windows.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`), |
|
21 | 21 |
0, |
22 |
- syscall.KEY_READ, |
|
22 |
+ windows.KEY_READ, |
|
23 | 23 |
&h); err != nil { |
24 | 24 |
return ret, err |
25 | 25 |
} |
26 |
- defer syscall.RegCloseKey(h) |
|
26 |
+ defer windows.RegCloseKey(h) |
|
27 | 27 |
|
28 | 28 |
var buf [1 << 10]uint16 |
29 | 29 |
var typ uint32 |
30 | 30 |
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16 |
31 | 31 |
|
32 |
- if err := syscall.RegQueryValueEx(h, |
|
33 |
- syscall.StringToUTF16Ptr("ProductName"), |
|
32 |
+ if err := windows.RegQueryValueEx(h, |
|
33 |
+ windows.StringToUTF16Ptr("ProductName"), |
|
34 | 34 |
nil, |
35 | 35 |
&typ, |
36 | 36 |
(*byte)(unsafe.Pointer(&buf[0])), |
37 | 37 |
&n); err != nil { |
38 | 38 |
return ret, err |
39 | 39 |
} |
40 |
- ret = syscall.UTF16ToString(buf[:]) |
|
40 |
+ ret = windows.UTF16ToString(buf[:]) |
|
41 | 41 |
|
42 | 42 |
return ret, nil |
43 | 43 |
} |
... | ... |
@@ -3,12 +3,12 @@ |
3 | 3 |
package pidfile |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
6 |
+ "golang.org/x/sys/unix" |
|
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
func processExists(pid int) bool { |
10 | 10 |
// OS X does not have a proc filesystem. |
11 | 11 |
// Use kill -0 pid to judge if the process exists. |
12 |
- err := syscall.Kill(pid, 0) |
|
12 |
+ err := unix.Kill(pid, 0) |
|
13 | 13 |
return err == nil |
14 | 14 |
} |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
package pidfile |
2 | 2 |
|
3 |
-import "syscall" |
|
3 |
+import ( |
|
4 |
+ "golang.org/x/sys/windows" |
|
5 |
+) |
|
4 | 6 |
|
5 | 7 |
const ( |
6 | 8 |
processQueryLimitedInformation = 0x1000 |
... | ... |
@@ -9,13 +11,13 @@ const ( |
9 | 9 |
) |
10 | 10 |
|
11 | 11 |
func processExists(pid int) bool { |
12 |
- h, err := syscall.OpenProcess(processQueryLimitedInformation, false, uint32(pid)) |
|
12 |
+ h, err := windows.OpenProcess(processQueryLimitedInformation, false, uint32(pid)) |
|
13 | 13 |
if err != nil { |
14 | 14 |
return false |
15 | 15 |
} |
16 | 16 |
var c uint32 |
17 |
- err = syscall.GetExitCodeProcess(h, &c) |
|
18 |
- syscall.Close(h) |
|
17 |
+ err = windows.GetExitCodeProcess(h, &c) |
|
18 |
+ windows.Close(h) |
|
19 | 19 |
if err != nil { |
20 | 20 |
return c == stillActive |
21 | 21 |
} |
... | ... |
@@ -3,13 +3,13 @@ |
3 | 3 |
package platform |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
6 |
+ "golang.org/x/sys/unix" |
|
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
// runtimeArchitecture gets the name of the current architecture (x86, x86_64, …) |
10 | 10 |
func runtimeArchitecture() (string, error) { |
11 |
- utsname := &syscall.Utsname{} |
|
12 |
- if err := syscall.Uname(utsname); err != nil { |
|
11 |
+ utsname := &unix.Utsname{} |
|
12 |
+ if err := unix.Uname(utsname); err != nil { |
|
13 | 13 |
return "", err |
14 | 14 |
} |
15 | 15 |
return charsToString(utsname.Machine), nil |
... | ... |
@@ -1,5 +1,5 @@ |
1 |
-// +build linux,386 linux,amd64 linux,arm64 |
|
2 |
-// see golang's sources src/syscall/ztypes_linux_*.go that use int8 |
|
1 |
+// +build linux,386 linux,amd64 linux,arm64 s390x |
|
2 |
+// see golang's sources golang.org/x/sys/unix/ztypes_linux_*.go that use int8 |
|
3 | 3 |
|
4 | 4 |
package platform |
5 | 5 |
|
... | ... |
@@ -1,5 +1,5 @@ |
1 |
-// +build linux,arm linux,ppc64 linux,ppc64le s390x |
|
2 |
-// see golang's sources src/syscall/ztypes_linux_*.go that use uint8 |
|
1 |
+// +build linux,arm linux,ppc64 linux,ppc64le |
|
2 |
+// see golang's sources golang.org/x/sys/unix/ztypes_linux_*.go that use uint8 |
|
3 | 3 |
|
4 | 4 |
package platform |
5 | 5 |
|
... | ... |
@@ -5,6 +5,8 @@ package reexec |
5 | 5 |
import ( |
6 | 6 |
"os/exec" |
7 | 7 |
"syscall" |
8 |
+ |
|
9 |
+ "golang.org/x/sys/unix" |
|
8 | 10 |
) |
9 | 11 |
|
10 | 12 |
// Self returns the path to the current process's binary. |
... | ... |
@@ -22,7 +24,7 @@ func Command(args ...string) *exec.Cmd { |
22 | 22 |
Path: Self(), |
23 | 23 |
Args: args, |
24 | 24 |
SysProcAttr: &syscall.SysProcAttr{ |
25 |
- Pdeathsig: syscall.SIGTERM, |
|
25 |
+ Pdeathsig: unix.SIGTERM, |
|
26 | 26 |
}, |
27 | 27 |
} |
28 | 28 |
} |
... | ... |
@@ -2,6 +2,8 @@ package signal |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"syscall" |
5 |
+ |
|
6 |
+ "golang.org/x/sys/unix" |
|
5 | 7 |
) |
6 | 8 |
|
7 | 9 |
const ( |
... | ... |
@@ -11,41 +13,41 @@ const ( |
11 | 11 |
|
12 | 12 |
// SignalMap is a map of Linux signals. |
13 | 13 |
var SignalMap = map[string]syscall.Signal{ |
14 |
- "ABRT": syscall.SIGABRT, |
|
15 |
- "ALRM": syscall.SIGALRM, |
|
16 |
- "BUS": syscall.SIGBUS, |
|
17 |
- "CHLD": syscall.SIGCHLD, |
|
18 |
- "CLD": syscall.SIGCLD, |
|
19 |
- "CONT": syscall.SIGCONT, |
|
20 |
- "FPE": syscall.SIGFPE, |
|
21 |
- "HUP": syscall.SIGHUP, |
|
22 |
- "ILL": syscall.SIGILL, |
|
23 |
- "INT": syscall.SIGINT, |
|
24 |
- "IO": syscall.SIGIO, |
|
25 |
- "IOT": syscall.SIGIOT, |
|
26 |
- "KILL": syscall.SIGKILL, |
|
27 |
- "PIPE": syscall.SIGPIPE, |
|
28 |
- "POLL": syscall.SIGPOLL, |
|
29 |
- "PROF": syscall.SIGPROF, |
|
30 |
- "PWR": syscall.SIGPWR, |
|
31 |
- "QUIT": syscall.SIGQUIT, |
|
32 |
- "SEGV": syscall.SIGSEGV, |
|
33 |
- "STKFLT": syscall.SIGSTKFLT, |
|
34 |
- "STOP": syscall.SIGSTOP, |
|
35 |
- "SYS": syscall.SIGSYS, |
|
36 |
- "TERM": syscall.SIGTERM, |
|
37 |
- "TRAP": syscall.SIGTRAP, |
|
38 |
- "TSTP": syscall.SIGTSTP, |
|
39 |
- "TTIN": syscall.SIGTTIN, |
|
40 |
- "TTOU": syscall.SIGTTOU, |
|
41 |
- "UNUSED": syscall.SIGUNUSED, |
|
42 |
- "URG": syscall.SIGURG, |
|
43 |
- "USR1": syscall.SIGUSR1, |
|
44 |
- "USR2": syscall.SIGUSR2, |
|
45 |
- "VTALRM": syscall.SIGVTALRM, |
|
46 |
- "WINCH": syscall.SIGWINCH, |
|
47 |
- "XCPU": syscall.SIGXCPU, |
|
48 |
- "XFSZ": syscall.SIGXFSZ, |
|
14 |
+ "ABRT": unix.SIGABRT, |
|
15 |
+ "ALRM": unix.SIGALRM, |
|
16 |
+ "BUS": unix.SIGBUS, |
|
17 |
+ "CHLD": unix.SIGCHLD, |
|
18 |
+ "CLD": unix.SIGCLD, |
|
19 |
+ "CONT": unix.SIGCONT, |
|
20 |
+ "FPE": unix.SIGFPE, |
|
21 |
+ "HUP": unix.SIGHUP, |
|
22 |
+ "ILL": unix.SIGILL, |
|
23 |
+ "INT": unix.SIGINT, |
|
24 |
+ "IO": unix.SIGIO, |
|
25 |
+ "IOT": unix.SIGIOT, |
|
26 |
+ "KILL": unix.SIGKILL, |
|
27 |
+ "PIPE": unix.SIGPIPE, |
|
28 |
+ "POLL": unix.SIGPOLL, |
|
29 |
+ "PROF": unix.SIGPROF, |
|
30 |
+ "PWR": unix.SIGPWR, |
|
31 |
+ "QUIT": unix.SIGQUIT, |
|
32 |
+ "SEGV": unix.SIGSEGV, |
|
33 |
+ "STKFLT": unix.SIGSTKFLT, |
|
34 |
+ "STOP": unix.SIGSTOP, |
|
35 |
+ "SYS": unix.SIGSYS, |
|
36 |
+ "TERM": unix.SIGTERM, |
|
37 |
+ "TRAP": unix.SIGTRAP, |
|
38 |
+ "TSTP": unix.SIGTSTP, |
|
39 |
+ "TTIN": unix.SIGTTIN, |
|
40 |
+ "TTOU": unix.SIGTTOU, |
|
41 |
+ "UNUSED": unix.SIGUNUSED, |
|
42 |
+ "URG": unix.SIGURG, |
|
43 |
+ "USR1": unix.SIGUSR1, |
|
44 |
+ "USR2": unix.SIGUSR2, |
|
45 |
+ "VTALRM": unix.SIGVTALRM, |
|
46 |
+ "WINCH": unix.SIGWINCH, |
|
47 |
+ "XCPU": unix.SIGXCPU, |
|
48 |
+ "XFSZ": unix.SIGXFSZ, |
|
49 | 49 |
"RTMIN": sigrtmin, |
50 | 50 |
"RTMIN+1": sigrtmin + 1, |
51 | 51 |
"RTMIN+2": sigrtmin + 2, |
... | ... |
@@ -6,49 +6,49 @@ import ( |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 | 8 |
"strings" |
9 |
- "syscall" |
|
10 | 9 |
|
11 | 10 |
"github.com/docker/docker/pkg/longpath" |
11 |
+ "golang.org/x/sys/windows" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
func toShort(path string) (string, error) { |
15 |
- p, err := syscall.UTF16FromString(path) |
|
15 |
+ p, err := windows.UTF16FromString(path) |
|
16 | 16 |
if err != nil { |
17 | 17 |
return "", err |
18 | 18 |
} |
19 | 19 |
b := p // GetShortPathName says we can reuse buffer |
20 |
- n, err := syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))) |
|
20 |
+ n, err := windows.GetShortPathName(&p[0], &b[0], uint32(len(b))) |
|
21 | 21 |
if err != nil { |
22 | 22 |
return "", err |
23 | 23 |
} |
24 | 24 |
if n > uint32(len(b)) { |
25 | 25 |
b = make([]uint16, n) |
26 |
- if _, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))); err != nil { |
|
26 |
+ if _, err = windows.GetShortPathName(&p[0], &b[0], uint32(len(b))); err != nil { |
|
27 | 27 |
return "", err |
28 | 28 |
} |
29 | 29 |
} |
30 |
- return syscall.UTF16ToString(b), nil |
|
30 |
+ return windows.UTF16ToString(b), nil |
|
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
func toLong(path string) (string, error) { |
34 |
- p, err := syscall.UTF16FromString(path) |
|
34 |
+ p, err := windows.UTF16FromString(path) |
|
35 | 35 |
if err != nil { |
36 | 36 |
return "", err |
37 | 37 |
} |
38 | 38 |
b := p // GetLongPathName says we can reuse buffer |
39 |
- n, err := syscall.GetLongPathName(&p[0], &b[0], uint32(len(b))) |
|
39 |
+ n, err := windows.GetLongPathName(&p[0], &b[0], uint32(len(b))) |
|
40 | 40 |
if err != nil { |
41 | 41 |
return "", err |
42 | 42 |
} |
43 | 43 |
if n > uint32(len(b)) { |
44 | 44 |
b = make([]uint16, n) |
45 |
- n, err = syscall.GetLongPathName(&p[0], &b[0], uint32(len(b))) |
|
45 |
+ n, err = windows.GetLongPathName(&p[0], &b[0], uint32(len(b))) |
|
46 | 46 |
if err != nil { |
47 | 47 |
return "", err |
48 | 48 |
} |
49 | 49 |
} |
50 | 50 |
b = b[:n] |
51 |
- return syscall.UTF16ToString(b), nil |
|
51 |
+ return windows.UTF16ToString(b), nil |
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
func evalSymlinks(path string) (string, error) { |
... | ... |
@@ -65,7 +65,7 @@ func evalSymlinks(path string) (string, error) { |
65 | 65 |
if err != nil { |
66 | 66 |
return "", err |
67 | 67 |
} |
68 |
- // syscall.GetLongPathName does not change the case of the drive letter, |
|
68 |
+ // windows.GetLongPathName does not change the case of the drive letter, |
|
69 | 69 |
// but the result of EvalSymlinks must be unique, so we have |
70 | 70 |
// EvalSymlinks(`c:\a`) == EvalSymlinks(`C:\a`). |
71 | 71 |
// Make drive letter upper case. |
... | ... |
@@ -4,8 +4,9 @@ package sysinfo |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"runtime" |
7 |
- "syscall" |
|
8 | 7 |
"unsafe" |
8 |
+ |
|
9 |
+ "golang.org/x/sys/unix" |
|
9 | 10 |
) |
10 | 11 |
|
11 | 12 |
// numCPU queries the system for the count of threads available |
... | ... |
@@ -15,10 +16,10 @@ import ( |
15 | 15 |
// Returns 0 on errors. Use |runtime.NumCPU| in that case. |
16 | 16 |
func numCPU() int { |
17 | 17 |
// Gets the affinity mask for a process: The very one invoking this function. |
18 |
- pid, _, _ := syscall.RawSyscall(syscall.SYS_GETPID, 0, 0, 0) |
|
18 |
+ pid, _, _ := unix.RawSyscall(unix.SYS_GETPID, 0, 0, 0) |
|
19 | 19 |
|
20 | 20 |
var mask [1024 / 64]uintptr |
21 |
- _, _, err := syscall.RawSyscall(syscall.SYS_SCHED_GETAFFINITY, pid, uintptr(len(mask)*8), uintptr(unsafe.Pointer(&mask[0]))) |
|
21 |
+ _, _, err := unix.RawSyscall(unix.SYS_SCHED_GETAFFINITY, pid, uintptr(len(mask)*8), uintptr(unsafe.Pointer(&mask[0]))) |
|
22 | 22 |
if err != 0 { |
23 | 23 |
return 0 |
24 | 24 |
} |
... | ... |
@@ -6,10 +6,10 @@ import ( |
6 | 6 |
"os" |
7 | 7 |
"path" |
8 | 8 |
"strings" |
9 |
- "syscall" |
|
10 | 9 |
|
11 | 10 |
"github.com/Sirupsen/logrus" |
12 | 11 |
"github.com/opencontainers/runc/libcontainer/cgroups" |
12 |
+ "golang.org/x/sys/unix" |
|
13 | 13 |
) |
14 | 14 |
|
15 | 15 |
const ( |
... | ... |
@@ -60,9 +60,9 @@ func New(quiet bool) *SysInfo { |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
// Check if Seccomp is supported, via CONFIG_SECCOMP. |
63 |
- if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_GET_SECCOMP, 0, 0); err != syscall.EINVAL { |
|
63 |
+ if _, _, err := unix.RawSyscall(unix.SYS_PRCTL, unix.PR_GET_SECCOMP, 0, 0); err != unix.EINVAL { |
|
64 | 64 |
// Make sure the kernel has CONFIG_SECCOMP_FILTER. |
65 |
- if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_SECCOMP, SeccompModeFilter, 0); err != syscall.EINVAL { |
|
65 |
+ if _, _, err := unix.RawSyscall(unix.SYS_PRCTL, unix.PR_SET_SECCOMP, SeccompModeFilter, 0); err != unix.EINVAL { |
|
66 | 66 |
sysInfo.Seccomp = true |
67 | 67 |
} |
68 | 68 |
} |
... | ... |
@@ -3,25 +3,26 @@ |
3 | 3 |
package system |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
7 | 6 |
"time" |
7 |
+ |
|
8 |
+ "golang.org/x/sys/windows" |
|
8 | 9 |
) |
9 | 10 |
|
10 | 11 |
//setCTime will set the create time on a file. On Windows, this requires |
11 | 12 |
//calling SetFileTime and explicitly including the create time. |
12 | 13 |
func setCTime(path string, ctime time.Time) error { |
13 |
- ctimespec := syscall.NsecToTimespec(ctime.UnixNano()) |
|
14 |
- pathp, e := syscall.UTF16PtrFromString(path) |
|
14 |
+ ctimespec := windows.NsecToTimespec(ctime.UnixNano()) |
|
15 |
+ pathp, e := windows.UTF16PtrFromString(path) |
|
15 | 16 |
if e != nil { |
16 | 17 |
return e |
17 | 18 |
} |
18 |
- h, e := syscall.CreateFile(pathp, |
|
19 |
- syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil, |
|
20 |
- syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) |
|
19 |
+ h, e := windows.CreateFile(pathp, |
|
20 |
+ windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil, |
|
21 |
+ windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0) |
|
21 | 22 |
if e != nil { |
22 | 23 |
return e |
23 | 24 |
} |
24 |
- defer syscall.Close(h) |
|
25 |
- c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec)) |
|
26 |
- return syscall.SetFileTime(h, &c, nil, nil) |
|
25 |
+ defer windows.Close(h) |
|
26 |
+ c := windows.NsecToFiletime(windows.TimespecToNsec(ctimespec)) |
|
27 |
+ return windows.SetFileTime(h, &c, nil, nil) |
|
27 | 28 |
} |
... | ... |
@@ -19,8 +19,8 @@ var ( |
19 | 19 |
) |
20 | 20 |
|
21 | 21 |
// CreateEvent implements win32 CreateEventW func in golang. It will create an event object. |
22 |
-func CreateEvent(eventAttributes *syscall.SecurityAttributes, manualReset bool, initialState bool, name string) (handle syscall.Handle, err error) { |
|
23 |
- namep, _ := syscall.UTF16PtrFromString(name) |
|
22 |
+func CreateEvent(eventAttributes *windows.SecurityAttributes, manualReset bool, initialState bool, name string) (handle windows.Handle, err error) { |
|
23 |
+ namep, _ := windows.UTF16PtrFromString(name) |
|
24 | 24 |
var _p1 uint32 |
25 | 25 |
if manualReset { |
26 | 26 |
_p1 = 1 |
... | ... |
@@ -31,45 +31,45 @@ func CreateEvent(eventAttributes *syscall.SecurityAttributes, manualReset bool, |
31 | 31 |
} |
32 | 32 |
r0, _, e1 := procCreateEvent.Call(uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(namep))) |
33 | 33 |
use(unsafe.Pointer(namep)) |
34 |
- handle = syscall.Handle(r0) |
|
35 |
- if handle == syscall.InvalidHandle { |
|
34 |
+ handle = windows.Handle(r0) |
|
35 |
+ if handle == windows.InvalidHandle { |
|
36 | 36 |
err = e1 |
37 | 37 |
} |
38 | 38 |
return |
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
// OpenEvent implements win32 OpenEventW func in golang. It opens an event object. |
42 |
-func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle syscall.Handle, err error) { |
|
43 |
- namep, _ := syscall.UTF16PtrFromString(name) |
|
42 |
+func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle windows.Handle, err error) { |
|
43 |
+ namep, _ := windows.UTF16PtrFromString(name) |
|
44 | 44 |
var _p1 uint32 |
45 | 45 |
if inheritHandle { |
46 | 46 |
_p1 = 1 |
47 | 47 |
} |
48 | 48 |
r0, _, e1 := procOpenEvent.Call(uintptr(desiredAccess), uintptr(_p1), uintptr(unsafe.Pointer(namep))) |
49 | 49 |
use(unsafe.Pointer(namep)) |
50 |
- handle = syscall.Handle(r0) |
|
51 |
- if handle == syscall.InvalidHandle { |
|
50 |
+ handle = windows.Handle(r0) |
|
51 |
+ if handle == windows.InvalidHandle { |
|
52 | 52 |
err = e1 |
53 | 53 |
} |
54 | 54 |
return |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
// SetEvent implements win32 SetEvent func in golang. |
58 |
-func SetEvent(handle syscall.Handle) (err error) { |
|
58 |
+func SetEvent(handle windows.Handle) (err error) { |
|
59 | 59 |
return setResetPulse(handle, procSetEvent) |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
// ResetEvent implements win32 ResetEvent func in golang. |
63 |
-func ResetEvent(handle syscall.Handle) (err error) { |
|
63 |
+func ResetEvent(handle windows.Handle) (err error) { |
|
64 | 64 |
return setResetPulse(handle, procResetEvent) |
65 | 65 |
} |
66 | 66 |
|
67 | 67 |
// PulseEvent implements win32 PulseEvent func in golang. |
68 |
-func PulseEvent(handle syscall.Handle) (err error) { |
|
68 |
+func PulseEvent(handle windows.Handle) (err error) { |
|
69 | 69 |
return setResetPulse(handle, procPulseEvent) |
70 | 70 |
} |
71 | 71 |
|
72 |
-func setResetPulse(handle syscall.Handle, proc *windows.LazyProc) (err error) { |
|
72 |
+func setResetPulse(handle windows.Handle, proc *windows.LazyProc) (err error) { |
|
73 | 73 |
r0, _, _ := proc.Call(uintptr(handle)) |
74 | 74 |
if r0 != 0 { |
75 | 75 |
err = syscall.Errno(r0) |
... | ... |
@@ -14,6 +14,7 @@ import ( |
14 | 14 |
"unsafe" |
15 | 15 |
|
16 | 16 |
winio "github.com/Microsoft/go-winio" |
17 |
+ "golang.org/x/sys/windows" |
|
17 | 18 |
) |
18 | 19 |
|
19 | 20 |
const ( |
... | ... |
@@ -99,13 +100,12 @@ func mkdirall(path string, applyACL bool, sddl string) error { |
99 | 99 |
// mkdirWithACL creates a new directory. If there is an error, it will be of |
100 | 100 |
// type *PathError. . |
101 | 101 |
// |
102 |
-// This is a modified and combined version of os.Mkdir and syscall.Mkdir |
|
102 |
+// This is a modified and combined version of os.Mkdir and windows.Mkdir |
|
103 | 103 |
// in golang to cater for creating a directory am ACL permitting full |
104 | 104 |
// access, with inheritance, to any subfolder/file for Built-in Administrators |
105 | 105 |
// and Local System. |
106 | 106 |
func mkdirWithACL(name string, sddl string) error { |
107 |
- sa := syscall.SecurityAttributes{Length: 0} |
|
108 |
- |
|
107 |
+ sa := windows.SecurityAttributes{Length: 0} |
|
109 | 108 |
sd, err := winio.SddlToSecurityDescriptor(sddl) |
110 | 109 |
if err != nil { |
111 | 110 |
return &os.PathError{Op: "mkdir", Path: name, Err: err} |
... | ... |
@@ -114,12 +114,12 @@ func mkdirWithACL(name string, sddl string) error { |
114 | 114 |
sa.InheritHandle = 1 |
115 | 115 |
sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) |
116 | 116 |
|
117 |
- namep, err := syscall.UTF16PtrFromString(name) |
|
117 |
+ namep, err := windows.UTF16PtrFromString(name) |
|
118 | 118 |
if err != nil { |
119 | 119 |
return &os.PathError{Op: "mkdir", Path: name, Err: err} |
120 | 120 |
} |
121 | 121 |
|
122 |
- e := syscall.CreateDirectory(namep, &sa) |
|
122 |
+ e := windows.CreateDirectory(namep, &sa) |
|
123 | 123 |
if e != nil { |
124 | 124 |
return &os.PathError{Op: "mkdir", Path: name, Err: e} |
125 | 125 |
} |
... | ... |
@@ -142,7 +142,7 @@ func IsAbs(path string) bool { |
142 | 142 |
return true |
143 | 143 |
} |
144 | 144 |
|
145 |
-// The origin of the functions below here are the golang OS and syscall packages, |
|
145 |
+// The origin of the functions below here are the golang OS and windows packages, |
|
146 | 146 |
// slightly modified to only cope with files, not directories due to the |
147 | 147 |
// specific use case. |
148 | 148 |
// |
... | ... |
@@ -174,74 +174,74 @@ func OpenFileSequential(name string, flag int, _ os.FileMode) (*os.File, error) |
174 | 174 |
if name == "" { |
175 | 175 |
return nil, &os.PathError{Op: "open", Path: name, Err: syscall.ENOENT} |
176 | 176 |
} |
177 |
- r, errf := syscallOpenFileSequential(name, flag, 0) |
|
177 |
+ r, errf := windowsOpenFileSequential(name, flag, 0) |
|
178 | 178 |
if errf == nil { |
179 | 179 |
return r, nil |
180 | 180 |
} |
181 | 181 |
return nil, &os.PathError{Op: "open", Path: name, Err: errf} |
182 | 182 |
} |
183 | 183 |
|
184 |
-func syscallOpenFileSequential(name string, flag int, _ os.FileMode) (file *os.File, err error) { |
|
185 |
- r, e := syscallOpenSequential(name, flag|syscall.O_CLOEXEC, 0) |
|
184 |
+func windowsOpenFileSequential(name string, flag int, _ os.FileMode) (file *os.File, err error) { |
|
185 |
+ r, e := windowsOpenSequential(name, flag|windows.O_CLOEXEC, 0) |
|
186 | 186 |
if e != nil { |
187 | 187 |
return nil, e |
188 | 188 |
} |
189 | 189 |
return os.NewFile(uintptr(r), name), nil |
190 | 190 |
} |
191 | 191 |
|
192 |
-func makeInheritSa() *syscall.SecurityAttributes { |
|
193 |
- var sa syscall.SecurityAttributes |
|
192 |
+func makeInheritSa() *windows.SecurityAttributes { |
|
193 |
+ var sa windows.SecurityAttributes |
|
194 | 194 |
sa.Length = uint32(unsafe.Sizeof(sa)) |
195 | 195 |
sa.InheritHandle = 1 |
196 | 196 |
return &sa |
197 | 197 |
} |
198 | 198 |
|
199 |
-func syscallOpenSequential(path string, mode int, _ uint32) (fd syscall.Handle, err error) { |
|
199 |
+func windowsOpenSequential(path string, mode int, _ uint32) (fd windows.Handle, err error) { |
|
200 | 200 |
if len(path) == 0 { |
201 |
- return syscall.InvalidHandle, syscall.ERROR_FILE_NOT_FOUND |
|
201 |
+ return windows.InvalidHandle, windows.ERROR_FILE_NOT_FOUND |
|
202 | 202 |
} |
203 |
- pathp, err := syscall.UTF16PtrFromString(path) |
|
203 |
+ pathp, err := windows.UTF16PtrFromString(path) |
|
204 | 204 |
if err != nil { |
205 |
- return syscall.InvalidHandle, err |
|
205 |
+ return windows.InvalidHandle, err |
|
206 | 206 |
} |
207 | 207 |
var access uint32 |
208 |
- switch mode & (syscall.O_RDONLY | syscall.O_WRONLY | syscall.O_RDWR) { |
|
209 |
- case syscall.O_RDONLY: |
|
210 |
- access = syscall.GENERIC_READ |
|
211 |
- case syscall.O_WRONLY: |
|
212 |
- access = syscall.GENERIC_WRITE |
|
213 |
- case syscall.O_RDWR: |
|
214 |
- access = syscall.GENERIC_READ | syscall.GENERIC_WRITE |
|
208 |
+ switch mode & (windows.O_RDONLY | windows.O_WRONLY | windows.O_RDWR) { |
|
209 |
+ case windows.O_RDONLY: |
|
210 |
+ access = windows.GENERIC_READ |
|
211 |
+ case windows.O_WRONLY: |
|
212 |
+ access = windows.GENERIC_WRITE |
|
213 |
+ case windows.O_RDWR: |
|
214 |
+ access = windows.GENERIC_READ | windows.GENERIC_WRITE |
|
215 | 215 |
} |
216 |
- if mode&syscall.O_CREAT != 0 { |
|
217 |
- access |= syscall.GENERIC_WRITE |
|
216 |
+ if mode&windows.O_CREAT != 0 { |
|
217 |
+ access |= windows.GENERIC_WRITE |
|
218 | 218 |
} |
219 |
- if mode&syscall.O_APPEND != 0 { |
|
220 |
- access &^= syscall.GENERIC_WRITE |
|
221 |
- access |= syscall.FILE_APPEND_DATA |
|
219 |
+ if mode&windows.O_APPEND != 0 { |
|
220 |
+ access &^= windows.GENERIC_WRITE |
|
221 |
+ access |= windows.FILE_APPEND_DATA |
|
222 | 222 |
} |
223 |
- sharemode := uint32(syscall.FILE_SHARE_READ | syscall.FILE_SHARE_WRITE) |
|
224 |
- var sa *syscall.SecurityAttributes |
|
225 |
- if mode&syscall.O_CLOEXEC == 0 { |
|
223 |
+ sharemode := uint32(windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE) |
|
224 |
+ var sa *windows.SecurityAttributes |
|
225 |
+ if mode&windows.O_CLOEXEC == 0 { |
|
226 | 226 |
sa = makeInheritSa() |
227 | 227 |
} |
228 | 228 |
var createmode uint32 |
229 | 229 |
switch { |
230 |
- case mode&(syscall.O_CREAT|syscall.O_EXCL) == (syscall.O_CREAT | syscall.O_EXCL): |
|
231 |
- createmode = syscall.CREATE_NEW |
|
232 |
- case mode&(syscall.O_CREAT|syscall.O_TRUNC) == (syscall.O_CREAT | syscall.O_TRUNC): |
|
233 |
- createmode = syscall.CREATE_ALWAYS |
|
234 |
- case mode&syscall.O_CREAT == syscall.O_CREAT: |
|
235 |
- createmode = syscall.OPEN_ALWAYS |
|
236 |
- case mode&syscall.O_TRUNC == syscall.O_TRUNC: |
|
237 |
- createmode = syscall.TRUNCATE_EXISTING |
|
230 |
+ case mode&(windows.O_CREAT|windows.O_EXCL) == (windows.O_CREAT | windows.O_EXCL): |
|
231 |
+ createmode = windows.CREATE_NEW |
|
232 |
+ case mode&(windows.O_CREAT|windows.O_TRUNC) == (windows.O_CREAT | windows.O_TRUNC): |
|
233 |
+ createmode = windows.CREATE_ALWAYS |
|
234 |
+ case mode&windows.O_CREAT == windows.O_CREAT: |
|
235 |
+ createmode = windows.OPEN_ALWAYS |
|
236 |
+ case mode&windows.O_TRUNC == windows.O_TRUNC: |
|
237 |
+ createmode = windows.TRUNCATE_EXISTING |
|
238 | 238 |
default: |
239 |
- createmode = syscall.OPEN_EXISTING |
|
239 |
+ createmode = windows.OPEN_EXISTING |
|
240 | 240 |
} |
241 | 241 |
// Use FILE_FLAG_SEQUENTIAL_SCAN rather than FILE_ATTRIBUTE_NORMAL as implemented in golang. |
242 | 242 |
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx |
243 | 243 |
const fileFlagSequentialScan = 0x08000000 // FILE_FLAG_SEQUENTIAL_SCAN |
244 |
- h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, fileFlagSequentialScan, 0) |
|
244 |
+ h, e := windows.CreateFile(pathp, access, sharemode, sa, createmode, fileFlagSequentialScan, 0) |
|
245 | 245 |
return h, e |
246 | 246 |
} |
247 | 247 |
|
... | ... |
@@ -3,13 +3,13 @@ |
3 | 3 |
package system |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
6 |
+ "golang.org/x/sys/unix" |
|
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
// Mknod creates a filesystem node (file, device special file or named pipe) named path |
10 | 10 |
// with attributes specified by mode and dev. |
11 | 11 |
func Mknod(path string, mode uint32, dev int) error { |
12 |
- return syscall.Mknod(path, mode, dev) |
|
12 |
+ return unix.Mknod(path, mode, dev) |
|
13 | 13 |
} |
14 | 14 |
|
15 | 15 |
// Mkdev is used to build the value of linux devices (in /dev/) which specifies major |
... | ... |
@@ -4,12 +4,14 @@ package system |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"syscall" |
7 |
+ |
|
8 |
+ "golang.org/x/sys/unix" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// IsProcessAlive returns true if process with a given pid is running. |
10 | 12 |
func IsProcessAlive(pid int) bool { |
11 |
- err := syscall.Kill(pid, syscall.Signal(0)) |
|
12 |
- if err == nil || err == syscall.EPERM { |
|
13 |
+ err := unix.Kill(pid, syscall.Signal(0)) |
|
14 |
+ if err == nil || err == unix.EPERM { |
|
13 | 15 |
return true |
14 | 16 |
} |
15 | 17 |
|
... | ... |
@@ -18,5 +20,5 @@ func IsProcessAlive(pid int) bool { |
18 | 18 |
|
19 | 19 |
// KillProcess force-stops a process. |
20 | 20 |
func KillProcess(pid int) { |
21 |
- syscall.Kill(pid, syscall.SIGKILL) |
|
21 |
+ unix.Kill(pid, unix.SIGKILL) |
|
22 | 22 |
} |
... | ... |
@@ -2,12 +2,12 @@ |
2 | 2 |
|
3 | 3 |
package system |
4 | 4 |
|
5 |
-import "syscall" |
|
5 |
+import "golang.org/x/sys/unix" |
|
6 | 6 |
|
7 | 7 |
// Unmount is a platform-specific helper function to call |
8 | 8 |
// the unmount syscall. |
9 | 9 |
func Unmount(dest string) error { |
10 |
- return syscall.Unmount(dest, 0) |
|
10 |
+ return unix.Unmount(dest, 0) |
|
11 | 11 |
} |
12 | 12 |
|
13 | 13 |
// CommandLineToArgv should not be used on Unix. |
... | ... |
@@ -1,14 +1,14 @@ |
1 | 1 |
package system |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
5 | 4 |
"unsafe" |
6 | 5 |
|
7 | 6 |
"github.com/Sirupsen/logrus" |
7 |
+ "golang.org/x/sys/windows" |
|
8 | 8 |
) |
9 | 9 |
|
10 | 10 |
var ( |
11 |
- ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") |
|
11 |
+ ntuserApiset = windows.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") |
|
12 | 12 |
procGetVersionExW = modkernel32.NewProc("GetVersionExW") |
13 | 13 |
procGetProductInfo = modkernel32.NewProc("GetProductInfo") |
14 | 14 |
) |
... | ... |
@@ -42,7 +42,7 @@ type osVersionInfoEx struct { |
42 | 42 |
func GetOSVersion() OSVersion { |
43 | 43 |
var err error |
44 | 44 |
osv := OSVersion{} |
45 |
- osv.Version, err = syscall.GetVersion() |
|
45 |
+ osv.Version, err = windows.GetVersion() |
|
46 | 46 |
if err != nil { |
47 | 47 |
// GetVersion never fails. |
48 | 48 |
panic(err) |
... | ... |
@@ -93,20 +93,20 @@ func Unmount(dest string) error { |
93 | 93 |
func CommandLineToArgv(commandLine string) ([]string, error) { |
94 | 94 |
var argc int32 |
95 | 95 |
|
96 |
- argsPtr, err := syscall.UTF16PtrFromString(commandLine) |
|
96 |
+ argsPtr, err := windows.UTF16PtrFromString(commandLine) |
|
97 | 97 |
if err != nil { |
98 | 98 |
return nil, err |
99 | 99 |
} |
100 | 100 |
|
101 |
- argv, err := syscall.CommandLineToArgv(argsPtr, &argc) |
|
101 |
+ argv, err := windows.CommandLineToArgv(argsPtr, &argc) |
|
102 | 102 |
if err != nil { |
103 | 103 |
return nil, err |
104 | 104 |
} |
105 |
- defer syscall.LocalFree(syscall.Handle(uintptr(unsafe.Pointer(argv)))) |
|
105 |
+ defer windows.LocalFree(windows.Handle(uintptr(unsafe.Pointer(argv)))) |
|
106 | 106 |
|
107 | 107 |
newArgs := make([]string, argc) |
108 | 108 |
for i, v := range (*argv)[:argc] { |
109 |
- newArgs[i] = string(syscall.UTF16ToString((*v)[:])) |
|
109 |
+ newArgs[i] = string(windows.UTF16ToString((*v)[:])) |
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
return newArgs, nil |
... | ... |
@@ -3,11 +3,11 @@ |
3 | 3 |
package system |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
6 |
+ "golang.org/x/sys/unix" |
|
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
// Umask sets current process's file mode creation mask to newmask |
10 | 10 |
// and returns oldmask. |
11 | 11 |
func Umask(newmask int) (oldmask int, err error) { |
12 |
- return syscall.Umask(newmask), nil |
|
12 |
+ return unix.Umask(newmask), nil |
|
13 | 13 |
} |
... | ... |
@@ -3,18 +3,20 @@ package system |
3 | 3 |
import ( |
4 | 4 |
"syscall" |
5 | 5 |
"unsafe" |
6 |
+ |
|
7 |
+ "golang.org/x/sys/unix" |
|
6 | 8 |
) |
7 | 9 |
|
8 | 10 |
// LUtimesNano is used to change access and modification time of the specified path. |
9 |
-// It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. |
|
11 |
+// It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm. |
|
10 | 12 |
func LUtimesNano(path string, ts []syscall.Timespec) error { |
11 | 13 |
var _path *byte |
12 |
- _path, err := syscall.BytePtrFromString(path) |
|
14 |
+ _path, err := unix.BytePtrFromString(path) |
|
13 | 15 |
if err != nil { |
14 | 16 |
return err |
15 | 17 |
} |
16 | 18 |
|
17 |
- if _, _, err := syscall.Syscall(syscall.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != syscall.ENOSYS { |
|
19 |
+ if _, _, err := unix.Syscall(unix.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != unix.ENOSYS { |
|
18 | 20 |
return err |
19 | 21 |
} |
20 | 22 |
|
... | ... |
@@ -3,22 +3,21 @@ package system |
3 | 3 |
import ( |
4 | 4 |
"syscall" |
5 | 5 |
"unsafe" |
6 |
+ |
|
7 |
+ "golang.org/x/sys/unix" |
|
6 | 8 |
) |
7 | 9 |
|
8 | 10 |
// LUtimesNano is used to change access and modification time of the specified path. |
9 |
-// It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. |
|
11 |
+// It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm. |
|
10 | 12 |
func LUtimesNano(path string, ts []syscall.Timespec) error { |
11 |
- // These are not currently available in syscall |
|
12 |
- atFdCwd := -100 |
|
13 |
- atSymLinkNoFollow := 0x100 |
|
13 |
+ atFdCwd := unix.AT_FDCWD |
|
14 | 14 |
|
15 | 15 |
var _path *byte |
16 |
- _path, err := syscall.BytePtrFromString(path) |
|
16 |
+ _path, err := unix.BytePtrFromString(path) |
|
17 | 17 |
if err != nil { |
18 | 18 |
return err |
19 | 19 |
} |
20 |
- |
|
21 |
- 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 { |
|
20 |
+ if _, _, err := unix.Syscall6(unix.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), unix.AT_SYMLINK_NOFOLLOW, 0, 0); err != 0 && err != unix.ENOSYS { |
|
22 | 21 |
return err |
23 | 22 |
} |
24 | 23 |
|
... | ... |
@@ -1,33 +1,34 @@ |
1 | 1 |
package system |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "syscall" |
|
5 | 4 |
"unsafe" |
5 |
+ |
|
6 |
+ "golang.org/x/sys/unix" |
|
6 | 7 |
) |
7 | 8 |
|
8 | 9 |
// Lgetxattr retrieves the value of the extended attribute identified by attr |
9 | 10 |
// and associated with the given path in the file system. |
10 | 11 |
// It will returns a nil slice and nil error if the xattr is not set. |
11 | 12 |
func Lgetxattr(path string, attr string) ([]byte, error) { |
12 |
- pathBytes, err := syscall.BytePtrFromString(path) |
|
13 |
+ pathBytes, err := unix.BytePtrFromString(path) |
|
13 | 14 |
if err != nil { |
14 | 15 |
return nil, err |
15 | 16 |
} |
16 |
- attrBytes, err := syscall.BytePtrFromString(attr) |
|
17 |
+ attrBytes, err := unix.BytePtrFromString(attr) |
|
17 | 18 |
if err != nil { |
18 | 19 |
return nil, err |
19 | 20 |
} |
20 | 21 |
|
21 | 22 |
dest := make([]byte, 128) |
22 | 23 |
destBytes := unsafe.Pointer(&dest[0]) |
23 |
- sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) |
|
24 |
- if errno == syscall.ENODATA { |
|
24 |
+ sz, _, errno := unix.Syscall6(unix.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) |
|
25 |
+ if errno == unix.ENODATA { |
|
25 | 26 |
return nil, nil |
26 | 27 |
} |
27 |
- if errno == syscall.ERANGE { |
|
28 |
+ if errno == unix.ERANGE { |
|
28 | 29 |
dest = make([]byte, sz) |
29 | 30 |
destBytes := unsafe.Pointer(&dest[0]) |
30 |
- sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) |
|
31 |
+ sz, _, errno = unix.Syscall6(unix.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) |
|
31 | 32 |
} |
32 | 33 |
if errno != 0 { |
33 | 34 |
return nil, errno |
... | ... |
@@ -41,11 +42,11 @@ var _zero uintptr |
41 | 41 |
// Lsetxattr sets the value of the extended attribute identified by attr |
42 | 42 |
// and associated with the given path in the file system. |
43 | 43 |
func Lsetxattr(path string, attr string, data []byte, flags int) error { |
44 |
- pathBytes, err := syscall.BytePtrFromString(path) |
|
44 |
+ pathBytes, err := unix.BytePtrFromString(path) |
|
45 | 45 |
if err != nil { |
46 | 46 |
return err |
47 | 47 |
} |
48 |
- attrBytes, err := syscall.BytePtrFromString(attr) |
|
48 |
+ attrBytes, err := unix.BytePtrFromString(attr) |
|
49 | 49 |
if err != nil { |
50 | 50 |
return err |
51 | 51 |
} |
... | ... |
@@ -55,7 +56,7 @@ func Lsetxattr(path string, attr string, data []byte, flags int) error { |
55 | 55 |
} else { |
56 | 56 |
dataBytes = unsafe.Pointer(&_zero) |
57 | 57 |
} |
58 |
- _, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) |
|
58 |
+ _, _, errno := unix.Syscall6(unix.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) |
|
59 | 59 |
if errno != 0 { |
60 | 60 |
return errno |
61 | 61 |
} |
... | ... |
@@ -8,7 +8,6 @@ import ( |
8 | 8 |
"net" |
9 | 9 |
"os" |
10 | 10 |
"path/filepath" |
11 |
- "syscall" |
|
12 | 11 |
"time" |
13 | 12 |
|
14 | 13 |
"github.com/Sirupsen/logrus" |
... | ... |
@@ -23,6 +22,7 @@ import ( |
23 | 23 |
"github.com/opencontainers/go-digest" |
24 | 24 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
25 | 25 |
"github.com/pkg/errors" |
26 |
+ "golang.org/x/sys/unix" |
|
26 | 27 |
) |
27 | 28 |
|
28 | 29 |
func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error { |
... | ... |
@@ -146,7 +146,7 @@ func (pm *Manager) restore(p *v2.Plugin) error { |
146 | 146 |
func shutdownPlugin(p *v2.Plugin, c *controller, containerdClient libcontainerd.Client) { |
147 | 147 |
pluginID := p.GetID() |
148 | 148 |
|
149 |
- err := containerdClient.Signal(pluginID, int(syscall.SIGTERM)) |
|
149 |
+ err := containerdClient.Signal(pluginID, int(unix.SIGTERM)) |
|
150 | 150 |
if err != nil { |
151 | 151 |
logrus.Errorf("Sending SIGTERM to plugin failed with error: %v", err) |
152 | 152 |
} else { |
... | ... |
@@ -155,7 +155,7 @@ func shutdownPlugin(p *v2.Plugin, c *controller, containerdClient libcontainerd. |
155 | 155 |
logrus.Debug("Clean shutdown of plugin") |
156 | 156 |
case <-time.After(time.Second * 10): |
157 | 157 |
logrus.Debug("Force shutdown plugin") |
158 |
- if err := containerdClient.Signal(pluginID, int(syscall.SIGKILL)); err != nil { |
|
158 |
+ if err := containerdClient.Signal(pluginID, int(unix.SIGKILL)); err != nil { |
|
159 | 159 |
logrus.Errorf("Sending SIGKILL to plugin failed with error: %v", err) |
160 | 160 |
} |
161 | 161 |
} |
... | ... |
@@ -3,9 +3,8 @@ |
3 | 3 |
package seccomp |
4 | 4 |
|
5 | 5 |
import ( |
6 |
- "syscall" |
|
7 |
- |
|
8 | 6 |
"github.com/docker/docker/api/types" |
7 |
+ "golang.org/x/sys/unix" |
|
9 | 8 |
) |
10 | 9 |
|
11 | 10 |
func arches() []types.Architecture { |
... | ... |
@@ -510,7 +509,7 @@ func DefaultProfile() *types.Seccomp { |
510 | 510 |
Args: []*types.Arg{ |
511 | 511 |
{ |
512 | 512 |
Index: 0, |
513 |
- Value: syscall.CLONE_NEWNS | syscall.CLONE_NEWUTS | syscall.CLONE_NEWIPC | syscall.CLONE_NEWUSER | syscall.CLONE_NEWPID | syscall.CLONE_NEWNET, |
|
513 |
+ Value: unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET, |
|
514 | 514 |
ValueTwo: 0, |
515 | 515 |
Op: types.OpMaskedEqual, |
516 | 516 |
}, |
... | ... |
@@ -528,7 +527,7 @@ func DefaultProfile() *types.Seccomp { |
528 | 528 |
Args: []*types.Arg{ |
529 | 529 |
{ |
530 | 530 |
Index: 1, |
531 |
- Value: syscall.CLONE_NEWNS | syscall.CLONE_NEWUTS | syscall.CLONE_NEWIPC | syscall.CLONE_NEWUSER | syscall.CLONE_NEWPID | syscall.CLONE_NEWNET, |
|
531 |
+ Value: unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET, |
|
532 | 532 |
ValueTwo: 0, |
533 | 533 |
Op: types.OpMaskedEqual, |
534 | 534 |
}, |