github.com/skanehira/moby@v17.12.1-ce-rc2+incompatible/pkg/loopback/ioctl.go (about) 1 // +build linux,cgo 2 3 package loopback 4 5 import ( 6 "unsafe" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 func ioctlLoopCtlGetFree(fd uintptr) (int, error) { 12 index, err := unix.IoctlGetInt(int(fd), LoopCtlGetFree) 13 if err != nil { 14 return 0, err 15 } 16 return index, nil 17 } 18 19 func ioctlLoopSetFd(loopFd, sparseFd uintptr) error { 20 return unix.IoctlSetInt(int(loopFd), LoopSetFd, int(sparseFd)) 21 } 22 23 func ioctlLoopSetStatus64(loopFd uintptr, loopInfo *loopInfo64) error { 24 if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopSetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { 25 return err 26 } 27 return nil 28 } 29 30 func ioctlLoopClrFd(loopFd uintptr) error { 31 if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopClrFd, 0); err != 0 { 32 return err 33 } 34 return nil 35 } 36 37 func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) { 38 loopInfo := &loopInfo64{} 39 40 if _, _, err := unix.Syscall(unix.SYS_IOCTL, loopFd, LoopGetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { 41 return nil, err 42 } 43 return loopInfo, nil 44 } 45 46 func ioctlLoopSetCapacity(loopFd uintptr, value int) error { 47 return unix.IoctlSetInt(int(loopFd), LoopSetCapacity, value) 48 }