]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/gen/sysctl.3
zfs: merge openzfs/zfs@dbda45160
[FreeBSD/FreeBSD.git] / lib / libc / gen / sysctl.3
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. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .Dd March 16, 2023
29 .Dt SYSCTL 3
30 .Os
31 .Sh NAME
32 .Nm sysctl ,
33 .Nm sysctlbyname ,
34 .Nm sysctlnametomib
35 .Nd get or set system information
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .In sys/sysctl.h
40 .Ft int
41 .Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen"
42 .Ft int
43 .Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen"
44 .Ft int
45 .Fn sysctlnametomib "const char *name" "int *mibp" "size_t *sizep"
46 .Sh DESCRIPTION
47 The
48 .Fn sysctl
49 function retrieves system information and allows processes with
50 appropriate privileges to set system information.
51 The information available from
52 .Fn sysctl
53 consists of integers, strings, and tables.
54 Information may be retrieved and set from the command interface
55 using the
56 .Xr sysctl 8
57 utility.
58 .Pp
59 Unless explicitly noted below,
60 .Fn sysctl
61 returns a consistent snapshot of the data requested.
62 Consistency is obtained by locking the destination
63 buffer into memory so that the data may be copied out without blocking.
64 Calls to
65 .Fn sysctl
66 are serialized to avoid deadlock.
67 .Pp
68 The state is described using a ``Management Information Base'' (MIB)
69 style name, listed in
70 .Fa name ,
71 which is a
72 .Fa namelen
73 length array of integers.
74 .Pp
75 The
76 .Fn sysctlbyname
77 function accepts an ASCII representation of the name and internally
78 looks up the integer name vector.
79 Apart from that, it behaves the same
80 as the standard
81 .Fn sysctl
82 function.
83 .Pp
84 The information is copied into the buffer specified by
85 .Fa oldp .
86 The size of the buffer is given by the location specified by
87 .Fa oldlenp
88 before the call,
89 and that location gives the amount of data copied after a successful call
90 and after a call that returns with the error code
91 .Er ENOMEM .
92 If the amount of data available is greater
93 than the size of the buffer supplied,
94 the call supplies as much data as fits in the buffer provided
95 and returns with the error code
96 .Er ENOMEM .
97 If the old value is not desired,
98 .Fa oldp
99 and
100 .Fa oldlenp
101 should be set to NULL.
102 .Pp
103 The size of the available data can be determined by calling
104 .Fn sysctl
105 with the
106 .Dv NULL
107 argument for
108 .Fa oldp .
109 The size of the available data will be returned in the location pointed to by
110 .Fa oldlenp .
111 For some operations, the amount of space may change often.
112 For these operations,
113 the system attempts to round up so that the returned size is
114 large enough for a call to return the data shortly thereafter.
115 .Pp
116 To set a new value,
117 .Fa newp
118 is set to point to a buffer of length
119 .Fa newlen
120 from which the requested value is to be taken.
121 If a new value is not to be set,
122 .Fa newp
123 should be set to NULL and
124 .Fa newlen
125 set to 0.
126 .Pp
127 The
128 .Fn sysctlnametomib
129 function accepts an ASCII representation of the name,
130 looks up the integer name vector,
131 and returns the numeric representation in the mib array pointed to by
132 .Fa mibp .
133 The number of elements in the mib array is given by the location specified by
134 .Fa sizep
135 before the call,
136 and that location gives the number of entries copied after a successful call.
137 The resulting
138 .Fa mib
139 and
140 .Fa size
141 may be used in subsequent
142 .Fn sysctl
143 calls to get the data associated with the requested ASCII name.
144 This interface is intended for use by applications that want to
145 repeatedly request the same variable (the
146 .Fn sysctl
147 function runs in about a third the time as the same request made via the
148 .Fn sysctlbyname
149 function).
150 The
151 .Fn sysctlnametomib
152 function is also useful for fetching mib prefixes and then adding
153 a final component.
154 For example, to fetch process information
155 for processes with pid's less than 100:
156 .Pp
157 .Bd -literal -offset indent -compact
158 int i, mib[4];
159 size_t len;
160 struct kinfo_proc kp;
161
162 /* Fill out the first three components of the mib */
163 len = 4;
164 sysctlnametomib("kern.proc.pid", mib, &len);
165
166 /* Fetch and print entries for pid's < 100 */
167 for (i = 0; i < 100; i++) {
168         mib[3] = i;
169         len = sizeof(kp);
170         if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1)
171                 perror("sysctl");
172         else if (len > 0)
173                 printkproc(&kp);
174 }
175 .Ed
176 .Pp
177 The top level names are defined with a CTL_ prefix in
178 .In sys/sysctl.h ,
179 and are as follows.
180 The next and subsequent levels down are found in the include files
181 listed here, and described in separate sections below.
182 .Bl -column CTLXMACHDEPXXX "Next Level NamesXXXXXX" -offset indent
183 .It Sy Name Ta Sy Next Level Names Ta Sy Description
184 .It Dv CTL_DEBUG Ta In sys/sysctl.h Ta Debugging
185 .It Dv CTL_VFS Ta In sys/mount.h Ta File system
186 .It Dv CTL_HW Ta In sys/sysctl.h Ta Generic CPU, I/O
187 .It Dv CTL_KERN Ta In sys/sysctl.h Ta High kernel limits
188 .It Dv CTL_MACHDEP Ta In sys/sysctl.h Ta Machine dependent
189 .It Dv CTL_NET Ta In sys/socket.h Ta Networking
190 .It Dv CTL_USER Ta In sys/sysctl.h Ta User-level
191 .It Dv CTL_VM Ta In vm/vm_param.h Ta Virtual memory
192 .El
193 .Pp
194 For example, the following retrieves the maximum number of processes allowed
195 in the system:
196 .Pp
197 .Bd -literal -offset indent -compact
198 int mib[2], maxproc;
199 size_t len;
200
201 mib[0] = CTL_KERN;
202 mib[1] = KERN_MAXPROC;
203 len = sizeof(maxproc);
204 sysctl(mib, 2, &maxproc, &len, NULL, 0);
205 .Ed
206 .Pp
207 To retrieve the standard search path for the system utilities:
208 .Pp
209 .Bd -literal -offset indent -compact
210 int mib[2];
211 size_t len;
212 char *p;
213
214 mib[0] = CTL_USER;
215 mib[1] = USER_CS_PATH;
216 sysctl(mib, 2, NULL, &len, NULL, 0);
217 p = malloc(len);
218 sysctl(mib, 2, p, &len, NULL, 0);
219 .Ed
220 .Ss CTL_DEBUG
221 The debugging variables vary from system to system.
222 A debugging variable may be added or deleted without need to recompile
223 .Fn sysctl
224 to know about it.
225 Each time it runs,
226 .Fn sysctl
227 gets the list of debugging variables from the kernel and
228 displays their current values.
229 The system defines twenty
230 .Pq Vt "struct ctldebug"
231 variables named
232 .Va debug0
233 through
234 .Va debug19 .
235 They are declared as separate variables so that they can be
236 individually initialized at the location of their associated variable.
237 The loader prevents multiple use of the same variable by issuing errors
238 if a variable is initialized in more than one place.
239 For example, to export the variable
240 .Va dospecialcheck
241 as a debugging variable, the following declaration would be used:
242 .Pp
243 .Bd -literal -offset indent -compact
244 int dospecialcheck = 1;
245 struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
246 .Ed
247 .Ss CTL_VFS
248 A distinguished second level name, VFS_GENERIC,
249 is used to get general information about all file systems.
250 One of its third level identifiers is VFS_MAXTYPENUM
251 that gives the highest valid file system type number.
252 Its other third level identifier is VFS_CONF that
253 returns configuration information about the file system
254 type given as a fourth level identifier (see
255 .Xr getvfsbyname 3
256 as an example of its use).
257 The remaining second level identifiers are the
258 file system type number returned by a
259 .Xr statfs 2
260 call or from VFS_CONF.
261 The third level identifiers available for each file system
262 are given in the header file that defines the mount
263 argument structure for that file system.
264 .Ss CTL_HW
265 The string and integer information available for the CTL_HW level
266 is detailed below.
267 The changeable column shows whether a process with appropriate
268 privilege may change the value.
269 .Bl -column "Second Level Name" integerXXX Changeable -offset indent
270 .It Sy Second Level Name Ta Sy Type Ta Sy Changeable
271 .It Dv HW_MACHINE Ta string Ta no
272 .It Dv HW_MODEL Ta string Ta no
273 .It Dv HW_NCPU Ta integer Ta no
274 .It Dv HW_BYTEORDER Ta integer Ta no
275 .It Dv HW_PHYSMEM Ta integer Ta no
276 .It Dv HW_USERMEM Ta integer Ta no
277 .It Dv HW_PAGESIZE Ta integer Ta no
278 .\".It Dv HW_DISKNAMES Ta integer Ta no
279 .\".It Dv HW_DISKSTATS Ta integer Ta no
280 .It Dv HW_FLOATINGPT Ta integer Ta no
281 .It Dv HW_MACHINE_ARCH Ta string Ta no
282 .It Dv HW_REALMEM Ta integer Ta no
283 .It Dv HW_AVAILPAGES Ta integer Ta no
284 .El
285 .Bl -tag -width 6n
286 .It Li HW_MACHINE
287 The machine class.
288 .It Li HW_MODEL
289 The machine model
290 .It Li HW_NCPU
291 The number of cpus.
292 .It Li HW_BYTEORDER
293 The byteorder (4321 or 1234).
294 .It Li HW_PHYSMEM
295 Amount of physical memory (in bytes), minus the amount used by the kernel,
296 pre-loaded modules, and (on x86) the dcons buffer.
297 .It Li HW_USERMEM
298 Amount of memory (in bytes) which is not wired.
299 .It Li HW_PAGESIZE
300 The software page size.
301 .\".It Fa HW_DISKNAMES
302 .\".It Fa HW_DISKSTATS
303 .It Li HW_FLOATINGPT
304 Nonzero if the floating point support is in hardware.
305 .It Li HW_MACHINE_ARCH
306 The machine dependent architecture type.
307 .It Li HW_REALMEM
308 Amount of memory (in bytes) reported by the firmware.
309 That value is sometimes not sane; in that case, the kernel reports the max
310 memory address instead.
311 .It Li HW_AVAILPAGES
312 The same value as
313 .Li HW_PHYSMEM ,
314 measured in pages rather than bytes.
315 .El
316 .Ss CTL_KERN
317 The string and integer information available for the CTL_KERN level
318 is detailed below.
319 The changeable column shows whether a process with appropriate
320 privilege may change the value.
321 The types of data currently available are process information,
322 system vnodes, the open file entries, routing table entries,
323 virtual memory statistics, load average history, and clock rate
324 information.
325 .Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
326 .It Sy Second Level Name Ta Sy Type Ta Sy Changeable
327 .It Dv KERN_ARGMAX Ta integer Ta no
328 .It Dv KERN_BOOTFILE Ta string Ta yes
329 .It Dv KERN_BOOTTIME Ta struct timeval Ta no
330 .It Dv KERN_CLOCKRATE Ta struct clockinfo Ta no
331 .It Dv KERN_FILE Ta struct xfile Ta no
332 .It Dv KERN_HOSTID Ta integer Ta yes
333 .It Dv KERN_HOSTUUID Ta string Ta yes
334 .It Dv KERN_HOSTNAME Ta string Ta yes
335 .It Dv KERN_JOB_CONTROL Ta integer Ta no
336 .It Dv KERN_MAXFILES Ta integer Ta yes
337 .It Dv KERN_MAXFILESPERPROC Ta integer Ta yes
338 .It Dv KERN_MAXPROC Ta integer Ta no
339 .It Dv KERN_MAXPROCPERUID Ta integer Ta yes
340 .It Dv KERN_MAXVNODES Ta integer Ta yes
341 .It Dv KERN_NGROUPS Ta integer Ta no
342 .It Dv KERN_NISDOMAINNAME Ta string Ta yes
343 .It Dv KERN_OSRELDATE Ta integer Ta no
344 .It Dv KERN_OSRELEASE Ta string Ta no
345 .It Dv KERN_OSREV Ta integer Ta no
346 .It Dv KERN_OSTYPE Ta string Ta no
347 .It Dv KERN_POSIX1 Ta integer Ta no
348 .It Dv KERN_PROC Ta node Ta not applicable
349 .It Dv KERN_QUANTUM Ta integer Ta yes
350 .It Dv KERN_SAVED_IDS Ta integer Ta no
351 .It Dv KERN_SECURELVL Ta integer Ta raise only
352 .It Dv KERN_UPDATEINTERVAL Ta integer Ta no
353 .It Dv KERN_VERSION Ta string Ta no
354 .El
355 .Bl -tag -width 6n
356 .It Li KERN_ARGMAX
357 The maximum bytes of argument to
358 .Xr execve 2 .
359 .It Li KERN_BOOTFILE
360 The full pathname of the file from which the kernel was loaded.
361 .It Li KERN_BOOTTIME
362 A
363 .Va struct timeval
364 structure is returned.
365 This structure contains the time that the system was booted.
366 .It Li KERN_CLOCKRATE
367 A
368 .Va struct clockinfo
369 structure is returned.
370 This structure contains the clock, statistics clock and profiling clock
371 frequencies, the number of micro-seconds per hz tick and the skew rate.
372 .It Li KERN_FILE
373 Return the entire file table.
374 The returned data consists of an array of
375 .Va struct xfile ,
376 whose size depends on the current number of such objects in the system.
377 .It Li KERN_HOSTID
378 Get or set the host ID.
379 .It Li KERN_HOSTUUID
380 Get or set the host's universally unique identifier (UUID).
381 .It Li KERN_HOSTNAME
382 Get or set the hostname.
383 .It Li KERN_JOB_CONTROL
384 Return 1 if job control is available on this system, otherwise 0.
385 .It Li KERN_MAXFILES
386 The maximum number of files that may be open in the system.
387 .It Li KERN_MAXFILESPERPROC
388 The maximum number of files that may be open for a single process.
389 This limit only applies to processes with an effective uid of nonzero
390 at the time of the open request.
391 Files that have already been opened are not affected if the limit
392 or the effective uid is changed.
393 .It Li KERN_MAXPROC
394 The maximum number of concurrent processes the system will allow.
395 .It Li KERN_MAXPROCPERUID
396 The maximum number of concurrent processes the system will allow
397 for a single effective uid.
398 This limit only applies to processes with an effective uid of nonzero
399 at the time of a fork request.
400 Processes that have already been started are not affected if the limit
401 is changed.
402 .It Li KERN_MAXVNODES
403 The maximum number of vnodes available on the system.
404 .It Li KERN_NGROUPS
405 The maximum number of supplemental groups.
406 .It Li KERN_NISDOMAINNAME
407 The name of the current YP/NIS domain.
408 .It Li KERN_OSRELDATE
409 The kernel release version in the format
410 .Ar M Ns Ar mm Ns Ar R Ns Ar xx ,
411 where
412 .Ar M
413 is the major version,
414 .Ar mm
415 is the two digit minor version,
416 .Ar R
417 is 0 if release branch, otherwise 1,
418 and
419 .Ar xx
420 is updated when the available APIs change.
421 .Pp
422 The userland release version is available from
423 .In osreldate.h ;
424 parse this file if you need to get the release version of
425 the currently installed userland.
426 .It Li KERN_OSRELEASE
427 The system release string.
428 .It Li KERN_OSREV
429 The system revision string.
430 .It Li KERN_OSTYPE
431 The system type string.
432 .It Li KERN_POSIX1
433 The version of
434 .St -p1003.1
435 with which the system
436 attempts to comply.
437 .It Li KERN_PROC
438 Return selected information about specific running processes.
439 .Pp
440 For the following names, an array of
441 .Va struct kinfo_proc
442 structures is returned,
443 whose size depends on the current number of such objects in the system.
444 .Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent
445 .It Sy Third Level Name Ta Sy Fourth Level
446 .It Dv KERN_PROC_ALL Ta None
447 .It Dv KERN_PROC_PID Ta A process ID
448 .It Dv KERN_PROC_PGRP Ta A process group
449 .It Dv KERN_PROC_TTY Ta A tty device
450 .It Dv KERN_PROC_UID Ta A user ID
451 .It Dv KERN_PROC_RUID Ta A real user ID
452 .El
453 .Pp
454 If the third level name is
455 .Dv KERN_PROC_ARGS
456 then the command line argument
457 array is returned in a flattened form, i.e., zero-terminated arguments
458 follow each other.
459 The total size of array is returned.
460 It is also possible for a process to set its own process title this way.
461 If the third level name is
462 .Dv KERN_PROC_PATHNAME ,
463 the path of the
464 process' text file is stored.
465 For
466 .Dv KERN_PROC_PATHNAME ,
467 a process ID of
468 .Li \-1
469 implies the current process.
470 .Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent
471 .It Sy Third Level Name Ta Sy Fourth Level
472 .It Dv KERN_PROC_ARGS Ta "A process ID"
473 .It Dv KERN_PROC_PATHNAME Ta "A process ID"
474 .El
475 .It Li KERN_QUANTUM
476 The maximum period of time, in microseconds, for which a process is allowed
477 to run without being preempted if other processes are in the run queue.
478 .It Li KERN_SAVED_IDS
479 Returns 1 if saved set-group and saved set-user ID is available.
480 .It Li KERN_SECURELVL
481 The system security level.
482 This level may be raised by processes with appropriate privilege.
483 It may not be lowered.
484 .It Li KERN_VERSION
485 The system version string.
486 .El
487 .Ss CTL_NET
488 The string and integer information available for the CTL_NET level
489 is detailed below.
490 The changeable column shows whether a process with appropriate
491 privilege may change the value.
492 .Bl -column "Second Level NameXXXXXX" "routing messagesXXX" -offset indent
493 .It Sy Second Level Name Ta Sy Type Ta Sy Changeable
494 .It Dv PF_ROUTE Ta routing messages Ta no
495 .It Dv PF_INET Ta IPv4 values Ta yes
496 .It Dv PF_INET6 Ta IPv6 values Ta yes
497 .El
498 .Bl -tag -width 6n
499 .It Li PF_ROUTE
500 Return the entire routing table or a subset of it.
501 The data is returned as a sequence of routing messages (see
502 .Xr route 4
503 for the header file, format and meaning).
504 The length of each message is contained in the message header.
505 .Pp
506 The third level name is a protocol number, which is currently always 0.
507 The fourth level name is an address family, which may be set to 0 to
508 select all address families.
509 The fifth, sixth, and seventh level names are as follows:
510 .Bl -column -offset indent "Fifth Level" "Sixth Level" "Seventh Level"
511 .It Sy Fifth level Ta Sy Sixth Level Ta Sy Seventh Level
512 .It Dv NET_RT_FLAGS Ta rtflags Ta None
513 .It Dv NET_RT_DUMP Ta None Ta None or fib number
514 .It Dv NET_RT_IFLIST Ta 0 or if_index Ta None
515 .It Dv NET_RT_IFMALIST Ta 0 or if_index Ta None
516 .It Dv NET_RT_IFLISTL Ta 0 or if_index Ta None
517 .It Dv NET_RT_NHOPS Ta None Ta fib number
518 .El
519 .Pp
520 The
521 .Dv NET_RT_IFMALIST
522 name returns information about multicast group memberships on all interfaces
523 if 0 is specified, or for the interface specified by
524 .Va if_index .
525 .Pp
526 The
527 .Dv NET_RT_IFLISTL
528 is like
529 .Dv NET_RT_IFLIST ,
530 just returning message header structs with additional fields allowing the
531 interface to be extended without breaking binary compatibility.
532 The
533 .Dv NET_RT_IFLISTL
534 uses 'l' versions of the message header structures:
535 .Va struct if_msghdrl
536 and
537 .Va struct ifa_msghdrl .
538 .Pp
539 .Dv NET_RT_NHOPS
540 returns all nexthops for specified address family in given fib.
541 .It Li PF_INET
542 Get or set various global information about the IPv4
543 (Internet Protocol version 4).
544 The third level name is the protocol.
545 The fourth level name is the variable name.
546 The currently defined protocols and names are:
547 .Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
548 .It Sy Protocol Ta Sy Variable Ta Sy Type Ta Sy Changeable
549 .It icmp Ta bmcastecho Ta integer Ta yes
550 .It icmp Ta maskrepl Ta integer Ta yes
551 .It ip Ta forwarding Ta integer Ta yes
552 .It ip Ta redirect Ta integer Ta yes
553 .It ip Ta ttl Ta integer Ta yes
554 .It udp Ta checksum Ta integer Ta yes
555 .El
556 .Pp
557 The variables are as follows:
558 .Bl -tag -width 6n
559 .It Li icmp.bmcastecho
560 Returns 1 if an ICMP echo request to a broadcast or multicast address is
561 to be answered.
562 .It Li icmp.maskrepl
563 Returns 1 if ICMP network mask requests are to be answered.
564 .It Li ip.forwarding
565 Returns 1 when IP forwarding is enabled for the host,
566 meaning that the host is acting as a router.
567 .It Li ip.redirect
568 Returns 1 when ICMP redirects may be sent by the host.
569 This option is ignored unless the host is routing IP packets,
570 and should normally be enabled on all systems.
571 .It Li ip.ttl
572 The maximum time-to-live (hop count) value for an IP packet sourced by
573 the system.
574 This value applies to normal transport protocols, not to ICMP.
575 .It Li udp.checksum
576 Returns 1 when UDP checksums are being computed and checked.
577 Disabling UDP checksums is strongly discouraged.
578 .Pp
579 For variables net.inet.*.ipsec, please refer to
580 .Xr ipsec 4 .
581 .El
582 .It Li PF_INET6
583 Get or set various global information about the IPv6
584 (Internet Protocol version 6).
585 The third level name is the protocol.
586 The fourth level name is the variable name.
587 .Pp
588 For variables net.inet6.* please refer to
589 .Xr inet6 4 .
590 For variables net.inet6.*.ipsec6, please refer to
591 .Xr ipsec 4 .
592 .El
593 .Ss CTL_USER
594 The string and integer information available for the CTL_USER level
595 is detailed below.
596 The changeable column shows whether a process with appropriate
597 privilege may change the value.
598 .Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
599 .It Sy Second Level Name Ta Sy Type Ta Sy Changeable
600 .It Dv USER_BC_BASE_MAX Ta integer Ta no
601 .It Dv USER_BC_DIM_MAX Ta integer Ta no
602 .It Dv USER_BC_SCALE_MAX Ta integer Ta no
603 .It Dv USER_BC_STRING_MAX Ta integer Ta no
604 .It Dv USER_COLL_WEIGHTS_MAX Ta integer Ta no
605 .It Dv USER_CS_PATH Ta string Ta no
606 .It Dv USER_EXPR_NEST_MAX Ta integer Ta no
607 .It Dv USER_LINE_MAX Ta integer Ta no
608 .It Dv USER_LOCALBASE Ta string Ta no
609 .It Dv USER_POSIX2_CHAR_TERM Ta integer Ta no
610 .It Dv USER_POSIX2_C_BIND Ta integer Ta no
611 .It Dv USER_POSIX2_C_DEV Ta integer Ta no
612 .It Dv USER_POSIX2_FORT_DEV Ta integer Ta no
613 .It Dv USER_POSIX2_FORT_RUN Ta integer Ta no
614 .It Dv USER_POSIX2_LOCALEDEF Ta integer Ta no
615 .It Dv USER_POSIX2_SW_DEV Ta integer Ta no
616 .It Dv USER_POSIX2_UPE Ta integer Ta no
617 .It Dv USER_POSIX2_VERSION Ta integer Ta no
618 .It Dv USER_RE_DUP_MAX Ta integer Ta no
619 .It Dv USER_STREAM_MAX Ta integer Ta no
620 .It Dv USER_TZNAME_MAX Ta integer Ta no
621 .El
622 .Bl -tag -width 6n
623 .It Li USER_BC_BASE_MAX
624 The maximum ibase/obase values in the
625 .Xr bc 1
626 utility.
627 .It Li USER_BC_DIM_MAX
628 The maximum array size in the
629 .Xr bc 1
630 utility.
631 .It Li USER_BC_SCALE_MAX
632 The maximum scale value in the
633 .Xr bc 1
634 utility.
635 .It Li USER_BC_STRING_MAX
636 The maximum string length in the
637 .Xr bc 1
638 utility.
639 .It Li USER_COLL_WEIGHTS_MAX
640 The maximum number of weights that can be assigned to any entry of
641 the LC_COLLATE order keyword in the locale definition file.
642 .It Li USER_CS_PATH
643 Return a value for the
644 .Ev PATH
645 environment variable that finds all the standard utilities.
646 .It Li USER_EXPR_NEST_MAX
647 The maximum number of expressions that can be nested within
648 parenthesis by the
649 .Xr expr 1
650 utility.
651 .It Li USER_LINE_MAX
652 The maximum length in bytes of a text-processing utility's input
653 line.
654 .It Li USER_LOCALBASE
655 Return the value of localbase that has been compiled into system utilities
656 that need to have access to resources provided by a port or package.
657 .It Li USER_POSIX2_CHAR_TERM
658 Return 1 if the system supports at least one terminal type capable of
659 all operations described in
660 .St -p1003.2 ,
661 otherwise 0.
662 .It Li USER_POSIX2_C_BIND
663 Return 1 if the system's C-language development facilities support the
664 C-Language Bindings Option, otherwise 0.
665 .It Li USER_POSIX2_C_DEV
666 Return 1 if the system supports the C-Language Development Utilities Option,
667 otherwise 0.
668 .It Li USER_POSIX2_FORT_DEV
669 Return 1 if the system supports the FORTRAN Development Utilities Option,
670 otherwise 0.
671 .It Li USER_POSIX2_FORT_RUN
672 Return 1 if the system supports the FORTRAN Runtime Utilities Option,
673 otherwise 0.
674 .It Li USER_POSIX2_LOCALEDEF
675 Return 1 if the system supports the creation of locales, otherwise 0.
676 .It Li USER_POSIX2_SW_DEV
677 Return 1 if the system supports the Software Development Utilities Option,
678 otherwise 0.
679 .It Li USER_POSIX2_UPE
680 Return 1 if the system supports the User Portability Utilities Option,
681 otherwise 0.
682 .It Li USER_POSIX2_VERSION
683 The version of
684 .St -p1003.2
685 with which the system attempts to comply.
686 .It Li USER_RE_DUP_MAX
687 The maximum number of repeated occurrences of a regular expression
688 permitted when using interval notation.
689 .It Li USER_STREAM_MAX
690 The minimum maximum number of streams that a process may have open
691 at any one time.
692 .It Li USER_TZNAME_MAX
693 The minimum maximum number of types supported for the name of a
694 timezone.
695 .El
696 .Ss CTL_VM
697 The string and integer information available for the CTL_VM level
698 is detailed below.
699 The changeable column shows whether a process with appropriate
700 privilege may change the value.
701 .Bl -column "Second Level NameXXXXXX" "struct loadavgXXX" -offset indent
702 .It Sy Second Level Name Ta Sy Type Ta Sy Changeable
703 .It Dv VM_LOADAVG Ta struct loadavg Ta no
704 .It Dv VM_TOTAL Ta struct vmtotal Ta no
705 .It Dv VM_SWAPPING_ENABLED Ta integer Ta maybe
706 .It Dv VM_V_FREE_MIN Ta integer Ta yes
707 .It Dv VM_V_FREE_RESERVED Ta integer Ta yes
708 .It Dv VM_V_FREE_TARGET Ta integer Ta yes
709 .It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes
710 .It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes
711 .It Dv VM_OVERCOMMIT Ta integer Ta yes
712 .El
713 .Bl -tag -width 6n
714 .It Li VM_LOADAVG
715 Return the load average history.
716 The returned data consists of a
717 .Va struct loadavg .
718 .It Li VM_TOTAL
719 Return the system wide virtual memory statistics.
720 The returned data consists of a
721 .Va struct vmtotal .
722 .It Li VM_SWAPPING_ENABLED
723 1 if process swapping is enabled or 0 if disabled.
724 This variable is
725 permanently set to 0 if the kernel was built with swapping disabled.
726 .It Li VM_V_FREE_MIN
727 Minimum amount of memory (cache memory plus free memory)
728 required to be available before a process waiting on memory will be
729 awakened.
730 .It Li VM_V_FREE_RESERVED
731 Processes will awaken the pageout daemon and wait for memory if the
732 number of free and cached pages drops below this value.
733 .It Li VM_V_FREE_TARGET
734 The total amount of free memory (including cache memory) that the
735 pageout daemon tries to maintain.
736 .It Li VM_V_INACTIVE_TARGET
737 The desired number of inactive pages that the pageout daemon should
738 achieve when it runs.
739 Inactive pages can be quickly inserted into
740 process address space when needed.
741 .It Li VM_V_PAGEOUT_FREE_MIN
742 If the amount of free and cache memory falls below this value, the
743 pageout daemon will enter "memory conserving mode" to avoid deadlock.
744 .It Li VM_OVERCOMMIT
745 Overcommit behaviour, as described in
746 .Xr tuning 7 .
747 .El
748 .Sh RETURN VALUES
749 .Rv -std
750 .Sh FILES
751 .Bl -tag -width <netinet/icmpXvar.h> -compact
752 .It In sys/sysctl.h
753 definitions for top level identifiers, second level kernel and hardware
754 identifiers, and user level identifiers
755 .It In sys/socket.h
756 definitions for second level network identifiers
757 .It In sys/gmon.h
758 definitions for third level profiling identifiers
759 .It In vm/vm_param.h
760 definitions for second level virtual memory identifiers
761 .It In netinet/in.h
762 definitions for third level IPv4/IPv6 identifiers and
763 fourth level IPv4/v6 identifiers
764 .It In netinet/icmp_var.h
765 definitions for fourth level ICMP identifiers
766 .It In netinet/icmp6.h
767 definitions for fourth level ICMPv6 identifiers
768 .It In netinet/udp_var.h
769 definitions for fourth level UDP identifiers
770 .El
771 .Sh ERRORS
772 The following errors may be reported:
773 .Bl -tag -width Er
774 .It Bq Er EFAULT
775 The buffer
776 .Fa name ,
777 .Fa oldp ,
778 .Fa newp ,
779 or length pointer
780 .Fa oldlenp
781 contains an invalid address.
782 .It Bq Er EINVAL
783 The
784 .Fa name
785 array is less than two or greater than CTL_MAXNAME.
786 .It Bq Er EINVAL
787 A non-null
788 .Fa newp
789 is given and its specified length in
790 .Fa newlen
791 is too large or too small.
792 .It Bq Er ENOMEM
793 The length pointed to by
794 .Fa oldlenp
795 is too short to hold the requested value.
796 .It Bq Er ENOMEM
797 The smaller of either the length pointed to by
798 .Fa oldlenp
799 or the estimated size of the returned data exceeds the
800 system limit on locked memory.
801 .It Bq Er ENOMEM
802 Locking the buffer
803 .Fa oldp ,
804 or a portion of the buffer if the estimated size of the data
805 to be returned is smaller,
806 would cause the process to exceed its per-process locked memory limit.
807 .It Bq Er ENOTDIR
808 The
809 .Fa name
810 array specifies an intermediate rather than terminal name.
811 .It Bq Er EISDIR
812 The
813 .Fa name
814 array specifies a terminal name, but the actual name is not terminal.
815 .It Bq Er ENOENT
816 The
817 .Fa name
818 array specifies a value that is unknown.
819 .It Bq Er EPERM
820 An attempt is made to set a read-only value.
821 .It Bq Er EPERM
822 A process without appropriate privilege attempts to set a value.
823 .El
824 .Sh SEE ALSO
825 .Xr confstr 3 ,
826 .Xr kvm 3 ,
827 .Xr sysconf 3 ,
828 .Xr sysctl 8
829 .Sh HISTORY
830 The
831 .Fn sysctl
832 function first appeared in
833 .Bx 4.4 .