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 <tklauser@distanz.ch>
This commit is contained in:
parent
6476504695
commit
bedf09363c
|
@ -9,15 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ioctlLoopCtlGetFree(fd uintptr) (int, error) {
|
func ioctlLoopCtlGetFree(fd uintptr) (int, error) {
|
||||||
index, _, err := unix.Syscall(unix.SYS_IOCTL, fd, LoopCtlGetFree, 0)
|
index, err := unix.IoctlGetInt(int(fd), LoopCtlGetFree)
|
||||||
if err != 0 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return int(index), nil
|
return index, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ioctlLoopSetFd(loopFd, sparseFd uintptr) error {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -47,7 +47,7 @@ func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ioctlLoopSetCapacity(loopFd uintptr, value int) 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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue