Hi Max, Thanks for the suggestion, unfortunately it did not help, see below:
func GetGroupFD(group int, pciDevice *string) (int, error) { fmt.Printf("VFIO_GROUP_GET_DEVICE_FD() returned: %04x\n", VFIO_GROUP_GET_DEVICE_FD()) buffer := make([]byte, len(*pciDevice)+1) for i, c := range *pciDevice { buffer[i] = uint8(c) } buffer[len(*pciDevice)] = 0x0 fmt.Printf("pciDevice: %s\n", string(buffer)) device, _, errno := syscall.Syscall( syscall.SYS_IOCTL, uintptr(group), uintptr(VFIO_GROUP_GET_DEVICE_FD()), uintptr(unsafe.Pointer(&buffer[0])), ) if errno != 0 { return 0, fmt.Errorf("fail to get file descriptor for %d with errno: %+v", group, errno) } return int(device), nil } Any other suggestions? Thank you Serguei From: <golang-nuts@googlegroups.com> on behalf of Max <massimiliano.ghila...@gmail.com> Date: Thursday, August 23, 2018 at 10:46 AM To: golang-nuts <golang-nuts@googlegroups.com> Subject: Re: [go-nuts] Re: Ioctl Syscall with go and c Hi Serguei, a Go string or *string do not correspond to a C char * You must pass the address of the first byte of a sufficiently large buffer: func GetGroupFD(group int, pciDevice *string) (int, error) { const N = 256 var buffer [N]byte device, _, errno := syscall.Syscall( syscall.SYS_IOCTL, uintptr(group), uintptr(unsafe.Pointer(&ioctlId)), &buffer[0], ) /* if ioctl() is successful, find '\0' in buffer[] and copy the relevant portion in *pciDevice */ } On Thursday, August 23, 2018 at 2:55:29 PM UTC+2, sbez...@cisco.com wrote: I changed code a little bit to be able to examine variables: func GetGroupFD(group int, pciDevice *string) (int, error) { ioctlId := 0x3b6a var buffer uintptr buffer = uintptr(unsafe.Pointer(pciDevice)) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com<mailto:golang-nuts+unsubscr...@googlegroups.com>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.