Use IoctlGetInt/IoctlSetInt from golang.org/x/sys/unix (where
applicable) instead of manually reimplementing them.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
| ... | ... |
@@ -9,15 +9,15 @@ import ( |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
func ioctlLoopCtlGetFree(fd uintptr) (int, error) {
|
| 12 |
- index, _, err := unix.Syscall(unix.SYS_IOCTL, fd, LoopCtlGetFree, 0) |
|
| 13 |
- if err != 0 {
|
|
| 12 |
+ index, err := unix.IoctlGetInt(int(fd), LoopCtlGetFree) |
|
| 13 |
+ if err != nil {
|
|
| 14 | 14 |
return 0, err |
| 15 | 15 |
} |
| 16 |
- return int(index), nil |
|
| 16 |
+ return index, nil |
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
func ioctlLoopSetFd(loopFd, sparseFd uintptr) error {
|
| 20 |
- if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetFd, sparseFd); err != 0 {
|
|
| 20 |
+ if err := unix.IoctlSetInt(int(loopFd), LoopSetFd, int(sparseFd)); err != nil {
|
|
| 21 | 21 |
return err |
| 22 | 22 |
} |
| 23 | 23 |
return nil |
| ... | ... |
@@ -47,7 +47,7 @@ func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) {
|
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 | 49 |
func ioctlLoopSetCapacity(loopFd uintptr, value int) error {
|
| 50 |
- if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetCapacity, uintptr(value)); err != 0 {
|
|
| 50 |
+ if err := unix.IoctlSetInt(int(loopFd), LoopSetCapacity, value); err != nil {
|
|
| 51 | 51 |
return err |
| 52 | 52 |
} |
| 53 | 53 |
return nil |