xref: /csrg-svn/lib/libc/gen/sysctl.3 (revision 59978)
158401Smckusick.\" Copyright (c) 1993 The Regents of the University of California.
258401Smckusick.\" All rights reserved.
358401Smckusick.\"
458401Smckusick.\" %sccs.include.redist.roff%
558401Smckusick.\"
6*59978Smckusick.\"	@(#)sysctl.3	6.5 (Berkeley) 05/12/93
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
31*59978SmckusickUnless explicitly noted below,
32*59978Smckusick.Nm sysctl
33*59978Smckusickreturns a consistent snapshot of the data requested.
34*59978SmckusickConsistency is obtained by locking the destination
35*59978Smckusickbuffer into memory so that the data may be copied out without blocking.
36*59978SmckusickCalls to
37*59978Smckusick.Nm sysctl
38*59978Smckusickare serialized to avoid deadlock.
39*59978Smckusick.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
56*59978Smckusickand 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 .
67*59978SmckusickThe size of the available data will be returned in the location pointed to by
6858507Smckusick.Fa oldlenp .
69*59978SmckusickFor some operations, the amount of space may change often.
70*59978SmckusickFor 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
91*59978Smckusick.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
9459868Sbostic.It CTL\_FS	sys/sysctl.h	File system
9559868Sbostic.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
9659868Sbostic.It CTL\_KERN	sys/sysctl.h	High kernel: processes, 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
127*59978Smckusick.Sh CTL_DEBUG
128*59978SmckusickThe debugging variables vary from system to system.
129*59978SmckusickA debugging variable may be added or deleted without need to recompile
13059868Sbostic.Nm sysctl
131*59978Smckusickto know about it.
132*59978SmckusickEach time it runs,
133*59978Smckusick.Nm sysctl
134*59978Smckusickgets the list of debugging variables from the kernel and
135*59978Smckusickdisplays their current values.
136*59978SmckusickThe system defines twenty
137*59978Smckusick.Ns ( Va struct ctldebug )
138*59978Smckusickvariables named
139*59978Smckusick.Nm debug0
140*59978Smckusickthrough
141*59978Smckusick.Nm debug19 .
142*59978SmckusickThey are declared as separate variables so that they can be
143*59978Smckusickindividually initialized at the location of their associated variable.
144*59978SmckusickThe loader prevents multiple use of the same variable by issuing errors
145*59978Smckusickif a variable is initialized in more than one place.
146*59978SmckusickFor example, to export the variable
147*59978Smckusick.Nm dospecialcheck
148*59978Smckusickas a debugging variable, the following declaration would be used:
149*59978Smckusick.Bd -literal -offset indent -compact
150*59978Smckusickint dospecialcheck = 1;
151*59978Smckusickstruct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
152*59978Smckusick.Ed
15359868Sbostic.Sh CTL_FS
15459868SbosticThere are currently no second level names for the file system.
15559868Sbostic.Sh CTL_HW
156*59978SmckusickThe string and integer information available for the CTL_HW level
15759868Sbosticis detailed below.
15859868SbosticThe changeable column shows whether a process with appropriate
15959868Sbosticprivilege may change the value.
160*59978Smckusick.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
16159868Sbostic.It Sy Pa Second level name	Type	Changeable
16259868Sbostic.It HW\_MACHINE	string	no
16359868Sbostic.It HW\_MODEL	string	no
16459868Sbostic.It HW\_NCPU	integer	no
16559868Sbostic.It HW\_BYTEORDER	integer	no
16659868Sbostic.It HW\_PHYSMEM	integer	no
16759868Sbostic.It HW\_USERMEM	integer	no
16859868Sbostic.It HW\_PAGESIZE	integer	no
16959868Sbostic.\".It HW\_DISKNAMES	integer	no
17059868Sbostic.\".It HW\_DISKSTATS	integer	no
17159868Sbostic.El
17258507Smckusick.Pp
17359868Sbostic.Bl -tag -width "123456"
17459868Sbostic.It Li HW_MACHINE
175*59978SmckusickThe machine class.
17659868Sbostic.It Li HW_MODEL
177*59978SmckusickThe machine model
17859868Sbostic.It Li HW_NCPU
179*59978SmckusickThe number of cpus.
18059868Sbostic.It Li HW_BYTEORDER
181*59978SmckusickThe byteorder (4,321, or 1,234).
18259868Sbostic.It Li HW_PHYSMEM
183*59978SmckusickThe bytes of physical memory.
18459868Sbostic.It Li HW_USERMEM
185*59978SmckusickThe bytes of non-kernel memory.
18659868Sbostic.It Li HW_PAGESIZE
187*59978SmckusickThe software page size.
18859868Sbostic.\".It Fa HW_DISKNAMES
18959868Sbostic.\".It Fa HW_DISKSTATS
19059868Sbostic.El
19159868Sbostic.Sh CTL_KERN
19259868SbosticThe string and integer information available for the CTL_KERN level
19359868Sbosticis detailed below.
19459868SbosticThe changeable column shows whether a process with appropriate
19559868Sbosticprivilege may change the value.
19658507SmckusickThe types of data currently available are process information,
19758507Smckusicksystem vnodes, the open file entries, routing table entries,
19859868Sbosticvirtual memory statistics, load average history, and clock rate
19959868Sbosticinformation.
20059868Sbostic.Bl -column "KERNXCHOWNXRESTRICTEDXXX" "struct clockrateXXX" -offset indent
20159868Sbostic.It Sy Pa Second level name	Type	Changeable
20259868Sbostic.It KERN\_ARGMAX	integer	no
20359868Sbostic.It KERN\_CHOWN\_RESTRICTED	integer	no
204*59978Smckusick.It KERN\_CLOCKRATE	struct clockinfo	no
205*59978Smckusick.It KERN\_FILE	struct file	no
20659868Sbostic.It KERN\_HOSTID	integer	yes
20759868Sbostic.It KERN\_HOSTNAME	string	yes
20859868Sbostic.It KERN\_JOB\_CONTROL	integer	no
20959868Sbostic.It KERN\_LINK\_MAX	integer	no
21059868Sbostic.It KERN\_MAXFILES	integer	yes
21159868Sbostic.It KERN\_MAXPROC	integer	yes
212*59978Smckusick.It KERN\_MAXVNODES	integer	yes
21359868Sbostic.It KERN\_MAX\_CANON	integer	no
21459868Sbostic.It KERN\_MAX\_INPUT	integer	no
21559868Sbostic.It KERN\_NAME\_MAX	integer	no
21659868Sbostic.It KERN\_NGROUPS	integer	no
21759868Sbostic.It KERN\_NO\_TRUNC	integer	no
21859868Sbostic.It KERN\_OSRELEASE	string	no
21959868Sbostic.It KERN\_OSREV	integer	no
22059868Sbostic.It KERN\_OSTYPE	string	no
22159868Sbostic.It KERN\_PATH\_MAX	integer	no
22259868Sbostic.It KERN\_PIPE\_BUF	integer	no
22359868Sbostic.It KERN\_POSIX1	integer	no
224*59978Smckusick.It KERN\_PROC	struct proc	no
225*59978Smckusick.It KERN\_PROF	node	not applicable
22659868Sbostic.It KERN\_SAVED\_IDS	integer	no
22759868Sbostic.It KERN\_SECURELVL	integer	raise only
22859868Sbostic.It KERN\_VDISABLE	integer	no
22959868Sbostic.It KERN\_VERSION	string	no
230*59978Smckusick.It KERN\_VNODE	struct vnode	no
23159868Sbostic.El
23258507Smckusick.Pp
23359868Sbostic.Bl -tag -width "123456"
23459868Sbostic.It Li KERN_ARGMAX
23559868SbosticMaximum bytes of argument to exec.
23659868Sbostic.It Li KERN_CHOWN_RESTRICTED
23759868SbosticReturn 1 if appropriate privileges are required for the
23859868Sbostic.Xr chown 2
23959868Sbosticsystem call, otherwise 0.
24059868Sbostic.It Li KERN_CLOCKRATE
24159868SbosticA
242*59978Smckusick.Va struct clockinfo
24359868Sbosticstructure is returned.
24459868SbosticThis structure contains the clock, statistics clock and profiling clock
24559868Sbosticfrequencies, and the number of micro-seconds per hz tick.
24659868Sbostic.It Li KERN_FILE
24759868SbosticReturn the entire file table.
24859868SbosticThe returned data consists of a single
249*59978Smckusick.Va struct filehead
25059868Sbosticfollowed by an array of
251*59978Smckusick.Va struct file ,
25259868Sbosticwhose size depends on the current number of such objects in the system.
25359868Sbostic.It Li KERN_HOSTID
254*59978SmckusickGet or set the host id.
25559868Sbostic.It Li KERN_HOSTNAME
256*59978SmckusickGet or set the hostname.
25759868Sbostic.It Li KERN_JOB_CONTROL
25859868SbosticReturn 1 if job control is available on this system, otherwise 0.
25959868Sbostic.It Li KERN_LINK_MAX
260*59978SmckusickThe maximum file link count.
26159868Sbostic.It Li KERN_MAXFILES
262*59978SmckusickThe maximum number of open files that may be open in the system.
26359868Sbostic.It Li KERN_MAXPROC
264*59978SmckusickThe maximum number of simultaneous processes the system will allow.
26559868Sbostic.It Li KERN_MAXVNODES
266*59978SmckusickThe maximum number of vnodes available on the system.
26759868Sbostic.It Li KERN_MAX_CANON
268*59978SmckusickThe maximum number of bytes in terminal canonical input line.
26959868Sbostic.It Li KERN_MAX_INPUT
270*59978SmckusickThe minimum number of bytes for which space is available in
27159868Sbostica terminal input queue.
27259868Sbostic.It Li KERN_NAME_MAX
273*59978SmckusickThe maximum number of bytes in a file name.
27459868Sbostic.It Li KERN_NGROUPS
275*59978SmckusickThe maximum number of supplemental groups.
27659868Sbostic.It Li KERN_NO_TRUNC
277*59978SmckusickReturn 1 if file names longer than KERN_NAME_MAX are truncated.
27859868Sbostic.It Li KERN_OSRELEASE
279*59978SmckusickThe system release string.
28059868Sbostic.It Li KERN_OSREV
281*59978SmckusickThe system revision string.
28259868Sbostic.It Li KERN_OSTYPE
283*59978SmckusickThe system type string.
28459868Sbostic.It Li KERN_PATH_MAX
285*59978SmckusickThe maximum number of bytes in a pathname.
28659868Sbostic.It Li KERN_PIPE_BUF
287*59978SmckusickThe maximum number of bytes which will be written atomically to a pipe.
28859868Sbostic.It Li KERN_POSIX1
289*59978SmckusickThe POSIX 1003.1 version with which the system attempts to comply.
29059868Sbostic.It Li KERN_PROC
29159868SbosticReturn the entire process table, or a subset of it.
29258507SmckusickAn array of
293*59978Smckusick.Va struct kinfo_proc
29458507Smckusickstructures is returned,
29558507Smckusickwhose size depends on the current number of such objects in the system.
29659868SbosticThe third and fourth level names are as follows:
297*59978Smckusick.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
29859868Sbostic.It Pa Third level name	Fourth level is:
29959868Sbostic.It KERN\_PROC\_ALL	None
30059868Sbostic.It KERN\_PROC\_PID	A process ID
30159868Sbostic.It KERN\_PROC\_PGRP	A process group
30259868Sbostic.It KERN\_PROC\_TTY	A tty device
30359868Sbostic.It KERN\_PROC\_UID	A user ID
30459868Sbostic.It KERN\_PROC\_RUID	A real user ID
30558507Smckusick.El
30659868Sbostic.It Li KERN_PROF
307*59978SmckusickReturn profiling information about the kernel.
308*59978SmckusickIf the kernel is not compiled for profiling,
309*59978Smckusickattempts to retrieve any of the KERN_PROF values will
310*59978Smckusickfail with EOPNOTSUPP.
311*59978SmckusickThe third level names for the string and integer profiling information
312*59978Smckusickis detailed below.
313*59978SmckusickThe changeable column shows whether a process with appropriate
314*59978Smckusickprivilege may change the value.
315*59978Smckusick.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
316*59978Smckusick.It Sy Pa Third level name	Type	Changeable
317*59978Smckusick.It GPROF\_STATE	integer	yes
318*59978Smckusick.It GPROF\_COUNT	u_short[\|]	yes
319*59978Smckusick.It GPROF\_FROMS	u_short[\|]	yes
320*59978Smckusick.It GPROF\_TOS	struct tostruct	yes
321*59978Smckusick.It GPROF\_GMONPARAM	struct gmonparam	no
322*59978Smckusick.El
323*59978Smckusick.Pp
324*59978SmckusickThe variables are as follows:
325*59978Smckusick.Bl -tag -width "123456"
326*59978Smckusick.It Li GPROF_STATE
327*59978SmckusickReturns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
328*59978Smckusickis running or stopped.
329*59978Smckusick.It Li GPROF_COUNT
330*59978SmckusickArray of statistical program counter counts.
331*59978Smckusick.It Li GPROF_FROMS
332*59978SmckusickArray indexed by program counter of call-from points.
333*59978Smckusick.It Li GPROF_TOS
334*59978SmckusickArray of
335*59978Smckusick.Va struct tostruct
336*59978Smckusickdescribing destination of calls and their counts.
337*59978Smckusick.It Li GPROF_GMONPARAM
338*59978SmckusickStructure giving the sizes of the above arrays.
339*59978Smckusick.El
34059868Sbostic.It Li KERN_SAVED_IDS
34159868SbosticReturns 1 if saved set-group and saved set-user ID is available.
34259868Sbostic.It Li KERN_SECURELVL
343*59978SmckusickThe system security level.
34459868SbosticThis level may be raised by processes with appropriate privilege.
345*59978SmckusickIt may only be lowered by process 1.
34659868Sbostic.It Li KERN_VDISABLE
34759868SbosticReturns the terminal character disabling value.
34859868Sbostic.It Li KERN_VERSION
349*59978SmckusickThe system version string.
35059868Sbostic.It Li KERN_VNODE
35159868SbosticReturn the entire vnode table.
352*59978SmckusickNote, the vnode table is not necessarily a consistent snapshot of
353*59978Smckusickthe system.
35459868SbosticThe returned data consists of an array whose size depends on the
35559868Sbosticcurrent number of such objects in the system.
35658507SmckusickEach element of the array contains the kernel address of a vnode
357*59978Smckusick.Va struct vnode *
35858507Smckusickfollowed by the vnode itself
359*59978Smckusick.Va struct vnode .
36059868Sbostic.El
36159868Sbostic.Sh CTL_MACHDEP
36259868SbosticThere are currently no second level names for the machine dependent
36359868Sbosticinterface.
36459868Sbostic.Sh CTL_NET
36559868SbosticThe string and integer information available for the CTL_NET level
36659868Sbosticis detailed below.
36759868SbosticThe changeable column shows whether a process with appropriate
36859868Sbosticprivilege may change the value.
369*59978Smckusick.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
37059868Sbostic.It Sy Pa Second level name	Type	Changeable
371*59978Smckusick.It PF\_ROUTE	routing messages	no
372*59978Smckusick.It PF\_INET	internet values	yes
37359868Sbostic.El
37458507Smckusick.Pp
37559868Sbostic.Bl -tag -width "123456"
37659868Sbostic.It Li PF_ROUTE
37759868SbosticReturn the entire routing table or a subset of it.
37859868SbosticThe data is returned as a sequence of routing messages (see
37959868Sbostic.Xr route 4
38059868Sbosticfor the header file, format and meaning).
38159868SbosticThe length of each message is contained in the message header.
38258507Smckusick.Pp
38359868SbosticThe third level name is a protocol number, which is currently always 0.
38459868SbosticThe fourth level name is an address family, which may be set to 0 to
38559868Sbosticselect all address families.
38659868SbosticThe fifth and sixth level names are as follows:
387*59978Smckusick.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
38859868Sbostic.It Pa Fifth level name	Sixth level is:
38959868Sbostic.It NET\_RT\_FLAGS	rtflags
39059868Sbostic.It NET\_RT\_DUMP	None
39159868Sbostic.It NET\_RT\_IFLIST	None
39259868Sbostic.El
393*59978Smckusick.It Li PF_INET
394*59978SmckusickGet or set various global information about the internet protocols.
395*59978SmckusickThe third level name is the protocol.
396*59978SmckusickThe fourth level name is the variable name.
397*59978SmckusickThe currently defined protocols and names are:
398*59978Smckusick.Bl -column "Protocol nameXXXXXX" "Variable nameXXX" "integerXXX" -offset indent
399*59978Smckusick.It Pa Protocol name	Variable name	Type	Changeable
400*59978Smckusick.It ip	forwarding	integer	yes
401*59978Smckusick.It ip	redirect	integer	yes
402*59978Smckusick.It ip	ttl	integer	yes
403*59978Smckusick.It icmp	maskrepl	integer	yes
404*59978Smckusick.It udp	checksum	integer	yes
405*59978Smckusick.El
406*59978Smckusick.Pp
407*59978SmckusickThe variables are as follows:
408*59978Smckusick.Bl -tag -width "123456"
409*59978Smckusick.It Li ip.forwarding
410*59978SmckusickReturns 1 when ip forwarding is enabled for the host.
411*59978Smckusick.It Li ip.redirect
412*59978SmckusickReturns 1 when redirects may be sent by the host.
413*59978Smckusick.It Li ip.ttl
414*59978SmckusickThe maximum time-to-live for an ip packet.
415*59978Smckusick.It Li icmp.maskrepl
416*59978SmckusickReturns 1 when icmp mask requests are provided.
417*59978Smckusick.It Li udp.checksum
418*59978SmckusickReturns 1 when udp checksums are being done.
419*59978Smckusick.El
42059868Sbostic.Sh CTL_USER
42159868SbosticThe string and integer information available for the CTL_USER level
42259868Sbosticis detailed below.
42359868SbosticThe changeable column shows whether a process with appropriate
42459868Sbosticprivilege may change the value.
425*59978Smckusick.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
42659868Sbostic.It Sy Pa Second level name	Type	Changeable
42759868Sbostic.It USER\_BC\_BASE\_MAX	integer	no
42859868Sbostic.It USER\_BC\_DIM\_MAX	integer	no
42959868Sbostic.It USER\_BC\_SCALE\_MAX	integer	no
43059868Sbostic.It USER\_BC\_STRING\_MAX	integer	no
43159868Sbostic.It USER\_COLL\_WEIGHTS\_MAX	integer	no
43259868Sbostic.It USER\_CS\_PATH	string	no
43359868Sbostic.It USER\_EXPR\_NEST\_MAX	integer	no
43459868Sbostic.It USER\_LINE\_MAX	integer	no
43559868Sbostic.It USER\_POSIX2\_CHAR\_TERM	integer	no
43659868Sbostic.It USER\_POSIX2\_C\_BIND	integer	no
43759868Sbostic.It USER\_POSIX2\_C\_DEV	integer	no
43859868Sbostic.It USER\_POSIX2\_FORT\_DEV	integer	no
43959868Sbostic.It USER\_POSIX2\_FORT\_RUN	integer	no
44059868Sbostic.It USER\_POSIX2\_LOCALEDEF	integer	no
44159868Sbostic.It USER\_POSIX2\_SW\_DEV	integer	no
44259868Sbostic.It USER\_POSIX2\_UPE	integer	no
44359868Sbostic.It USER\_POSIX2\_VERSION	integer	no
44459868Sbostic.It USER\_RE\_DUP\_MAX	integer	no
44559868Sbostic.El
44659868Sbostic.Bl -tag -width "123456"
44758507Smckusick.Pp
44859868Sbostic.It Li USER_BC_BASE_MAX
449*59978SmckusickThe maximum ibase/obase values in the
45059868Sbostic.Xr bc 1
45159868Sbosticutility
45259868Sbostic.It Li USER_BC_DIM_MAX
453*59978SmckusickThe maximum array size in the
45459868Sbostic.Xr bc 1
45559868Sbosticutility.
45659868Sbostic.It Li USER_BC_SCALE_MAX
457*59978SmckusickThe maximum scale value in the
45859868Sbostic.Xr bc 1
45959868Sbosticutility.
46059868Sbostic.It Li USER_BC_STRING_MAX
461*59978SmckusickThe maximum string length in the
46259868Sbostic.Xr bc 1
46359868Sbosticutility.
46459868Sbostic.It Li USER_COLL_WEIGHTS_MAX
465*59978SmckusickThe maximum number of weights that can be assigned to any entry of
46659868Sbosticthe LC_COLLATE order keyword in the locale definition file.
46759868Sbostic.It Li USER_CS_PATH
46859868SbosticReturn a value for the
46959868Sbostic.Ev PATH
470*59978Smckusickenvironment variable that finds all the standard utilities.
47159868Sbostic.It Li USER_EXPR_NEST_MAX
472*59978SmckusickThe maximum number of expressions that can be nested within
47359868Sbosticparenthesis by the
47459868Sbostic.Xr expr 1
47559868Sbosticutility.
47659868Sbostic.It Li USER_LINE_MAX
477*59978SmckusickThe maximum length in bytes of a text-processing utility's input
47859868Sbosticline.
47959868Sbostic.It Li USER_POSIX2_CHAR_TERM
48059868SbosticReturn 1 if the system supports at least one terminal type capable of
48159868Sbosticall operations described in POSIX 1003.2, otherwise 0.
48259868Sbostic.It Li USER_POSIX2_C_BIND
48359868SbosticReturn 1 if the system's C-language development facilities support the
48459868SbosticC-Language Bindings Option, otherwise 0.
48559868Sbostic.It Li USER_POSIX2_C_DEV
48659868SbosticReturn 1 if the system supports the C-Language Development Utilities Option,
48759868Sbosticotherwise 0.
48859868Sbostic.It Li USER_POSIX2_FORT_DEV
48959868SbosticReturn 1 if the system supports the FORTRAN Development Utilities Option,
49059868Sbosticotherwise 0.
49159868Sbostic.It Li USER_POSIX2_FORT_RUN
49259868SbosticReturn 1 if the system supports the FORTRAN Runtime Utilities Option,
49359868Sbosticotherwise 0.
49459868Sbostic.It Li USER_POSIX2_LOCALEDEF
49559868SbosticReturn 1 if the system supports the creation of locales, otherwise 0.
49659868Sbostic.It Li USER_POSIX2_SW_DEV
49759868SbosticReturn 1 if the system supports the Software Development Utilities Option,
49859868Sbosticotherwise 0.
49959868Sbostic.It Li USER_POSIX2_UPE
50059868SbosticReturn 1 if the system supports the User Portability Utilities Option,
50159868Sbosticotherwise 0.
50259868Sbostic.It Li USER_POSIX2_VERSION
503*59978SmckusickThe POSIX 1003.2 version with which the system attempts to comply.
50459868Sbostic.It Li USER_RE_DUP_MAX
505*59978SmckusickThe maximum number of repeated occurrences of a regular expression
50659868Sbosticpermitted when using interval notation.
50759868Sbostic.El
50859868Sbostic.Sh CTL_VM
50959868SbosticThe string and integer information available for the CTL_VM level
51059868Sbosticis detailed below.
51159868SbosticThe changeable column shows whether a process with appropriate
51259868Sbosticprivilege may change the value.
513*59978Smckusick.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
51459868Sbostic.It Sy Pa Second level name	Type	Changeable
51559868Sbostic.It VM\_LOADAVG	struct loadavg	no
51659868Sbostic.It VM\_METER	struct vmtotal	no
51759868Sbostic.El
51858507Smckusick.Pp
51959868Sbostic.Bl -tag -width "123456"
52059868Sbostic.It Li VM_LOADAVG
52159868SbosticReturn the load average history.
52258507SmckusickThe returned data consists of a
523*59978Smckusick.Va struct loadavg .
52459868Sbostic.It Li VM_METER
52559868SbosticReturn the system wide virtual memory statistics.
52659868SbosticThe returned data consists of a
527*59978Smckusick.Va struct vmtotal .
52858507Smckusick.El
529*59978Smckusick.Sh RETURN VALUES
530*59978SmckusickIf the call to
531*59978Smckusick.Nm sysctl
532*59978Smckusickis successful, 0 is returned.
533*59978SmckusickOtherwise \-1 is returned and
534*59978Smckusick.Va errno
535*59978Smckusickis set appropriately.
53658401Smckusick.Sh ERRORS
53759868SbosticThe following errors may be reported:
53858401Smckusick.Bl -tag -width Er
53958401Smckusick.It Bq Er EFAULT
54058401SmckusickThe buffer
54158401Smckusick.Fa name ,
54259868Sbostic.Fa oldp ,
54359868Sbostic.Fa newp ,
54458401Smckusickor length pointer
54558401Smckusick.Fa oldlenp
54658401Smckusickcontains an invalid address.
54758401Smckusick.It Bq Er EINVAL
54858401SmckusickThe
54958401Smckusick.Fa name
55058401Smckusickarray is less than two or greater than CTL_MAXNAME.
55158401Smckusick.It Bq Er EINVAL
55258401SmckusickA non-null
55359868Sbostic.Fa newp
55458401Smckusickis given and its specified length in
55558401Smckusick.Fa newlen
55658401Smckusickis too large or too small.
55758401Smckusick.It Bq Er ENOMEM
55858401SmckusickThe length pointed to by
55958401Smckusick.Fa oldlenp
56058401Smckusickis too short to hold the requested value.
56158401Smckusick.It Bq Er ENOTDIR
56258401SmckusickThe
56358401Smckusick.Fa name
56458401Smckusickarray specifies an intermediate rather than terminal name.
56558401Smckusick.It Bq Er EOPNOTSUPP
56658401SmckusickThe
56758401Smckusick.Fa name
56858401Smckusickarray specifies a value that is unknown.
56958401Smckusick.It Bq Er EPERM
57058401SmckusickAn attempt is made to set a read-only value.
57158401Smckusick.It Bq Er EPERM
57258401SmckusickA process without appropriate privilege attempts to set a value.
57358401Smckusick.El
57458401Smckusick.Sh FILES
575*59978Smckusick.Bl -tag -width <netinet/icmpXvar.h> -compact
57658401Smckusick.It Pa <sys/sysctl.h>
57759868Sbosticdefinitions for top level identifiers, second level kernel and hardware
578*59978Smckusickidentifiers, and user level identifiers
57958401Smckusick.It Pa <sys/socket.h>
58058401Smckusickdefinitions for second level network identifiers
581*59978Smckusick.It Pa <sys/gmon.h>
582*59978Smckusickdefinitions for third level profiling identifiers
58358401Smckusick.It Pa <vm/vm_param.h>
58458401Smckusickdefinitions for second level virtual memory identifiers
585*59978Smckusick.It Pa <netinet/in.h>
586*59978Smckusickdefinitions for third level Internet identifiers and
587*59978Smckusickfourth level IP identifiers
588*59978Smckusick.It Pa <netinet/icmp_var.h>
589*59978Smckusickdefinitions for fourth level ICMP identifiers
590*59978Smckusick.It Pa <netinet/udp_var.h>
591*59978Smckusickdefinitions for fourth level UDP identifiers
59258401Smckusick.El
59358401Smckusick.Sh SEE ALSO
59458401Smckusick.Xr sysctl 8
59558401Smckusick.Sh HISTORY
59658507SmckusickThe
59759868Sbostic.Nm sysctl
59858507Smckusickfunction first appeared in 4.4BSD.
599