From 149027868312351d79da6a219c3ece021580439a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 17 Jul 2017 10:36:56 +0200 Subject: [PATCH] loopback: use IoctlGetInt/IoctlSetInt from x/sys/unix Use IoctlGetInt/IoctlSetInt from golang.org/x/sys/unix (where applicable) instead of manually reimplementing them. Signed-off-by: Tobias Klauser Upstream-commit: bedf09363cb7f2f59bf2b72fea0704351b9f5c8d Component: engine --- components/engine/pkg/loopback/ioctl.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/engine/pkg/loopback/ioctl.go b/components/engine/pkg/loopback/ioctl.go index 534907a023..fa744f0a69 100644 --- a/components/engine/pkg/loopback/ioctl.go +++ b/components/engine/pkg/loopback/ioctl.go @@ -9,15 +9,15 @@ import ( ) func ioctlLoopCtlGetFree(fd uintptr) (int, error) { - index, _, err := unix.Syscall(unix.SYS_IOCTL, fd, LoopCtlGetFree, 0) - if err != 0 { + index, err := unix.IoctlGetInt(int(fd), LoopCtlGetFree) + if err != nil { return 0, err } - return int(index), nil + return index, nil } func ioctlLoopSetFd(loopFd, sparseFd uintptr) error { - if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetFd, sparseFd); err != 0 { + if err := unix.IoctlSetInt(int(loopFd), LoopSetFd, int(sparseFd)); err != nil { return err } return nil @@ -47,7 +47,7 @@ func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) { } func ioctlLoopSetCapacity(loopFd uintptr, value int) error { - if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetCapacity, uintptr(value)); err != 0 { + if err := unix.IoctlSetInt(int(loopFd), LoopSetCapacity, value); err != nil { return err } return nil