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