sysctl()的参数是什么? [英] What are the arguments to sysctl()?

查看:227
本文介绍了sysctl()的参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了手册页和文档,但它们仅讨论命令行调用.我说的是C函数.关于此的两个问题:

I checked the man pages and documentation but they only discuss the command line call. I am talking about the C function. Two questions about it:

  • C中sysctl()的参数是什么? (我只想要一个将军 每个参数的含义及其用途的说明)
  • 在Mac OS X Lion中sysctl()调用仍然有效吗?
  • What are the arguments to sysctl() in C? (I just want a general description of what each argument is and what it is used for)
  • Is the sysctl() call still valid in Mac OS X Lion?

我在Mac OS X Snow Leopard上使用Xcode 3.2.6

I am on Mac OS X Snow Leopard using Xcode 3.2.6

推荐答案

好吧,引用此页面,假设它具有原型:

Well, quoting this page, assuming it has the prototype:

int sysctl (int *name,
            int nlen, 
            void *oldval,
            size_t *oldlenp,
            void *newval, 
            size_t newlen);

然后它的参数如下:

  • name ->指向整数数组:每个整数值都标识一个sysctl项(目录或叶节点文件).这些值的符号名称在<linux/sysctl.h>中定义.
  • nlen ->指出数组名称中列出了多少个整数:要到达特定条目,您需要指定通过子目录的路径,因此您需要知道该路径有多长时间.
  • oldval ->是指向数据缓冲区的指针,该缓冲区必须存储sysctl项的旧值.如果为NULL,则系统调用不会将值返回到用户空间.
  • oldlenp ->指向一个整数,表示oldval缓冲区的长度.系统调用更改该值以反映已写入了多少数据,该数据可以小于缓冲区长度.
  • newval ->指向托管替换数据的数据缓冲区:内核将读取此缓冲区以更改要执行的sysctl条目.如果为NULL,则不更改内核值.
  • newlen ->是newval的长度.内核将从newval中读取的内容不超过newlen个字节.
  • name -> points to an array of integers: each of the integer values identifies a sysctl item, either a directory or a leaf node file. The symbolic names for such values are defined in <linux/sysctl.h>.
  • nlen -> states how many integer numbers are listed in the array name: to reach a particular entry you need to specify the path through the subdirectories, so you need to tell how long is such path.
  • oldval -> is a pointer to a data buffer where the old value of the sysctl item must be stored. If it is NULL, the system call won't return values to user space.
  • oldlenp -> points to an integer number stating the length of the oldval buffer. The system call changes the value to reflect how much data has been written, which can be less than the buffer length.
  • newval -> points to a data buffer hosting replacement data: the kernel will read this buffer to change the sysctl entry being acted upon. If it is NULL, the kernel value is not changed.
  • newlen -> is the length of newval. The kernel will read no more than newlen bytes from newval.

我建议您阅读整个页面,因为它提供了更多信息详尽的细节.至于它在Mac OS X Lion中是否有效,我不确定,但我可以想象.

I'd recommend you read that entire page, since it provides more extensive details. And as for it being valid in Mac OS X Lion, I'm not sure, but I'd imagine.

希望我能帮上忙!

这篇关于sysctl()的参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆