Skip to content

x/sys/unix: ioctl wrapper signatures do not match C on Solaris and AIX #59030

Closed
@nshalman

Description

@nshalman

(Can be assigned to me unless some kind soul has the bandwidth to work on it before me.)

Copied from WireGuard/wireguard-go#39 (comment)

It looks like ioctl has the wrong signature in Go. According to https://illumos.org/man/2/ioctl req is an int. In Go, that's int32, not int or uint as the Go code has now. Presumably it's too late to fix that, which is unfortunate.

Is it too late?

Regarding ioctls using negative numbers:

The easiest way to do this is probably just by adding & 0xffffffff onto the end of the constant definition.
(The lazy version, by the way, is just unix.IoctlLifreq(tun.ipfd, unix.SIOCGLIFMTU & 0xffffffff, &l)).

Affected functions:

$ git grep "req uint" unix/syscall_solaris.go
unix/syscall_solaris.go://sys   ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) = libc.ioctl
unix/syscall_solaris.go://sys   ioctlPtrRet(fd int, req uint, arg unsafe.Pointer) (ret int, err error) = libc.ioctl
unix/syscall_solaris.go:func ioctl(fd int, req uint, arg uintptr) (err error) {
unix/syscall_solaris.go:func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) {
unix/syscall_solaris.go:func IoctlSetTermio(fd int, req uint, value *Termio) error {
unix/syscall_solaris.go:func IoctlGetTermio(fd int, req uint) (*Termio, error) {
unix/syscall_solaris.go:func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) {
unix/syscall_solaris.go:func IoctlSetString(fd int, req uint, val string) error {
unix/syscall_solaris.go:func IoctlLifreq(fd int, req uint, l *Lifreq) error {
unix/syscall_solaris.go:func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) {

To anyone labeling this issue, this affects both solaris and illumos.

While I'm likely going to be the one doing the work, I could definitely use some guidance on what approach will make the most sense.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions