Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: add new ioctls and refactor existing ioctls for solaris in x/sys/unix #14873

Open
kim-racktop opened this issue Mar 19, 2016 · 6 comments

Comments

Projects
None yet
5 participants
@kim-racktop
Copy link

commented Mar 19, 2016

I propose adding 4 additional ioctl functions for solaris:

IoctlGetUint
IoctlSetUint
IoctlGetString
IoctlSetString

In addition, I propose modifying the existing IoctlGetInt function to support passing in a nil pointer for the ioctl arg parameter. In the case of IoctlGetInt and IoctlGetUint, if arg is nil, the return value is the same as the return value from the underlying ioctl function. If the arg pointer is not nil, then the return value is also written into the memory location pointed to by arg.

To support the functionality of IoctlGetInt and IoctlGetUint, we need to change the underlying ioctl function from the current definition:

//sys   ioctl(fd int, req int, arg uintptr) (err error)

to

//sys   ioctl(fd int, req int, arg uintptr) (n int, err error)

The existing IoctlGet and IoctlSet functions would also need to be modified to use the updated ioctl function.

To summarize, the existing IoctlGetInt function would change from:

func IoctlGetInt(fd int, req int) (int, error)

to

func IoctlGetInt(fd int, req int, value *int) (int, error)

And the following 4 functions would be added:

func IoctlGetUint(fd int, req int, value *uint) (uint, error)
func IoctlSetUint(fd int, req int, value uint) (err error)
func IoctlGetString(fd int, req int) (string, error)
func IoctlSetString(fd int, req int, value string) (err error)

@minux minux added this to the Unreleased milestone Mar 19, 2016

@minux

This comment has been minimized.

Copy link
Member

commented Mar 19, 2016

@kim-racktop

This comment has been minimized.

Copy link
Author

commented Mar 21, 2016

The implementation I have is solaris only and builds on existing solaris specific code. As a follow-on to these modifications, I could look at adding them for freebsd and darwin as these are the other flavors of Unix I have on my machines.

@rakyll rakyll changed the title Proposal add new ioctl's and refactor existing ioctl's for solaris in x/sys/unix proposal: add new ioctl's and refactor existing ioctl's for solaris in x/sys/unix Mar 22, 2016

@robpike robpike changed the title proposal: add new ioctl's and refactor existing ioctl's for solaris in x/sys/unix proposal: add new ioctls and refactor existing ioctls for solaris in x/sys/unix Aug 10, 2016

@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

I commented on the CL, but really should have said something here. This is a proposal but it was not accepted. Proposals should be handled faster, and that is not your fault.

My point is that I don't want to see ioctl get helpers to make it look nice. It really doesn't need int and uint and *Termio and *Whatever helpers. The caller can do the conversion. It may be uglier but it will actually be faster, and anyway ioctl is hideous and I prefer not to hide that fact.

@kim-racktop

This comment has been minimized.

Copy link
Author

commented Aug 10, 2016

Ok. My apologies for not following procedure.

What about taking the following approach. I replace all the IoctlGetXxx and IoctlSetXxx functions with the following:

func IoctlGet(fd int, req int) (uintptr, error)
func IoctlSet(fd int, req int, value uintptr) (error)

The only exception would be that I am inclined to leave the IoctlGetString and IoctlSetString functions in place to handle the conversion to/from Go strings, since that is more involved than a type conversion.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

That seems reasonable to me but others should weigh in as well.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 17, 2016

CL https://golang.org/cl/26650 mentions this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.