Loading...
--- Libc/Libc-262/gen/sysctl.3
+++ Libc/Libc-498/gen/sysctl.3
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
-.\" $FreeBSD: src/lib/libc/gen/sysctl.3,v 1.51 2001/10/01 16:08:51 ru Exp $
+.\" $FreeBSD: src/lib/libc/gen/sysctl.3,v 1.63 2004/07/02 23:52:10 ru Exp $
.\"
.Dd January 23, 2001
.Dt SYSCTL 3
@@ -83,7 +83,8 @@
The
.Fn sysctlbyname
function accepts an ASCII representation of the name and internally
-looks up the integer name vector. Apart from that, it behaves the same
+looks up the integer name vector.
+Apart from that, it behaves the same
as the standard
.Fn sysctl
function.
@@ -109,7 +110,9 @@
.Pp
The size of the available data can be determined by calling
.Fn sysctl
-with a NULL parameter for
+with the
+.Dv NULL
+argument for
.Fa oldp .
The size of the available data will be returned in the location pointed to by
.Fa oldlenp .
@@ -153,7 +156,7 @@
.Fn sysctlbyname
function).
The
-.Fn sysctlbyname
+.Fn sysctlnametomib
function is also useful for fetching mib prefixes and then adding
a final component.
For example, to fetch process information
@@ -179,22 +182,31 @@
}
.Ed
.Pp
+Note: Implementation of
+.Fn printkproc
+-- to print whatever data deemed necessary from the large
+.Vt kinfo_proc
+structure (
+.In sysctl.h
+) -- is left as an exercise for the reader.
+.Pp
The top level names are defined with a CTL_ prefix in
-.Aq Pa sys/sysctl.h ,
+.In sys/sysctl.h ,
and are as follows.
The next and subsequent levels down are found in the include files
listed here, and described in separate sections below.
.Pp
-.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
+.Bl -column CTLXMACHDEP "Next level names" -offset indent
.It Sy "Name Next level names Description"
-.It "CTL\_DEBUG sys/sysctl.h Debugging"
-.It "CTL\_VFS sys/mount.h Filesystem"
-.It "CTL\_HW sys/sysctl.h Generic CPU, I/O"
-.It "CTL\_KERN sys/sysctl.h High kernel limits"
-.It "CTL\_MACHDEP sys/sysctl.h Machine dependent"
-.It "CTL\_NET sys/socket.h Networking"
-.It "CTL\_USER sys/sysctl.h User-level"
-.It "CTL\_VM vm/vm_param.h Virtual memory"
+.It "CTL_DEBUG sys/sysctl.h Debugging"
+.It "CTL_VFS sys/mount.h File system"
+.It "CTL_HW sys/sysctl.h Generic CPU, I/O"
+.It "CTL_KERN sys/sysctl.h High kernel limits"
+.It "CTL_MACHDEP sys/sysctl.h Machine dependent"
+.It "CTL_NET sys/socket.h Networking"
+.It "CTL_USER sys/sysctl.h User-level"
+.It "CTL_VM sys/resources.h Virtual memory (struct loadavg)"
+.It "CTL_VM sys/vmmeter.h Virtual memory (struct vmtotal)"
.El
.Pp
For example, the following retrieves the maximum number of processes allowed
@@ -233,39 +245,40 @@
gets the list of debugging variables from the kernel and
displays their current values.
The system defines twenty
-.Ns ( Va struct ctldebug )
+.Pq Vt "struct ctldebug"
variables named
-.Nm debug0
+.Va debug0
through
-.Nm debug19 .
+.Va debug19 .
They are declared as separate variables so that they can be
individually initialized at the location of their associated variable.
The loader prevents multiple use of the same variable by issuing errors
if a variable is initialized in more than one place.
For example, to export the variable
-.Nm dospecialcheck
+.Va dospecialcheck
as a debugging variable, the following declaration would be used:
+.Pp
.Bd -literal -offset indent -compact
int dospecialcheck = 1;
struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
.Ed
.Ss CTL_VFS
A distinguished second level name, VFS_GENERIC,
-is used to get general information about all filesystems.
+is used to get general information about all file systems.
One of its third level identifiers is VFS_MAXTYPENUM
-that gives the highest valid filesystem type number.
+that gives the highest valid file system type number.
Its other third level identifier is VFS_CONF that
-returns configuration information about the filesystem
+returns configuration information about the file system
type given as a fourth level identifier (see
.Xr getvfsbyname 3
as an example of its use).
The remaining second level identifiers are the
-filesystem type number returned by a
+file system type number returned by a
.Xr statfs 2
call or from VFS_CONF.
-The third level identifiers available for each filesystem
+The third level identifiers available for each file system
are given in the header file that defines the mount
-argument structure for that filesystem.
+argument structure for that file system.
.Ss CTL_HW
The string and integer information available for the CTL_HW level
is detailed below.
@@ -273,17 +286,17 @@
privilege may change the value.
.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
.It Sy "Second level name Type Changeable"
-.It "HW\_MACHINE string no"
-.It "HW\_MODEL string no"
-.It "HW\_NCPU integer no"
-.It "HW\_BYTEORDER integer no"
-.It "HW\_PHYSMEM integer no"
-.It "HW\_USERMEM integer no"
-.It "HW\_PAGESIZE integer no"
-.It "HW\_FLOATINGPOINT integer no"
-.It "HW\_MACHINE\_ARCH string no"
-.\".It "HW\_DISKNAMES integer no"
-.\".It "HW\_DISKSTATS integer no"
+.It "HW_MACHINE string no"
+.It "HW_MODEL string no"
+.It "HW_NCPU integer no"
+.It "HW_BYTEORDER integer no"
+.It "HW_PHYSMEM integer no"
+.It "HW_USERMEM integer no"
+.It "HW_PAGESIZE integer no"
+.It "HW_FLOATINGPOINT integer no"
+.It "HW_MACHINE_ARCH string no"
+.\".It "HW_DISKNAMES integer no"
+.\".It "HW_DISKSTATS integer no"
.El
.Pp
.Bl -tag -width 6n
@@ -319,34 +332,34 @@
information.
.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
.It Sy "Second level name Type Changeable"
-.It "KERN\_ARGMAX integer no"
-.It "KERN\_BOOTFILE string yes"
-.It "KERN\_BOOTTIME struct timeval no"
-.It "KERN\_CLOCKRATE struct clockinfo no"
-.It "KERN\_FILE struct file no"
-.It "KERN\_HOSTID integer yes"
-.It "KERN\_HOSTNAME string yes"
-.It "KERN\_JOB\_CONTROL integer no"
-.It "KERN\_MAXFILES integer yes"
-.It "KERN\_MAXFILESPERPROC integer yes"
-.It "KERN\_MAXPROC integer no"
-.It "KERN\_MAXPROCPERUID integer yes"
-.It "KERN\_MAXVNODES integer yes"
-.It "KERN\_NGROUPS integer no"
-.It "KERN\_NISDOMAINNAME string yes"
-.It "KERN\_OSRELDATE integer no"
-.It "KERN\_OSRELEASE string no"
-.It "KERN\_OSREV integer no"
-.It "KERN\_OSTYPE string no"
-.It "KERN\_POSIX1 integer no"
-.It "KERN\_PROC struct proc no"
-.It "KERN\_PROF node not applicable"
-.It "KERN\_QUANTUM integer yes"
-.It "KERN\_SAVED\_IDS integer no"
-.It "KERN\_SECURELVL integer raise only"
-.It "KERN\_UPDATEINTERVAL integer no"
-.It "KERN\_VERSION string no"
-.It "KERN\_VNODE struct vnode no"
+.It "KERN_ARGMAX integer no"
+.It "KERN_BOOTFILE string yes"
+.It "KERN_BOOTTIME struct timeval no"
+.It "KERN_CLOCKRATE struct clockinfo no"
+.It "KERN_FILE struct file no"
+.It "KERN_HOSTID integer yes"
+.It "KERN_HOSTNAME string yes"
+.It "KERN_JOB_CONTROL integer no"
+.It "KERN_MAXFILES integer yes"
+.It "KERN_MAXFILESPERPROC integer yes"
+.It "KERN_MAXPROC integer no"
+.It "KERN_MAXPROCPERUID integer yes"
+.It "KERN_MAXVNODES integer yes"
+.It "KERN_NGROUPS integer no"
+.It "KERN_NISDOMAINNAME string yes"
+.It "KERN_OSRELDATE integer no"
+.It "KERN_OSRELEASE string no"
+.It "KERN_OSREV integer no"
+.It "KERN_OSTYPE string no"
+.It "KERN_POSIX1 integer no"
+.It "KERN_PROC struct proc no"
+.It "KERN_PROF node not applicable"
+.It "KERN_QUANTUM integer yes"
+.It "KERN_SAVED_IDS integer no"
+.It "KERN_SECURELVL integer raise only"
+.It "KERN_UPDATEINTERVAL integer no"
+.It "KERN_VERSION string no"
+.It "KERN_VNODE struct vnode no"
.El
.Pp
.Bl -tag -width 6n
@@ -403,8 +416,23 @@
.It Li KERN_NISDOMAINNAME
The name of the current YP/NIS domain.
.It Li KERN_OSRELDATE
-The system release date in YYYYMM format
-(January 1996 is encoded as 199601).
+The kernel release version in the format
+.Ar M Ns Ar mm Ns Ar R Ns Ar xx ,
+where
+.Ar M
+is the major version,
+.Ar mm
+is the two digit minor version,
+.Ar R
+is 0 if release branch, otherwise 1,
+and
+.Ar xx
+is updated when the available APIs change.
+.Pp
+The userland release version is available from
+.In osreldate.h ;
+parse this file if you need to get the release version of
+the currently installed userland.
.It Li KERN_OSRELEASE
The system release string.
.It Li KERN_OSREV
@@ -427,40 +455,30 @@
The third and fourth level names are as follows:
.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
.It "Third level name Fourth level is:"
-.It "KERN\_PROC\_ALL None"
-.It "KERN\_PROC\_PID A process ID"
-.It "KERN\_PROC\_PGRP A process group"
-.It "KERN\_PROC\_TTY A tty device"
-.It "KERN\_PROC\_UID A user ID"
-.It "KERN\_PROC\_RUID A real user ID"
-.El
-.Pp
-If the third level name is KERN_PROC_ARGS then the command line argument
-array is returned in a flattened form, i.e. zero-terminated arguments
-follow each other.
-The total size of array is returned.
-It is also possible for a process to set its own process title this way.
-.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
-.It Sy "Third level name Fourth level is:"
-.It "KERN\_PROC\_ARGS A process ID"
+.It "KERN_PROC_ALL None"
+.It "KERN_PROC_PID A process ID"
+.It "KERN_PROC_PGRP A process group"
+.It "KERN_PROC_TTY A tty device"
+.It "KERN_PROC_UID A user ID"
+.It "KERN_PROC_RUID A real user ID"
.El
.It Li KERN_PROF
Return profiling information about the kernel.
If the kernel is not compiled for profiling,
attempts to retrieve any of the KERN_PROF values will
fail with
-.Er EOPNOTSUPP .
+.Er ENOENT .
The third level names for the string and integer profiling information
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
.It Sy "Third level name Type Changeable"
-.It "GPROF\_STATE integer yes"
-.It "GPROF\_COUNT u_short[\|] yes"
-.It "GPROF\_FROMS u_short[\|] yes"
-.It "GPROF\_TOS struct tostruct yes"
-.It "GPROF\_GMONPARAM struct gmonparam no"
+.It "GPROF_STATE integer yes"
+.It "GPROF_COUNT u_short[\|] yes"
+.It "GPROF_FROMS u_short[\|] yes"
+.It "GPROF_TOS struct tostruct yes"
+.It "GPROF_GMONPARAM struct gmonparam no"
.El
.Pp
The variables are as follows:
@@ -519,9 +537,9 @@
privilege may change the value.
.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
.It Sy "Second level name Type Changeable"
-.It "PF\_ROUTE routing messages no"
-.It "PF\_INET IPv4 values yes"
-.It "PF\_INET6 IPv6 values yes"
+.It "PF_ROUTE routing messages no"
+.It "PF_INET IPv4 values yes"
+.It "PF_INET6 IPv6 values yes"
.El
.Pp
.Bl -tag -width 6n
@@ -538,10 +556,17 @@
The fifth and sixth level names are as follows:
.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
.It Sy "Fifth level name Sixth level is:"
-.It "NET\_RT\_FLAGS rtflags"
-.It "NET\_RT\_DUMP None"
-.It "NET\_RT\_IFLIST None"
-.El
+.It "NET_RT_FLAGS rtflags"
+.It "NET_RT_DUMP None"
+.It "NET_RT_IFLIST 0 or if_index"
+.It "NET_RT_IFMALIST 0 or if_index"
+.El
+.Pp
+The
+.Dv NET_RT_IFMALIST
+name returns information about multicast group memberships on all interfaces
+if 0 is specified, or for the interface specified by
+.Va if_index .
.It Li PF_INET
Get or set various global information about the IPv4
(Internet Protocol version 4).
@@ -601,26 +626,26 @@
privilege may change the value.
.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
.It Sy "Second level name Type Changeable"
-.It "USER\_BC\_BASE\_MAX integer no"
-.It "USER\_BC\_DIM\_MAX integer no"
-.It "USER\_BC\_SCALE\_MAX integer no"
-.It "USER\_BC\_STRING\_MAX integer no"
-.It "USER\_COLL\_WEIGHTS\_MAX integer no"
-.It "USER\_CS\_PATH string no"
-.It "USER\_EXPR\_NEST\_MAX integer no"
-.It "USER\_LINE\_MAX integer no"
-.It "USER\_POSIX2\_CHAR\_TERM integer no"
-.It "USER\_POSIX2\_C\_BIND integer no"
-.It "USER\_POSIX2\_C\_DEV integer no"
-.It "USER\_POSIX2\_FORT\_DEV integer no"
-.It "USER\_POSIX2\_FORT\_RUN integer no"
-.It "USER\_POSIX2\_LOCALEDEF integer no"
-.It "USER\_POSIX2\_SW\_DEV integer no"
-.It "USER\_POSIX2\_UPE integer no"
-.It "USER\_POSIX2\_VERSION integer no"
-.It "USER\_RE\_DUP\_MAX integer no"
-.It "USER\_STREAM\_MAX integer no"
-.It "USER\_TZNAME\_MAX integer no"
+.It "USER_BC_BASE_MAX integer no"
+.It "USER_BC_DIM_MAX integer no"
+.It "USER_BC_SCALE_MAX integer no"
+.It "USER_BC_STRING_MAX integer no"
+.It "USER_COLL_WEIGHTS_MAX integer no"
+.It "USER_CS_PATH string no"
+.It "USER_EXPR_NEST_MAX integer no"
+.It "USER_LINE_MAX integer no"
+.It "USER_POSIX2_CHAR_TERM integer no"
+.It "USER_POSIX2_C_BIND integer no"
+.It "USER_POSIX2_C_DEV integer no"
+.It "USER_POSIX2_FORT_DEV integer no"
+.It "USER_POSIX2_FORT_RUN integer no"
+.It "USER_POSIX2_LOCALEDEF integer no"
+.It "USER_POSIX2_SW_DEV integer no"
+.It "USER_POSIX2_UPE integer no"
+.It "USER_POSIX2_VERSION integer no"
+.It "USER_RE_DUP_MAX integer no"
+.It "USER_STREAM_MAX integer no"
+.It "USER_TZNAME_MAX integer no"
.El
.Bl -tag -width 6n
.Pp
@@ -701,17 +726,17 @@
privilege may change the value.
.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
.It Sy "Second level name Type Changeable"
-.It "VM\_LOADAVG struct loadavg no"
-.It "VM\_METER struct vmtotal no"
-.It "VM\_PAGEOUT\_ALGORITHM integer yes"
-.It "VM\_SWAPPING\_ENABLED integer maybe"
-.It "VM\_V\_CACHE\_MAX integer yes"
-.It "VM\_V\_CACHE\_MIN integer yes"
-.It "VM\_V\_FREE\_MIN integer yes"
-.It "VM\_V\_FREE\_RESERVED integer yes"
-.It "VM\_V\_FREE\_TARGET integer yes"
-.It "VM\_V\_INACTIVE\_TARGET integer yes"
-.It "VM\_V\_PAGEOUT\_FREE\_MIN integer yes"
+.It "VM_LOADAVG struct loadavg no"
+.It "VM_METER struct vmtotal no"
+.It "VM_PAGEOUT_ALGORITHM integer yes"
+.It "VM_SWAPPING_ENABLED integer maybe"
+.It "VM_V_CACHE_MAX integer yes"
+.It "VM_V_CACHE_MIN integer yes"
+.It "VM_V_FREE_MIN integer yes"
+.It "VM_V_FREE_RESERVED integer yes"
+.It "VM_V_FREE_TARGET integer yes"
+.It "VM_V_INACTIVE_TARGET integer yes"
+.It "VM_V_PAGEOUT_FREE_MIN integer yes"
.El
.Pp
.Bl -tag -width 6n
@@ -727,12 +752,14 @@
0 if the statistics-based page management algorithm is in use
or 1 if the near-LRU algorithm is in use.
.It Li VM_SWAPPING_ENABLED
-1 if process swapping is enabled or 0 if disabled. This variable is
+1 if process swapping is enabled or 0 if disabled.
+This variable is
permanently set to 0 if the kernel was built with swapping disabled.
.It Li VM_V_CACHE_MAX
Maximum desired size of the cache queue.
.It Li VM_V_CACHE_MIN
-Minimum desired size of the cache queue. If the cache queue size
+Minimum desired size of the cache queue.
+If the cache queue size
falls very far below this value, the pageout daemon is awakened.
.It Li VM_V_FREE_MIN
Minimum amount of memory (cache memory plus free memory)
@@ -746,7 +773,8 @@
pageout daemon tries to maintain.
.It Li VM_V_INACTIVE_TARGET
The desired number of inactive pages that the pageout daemon should
-achieve when it runs. Inactive pages can be quickly inserted into
+achieve when it runs.
+Inactive pages can be quickly inserted into
process address space when needed.
.It Li VM_V_PAGEOUT_FREE_MIN
If the amount of free and cache memory falls below this value, the
@@ -779,6 +807,17 @@
The length pointed to by
.Fa oldlenp
is too short to hold the requested value.
+.It Bq Er ENOMEM
+The smaller of either the length pointed to by
+.Fa oldlenp
+or the estimated size of the returned data exceeds the
+system limit on locked memory.
+.It Bq Er ENOMEM
+Locking the buffer
+.Fa oldp ,
+or a portion of the buffer if the estimated size of the data
+to be returned is smaller,
+would cause the process to exceed its per-process locked memory limit.
.It Bq Er ENOTDIR
The
.Fa name
@@ -787,7 +826,7 @@
The
.Fa name
array specifies a terminal name, but the actual name is not terminal.
-.It Bq Er EOPNOTSUPP
+.It Bq Er ENOENT
The
.Fa name
array specifies a value that is unknown.
@@ -798,23 +837,23 @@
.El
.Sh FILES
.Bl -tag -width <netinet/icmpXvar.h> -compact
-.It Aq Pa sys/sysctl.h
+.It In sys/sysctl.h
definitions for top level identifiers, second level kernel and hardware
identifiers, and user level identifiers
-.It Aq Pa sys/socket.h
+.It In sys/socket.h
definitions for second level network identifiers
-.It Aq Pa sys/gmon.h
+.It In sys/gmon.h
definitions for third level profiling identifiers
-.It Aq Pa vm/vm_param.h
+.It In mach/vm_param.h
definitions for second level virtual memory identifiers
-.It Aq Pa netinet/in.h
+.It In netinet/in.h
definitions for third level IPv4/IPv6 identifiers and
fourth level IPv4/v6 identifiers
-.It Aq Pa netinet/icmp_var.h
+.It In netinet/icmp_var.h
definitions for fourth level ICMP identifiers
-.It Aq Pa netinet/icmp6.h
+.It In netinet/icmp6.h
definitions for fourth level ICMPv6 identifiers
-.It Aq Pa netinet/udp_var.h
+.It In netinet/udp_var.h
definitions for fourth level UDP identifiers
.El
.Sh SEE ALSO