xref: /freebsd/lib/libc/gen/sysctl.3 (revision b601c69bdbe8755d26570261d7fd4c02ee4eff74)
1.\" Copyright (c) 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
33.\" $FreeBSD$
34.\"
35.Dd May 9, 1995
36.Dt SYSCTL 3
37.Os
38.Sh NAME
39.Nm sysctl ,
40.Nm sysctlbyname
41.Nd get or set system information
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.Fd #include <sys/types.h>
46.Fd #include <sys/sysctl.h>
47.Ft int
48.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
49.Ft int
50.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
51.Sh DESCRIPTION
52The
53.Fn sysctl
54function retrieves system information and allows processes with
55appropriate privileges to set system information.
56The information available from
57.Fn sysctl
58consists of integers, strings, and tables.
59Information may be retrieved and set from the command interface
60using the
61.Xr sysctl 8
62utility.
63.Pp
64Unless explicitly noted below,
65.Fn sysctl
66returns a consistent snapshot of the data requested.
67Consistency is obtained by locking the destination
68buffer into memory so that the data may be copied out without blocking.
69Calls to
70.Fn sysctl
71are serialized to avoid deadlock.
72.Pp
73The state is described using a ``Management Information Base'' (MIB)
74style name, listed in
75.Fa name ,
76which is a
77.Fa namelen
78length array of integers.
79.Pp
80The
81.Fn sysctlbyname
82function accepts an ASCII representation of the name and internally
83looks up the integer name vector.  Apart from that, it behaves the same
84as the standard
85.Fn sysctl
86function.
87.Pp
88The information is copied into the buffer specified by
89.Fa oldp .
90The size of the buffer is given by the location specified by
91.Fa oldlenp
92before the call,
93and that location gives the amount of data copied after a successful call
94and after a call that returns with the error code ENOMEM.
95If the amount of data available is greater
96than the size of the buffer supplied,
97the call supplies as much data as fits in the buffer provided
98and returns with the error code ENOMEM.
99If the old value is not desired,
100.Fa oldp
101and
102.Fa oldlenp
103should be set to NULL.
104.Pp
105The size of the available data can be determined by calling
106.Fn sysctl
107with a NULL parameter for
108.Fa oldp .
109The size of the available data will be returned in the location pointed to by
110.Fa oldlenp .
111For some operations, the amount of space may change often.
112For these operations,
113the system attempts to round up so that the returned size is
114large enough for a call to return the data shortly thereafter.
115.Pp
116To set a new value,
117.Fa newp
118is set to point to a buffer of length
119.Fa newlen
120from which the requested value is to be taken.
121If a new value is not to be set,
122.Fa newp
123should be set to NULL and
124.Fa newlen
125set to 0.
126.Pp
127The top level names are defined with a CTL_ prefix in
128.Aq Pa sys/sysctl.h ,
129and are as follows.
130The next and subsequent levels down are found in the include files
131listed here, and described in separate sections below.
132.Pp
133.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
134.It Sy Pa Name	Next level names	Description
135.It CTL\_DEBUG	sys/sysctl.h	Debugging
136.It CTL\_VFS	sys/mount.h	Filesystem
137.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
138.It CTL\_KERN	sys/sysctl.h	High kernel limits
139.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
140.It CTL\_NET	sys/socket.h	Networking
141.It CTL\_USER	sys/sysctl.h	User-level
142.It CTL\_VM	vm/vm_param.h	Virtual memory
143.El
144.Pp
145For example, the following retrieves the maximum number of processes allowed
146in the system:
147.Pp
148.Bd -literal -offset indent -compact
149int mib[2], maxproc;
150size_t len;
151
152mib[0] = CTL_KERN;
153mib[1] = KERN_MAXPROC;
154len = sizeof(maxproc);
155sysctl(mib, 2, &maxproc, &len, NULL, 0);
156.Ed
157.Pp
158To retrieve the standard search path for the system utilities:
159.Pp
160.Bd -literal -offset indent -compact
161int mib[2];
162size_t len;
163char *p;
164
165mib[0] = CTL_USER;
166mib[1] = USER_CS_PATH;
167sysctl(mib, 2, NULL, &len, NULL, 0);
168p = malloc(len);
169sysctl(mib, 2, p, &len, NULL, 0);
170.Ed
171.Ss CTL_DEBUG
172The debugging variables vary from system to system.
173A debugging variable may be added or deleted without need to recompile
174.Fn sysctl
175to know about it.
176Each time it runs,
177.Fn sysctl
178gets the list of debugging variables from the kernel and
179displays their current values.
180The system defines twenty
181.Ns ( Va struct ctldebug )
182variables named
183.Nm debug0
184through
185.Nm debug19 .
186They are declared as separate variables so that they can be
187individually initialized at the location of their associated variable.
188The loader prevents multiple use of the same variable by issuing errors
189if a variable is initialized in more than one place.
190For example, to export the variable
191.Nm dospecialcheck
192as a debugging variable, the following declaration would be used:
193.Bd -literal -offset indent -compact
194int dospecialcheck = 1;
195struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
196.Ed
197.Ss CTL_VFS
198A distinguished second level name, VFS_GENERIC,
199is used to get general information about all filesystems.
200One of its third level identifiers is VFS_MAXTYPENUM
201that gives the highest valid filesystem type number.
202Its other third level identifier is VFS_CONF that
203returns configuration information about the filesystem
204type given as a fourth level identifier (see
205.Xr getvfsbyname 3
206as an example of its use).
207The remaining second level identifiers are the
208filesystem type number returned by a
209.Xr statfs 2
210call or from VFS_CONF.
211The third level identifiers available for each filesystem
212are given in the header file that defines the mount
213argument structure for that filesystem.
214.Ss CTL_HW
215The string and integer information available for the CTL_HW level
216is detailed below.
217The changeable column shows whether a process with appropriate
218privilege may change the value.
219.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
220.It Sy Pa Second level name	Type	Changeable
221.It HW\_MACHINE	string	no
222.It HW\_MODEL	string	no
223.It HW\_NCPU	integer	no
224.It HW\_BYTEORDER	integer	no
225.It HW\_PHYSMEM	integer	no
226.It HW\_USERMEM	integer	no
227.It HW\_PAGESIZE	integer	no
228.It HW\_FLOATINGPOINT	integer	no
229.It HW\_MACHINE\_ARCH	string	no
230.\".It HW\_DISKNAMES	integer	no
231.\".It HW\_DISKSTATS	integer	no
232.El
233.Pp
234.Bl -tag -width "123456"
235.It Li HW_MACHINE
236The machine class.
237.It Li HW_MODEL
238The machine model
239.It Li HW_NCPU
240The number of cpus.
241.ne 1i
242.It Li HW_BYTEORDER
243The byteorder (4,321, or 1,234).
244.It Li HW_PHYSMEM
245The bytes of physical memory.
246.It Li HW_USERMEM
247The bytes of non-kernel memory.
248.It Li HW_PAGESIZE
249The software page size.
250.It Li HW_FLOATINGPOINT
251Nonzero if the floating point support is in hardware.
252.It Li HW_MACHINE_ARCH
253The machine dependent architecture type.
254.\".It Fa HW_DISKNAMES
255.\".It Fa HW_DISKSTATS
256.El
257.Ss CTL_KERN
258The string and integer information available for the CTL_KERN level
259is detailed below.
260The changeable column shows whether a process with appropriate
261privilege may change the value.
262The types of data currently available are process information,
263system vnodes, the open file entries, routing table entries,
264virtual memory statistics, load average history, and clock rate
265information.
266.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
267.It Sy Pa Second level name	Type	Changeable
268.It KERN\_ARGMAX	integer	no
269.It KERN\_BOOTFILE	string	yes
270.It KERN\_BOOTTIME	struct timeval	no
271.It KERN\_CLOCKRATE	struct clockinfo	no
272.It KERN\_FILE	struct file	no
273.It KERN\_HOSTID	integer	yes
274.It KERN\_HOSTNAME	string	yes
275.It KERN\_JOB\_CONTROL	integer	no
276.It KERN\_MAXFILES	integer	yes
277.It KERN\_MAXFILESPERPROC	integer	yes
278.It KERN\_MAXPROC	integer	no
279.It KERN\_MAXPROCPERUID	integer	yes
280.It KERN\_MAXVNODES	integer	yes
281.It KERN\_NGROUPS	integer	no
282.It KERN\_NISDOMAINNAME	string	yes
283.It KERN\_OSRELDATE	integer	no
284.It KERN\_OSRELEASE	string	no
285.It KERN\_OSREV	integer	no
286.It KERN\_OSTYPE	string	no
287.It KERN\_POSIX1	integer	no
288.It KERN\_PROC	struct proc	no
289.It KERN\_PROF	node	not applicable
290.It KERN\_QUANTUM	integer	yes
291.It KERN\_SAVED\_IDS	integer	no
292.It KERN\_SECURELVL	integer	raise only
293.It KERN\_UPDATEINTERVAL	integer	no
294.It KERN\_VERSION	string	no
295.It KERN\_VNODE	struct vnode	no
296.El
297.ne 1i
298.Pp
299.Bl -tag -width "123456"
300.It Li KERN_ARGMAX
301The maximum bytes of argument to
302.Xr execve 2 .
303.It Li KERN_BOOTFILE
304The full pathname of the file from which the kernel was loaded.
305.It Li KERN_BOOTTIME
306A
307.Va struct timeval
308structure is returned.
309This structure contains the time that the system was booted.
310.It Li KERN_CLOCKRATE
311A
312.Va struct clockinfo
313structure is returned.
314This structure contains the clock, statistics clock and profiling clock
315frequencies, the number of micro-seconds per hz tick and the skew rate.
316.It Li KERN_FILE
317Return the entire file table.
318The returned data consists of a single
319.Va struct filehead
320followed by an array of
321.Va struct file ,
322whose size depends on the current number of such objects in the system.
323.It Li KERN_HOSTID
324Get or set the host id.
325.It Li KERN_HOSTNAME
326Get or set the hostname.
327.It Li KERN_JOB_CONTROL
328Return 1 if job control is available on this system, otherwise 0.
329.It Li KERN_MAXFILES
330The maximum number of files that may be open in the system.
331.It Li KERN_MAXFILESPERPROC
332The maximum number of files that may be open for a single process.
333This limit only applies to processes with an effective uid of nonzero
334at the time of the open request.
335Files that have already been opened are not affected if the limit
336or the effective uid is changed.
337.It Li KERN_MAXPROC
338The maximum number of concurrent processes the system will allow.
339.It Li KERN_MAXPROCPERUID
340The maximum number of concurrent processes the system will allow
341for a single effective uid.
342This limit only applies to processes with an effective uid of nonzero
343at the time of a fork request.
344Processes that have already been started are not affected if the limit
345is changed.
346.It Li KERN_MAXVNODES
347The maximum number of vnodes available on the system.
348.It Li KERN_NGROUPS
349The maximum number of supplemental groups.
350.It Li KERN_NISDOMAINNAME
351The name of the current YP/NIS domain.
352.It Li KERN_OSRELDATE
353The system release date in YYYYMM format
354(January 1996 is encoded as 199601).
355.It Li KERN_OSRELEASE
356The system release string.
357.It Li KERN_OSREV
358The system revision string.
359.It Li KERN_OSTYPE
360The system type string.
361.It Li KERN_POSIX1
362The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
363attempts to comply.
364.It Li KERN_PROC
365Return the entire process table, or a subset of it.
366An array of
367.Va struct kinfo_proc
368structures is returned,
369whose size depends on the current number of such objects in the system.
370The third and fourth level names are as follows:
371.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
372.It Pa Third level name	Fourth level is:
373.It KERN\_PROC\_ALL	None
374.It KERN\_PROC\_PID	A process ID
375.It KERN\_PROC\_PGRP	A process group
376.It KERN\_PROC\_TTY	A tty device
377.It KERN\_PROC\_UID	A user ID
378.It KERN\_PROC\_RUID	A real user ID
379.El
380.It Li KERN_PROF
381Return profiling information about the kernel.
382If the kernel is not compiled for profiling,
383attempts to retrieve any of the KERN_PROF values will
384fail with EOPNOTSUPP.
385The third level names for the string and integer profiling information
386is detailed below.
387The changeable column shows whether a process with appropriate
388privilege may change the value.
389.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
390.It Sy Pa Third level name	Type	Changeable
391.It GPROF\_STATE	integer	yes
392.It GPROF\_COUNT	u_short[\|]	yes
393.It GPROF\_FROMS	u_short[\|]	yes
394.It GPROF\_TOS	struct tostruct	yes
395.It GPROF\_GMONPARAM	struct gmonparam	no
396.El
397.Pp
398The variables are as follows:
399.Bl -tag -width "123456"
400.It Li GPROF_STATE
401Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
402is running or stopped.
403.It Li GPROF_COUNT
404Array of statistical program counter counts.
405.It Li GPROF_FROMS
406Array indexed by program counter of call-from points.
407.It Li GPROF_TOS
408Array of
409.Va struct tostruct
410describing destination of calls and their counts.
411.It Li GPROF_GMONPARAM
412Structure giving the sizes of the above arrays.
413.El
414.ne 1i
415.It Li KERN_QUANTUM
416The maximum period of time, in microseconds, for which a process is allowed
417to run without being preempted if other processes are in the run queue.
418.It Li KERN_SAVED_IDS
419Returns 1 if saved set-group and saved set-user ID is available.
420.It Li KERN_SECURELVL
421The system security level.
422This level may be raised by processes with appropriate privilege.
423It may not be lowered.
424.It Li KERN_VERSION
425The system version string.
426.It Li KERN_VNODE
427Return the entire vnode table.
428Note, the vnode table is not necessarily a consistent snapshot of
429the system.
430The returned data consists of an array whose size depends on the
431current number of such objects in the system.
432Each element of the array contains the kernel address of a vnode
433.Va struct vnode *
434followed by the vnode itself
435.Va struct vnode .
436.It Li KERN_UPDATEINTERVAL
437The interval between
438.Xr sync 2
439calls in the
440.Xr syncer 4
441process.
442.El
443.Ss CTL_MACHDEP
444The set of variables defined is architecture dependent.
445The following variables are defined for the i386 architecture.
446.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent
447.It Sy Pa Second level name	Type	Changeable
448.It Li CPU_CONSDEV	dev_t	no
449.It Li CPU_ADJKERNTZ	int	yes
450.It Li CPU_DISRTCSET	int	yes
451.It Li CPU_BOOTINFO	struct bootinfo	no
452.It Li CPU_WALLCLOCK	int	yes
453.El
454.Ss CTL_NET
455The string and integer information available for the CTL_NET level
456is detailed below.
457The changeable column shows whether a process with appropriate
458privilege may change the value.
459.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
460.It Sy Pa Second level name	Type	Changeable
461.It PF\_ROUTE	routing messages	no
462.It PF\_INET	IPv4 values	yes
463.It PF\_INET6	IPv6 values	yes
464.El
465.Pp
466.Bl -tag -width "123456"
467.It Li PF_ROUTE
468Return the entire routing table or a subset of it.
469The data is returned as a sequence of routing messages (see
470.Xr route 4
471for the header file, format and meaning).
472The length of each message is contained in the message header.
473.Pp
474The third level name is a protocol number, which is currently always 0.
475The fourth level name is an address family, which may be set to 0 to
476select all address families.
477The fifth and sixth level names are as follows:
478.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
479.It Pa Fifth level name	Sixth level is:
480.It NET\_RT\_FLAGS	rtflags
481.It NET\_RT\_DUMP	None
482.It NET\_RT\_IFLIST	None
483.El
484.It Li PF_INET
485Get or set various global information about the IPv4
486.Pq Internet Protocol version 4 .
487The third level name is the protocol.
488The fourth level name is the variable name.
489The currently defined protocols and names are:
490.ne 1i
491.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
492.It Pa Protocol	Variable	Type	Changeable
493.It icmp	bmcastecho	integer	yes
494.It icmp	maskrepl	integer	yes
495.It ip	forwarding	integer	yes
496.It ip	redirect	integer	yes
497.It ip	ttl	integer	yes
498.It udp	checksum	integer	yes
499.El
500.Pp
501The variables are as follows:
502.Bl -tag -width "123456"
503.It Li icmp.bmcastecho
504Returns 1 if an ICMP echo request to a broadcast or multicast address is
505to be answered.
506.It Li icmp.maskrepl
507Returns 1 if ICMP network mask requests are to be answered.
508.It Li ip.forwarding
509Returns 1 when IP forwarding is enabled for the host,
510meaning that the host is acting as a router.
511.It Li ip.redirect
512Returns 1 when ICMP redirects may be sent by the host.
513This option is ignored unless the host is routing IP packets,
514and should normally be enabled on all systems.
515.It Li ip.ttl
516The maximum time-to-live (hop count) value for an IP packet sourced by
517the system.
518This value applies to normal transport protocols, not to ICMP.
519.It Li udp.checksum
520Returns 1 when UDP checksums are being computed and checked.
521Disabling UDP checksums is strongly discouraged.
522.Pp
523For variables net.inet.*.ipsec, please refer to
524.Xr ipsec 4 .
525.El
526.It Li PF_INET6
527Get or set various global information about the IPv6
528.Pq Internet Protocol version 6 .
529The third level name is the protocol.
530The fourth level name is the variable name.
531.Pp
532For variables net.inet6.* please refer to
533.Xr inet6 4 .
534For variables net.inet6.*.ipsec6, please refer to
535.Xr ipsec 4 .
536.El
537.Ss CTL_USER
538The string and integer information available for the CTL_USER level
539is detailed below.
540The changeable column shows whether a process with appropriate
541privilege may change the value.
542.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
543.It Sy Pa Second level name	Type	Changeable
544.It USER\_BC\_BASE\_MAX	integer	no
545.It USER\_BC\_DIM\_MAX	integer	no
546.It USER\_BC\_SCALE\_MAX	integer	no
547.It USER\_BC\_STRING\_MAX	integer	no
548.It USER\_COLL\_WEIGHTS\_MAX	integer	no
549.It USER\_CS\_PATH	string	no
550.It USER\_EXPR\_NEST\_MAX	integer	no
551.It USER\_LINE\_MAX	integer	no
552.It USER\_POSIX2\_CHAR\_TERM	integer	no
553.It USER\_POSIX2\_C\_BIND	integer	no
554.It USER\_POSIX2\_C\_DEV	integer	no
555.It USER\_POSIX2\_FORT\_DEV	integer	no
556.It USER\_POSIX2\_FORT\_RUN	integer	no
557.It USER\_POSIX2\_LOCALEDEF	integer	no
558.It USER\_POSIX2\_SW\_DEV	integer	no
559.It USER\_POSIX2\_UPE	integer	no
560.It USER\_POSIX2\_VERSION	integer	no
561.It USER\_RE\_DUP\_MAX	integer	no
562.It USER\_STREAM\_MAX	integer	no
563.It USER\_TZNAME\_MAX	integer	no
564.El
565.Bl -tag -width "123456"
566.Pp
567.It Li USER_BC_BASE_MAX
568The maximum ibase/obase values in the
569.Xr bc 1
570utility.
571.It Li USER_BC_DIM_MAX
572The maximum array size in the
573.Xr bc 1
574utility.
575.It Li USER_BC_SCALE_MAX
576The maximum scale value in the
577.Xr bc 1
578utility.
579.It Li USER_BC_STRING_MAX
580The maximum string length in the
581.Xr bc 1
582utility.
583.It Li USER_COLL_WEIGHTS_MAX
584The maximum number of weights that can be assigned to any entry of
585the LC_COLLATE order keyword in the locale definition file.
586.It Li USER_CS_PATH
587Return a value for the
588.Ev PATH
589environment variable that finds all the standard utilities.
590.It Li USER_EXPR_NEST_MAX
591The maximum number of expressions that can be nested within
592parenthesis by the
593.Xr expr 1
594utility.
595.It Li USER_LINE_MAX
596The maximum length in bytes of a text-processing utility's input
597line.
598.It Li USER_POSIX2_CHAR_TERM
599Return 1 if the system supports at least one terminal type capable of
600all operations described in POSIX 1003.2, otherwise 0.
601.It Li USER_POSIX2_C_BIND
602Return 1 if the system's C-language development facilities support the
603C-Language Bindings Option, otherwise 0.
604.It Li USER_POSIX2_C_DEV
605Return 1 if the system supports the C-Language Development Utilities Option,
606otherwise 0.
607.It Li USER_POSIX2_FORT_DEV
608Return 1 if the system supports the FORTRAN Development Utilities Option,
609otherwise 0.
610.It Li USER_POSIX2_FORT_RUN
611Return 1 if the system supports the FORTRAN Runtime Utilities Option,
612otherwise 0.
613.It Li USER_POSIX2_LOCALEDEF
614Return 1 if the system supports the creation of locales, otherwise 0.
615.It Li USER_POSIX2_SW_DEV
616Return 1 if the system supports the Software Development Utilities Option,
617otherwise 0.
618.It Li USER_POSIX2_UPE
619Return 1 if the system supports the User Portability Utilities Option,
620otherwise 0.
621.It Li USER_POSIX2_VERSION
622The version of POSIX 1003.2 with which the system attempts to comply.
623.It Li USER_RE_DUP_MAX
624The maximum number of repeated occurrences of a regular expression
625permitted when using interval notation.
626.ne 1i
627.It Li USER_STREAM_MAX
628The minimum maximum number of streams that a process may have open
629at any one time.
630.It Li USER_TZNAME_MAX
631The minimum maximum number of types supported for the name of a
632timezone.
633.El
634.Ss CTL_VM
635The string and integer information available for the CTL_VM level
636is detailed below.
637The changeable column shows whether a process with appropriate
638privilege may change the value.
639.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
640.It Sy Pa Second level name	Type	Changeable
641.It VM\_LOADAVG	struct loadavg	no
642.It VM\_METER	struct vmtotal	no
643.It VM\_PAGEOUT\_ALGORITHM	integer	yes
644.It VM\_SWAPPING\_ENABLED	integer	maybe
645.It VM\_V\_CACHE\_MAX	integer	yes
646.It VM\_V\_CACHE\_MIN	integer	yes
647.It VM\_V\_FREE\_MIN	integer	yes
648.It VM\_V\_FREE\_RESERVED	integer	yes
649.It VM\_V\_FREE\_TARGET	integer	yes
650.It VM\_V\_INACTIVE\_TARGET	integer	yes
651.It VM\_V\_PAGEOUT\_FREE\_MIN	integer	yes
652.El
653.Pp
654.Bl -tag -width "123456"
655.It Li VM_LOADAVG
656Return the load average history.
657The returned data consists of a
658.Va struct loadavg .
659.It Li VM_METER
660Return the system wide virtual memory statistics.
661The returned data consists of a
662.Va struct vmtotal .
663.It Li VM_PAGEOUT_ALGORITHM
6640 if the statistics-based page management algorithm is in use
665or 1 if the near-LRU algorithm is in use.
666.It Li VM_SWAPPING_ENABLED
6671 if process swapping is enabled or 0 if disabled.  This variable is
668permanently set to 0 if the kernel was built with swapping disabled.
669.It Li VM_V_CACHE_MAX
670Maximum desired size of the cache queue.
671.It Li VM_V_CACHE_MIN
672Minimum desired size of the cache queue.  If the cache queue size
673falls very far below this value, the pageout daemon is awakened.
674.It Li VM_V_FREE_MIN
675Minimum amount of memory (cache memory plus free memory)
676required to be available before a process waiting on memory will be
677awakened.
678.It Li VM_V_FREE_RESERVED
679Processes will awaken the pageout daemon and wait for memory if the
680number of free and cached pages drops below this value.
681.It Li VM_V_FREE_TARGET
682The total amount of free memory (including cache memory) that the
683pageout daemon tries to maintain.
684.It Li VM_V_INACTIVE_TARGET
685The desired number of inactive pages that the pageout daemon should
686achieve when it runs.  Inactive pages can be quickly inserted into
687process address space when needed.
688.It Li VM_V_PAGEOUT_FREE_MIN
689If the amount of free and cache memory falls below this value, the
690pageout daemon will enter "memory conserving mode" to avoid deadlock.
691.El
692.Sh RETURN VALUES
693.Fn sysctl
694and
695.Fn sysctlbyname
696return 0 when successful.
697Otherwise \-1 is returned and
698.Va errno
699is set appropriately.
700.Sh ERRORS
701The following errors may be reported:
702.Bl -tag -width Er
703.It Bq Er EFAULT
704The buffer
705.Fa name ,
706.Fa oldp ,
707.Fa newp ,
708or length pointer
709.Fa oldlenp
710contains an invalid address.
711.It Bq Er EINVAL
712The
713.Fa name
714array is less than two or greater than CTL_MAXNAME.
715.It Bq Er EINVAL
716A non-null
717.Fa newp
718is given and its specified length in
719.Fa newlen
720is too large or too small.
721.It Bq Er ENOMEM
722The length pointed to by
723.Fa oldlenp
724is too short to hold the requested value.
725.It Bq Er ENOTDIR
726The
727.Fa name
728array specifies an intermediate rather than terminal name.
729.It Bq Er EISDIR
730The
731.Fa name
732array specifies a terminal name, but the actual name is not terminal.
733.It Bq Er EOPNOTSUPP
734The
735.Fa name
736array specifies a value that is unknown.
737.It Bq Er EPERM
738An attempt is made to set a read-only value.
739.It Bq Er EPERM
740A process without appropriate privilege attempts to set a value.
741.El
742.Sh FILES
743.Bl -tag -width <netinet/icmpXvar.h> -compact
744.It Aq Pa sys/sysctl.h
745definitions for top level identifiers, second level kernel and hardware
746identifiers, and user level identifiers
747.It Aq Pa sys/socket.h
748definitions for second level network identifiers
749.It Aq Pa sys/gmon.h
750definitions for third level profiling identifiers
751.It Aq Pa vm/vm_param.h
752definitions for second level virtual memory identifiers
753.It Aq Pa netinet/in.h
754definitions for third level IPv4/IPv6 identifiers and
755fourth level IPv4/v6 identifiers
756.It Aq Pa netinet/icmp_var.h
757definitions for fourth level ICMP identifiers
758.It Aq Pa netinet/icmp6.h
759definitions for fourth level ICMPv6 identifiers
760.It Aq Pa netinet/udp_var.h
761definitions for fourth level UDP identifiers
762.El
763.Sh SEE ALSO
764.Xr sysconf 3 ,
765.Xr sysctl 8
766.Sh HISTORY
767The
768.Fn sysctl
769function first appeared in
770.Bx 4.4 .
771