xref: /freebsd/lib/libc/gen/sysctl.3 (revision c1462236787ec09d00d5e2d222edc3e34bce1e69)
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.El
437.Ss CTL_MACHDEP
438The set of variables defined is architecture dependent.
439The following variables are defined for the i386 architecture.
440.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent
441.It Sy Pa Second level name	Type	Changeable
442.It Li CPU_CONSDEV	dev_t	no
443.It Li CPU_ADJKERNTZ	int	yes
444.It Li CPU_DISRTCSET	int	yes
445.It Li CPU_BOOTINFO	struct bootinfo	no
446.It Li CPU_WALLCLOCK	int	yes
447.El
448.Ss CTL_NET
449The string and integer information available for the CTL_NET level
450is detailed below.
451The changeable column shows whether a process with appropriate
452privilege may change the value.
453.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
454.It Sy Pa Second level name	Type	Changeable
455.It PF\_ROUTE	routing messages	no
456.It PF\_INET	IPv4 values	yes
457.It PF\_INET6	IPv6 values	yes
458.El
459.Pp
460.Bl -tag -width "123456"
461.It Li PF_ROUTE
462Return the entire routing table or a subset of it.
463The data is returned as a sequence of routing messages (see
464.Xr route 4
465for the header file, format and meaning).
466The length of each message is contained in the message header.
467.Pp
468The third level name is a protocol number, which is currently always 0.
469The fourth level name is an address family, which may be set to 0 to
470select all address families.
471The fifth and sixth level names are as follows:
472.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
473.It Pa Fifth level name	Sixth level is:
474.It NET\_RT\_FLAGS	rtflags
475.It NET\_RT\_DUMP	None
476.It NET\_RT\_IFLIST	None
477.El
478.It Li PF_INET
479Get or set various global information about the IPv4
480.Pq Internet Protocol version 4 .
481The third level name is the protocol.
482The fourth level name is the variable name.
483The currently defined protocols and names are:
484.ne 1i
485.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
486.It Pa Protocol	Variable	Type	Changeable
487.It icmp	bmcastecho	integer	yes
488.It icmp	maskrepl	integer	yes
489.It ip	forwarding	integer	yes
490.It ip	redirect	integer	yes
491.It ip	ttl	integer	yes
492.It udp	checksum	integer	yes
493.El
494.Pp
495The variables are as follows:
496.Bl -tag -width "123456"
497.It Li icmp.bmcastecho
498Returns 1 if an ICMP echo request to a broadcast or multicast address is
499to be answered.
500.It Li icmp.maskrepl
501Returns 1 if ICMP network mask requests are to be answered.
502.It Li ip.forwarding
503Returns 1 when IP forwarding is enabled for the host,
504meaning that the host is acting as a router.
505.It Li ip.redirect
506Returns 1 when ICMP redirects may be sent by the host.
507This option is ignored unless the host is routing IP packets,
508and should normally be enabled on all systems.
509.It Li ip.ttl
510The maximum time-to-live (hop count) value for an IP packet sourced by
511the system.
512This value applies to normal transport protocols, not to ICMP.
513.It Li udp.checksum
514Returns 1 when UDP checksums are being computed and checked.
515Disabling UDP checksums is strongly discouraged.
516.Pp
517For variables net.inet.*.ipsec, please refer to
518.Xr ipsec 4 .
519.El
520.It Li PF_INET6
521Get or set various global information about the IPv6
522.Pq Internet Protocol version 6 .
523The third level name is the protocol.
524The fourth level name is the variable name.
525.Pp
526For variables net.inet6.* please refer to
527.Xr inet6 4 .
528For variables net.inet6.*.ipsec6, please refer to
529.Xr ipsec 4 .
530.El
531.Ss CTL_USER
532The string and integer information available for the CTL_USER level
533is detailed below.
534The changeable column shows whether a process with appropriate
535privilege may change the value.
536.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
537.It Sy Pa Second level name	Type	Changeable
538.It USER\_BC\_BASE\_MAX	integer	no
539.It USER\_BC\_DIM\_MAX	integer	no
540.It USER\_BC\_SCALE\_MAX	integer	no
541.It USER\_BC\_STRING\_MAX	integer	no
542.It USER\_COLL\_WEIGHTS\_MAX	integer	no
543.It USER\_CS\_PATH	string	no
544.It USER\_EXPR\_NEST\_MAX	integer	no
545.It USER\_LINE\_MAX	integer	no
546.It USER\_POSIX2\_CHAR\_TERM	integer	no
547.It USER\_POSIX2\_C\_BIND	integer	no
548.It USER\_POSIX2\_C\_DEV	integer	no
549.It USER\_POSIX2\_FORT\_DEV	integer	no
550.It USER\_POSIX2\_FORT\_RUN	integer	no
551.It USER\_POSIX2\_LOCALEDEF	integer	no
552.It USER\_POSIX2\_SW\_DEV	integer	no
553.It USER\_POSIX2\_UPE	integer	no
554.It USER\_POSIX2\_VERSION	integer	no
555.It USER\_RE\_DUP\_MAX	integer	no
556.It USER\_STREAM\_MAX	integer	no
557.It USER\_TZNAME\_MAX	integer	no
558.El
559.Bl -tag -width "123456"
560.Pp
561.It Li USER_BC_BASE_MAX
562The maximum ibase/obase values in the
563.Xr bc 1
564utility.
565.It Li USER_BC_DIM_MAX
566The maximum array size in the
567.Xr bc 1
568utility.
569.It Li USER_BC_SCALE_MAX
570The maximum scale value in the
571.Xr bc 1
572utility.
573.It Li USER_BC_STRING_MAX
574The maximum string length in the
575.Xr bc 1
576utility.
577.It Li USER_COLL_WEIGHTS_MAX
578The maximum number of weights that can be assigned to any entry of
579the LC_COLLATE order keyword in the locale definition file.
580.It Li USER_CS_PATH
581Return a value for the
582.Ev PATH
583environment variable that finds all the standard utilities.
584.It Li USER_EXPR_NEST_MAX
585The maximum number of expressions that can be nested within
586parenthesis by the
587.Xr expr 1
588utility.
589.It Li USER_LINE_MAX
590The maximum length in bytes of a text-processing utility's input
591line.
592.It Li USER_POSIX2_CHAR_TERM
593Return 1 if the system supports at least one terminal type capable of
594all operations described in POSIX 1003.2, otherwise 0.
595.It Li USER_POSIX2_C_BIND
596Return 1 if the system's C-language development facilities support the
597C-Language Bindings Option, otherwise 0.
598.It Li USER_POSIX2_C_DEV
599Return 1 if the system supports the C-Language Development Utilities Option,
600otherwise 0.
601.It Li USER_POSIX2_FORT_DEV
602Return 1 if the system supports the FORTRAN Development Utilities Option,
603otherwise 0.
604.It Li USER_POSIX2_FORT_RUN
605Return 1 if the system supports the FORTRAN Runtime Utilities Option,
606otherwise 0.
607.It Li USER_POSIX2_LOCALEDEF
608Return 1 if the system supports the creation of locales, otherwise 0.
609.It Li USER_POSIX2_SW_DEV
610Return 1 if the system supports the Software Development Utilities Option,
611otherwise 0.
612.It Li USER_POSIX2_UPE
613Return 1 if the system supports the User Portability Utilities Option,
614otherwise 0.
615.It Li USER_POSIX2_VERSION
616The version of POSIX 1003.2 with which the system attempts to comply.
617.It Li USER_RE_DUP_MAX
618The maximum number of repeated occurrences of a regular expression
619permitted when using interval notation.
620.ne 1i
621.It Li USER_STREAM_MAX
622The minimum maximum number of streams that a process may have open
623at any one time.
624.It Li USER_TZNAME_MAX
625The minimum maximum number of types supported for the name of a
626timezone.
627.El
628.Ss CTL_VM
629The string and integer information available for the CTL_VM level
630is detailed below.
631The changeable column shows whether a process with appropriate
632privilege may change the value.
633.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
634.It Sy Pa Second level name	Type	Changeable
635.It VM\_LOADAVG	struct loadavg	no
636.It VM\_METER	struct vmtotal	no
637.It VM\_PAGEOUT\_ALGORITHM	integer	yes
638.It VM\_SWAPPING\_ENABLED	integer	maybe
639.It VM\_V\_CACHE\_MAX	integer	yes
640.It VM\_V\_CACHE\_MIN	integer	yes
641.It VM\_V\_FREE\_MIN	integer	yes
642.It VM\_V\_FREE\_RESERVED	integer	yes
643.It VM\_V\_FREE\_TARGET	integer	yes
644.It VM\_V\_INACTIVE\_TARGET	integer	yes
645.It VM\_V\_PAGEOUT\_FREE\_MIN	integer	yes
646.El
647.Pp
648.Bl -tag -width "123456"
649.It Li VM_LOADAVG
650Return the load average history.
651The returned data consists of a
652.Va struct loadavg .
653.It Li VM_METER
654Return the system wide virtual memory statistics.
655The returned data consists of a
656.Va struct vmtotal .
657.It Li VM_PAGEOUT_ALGORITHM
6580 if the statistics-based page management algorithm is in use
659or 1 if the near-LRU algorithm is in use.
660.It Li VM_SWAPPING_ENABLED
6611 if process swapping is enabled or 0 if disabled.  This variable is
662permanently set to 0 if the kernel was built with swapping disabled.
663.It Li VM_V_CACHE_MAX
664Maximum desired size of the cache queue.
665.It Li VM_V_CACHE_MIN
666Minimum desired size of the cache queue.  If the cache queue size
667falls very far below this value, the pageout daemon is awakened.
668.It Li VM_V_FREE_MIN
669Minimum amount of memory (cache memory plus free memory)
670required to be available before a process waiting on memory will be
671awakened.
672.It Li VM_V_FREE_RESERVED
673Processes will awaken the pageout daemon and wait for memory if the
674number of free and cached pages drops below this value.
675.It Li VM_V_FREE_TARGET
676The total amount of free memory (including cache memory) that the
677pageout daemon tries to maintain.
678.It Li VM_V_INACTIVE_TARGET
679The desired number of inactive pages that the pageout daemon should
680achieve when it runs.  Inactive pages can be quickly inserted into
681process address space when needed.
682.It Li VM_V_PAGEOUT_FREE_MIN
683If the amount of free and cache memory falls below this value, the
684pageout daemon will enter "memory conserving mode" to avoid deadlock.
685.El
686.Sh RETURN VALUES
687.Fn sysctl
688and
689.Fn sysctlbyname
690return 0 when successful.
691Otherwise \-1 is returned and
692.Va errno
693is set appropriately.
694.Sh ERRORS
695The following errors may be reported:
696.Bl -tag -width Er
697.It Bq Er EFAULT
698The buffer
699.Fa name ,
700.Fa oldp ,
701.Fa newp ,
702or length pointer
703.Fa oldlenp
704contains an invalid address.
705.It Bq Er EINVAL
706The
707.Fa name
708array is less than two or greater than CTL_MAXNAME.
709.It Bq Er EINVAL
710A non-null
711.Fa newp
712is given and its specified length in
713.Fa newlen
714is too large or too small.
715.It Bq Er ENOMEM
716The length pointed to by
717.Fa oldlenp
718is too short to hold the requested value.
719.It Bq Er ENOTDIR
720The
721.Fa name
722array specifies an intermediate rather than terminal name.
723.It Bq Er EISDIR
724The
725.Fa name
726array specifies a terminal name, but the actual name is not terminal.
727.It Bq Er EOPNOTSUPP
728The
729.Fa name
730array specifies a value that is unknown.
731.It Bq Er EPERM
732An attempt is made to set a read-only value.
733.It Bq Er EPERM
734A process without appropriate privilege attempts to set a value.
735.El
736.Sh FILES
737.Bl -tag -width <netinet/icmpXvar.h> -compact
738.It Aq Pa sys/sysctl.h
739definitions for top level identifiers, second level kernel and hardware
740identifiers, and user level identifiers
741.It Aq Pa sys/socket.h
742definitions for second level network identifiers
743.It Aq Pa sys/gmon.h
744definitions for third level profiling identifiers
745.It Aq Pa vm/vm_param.h
746definitions for second level virtual memory identifiers
747.It Aq Pa netinet/in.h
748definitions for third level IPv4/IPv6 identifiers and
749fourth level IPv4/v6 identifiers
750.It Aq Pa netinet/icmp_var.h
751definitions for fourth level ICMP identifiers
752.It Aq Pa netinet/icmp6.h
753definitions for fourth level ICMPv6 identifiers
754.It Aq Pa netinet/udp_var.h
755definitions for fourth level UDP identifiers
756.El
757.Sh SEE ALSO
758.Xr sysconf 3 ,
759.Xr sysctl 8
760.Sh HISTORY
761The
762.Fn sysctl
763function first appeared in
764.Bx 4.4 .
765