xref: /csrg-svn/lib/libc/gen/sysctl.3 (revision 69324)
161111Sbostic.\" Copyright (c) 1993
261111Sbostic.\"	The Regents of the University of California.  All rights reserved.
358401Smckusick.\"
458401Smckusick.\" %sccs.include.redist.roff%
558401Smckusick.\"
6*69324Smckusick.\"	@(#)sysctl.3	8.4 (Berkeley) 05/09/95
758401Smckusick.\"
858401Smckusick.Dd ""
959868Sbostic.Dt SYSCTL 3
1058401Smckusick.Os
1158401Smckusick.Sh NAME
1258401Smckusick.Nm sysctl
1359868Sbostic.Nd get or set system information
1458401Smckusick.Sh SYNOPSIS
1558401Smckusick.Fd #include <sys/sysctl.h>
1658401Smckusick.Ft int
1759868Sbostic.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
1858401Smckusick.Sh DESCRIPTION
1958401SmckusickThe
2059868Sbostic.Nm sysctl
2159868Sbosticfunction retrieves system information and allows processes with
2259868Sbosticappropriate privileges to set system information.
2359868SbosticThe information available from
2459868Sbostic.Nm sysctl
2559868Sbosticconsists of integers, strings, and tables.
2659868SbosticInformation may be retrieved and set from the command interface
2759868Sbosticusing the
2859868Sbostic.Xr sysctl 1
2959868Sbosticutility.
3059868Sbostic.Pp
3159978SmckusickUnless explicitly noted below,
3259978Smckusick.Nm sysctl
3359978Smckusickreturns a consistent snapshot of the data requested.
3459978SmckusickConsistency is obtained by locking the destination
3559978Smckusickbuffer into memory so that the data may be copied out without blocking.
3659978SmckusickCalls to
3759978Smckusick.Nm sysctl
3859978Smckusickare serialized to avoid deadlock.
3959978Smckusick.Pp
4059868SbosticThe state is described using a ``Management Information Base'' (MIB)
4159868Sbosticstyle name, listed in
4259868Sbostic.Fa name ,
4359868Sbosticwhich is a
4458401Smckusick.Fa namelen
4559868Sbosticlength array of integers.
4658401Smckusick.Pp
4758507SmckusickThe information is copied into the buffer specified by
4859868Sbostic.Fa oldp .
4958507SmckusickThe size of the buffer is given by the location specified by
5058507Smckusick.Fa oldlenp
5158507Smckusickbefore the call,
5258507Smckusickand that location gives the amount of data copied after a successful call.
5358507SmckusickIf the amount of data available is greater
5458507Smckusickthan the size of the buffer supplied,
5558507Smckusickthe call supplies as much data as fits in the buffer provided
5659978Smckusickand returns with the error code ENOMEM.
5758401SmckusickIf the old value is not desired,
5859868Sbostic.Fa oldp
5958401Smckusickand
6058401Smckusick.Fa oldlenp
6159868Sbosticshould be set to NULL.
6258401Smckusick.Pp
6358507SmckusickThe size of the available data can be determined by calling
6459868Sbostic.Nm sysctl
6558507Smckusickwith a NULL parameter for
6659868Sbostic.Fa oldp .
6759978SmckusickThe size of the available data will be returned in the location pointed to by
6858507Smckusick.Fa oldlenp .
6959978SmckusickFor some operations, the amount of space may change often.
7059978SmckusickFor these operations,
7158507Smckusickthe system attempts to round up so that the returned size is
7258507Smckusicklarge enough for a call to return the data shortly thereafter.
7358507Smckusick.Pp
7458401SmckusickTo set a new value,
7559868Sbostic.Fa newp
7658401Smckusickis set to point to a buffer of length
7758401Smckusick.Fa newlen
7858401Smckusickfrom which the requested value is to be taken.
7958507SmckusickIf a new value is not to be set,
8059868Sbostic.Fa newp
8158401Smckusickshould be set to NULL and
8258401Smckusick.Fa newlen
8358401Smckusickset to 0.
8458401Smckusick.Pp
8559868SbosticThe top level names are defined with a CTL_ prefix in
8659868Sbostic.Pa <sys/sysctl.h> ,
8759868Sbosticand are as follows.
8859868SbosticThe next and subsequent levels down are found in the include files
8959868Sbosticlisted here, and described in separate sections below.
9059868Sbostic.Pp
9159978Smckusick.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
9259868Sbostic.It Sy Pa Name	Next level names	Description
9359868Sbostic.It CTL\_DEBUG	sys/sysctl.h	Debugging
94*69324Smckusick.It CTL\_VFS	sys/mount.h	Filesystem
9559868Sbostic.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
9660429Smckusick.It CTL\_KERN	sys/sysctl.h	High kernel limits
9759868Sbostic.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
9859868Sbostic.It CTL\_NET	sys/socket.h	Networking
9959868Sbostic.It CTL\_USER	sys/sysctl.h	User-level
10059868Sbostic.It CTL\_VM	vm/vm_param.h	Virtual memory
10158507Smckusick.El
10258507Smckusick.Pp
10358507SmckusickFor example, the following retrieves the maximum number of processes allowed
10458507Smckusickin the system:
10558401Smckusick.Bd -literal -offset indent -compact
10659868Sbosticint mib[2], maxproc;
10758462Sbosticsize_t len;
10858507Smckusick.sp
10959868Sbosticmib[0] = CTL_KERN;
11059868Sbosticmib[1] = KERN_MAXPROC;
11158462Sbosticlen = sizeof(maxproc);
11259868Sbosticsysctl(mib, 2, &maxproc, &len, NULL, 0);
11358401Smckusick.Ed
11459868Sbostic.sp
11559868SbosticTo retrieve the standard search path for the system utilities:
11659868Sbostic.Bd -literal -offset indent -compact
11759868Sbosticint mib[2];
11859868Sbosticsize_t len;
11959868Sbosticchar *p;
12059868Sbostic.sp
12159868Sbosticmib[0] = CTL_USER;
12259868Sbosticmib[1] = USER_CS_PATH;
12359868Sbosticsysctl(mib, 2, NULL, &len, NULL, 0);
12459868Sbosticp = malloc(len);
12559868Sbosticsysctl(mib, 2, p, &len, NULL, 0);
12659868Sbostic.Ed
12759978Smckusick.Sh CTL_DEBUG
12859978SmckusickThe debugging variables vary from system to system.
12959978SmckusickA debugging variable may be added or deleted without need to recompile
13059868Sbostic.Nm sysctl
13159978Smckusickto know about it.
13259978SmckusickEach time it runs,
13359978Smckusick.Nm sysctl
13459978Smckusickgets the list of debugging variables from the kernel and
13559978Smckusickdisplays their current values.
13659978SmckusickThe system defines twenty
13759978Smckusick.Ns ( Va struct ctldebug )
13859978Smckusickvariables named
13959978Smckusick.Nm debug0
14059978Smckusickthrough
14159978Smckusick.Nm debug19 .
14259978SmckusickThey are declared as separate variables so that they can be
14359978Smckusickindividually initialized at the location of their associated variable.
14459978SmckusickThe loader prevents multiple use of the same variable by issuing errors
14559978Smckusickif a variable is initialized in more than one place.
14659978SmckusickFor example, to export the variable
14759978Smckusick.Nm dospecialcheck
14859978Smckusickas a debugging variable, the following declaration would be used:
14959978Smckusick.Bd -literal -offset indent -compact
15059978Smckusickint dospecialcheck = 1;
15159978Smckusickstruct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
15259978Smckusick.Ed
153*69324Smckusick.Sh CTL_VFS
154*69324SmckusickA distinguished second level name, VFS_GENERIC,
155*69324Smckusickis used to get general information about all filesystems.
156*69324SmckusickOne of its third level identifiers is VFS_MAXTYPENUM
157*69324Smckusickthat gives the highest valid filesystem type number.
158*69324SmckusickIts other third level identifier is VFS_CONF that
159*69324Smckusickreturns configuration information about the filesystem
160*69324Smckusicktype given as a fourth level identifier (see
161*69324Smckusick.Xr getvfsbyname 3
162*69324Smckusickas an example of its use).
163*69324SmckusickThe remaining second level identifiers are the
164*69324Smckusickfilesystem type number returned by a
165*69324Smckusick.Xr statfs 2
166*69324Smckusickcall or from VFS_CONF.
167*69324SmckusickThe third level identifiers available for each filesystem
168*69324Smckusickare given in the header file that defines the mount
169*69324Smckusickargument structure for that filesystem.
17059868Sbostic.Sh CTL_HW
17159978SmckusickThe string and integer information available for the CTL_HW level
17259868Sbosticis detailed below.
17359868SbosticThe changeable column shows whether a process with appropriate
17459868Sbosticprivilege may change the value.
17559978Smckusick.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
17659868Sbostic.It Sy Pa Second level name	Type	Changeable
17759868Sbostic.It HW\_MACHINE	string	no
17859868Sbostic.It HW\_MODEL	string	no
17959868Sbostic.It HW\_NCPU	integer	no
18059868Sbostic.It HW\_BYTEORDER	integer	no
18159868Sbostic.It HW\_PHYSMEM	integer	no
18259868Sbostic.It HW\_USERMEM	integer	no
18359868Sbostic.It HW\_PAGESIZE	integer	no
18459868Sbostic.\".It HW\_DISKNAMES	integer	no
18559868Sbostic.\".It HW\_DISKSTATS	integer	no
18659868Sbostic.El
18758507Smckusick.Pp
18859868Sbostic.Bl -tag -width "123456"
18959868Sbostic.It Li HW_MACHINE
19059978SmckusickThe machine class.
19159868Sbostic.It Li HW_MODEL
19259978SmckusickThe machine model
19359868Sbostic.It Li HW_NCPU
19459978SmckusickThe number of cpus.
19567357Sah.ne 1i
19659868Sbostic.It Li HW_BYTEORDER
19759978SmckusickThe byteorder (4,321, or 1,234).
19859868Sbostic.It Li HW_PHYSMEM
19959978SmckusickThe bytes of physical memory.
20059868Sbostic.It Li HW_USERMEM
20159978SmckusickThe bytes of non-kernel memory.
20259868Sbostic.It Li HW_PAGESIZE
20359978SmckusickThe software page size.
20459868Sbostic.\".It Fa HW_DISKNAMES
20559868Sbostic.\".It Fa HW_DISKSTATS
20659868Sbostic.El
20759868Sbostic.Sh CTL_KERN
20859868SbosticThe string and integer information available for the CTL_KERN level
20959868Sbosticis detailed below.
21059868SbosticThe changeable column shows whether a process with appropriate
21159868Sbosticprivilege may change the value.
21258507SmckusickThe types of data currently available are process information,
21358507Smckusicksystem vnodes, the open file entries, routing table entries,
21459868Sbosticvirtual memory statistics, load average history, and clock rate
21559868Sbosticinformation.
21659868Sbostic.Bl -column "KERNXCHOWNXRESTRICTEDXXX" "struct clockrateXXX" -offset indent
21759868Sbostic.It Sy Pa Second level name	Type	Changeable
21859868Sbostic.It KERN\_ARGMAX	integer	no
21960166Smckusick.It KERN\_BOOTTIME	struct timeval	no
22059868Sbostic.It KERN\_CHOWN\_RESTRICTED	integer	no
22159978Smckusick.It KERN\_CLOCKRATE	struct clockinfo	no
22259978Smckusick.It KERN\_FILE	struct file	no
22359868Sbostic.It KERN\_HOSTID	integer	yes
22459868Sbostic.It KERN\_HOSTNAME	string	yes
22559868Sbostic.It KERN\_JOB\_CONTROL	integer	no
22659868Sbostic.It KERN\_LINK\_MAX	integer	no
22759868Sbostic.It KERN\_MAXFILES	integer	yes
22859868Sbostic.It KERN\_MAXPROC	integer	yes
22959978Smckusick.It KERN\_MAXVNODES	integer	yes
23059868Sbostic.It KERN\_MAX\_CANON	integer	no
23159868Sbostic.It KERN\_MAX\_INPUT	integer	no
23259868Sbostic.It KERN\_NAME\_MAX	integer	no
23359868Sbostic.It KERN\_NGROUPS	integer	no
23459868Sbostic.It KERN\_NO\_TRUNC	integer	no
23559868Sbostic.It KERN\_OSRELEASE	string	no
23659868Sbostic.It KERN\_OSREV	integer	no
23759868Sbostic.It KERN\_OSTYPE	string	no
23859868Sbostic.It KERN\_PATH\_MAX	integer	no
23959868Sbostic.It KERN\_PIPE\_BUF	integer	no
24059868Sbostic.It KERN\_POSIX1	integer	no
24159978Smckusick.It KERN\_PROC	struct proc	no
24259978Smckusick.It KERN\_PROF	node	not applicable
24359868Sbostic.It KERN\_SAVED\_IDS	integer	no
24459868Sbostic.It KERN\_SECURELVL	integer	raise only
24559868Sbostic.It KERN\_VDISABLE	integer	no
24659868Sbostic.It KERN\_VERSION	string	no
24759978Smckusick.It KERN\_VNODE	struct vnode	no
24859868Sbostic.El
24967357Sah.ne 1i
25058507Smckusick.Pp
25159868Sbostic.Bl -tag -width "123456"
25259868Sbostic.It Li KERN_ARGMAX
25360274SbosticThe maximum bytes of argument to
25460274Sbostic.Xr exec 2 .
25560166Smckusick.It Li KERN_BOOTTIME
25660166SmckusickA
25760166Smckusick.Va struct timeval
25860166Smckusickstructure is returned.
25960166SmckusickThis structure contains the time that the system was booted.
26059868Sbostic.It Li KERN_CHOWN_RESTRICTED
26159868SbosticReturn 1 if appropriate privileges are required for the
26259868Sbostic.Xr chown 2
26359868Sbosticsystem call, otherwise 0.
26459868Sbostic.It Li KERN_CLOCKRATE
26559868SbosticA
26659978Smckusick.Va struct clockinfo
26759868Sbosticstructure is returned.
26859868SbosticThis structure contains the clock, statistics clock and profiling clock
26959868Sbosticfrequencies, and the number of micro-seconds per hz tick.
27059868Sbostic.It Li KERN_FILE
27159868SbosticReturn the entire file table.
27259868SbosticThe returned data consists of a single
27359978Smckusick.Va struct filehead
27459868Sbosticfollowed by an array of
27559978Smckusick.Va struct file ,
27659868Sbosticwhose size depends on the current number of such objects in the system.
27759868Sbostic.It Li KERN_HOSTID
27859978SmckusickGet or set the host id.
27959868Sbostic.It Li KERN_HOSTNAME
28059978SmckusickGet or set the hostname.
28159868Sbostic.It Li KERN_JOB_CONTROL
28259868SbosticReturn 1 if job control is available on this system, otherwise 0.
28359868Sbostic.It Li KERN_LINK_MAX
28459978SmckusickThe maximum file link count.
28559868Sbostic.It Li KERN_MAXFILES
28659978SmckusickThe maximum number of open files that may be open in the system.
28759868Sbostic.It Li KERN_MAXPROC
28859978SmckusickThe maximum number of simultaneous processes the system will allow.
28959868Sbostic.It Li KERN_MAXVNODES
29059978SmckusickThe maximum number of vnodes available on the system.
29159868Sbostic.It Li KERN_MAX_CANON
29259978SmckusickThe maximum number of bytes in terminal canonical input line.
29359868Sbostic.It Li KERN_MAX_INPUT
29460278SbosticThe minimum maximum number of bytes for which space is available in
29559868Sbostica terminal input queue.
29659868Sbostic.It Li KERN_NAME_MAX
29759978SmckusickThe maximum number of bytes in a file name.
29859868Sbostic.It Li KERN_NGROUPS
29959978SmckusickThe maximum number of supplemental groups.
30059868Sbostic.It Li KERN_NO_TRUNC
30159978SmckusickReturn 1 if file names longer than KERN_NAME_MAX are truncated.
30259868Sbostic.It Li KERN_OSRELEASE
30359978SmckusickThe system release string.
30459868Sbostic.It Li KERN_OSREV
30559978SmckusickThe system revision string.
30659868Sbostic.It Li KERN_OSTYPE
30759978SmckusickThe system type string.
30859868Sbostic.It Li KERN_PATH_MAX
30959978SmckusickThe maximum number of bytes in a pathname.
31059868Sbostic.It Li KERN_PIPE_BUF
31159978SmckusickThe maximum number of bytes which will be written atomically to a pipe.
31259868Sbostic.It Li KERN_POSIX1
31360274SbosticThe version of ISO/IEC 9945 (POSIX 1003.1) with which the system
31460274Sbosticattempts to comply.
31559868Sbostic.It Li KERN_PROC
31659868SbosticReturn the entire process table, or a subset of it.
31758507SmckusickAn array of
31859978Smckusick.Va struct kinfo_proc
31958507Smckusickstructures is returned,
32058507Smckusickwhose size depends on the current number of such objects in the system.
32159868SbosticThe third and fourth level names are as follows:
32259978Smckusick.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
32359868Sbostic.It Pa Third level name	Fourth level is:
32459868Sbostic.It KERN\_PROC\_ALL	None
32559868Sbostic.It KERN\_PROC\_PID	A process ID
32659868Sbostic.It KERN\_PROC\_PGRP	A process group
32759868Sbostic.It KERN\_PROC\_TTY	A tty device
32859868Sbostic.It KERN\_PROC\_UID	A user ID
32959868Sbostic.It KERN\_PROC\_RUID	A real user ID
33058507Smckusick.El
33159868Sbostic.It Li KERN_PROF
33259978SmckusickReturn profiling information about the kernel.
33359978SmckusickIf the kernel is not compiled for profiling,
33459978Smckusickattempts to retrieve any of the KERN_PROF values will
33559978Smckusickfail with EOPNOTSUPP.
33659978SmckusickThe third level names for the string and integer profiling information
33759978Smckusickis detailed below.
33859978SmckusickThe changeable column shows whether a process with appropriate
33959978Smckusickprivilege may change the value.
34059978Smckusick.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
34159978Smckusick.It Sy Pa Third level name	Type	Changeable
34259978Smckusick.It GPROF\_STATE	integer	yes
34359978Smckusick.It GPROF\_COUNT	u_short[\|]	yes
34459978Smckusick.It GPROF\_FROMS	u_short[\|]	yes
34559978Smckusick.It GPROF\_TOS	struct tostruct	yes
34659978Smckusick.It GPROF\_GMONPARAM	struct gmonparam	no
34759978Smckusick.El
34859978Smckusick.Pp
34959978SmckusickThe variables are as follows:
35059978Smckusick.Bl -tag -width "123456"
35159978Smckusick.It Li GPROF_STATE
35259978SmckusickReturns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
35359978Smckusickis running or stopped.
35459978Smckusick.It Li GPROF_COUNT
35559978SmckusickArray of statistical program counter counts.
35659978Smckusick.It Li GPROF_FROMS
35759978SmckusickArray indexed by program counter of call-from points.
35859978Smckusick.It Li GPROF_TOS
35959978SmckusickArray of
36059978Smckusick.Va struct tostruct
36159978Smckusickdescribing destination of calls and their counts.
36259978Smckusick.It Li GPROF_GMONPARAM
36359978SmckusickStructure giving the sizes of the above arrays.
36459978Smckusick.El
36567357Sah.ne 1i
36659868Sbostic.It Li KERN_SAVED_IDS
36759868SbosticReturns 1 if saved set-group and saved set-user ID is available.
36859868Sbostic.It Li KERN_SECURELVL
36959978SmckusickThe system security level.
37059868SbosticThis level may be raised by processes with appropriate privilege.
37159978SmckusickIt may only be lowered by process 1.
37259868Sbostic.It Li KERN_VDISABLE
37359868SbosticReturns the terminal character disabling value.
37459868Sbostic.It Li KERN_VERSION
37559978SmckusickThe system version string.
37659868Sbostic.It Li KERN_VNODE
37759868SbosticReturn the entire vnode table.
37859978SmckusickNote, the vnode table is not necessarily a consistent snapshot of
37959978Smckusickthe system.
38059868SbosticThe returned data consists of an array whose size depends on the
38159868Sbosticcurrent number of such objects in the system.
38258507SmckusickEach element of the array contains the kernel address of a vnode
38359978Smckusick.Va struct vnode *
38458507Smckusickfollowed by the vnode itself
38559978Smckusick.Va struct vnode .
38659868Sbostic.El
38759868Sbostic.Sh CTL_MACHDEP
38860429SmckusickThe set of variables defined is architecture dependent.
38960429SmckusickMost architectures define at least the following variables.
39060429Smckusick.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
39160429Smckusick.It Sy Pa Second level name	Type	Changeable
39260429Smckusick.It Li CPU_CONSDEV	dev_t	no
39360429Smckusick.El
39459868Sbostic.Sh CTL_NET
39559868SbosticThe string and integer information available for the CTL_NET level
39659868Sbosticis detailed below.
39759868SbosticThe changeable column shows whether a process with appropriate
39859868Sbosticprivilege may change the value.
39959978Smckusick.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
40059868Sbostic.It Sy Pa Second level name	Type	Changeable
40159978Smckusick.It PF\_ROUTE	routing messages	no
40259978Smckusick.It PF\_INET	internet values	yes
40359868Sbostic.El
40458507Smckusick.Pp
40559868Sbostic.Bl -tag -width "123456"
40659868Sbostic.It Li PF_ROUTE
40759868SbosticReturn the entire routing table or a subset of it.
40859868SbosticThe data is returned as a sequence of routing messages (see
40959868Sbostic.Xr route 4
41059868Sbosticfor the header file, format and meaning).
41159868SbosticThe length of each message is contained in the message header.
41258507Smckusick.Pp
41359868SbosticThe third level name is a protocol number, which is currently always 0.
41459868SbosticThe fourth level name is an address family, which may be set to 0 to
41559868Sbosticselect all address families.
41659868SbosticThe fifth and sixth level names are as follows:
41759978Smckusick.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
41859868Sbostic.It Pa Fifth level name	Sixth level is:
41959868Sbostic.It NET\_RT\_FLAGS	rtflags
42059868Sbostic.It NET\_RT\_DUMP	None
42159868Sbostic.It NET\_RT\_IFLIST	None
42259868Sbostic.El
42359978Smckusick.It Li PF_INET
42459978SmckusickGet or set various global information about the internet protocols.
42559978SmckusickThe third level name is the protocol.
42659978SmckusickThe fourth level name is the variable name.
42759978SmckusickThe currently defined protocols and names are:
42867357Sah.ne 1i
42959978Smckusick.Bl -column "Protocol nameXXXXXX" "Variable nameXXX" "integerXXX" -offset indent
43059978Smckusick.It Pa Protocol name	Variable name	Type	Changeable
43159978Smckusick.It ip	forwarding	integer	yes
43259978Smckusick.It ip	redirect	integer	yes
43359978Smckusick.It ip	ttl	integer	yes
43459978Smckusick.It icmp	maskrepl	integer	yes
43559978Smckusick.It udp	checksum	integer	yes
43659978Smckusick.El
43759978Smckusick.Pp
43859978SmckusickThe variables are as follows:
43959978Smckusick.Bl -tag -width "123456"
44059978Smckusick.It Li ip.forwarding
44160011SmckusickReturns 1 when IP forwarding is enabled for the host,
44260011Smckusickmeaning that the host is acting as a router.
44359978Smckusick.It Li ip.redirect
44460011SmckusickReturns 1 when ICMP redirects may be sent by the host.
44560011SmckusickThis option is ignored unless the host is routing IP packets,
44660011Smckusickand should normally be enabled on all systems.
44759978Smckusick.It Li ip.ttl
44860011SmckusickThe maximum time-to-live (hop count) value for an IP packet sourced by
44960011Smckusickthe system.
45060011SmckusickThis value applies to normal transport protocols, not to ICMP.
45159978Smckusick.It Li icmp.maskrepl
45260011SmckusickReturns 1 if ICMP network mask requests are to be answered.
45359978Smckusick.It Li udp.checksum
45460011SmckusickReturns 1 when UDP checksums are being computed and checked.
45560011SmckusickDisabling UDP checksums is strongly discouraged.
45659978Smckusick.El
45759868Sbostic.Sh CTL_USER
45859868SbosticThe string and integer information available for the CTL_USER level
45959868Sbosticis detailed below.
46059868SbosticThe changeable column shows whether a process with appropriate
46159868Sbosticprivilege may change the value.
46259978Smckusick.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
46359868Sbostic.It Sy Pa Second level name	Type	Changeable
46459868Sbostic.It USER\_BC\_BASE\_MAX	integer	no
46559868Sbostic.It USER\_BC\_DIM\_MAX	integer	no
46659868Sbostic.It USER\_BC\_SCALE\_MAX	integer	no
46759868Sbostic.It USER\_BC\_STRING\_MAX	integer	no
46859868Sbostic.It USER\_COLL\_WEIGHTS\_MAX	integer	no
46959868Sbostic.It USER\_CS\_PATH	string	no
47059868Sbostic.It USER\_EXPR\_NEST\_MAX	integer	no
47159868Sbostic.It USER\_LINE\_MAX	integer	no
47259868Sbostic.It USER\_POSIX2\_CHAR\_TERM	integer	no
47359868Sbostic.It USER\_POSIX2\_C\_BIND	integer	no
47459868Sbostic.It USER\_POSIX2\_C\_DEV	integer	no
47559868Sbostic.It USER\_POSIX2\_FORT\_DEV	integer	no
47659868Sbostic.It USER\_POSIX2\_FORT\_RUN	integer	no
47759868Sbostic.It USER\_POSIX2\_LOCALEDEF	integer	no
47859868Sbostic.It USER\_POSIX2\_SW\_DEV	integer	no
47959868Sbostic.It USER\_POSIX2\_UPE	integer	no
48059868Sbostic.It USER\_POSIX2\_VERSION	integer	no
48159868Sbostic.It USER\_RE\_DUP\_MAX	integer	no
48260274Sbostic.It USER\_STREAM\_MAX	integer	no
48360274Sbostic.It USER\_TZNAME\_MAX	integer	no
48459868Sbostic.El
48559868Sbostic.Bl -tag -width "123456"
48658507Smckusick.Pp
48759868Sbostic.It Li USER_BC_BASE_MAX
48859978SmckusickThe maximum ibase/obase values in the
48959868Sbostic.Xr bc 1
49060274Sbosticutility.
49159868Sbostic.It Li USER_BC_DIM_MAX
49259978SmckusickThe maximum array size in the
49359868Sbostic.Xr bc 1
49459868Sbosticutility.
49559868Sbostic.It Li USER_BC_SCALE_MAX
49659978SmckusickThe maximum scale value in the
49759868Sbostic.Xr bc 1
49859868Sbosticutility.
49959868Sbostic.It Li USER_BC_STRING_MAX
50059978SmckusickThe maximum string length in the
50159868Sbostic.Xr bc 1
50259868Sbosticutility.
50359868Sbostic.It Li USER_COLL_WEIGHTS_MAX
50459978SmckusickThe maximum number of weights that can be assigned to any entry of
50559868Sbosticthe LC_COLLATE order keyword in the locale definition file.
50659868Sbostic.It Li USER_CS_PATH
50759868SbosticReturn a value for the
50859868Sbostic.Ev PATH
50959978Smckusickenvironment variable that finds all the standard utilities.
51059868Sbostic.It Li USER_EXPR_NEST_MAX
51159978SmckusickThe maximum number of expressions that can be nested within
51259868Sbosticparenthesis by the
51359868Sbostic.Xr expr 1
51459868Sbosticutility.
51559868Sbostic.It Li USER_LINE_MAX
51659978SmckusickThe maximum length in bytes of a text-processing utility's input
51759868Sbosticline.
51859868Sbostic.It Li USER_POSIX2_CHAR_TERM
51959868SbosticReturn 1 if the system supports at least one terminal type capable of
52059868Sbosticall operations described in POSIX 1003.2, otherwise 0.
52159868Sbostic.It Li USER_POSIX2_C_BIND
52259868SbosticReturn 1 if the system's C-language development facilities support the
52359868SbosticC-Language Bindings Option, otherwise 0.
52459868Sbostic.It Li USER_POSIX2_C_DEV
52559868SbosticReturn 1 if the system supports the C-Language Development Utilities Option,
52659868Sbosticotherwise 0.
52759868Sbostic.It Li USER_POSIX2_FORT_DEV
52859868SbosticReturn 1 if the system supports the FORTRAN Development Utilities Option,
52959868Sbosticotherwise 0.
53059868Sbostic.It Li USER_POSIX2_FORT_RUN
53159868SbosticReturn 1 if the system supports the FORTRAN Runtime Utilities Option,
53259868Sbosticotherwise 0.
53359868Sbostic.It Li USER_POSIX2_LOCALEDEF
53459868SbosticReturn 1 if the system supports the creation of locales, otherwise 0.
53559868Sbostic.It Li USER_POSIX2_SW_DEV
53659868SbosticReturn 1 if the system supports the Software Development Utilities Option,
53759868Sbosticotherwise 0.
53859868Sbostic.It Li USER_POSIX2_UPE
53959868SbosticReturn 1 if the system supports the User Portability Utilities Option,
54059868Sbosticotherwise 0.
54159868Sbostic.It Li USER_POSIX2_VERSION
54260274SbosticThe version of POSIX 1003.2 with which the system attempts to comply.
54359868Sbostic.It Li USER_RE_DUP_MAX
54459978SmckusickThe maximum number of repeated occurrences of a regular expression
54559868Sbosticpermitted when using interval notation.
54667357Sah.ne 1i
54760274Sbostic.It Li USER_STREAM_MAX
54860274SbosticThe minimum maximum number of streams that a process may have open
54960274Sbosticat any one time.
55060274Sbostic.It Li USER_TZNAME_MAX
55160274SbosticThe minimum maximum number of types supported for the name of a
55260274Sbostictimezone.
55359868Sbostic.El
55459868Sbostic.Sh CTL_VM
55559868SbosticThe string and integer information available for the CTL_VM level
55659868Sbosticis detailed below.
55759868SbosticThe changeable column shows whether a process with appropriate
55859868Sbosticprivilege may change the value.
55959978Smckusick.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
56059868Sbostic.It Sy Pa Second level name	Type	Changeable
56159868Sbostic.It VM\_LOADAVG	struct loadavg	no
56259868Sbostic.It VM\_METER	struct vmtotal	no
56359868Sbostic.El
56458507Smckusick.Pp
56559868Sbostic.Bl -tag -width "123456"
56659868Sbostic.It Li VM_LOADAVG
56759868SbosticReturn the load average history.
56858507SmckusickThe returned data consists of a
56959978Smckusick.Va struct loadavg .
57059868Sbostic.It Li VM_METER
57159868SbosticReturn the system wide virtual memory statistics.
57259868SbosticThe returned data consists of a
57359978Smckusick.Va struct vmtotal .
57458507Smckusick.El
57559978Smckusick.Sh RETURN VALUES
57659978SmckusickIf the call to
57759978Smckusick.Nm sysctl
57869185Smckusickis successful, the number of bytes copied out is returned.
57959978SmckusickOtherwise \-1 is returned and
58059978Smckusick.Va errno
58159978Smckusickis set appropriately.
58258401Smckusick.Sh ERRORS
58359868SbosticThe following errors may be reported:
58458401Smckusick.Bl -tag -width Er
58558401Smckusick.It Bq Er EFAULT
58658401SmckusickThe buffer
58758401Smckusick.Fa name ,
58859868Sbostic.Fa oldp ,
58959868Sbostic.Fa newp ,
59058401Smckusickor length pointer
59158401Smckusick.Fa oldlenp
59258401Smckusickcontains an invalid address.
59358401Smckusick.It Bq Er EINVAL
59458401SmckusickThe
59558401Smckusick.Fa name
59658401Smckusickarray is less than two or greater than CTL_MAXNAME.
59758401Smckusick.It Bq Er EINVAL
59858401SmckusickA non-null
59959868Sbostic.Fa newp
60058401Smckusickis given and its specified length in
60158401Smckusick.Fa newlen
60258401Smckusickis too large or too small.
60358401Smckusick.It Bq Er ENOMEM
60458401SmckusickThe length pointed to by
60558401Smckusick.Fa oldlenp
60658401Smckusickis too short to hold the requested value.
60758401Smckusick.It Bq Er ENOTDIR
60858401SmckusickThe
60958401Smckusick.Fa name
61058401Smckusickarray specifies an intermediate rather than terminal name.
61158401Smckusick.It Bq Er EOPNOTSUPP
61258401SmckusickThe
61358401Smckusick.Fa name
61458401Smckusickarray specifies a value that is unknown.
61558401Smckusick.It Bq Er EPERM
61658401SmckusickAn attempt is made to set a read-only value.
61758401Smckusick.It Bq Er EPERM
61858401SmckusickA process without appropriate privilege attempts to set a value.
61958401Smckusick.El
62058401Smckusick.Sh FILES
62159978Smckusick.Bl -tag -width <netinet/icmpXvar.h> -compact
62258401Smckusick.It Pa <sys/sysctl.h>
62359868Sbosticdefinitions for top level identifiers, second level kernel and hardware
62459978Smckusickidentifiers, and user level identifiers
62558401Smckusick.It Pa <sys/socket.h>
62658401Smckusickdefinitions for second level network identifiers
62759978Smckusick.It Pa <sys/gmon.h>
62859978Smckusickdefinitions for third level profiling identifiers
62958401Smckusick.It Pa <vm/vm_param.h>
63058401Smckusickdefinitions for second level virtual memory identifiers
63159978Smckusick.It Pa <netinet/in.h>
63259978Smckusickdefinitions for third level Internet identifiers and
63359978Smckusickfourth level IP identifiers
63459978Smckusick.It Pa <netinet/icmp_var.h>
63559978Smckusickdefinitions for fourth level ICMP identifiers
63659978Smckusick.It Pa <netinet/udp_var.h>
63759978Smckusickdefinitions for fourth level UDP identifiers
63858401Smckusick.El
63958401Smckusick.Sh SEE ALSO
64058401Smckusick.Xr sysctl 8
64158401Smckusick.Sh HISTORY
64258507SmckusickThe
64359868Sbostic.Nm sysctl
64458507Smckusickfunction first appeared in 4.4BSD.
645