What are the arguments to sysctl()? What are the arguments to sysctl()? unix unix

What are the arguments to sysctl()?


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);

then it's parameters would be as follows:

  • 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.

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.

Hope I helped!