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

x/sys/unix: Sysctl doesn't supporting writing values #8757

Open
songgao opened this issue Sep 17, 2014 · 5 comments
Open

x/sys/unix: Sysctl doesn't supporting writing values #8757

songgao opened this issue Sep 17, 2014 · 5 comments
Milestone

Comments

@songgao
Copy link

songgao commented Sep 17, 2014

Hello,

This is not really reporting defects but more like a feature request.

In syscall package, or go.sys package, Sysctl is defined as: 

func Sysctl(name string) (value string, err error)

It provides a way to read values through sysctl, but makes it impossible to write/update
values. Internally, it uses "sysctl" defined in each particular OS / ARCH. For
example, (from zsyscall_freebsd_amd64.go):

func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err
error)

It would be nice if it can be exported in some way because this is essentially the same
interface as defined in BSD systems. e.g. https://www.freebsd.org/cgi/man.cgi?sysctl(3)

int sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, const void
*newp, size_t newlen);
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, const void *newp, size_t
newlen);

Can we provide a similar set of functions in go.sys that provides full sysctl support
(both read / write)? If go.sys is not frozen yet, maybe it's a good idea to use the
function names used in most BSD systems, in which case current Sysctl will need to be
renamed to, e.g., SysctlRead.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-sys, release-none.

Status changed to Accepted.

@songgao
Copy link
Author

songgao commented Sep 18, 2014

Comment 2:

I'd like to at that, current form of Sysctl only supports string values. If a sysctl
value is integer (e.g. machdep.tsc_freq) , it would be interpreted (not parsed) as
string.

@songgao
Copy link
Author

songgao commented Dec 8, 2014

Kudos to the migrating robots :D

I wonder if this issue is best to be in golang/sys now?

@ianlancetaylor
Copy link
Contributor

Yes, this is for the sys subrepo. As Andrew said in his e-mail to golang-dev, we are using this single issue tracker for the subrepos as well.

@songgao
Copy link
Author

songgao commented Dec 8, 2014

Got it. Thanks @ianlancetaylor

@mikioh mikioh changed the title go.sys: Unix: Sysctl doesn't supporting writing values unix: Sysctl doesn't supporting writing values Jan 7, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title unix: Sysctl doesn't supporting writing values x/sys/unix: Sysctl doesn't supporting writing values Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-sys label Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants