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

Closed
kim-racktop opened this issue Mar 19, 2016 · 7 comments

Comments

@kim-racktop
Copy link

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
Copy link
Member

minux commented Mar 19, 2016 via email

@kim-racktop
Copy link
Author

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
Copy link
Contributor

robpike 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
Copy link
Author

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
Copy link
Contributor

robpike commented Aug 10, 2016

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

@gopherbot
Copy link

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

@ianlancetaylor
Copy link
Contributor

As far as I can tell, this proposal is implemented, albeit not exactly as discussed here.

@golang golang locked and limited conversation to collaborators May 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants