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