mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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
1 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue