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)) device, _, errno := syscall.Syscall( syscall.SYS_IOCTL, uintptr(group), uintptr(unsafe.Pointer(&ioctlId)), buffer, )
(gdb) p &buffer $8 = (uintptr *) 0xc4200c7b88 (gdb) x/g 0xc4200c7b88 0xc4200c7b88: 0x000000c4200c7d08 (gdb) x/g 0x000000c4200c7d08 0xc4200c7d08: 0x000000c4200122d0 (gdb) x/g 0x000000c4200122d0 0xc4200122d0: 0x3a31383a30303030 0x30303030 is start of expected string “0000:81:11.1”, first 4 bytes are not part of it. Anybody knows where those 4 bytes could have come from? And how to get rid of them? Thank you Serguei From: <golang-nuts@googlegroups.com> on behalf of Tamás Gulácsi <tgulacs...@gmail.com> Date: Thursday, August 23, 2018 at 8:13 AM To: golang-nuts <golang-nuts@googlegroups.com> Subject: [go-nuts] Re: Ioctl Syscall with go and c Is it \0-terminated? 2018. augusztus 23., csütörtök 13:02:13 UTC+2 időpontban sbez...@cisco.com a következőt írta: Hello, I am converting some C code to Go and hit an issue with one particular Syscall: In C: device = ioctl(group, 0x3b6a, path); where path is char[N] In Go: ioctlId := 0x3b6a device, _, errno := syscall.Syscall( syscall.SYS_IOCTL, uintptr(group), uintptr(unsafe.Pointer(&ioctlId)), uintptr(unsafe.Pointer(pciDevice)), ) Where pciDevice is *string with exactly the same value as path in C. When I run Go bits on the same h/w, same OS, same everything, it fails with "errno 22 (invalid argument)". It seems that the issue is how string gets passed to Syscall, but I could not find any examples how to do it correctly. Appreciate some advice here. Thank you Serguei -- 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.