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