github.com/ph/moby@v1.13.1/pkg/devicemapper/ioctl.go (about) 1 // +build linux 2 3 package devicemapper 4 5 import ( 6 "syscall" 7 "unsafe" 8 ) 9 10 func ioctlBlkGetSize64(fd uintptr) (int64, error) { 11 var size int64 12 if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkGetSize64, uintptr(unsafe.Pointer(&size))); err != 0 { 13 return 0, err 14 } 15 return size, nil 16 } 17 18 func ioctlBlkDiscard(fd uintptr, offset, length uint64) error { 19 var r [2]uint64 20 r[0] = offset 21 r[1] = length 22 23 if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkDiscard, uintptr(unsafe.Pointer(&r[0]))); err != 0 { 24 return err 25 } 26 return nil 27 }