1.\" $NetBSD: sysctl.3,v 1.19 1998/01/05 09:59:03 lukem 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 ip anonportmin integer yes 474.It ip anonportmax integer yes 475.It icmp maskrepl integer yes 476.It tcp rfc1323 integer yes 477.It tcp sendspace integer yes 478.It tcp recvspace integer yes 479.It tcp syn_cache_limit integer yes 480.It tcp syn_bucket_limit integer yes 481.It tcp syn_cache_interval integer yes 482.It tcp init_win integer yes 483.It udp checksum integer yes 484.It udp sendspace integer yes 485.It udp recvspace integer yes 486.El 487.Pp 488The variables are as follows: 489.Bl -tag -width "123456" 490.It Li ip.forwarding 491Returns 1 when IP forwarding is enabled for the host, 492meaning that the host is acting as a router. 493.It Li ip.redirect 494Returns 1 when ICMP redirects may be sent by the host. 495This option is ignored unless the host is routing IP packets, 496and should normally be enabled on all systems. 497.It Li ip.ttl 498The maximum time-to-live (hop count) value for an IP packet sourced by 499the system. 500This value applies to normal transport protocols, not to ICMP. 501.It Li ip.forwsrcrt 502Returns 1 when forwarding of source-routed packets is enabled for 503the host. This value may only be changed if the kernel security 504level is less than 1. 505.It Li ip.directed-broadcast 506Returns 1 if directed broadcast behavior is enabled for the host. 507.It Li ip.allowsrcrt 508Returns 1 if the host accepts source routed packets. 509.It Li ip.subnetsarelocal 510Returns 1 if subnets are to be considered local addresses. 511.It Li ip.anonportmin 512The lowest port number to use for TCP and UDP ephemeral port allocation. 513This cannot be set to less that 1024 or greater than 65535. 514.It Li ip.anonportmax 515The highest port number to use for TCP and UDP ephemeral port allocation. 516This cannot be set to less that 1024 or greater than 65535, and must 517be greater than 518.Li ip.anonportmin . 519.It Li icmp.maskrepl 520Returns 1 if ICMP network mask requests are to be answered. 521.It Li tcp.rfc1323 522Returns 1 if RFC1323 extensions to TCP are enabled. 523.It Li tcp.sendspace 524Returns the default TCP send buffer size. 525.It Li tcp.recvspace 526Returns the default TCP receive buffer size. 527.It Li tcp.syn_cache_limit 528Returns the maximum number of entries allowed in the TCP compressed state 529engine. 530.It Li tcp.syn_bucket_limit 531Returns the maximum number of entries allowed per hash bucket in the TCP 532compressed state engine. 533.It Li tcp.syn_cache_interval 534Returns the TCP compressed state engine's timer interval. 535.It Li tcp.init_win 536If greater than 0, returns the number of segments used for the inital 537slow start congestion window. A value of 0 indicates that an experimental 538auto-tuning algorithm is being used to compute the initial window. 539.It Li udp.checksum 540Returns 1 when UDP checksums are being computed and checked. 541Disabling UDP checksums is strongly discouraged. 542.It Li udp.sendspace 543Returns the default UDP send buffer size. 544.It Li udp.recvspace 545Returns the default UDP receive buffer size. 546.El 547.Sh CTL_USER 548The string and integer information available for the CTL_USER level 549is detailed below. 550The changeable column shows whether a process with appropriate 551privilege may change the value. 552.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent 553.It Sy Pa Second level name Type Changeable 554.It USER\_BC\_BASE\_MAX integer no 555.It USER\_BC\_DIM\_MAX integer no 556.It USER\_BC\_SCALE\_MAX integer no 557.It USER\_BC\_STRING\_MAX integer no 558.It USER\_COLL\_WEIGHTS\_MAX integer no 559.It USER\_CS\_PATH string no 560.It USER\_EXPR\_NEST\_MAX integer no 561.It USER\_LINE\_MAX integer no 562.It USER\_POSIX2\_CHAR\_TERM integer no 563.It USER\_POSIX2\_C\_BIND integer no 564.It USER\_POSIX2\_C\_DEV integer no 565.It USER\_POSIX2\_FORT\_DEV integer no 566.It USER\_POSIX2\_FORT\_RUN integer no 567.It USER\_POSIX2\_LOCALEDEF integer no 568.It USER\_POSIX2\_SW\_DEV integer no 569.It USER\_POSIX2\_UPE integer no 570.It USER\_POSIX2\_VERSION integer no 571.It USER\_RE\_DUP\_MAX integer no 572.It USER\_STREAM\_MAX integer no 573.It USER\_TZNAME\_MAX integer no 574.El 575.Bl -tag -width "123456" 576.Pp 577.It Li USER_BC_BASE_MAX 578The maximum ibase/obase values in the 579.Xr bc 1 580utility. 581.It Li USER_BC_DIM_MAX 582The maximum array size in the 583.Xr bc 1 584utility. 585.It Li USER_BC_SCALE_MAX 586The maximum scale value in the 587.Xr bc 1 588utility. 589.It Li USER_BC_STRING_MAX 590The maximum string length in the 591.Xr bc 1 592utility. 593.It Li USER_COLL_WEIGHTS_MAX 594The maximum number of weights that can be assigned to any entry of 595the LC_COLLATE order keyword in the locale definition file. 596.It Li USER_CS_PATH 597Return a value for the 598.Ev PATH 599environment variable that finds all the standard utilities. 600.It Li USER_EXPR_NEST_MAX 601The maximum number of expressions that can be nested within 602parenthesis by the 603.Xr expr 1 604utility. 605.It Li USER_LINE_MAX 606The maximum length in bytes of a text-processing utility's input 607line. 608.It Li USER_POSIX2_CHAR_TERM 609Return 1 if the system supports at least one terminal type capable of 610all operations described in POSIX 1003.2, otherwise 0. 611.It Li USER_POSIX2_C_BIND 612Return 1 if the system's C-language development facilities support the 613C-Language Bindings Option, otherwise 0. 614.It Li USER_POSIX2_C_DEV 615Return 1 if the system supports the C-Language Development Utilities Option, 616otherwise 0. 617.It Li USER_POSIX2_FORT_DEV 618Return 1 if the system supports the FORTRAN Development Utilities Option, 619otherwise 0. 620.It Li USER_POSIX2_FORT_RUN 621Return 1 if the system supports the FORTRAN Runtime Utilities Option, 622otherwise 0. 623.It Li USER_POSIX2_LOCALEDEF 624Return 1 if the system supports the creation of locales, otherwise 0. 625.It Li USER_POSIX2_SW_DEV 626Return 1 if the system supports the Software Development Utilities Option, 627otherwise 0. 628.It Li USER_POSIX2_UPE 629Return 1 if the system supports the User Portability Utilities Option, 630otherwise 0. 631.It Li USER_POSIX2_VERSION 632The version of POSIX 1003.2 with which the system attempts to comply. 633.It Li USER_RE_DUP_MAX 634The maximum number of repeated occurrences of a regular expression 635permitted when using interval notation. 636.It Li USER_STREAM_MAX 637The minimum maximum number of streams that a process may have open 638at any one time. 639.It Li USER_TZNAME_MAX 640The minimum maximum number of types supported for the name of a 641timezone. 642.El 643.Sh CTL_VM 644The string and integer information available for the CTL_VM level 645is detailed below. 646The changeable column shows whether a process with appropriate 647privilege may change the value. 648.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent 649.It Sy Pa Second level name Type Changeable 650.It VM\_LOADAVG struct loadavg no 651.It VM\_METER struct vmtotal no 652.El 653.Pp 654.Bl -tag -width "123456" 655.It Li VM_LOADAVG 656Return the load average history. 657The returned data consists of a 658.Va struct loadavg . 659.It Li VM_METER 660Return the system wide virtual memory statistics. 661The returned data consists of a 662.Va struct vmtotal . 663.El 664.Sh CTL_DDB 665The integer information available for the CTL_DDB level is detailed below. 666The changeable column shows whether a process with appropriate 667privilege may change the value. 668.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent 669.It Sy Pa Second level name Type Changeable 670.It DBCTL\_RADIX integer yes 671.It DBCTL\_MAXOFF integer yes 672.It DBCTL\_LINES integer yes 673.It DBCTL\_TABSTOPS integer yes 674.It DBCTL\_ONPANIC integer yes 675.El 676.Pp 677.Bl -tag -width "123456" 678.It Li DBCTL_RADIX 679The input and output radix. 680.It Li DBCTL_MAXOFF 681The maximum symbol offset. 682.It Li DBCTL_LINES 683Number of display lines. 684.It Li DBCTL_TABSTOPS 685Tab width. 686.It Li DBCTL_ONPANIC 687If non-zero, DDB will be entered when the kernel panics. 688.El 689.Pp 690These MIB nodes are also available as variables from within the 691DDB. See 692.Xr ddb 4 693for more details. 694.Sh RETURN VALUES 695If the call to 696.Nm sysctl 697is successful, 0 is returned. 698Otherwise \-1 is returned and 699.Va errno 700is set appropriately. 701.Sh ERRORS 702The following errors may be reported: 703.Bl -tag -width Er 704.It Bq Er EFAULT 705The buffer 706.Fa name , 707.Fa oldp , 708.Fa newp , 709or length pointer 710.Fa oldlenp 711contains an invalid address. 712.It Bq Er EINVAL 713The 714.Fa name 715array is less than two or greater than CTL_MAXNAME. 716.It Bq Er EINVAL 717A non-null 718.Fa newp 719is given and its specified length in 720.Fa newlen 721is too large or too small. 722.It Bq Er ENOMEM 723The length pointed to by 724.Fa oldlenp 725is too short to hold the requested value. 726.It Bq Er ENOTDIR 727The 728.Fa name 729array specifies an intermediate rather than terminal name. 730.It Bq Er EOPNOTSUPP 731The 732.Fa name 733array specifies a value that is unknown. 734.It Bq Er EPERM 735An attempt is made to set a read-only value. 736.It Bq Er EPERM 737A process without appropriate privilege attempts to set a value. 738.It Bq Er EPERM 739An attempt to change a value protected by the current kernel security 740level is made. 741.El 742.Sh FILES 743.Bl -tag -width <netinet/icmpXvar.h> -compact 744.It Pa <sys/sysctl.h> 745definitions for top level identifiers, second level kernel and hardware 746identifiers, and user level identifiers 747.It Pa <sys/socket.h> 748definitions for second level network identifiers 749.It Pa <sys/gmon.h> 750definitions for third level profiling identifiers 751.It Pa <vm/vm_param.h> 752definitions for second level virtual memory identifiers 753.It Pa <netinet/in.h> 754definitions for third level Internet identifiers and 755fourth level IP identifiers 756.It Pa <netinet/icmp_var.h> 757definitions for fourth level ICMP identifiers 758.It Pa <netinet/tcp_var.h> 759definitions for fourth level TCP identifiers 760.It Pa <netinet/udp_var.h> 761definitions for fourth level UDP identifiers 762.El 763.Sh SEE ALSO 764.Xr sysctl 8 765.Sh HISTORY 766The 767.Nm sysctl 768function first appeared in 4.4BSD. 769