1.\" $NetBSD: sysctl.3,v 1.207 2022/12/04 11:25:08 uwe 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. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 31.\" 32.Dd September 14, 2019 33.Dt SYSCTL 3 34.Os 35.Sh NAME 36.Nm sysctl , 37.Nm sysctlbyname , 38.Nm sysctlgetmibinfo , 39.Nm sysctlnametomib , 40.Nm asysctl , 41.Nm asysctlbyname 42.Nd get or set system information 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In sys/param.h 47.In sys/sysctl.h 48.Ft int 49.Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" \ 50"const void *newp" "size_t newlen" 51.Ft int 52.Fn sysctlbyname "const char *sname" "void *oldp" "size_t *oldlenp" \ 53"const void *newp" "size_t newlen" 54.Ft int 55.Fn sysctlgetmibinfo "const char *sname" "int *name" "u_int *namelenp" \ 56"char *cname" "size_t *csz" "struct sysctlnode **rnode" "int v" 57.Ft int 58.Fn sysctlnametomib "const char *sname" "int *name" "size_t *namelenp" 59.Ft void * 60.Fn asysctl "const int *name" "size_t namelen" "size_t *len" 61.Ft void * 62.Fn asysctlbyname "const char *sname" "size_t *len" 63.Sh DESCRIPTION 64The 65.Nm 66function retrieves system information and allows processes with 67appropriate privileges to set system information. 68The information available from 69.Nm 70consists of integers, strings, and tables. 71Information may be retrieved and set from the command interface 72using the 73.Xr sysctl 8 74utility. 75.Pp 76Unless explicitly noted below, 77.Nm 78returns a consistent snapshot of the data requested. 79Consistency is obtained by locking the destination 80buffer into memory so that the data may be copied out without blocking. 81Calls to 82.Nm 83are serialized to avoid deadlock. 84.Pp 85The state is described using a ``Management Information Base'' (MIB) 86style name, listed in 87.Fa name , 88which is a 89.Fa namelen 90length array of integers. 91.Pp 92The 93.Fn sysctlbyname 94function accepts a string representation of a MIB entry and internally 95maps it to the appropriate numeric MIB representation. 96Its semantics are otherwise no different from 97.Fn sysctl . 98.Pp 99The information is copied into the buffer specified by 100.Fa oldp . 101The size of the buffer is given by the location specified by 102.Fa oldlenp 103before the call, 104and that location gives the amount of data copied after a successful call. 105If the amount of data available is greater 106than the size of the buffer supplied, 107the call supplies as much data as fits in the buffer provided 108and returns with the error code 109.Er ENOMEM . 110If the old value is not desired, 111.Fa oldp 112and 113.Fa oldlenp 114should be set to 115.Dv NULL . 116.Pp 117The size of the available data can be determined by calling 118.Nm 119with a 120.Dv NULL 121parameter for 122.Fa oldp . 123The size of the available data will be returned in the location pointed to by 124.Fa oldlenp . 125For some operations, the amount of space may change often. 126For these operations, 127the system attempts to round up so that the returned size is 128large enough for a call to return the data shortly thereafter. 129.Pp 130To set a new value, 131.Fa newp 132is set to point to a buffer of length 133.Fa newlen 134from which the requested value is to be taken. 135If a new value is not to be set, 136.Fa newp 137should be set to 138.Dv NULL 139and 140.Fa newlen 141set to 0. 142.Pp 143The 144.Fn sysctlnametomib 145function can be used to map the string representation of a MIB entry 146to the numeric version. 147The 148.Fa name 149argument should point to an array of integers large enough to hold the 150MIB, and 151.Fa namelenp 152should indicate the number of integer slots available. 153Following a successful translation, the size_t indicated by 154.Fa namelenp 155will be changed to show the number of slots consumed. 156.Pp 157The 158.Fn sysctlgetmibinfo 159function performs name translation similar to 160.Fn sysctlnametomib , 161but also canonicalizes the name (or returns the first erroneous token 162from the string being parsed) into the space indicated by 163.Fa cname 164and 165.Fa csz . 166.Fa csz 167should indicate the size of the buffer pointed to by 168.Fa cname 169and on return, will indicate the size of the returned string including 170the trailing 171.Sq nul 172character. 173.Pp 174The 175.Fa rnode 176and 177.Fa v 178arguments to 179.Fn sysctlgetmibinfo 180are used to provide a tree for it to parse into, and to get back 181either a pointer to, or a copy of, the terminal node. 182If 183.Fa rnode 184is 185.Dv NULL , 186.Fn sysctlgetmibinfo 187uses its own internal tree for parsing, and checks it against the 188kernel at each call, to make sure that the name-to-number mapping is 189kept up to date. 190The 191.Fa v 192argument is ignored in this case. 193If 194.Fa rnode 195is not 196.Dv NULL 197but the pointer it references is, on a successful return, 198.Fa rnode 199will be adjusted to point to a copy of the terminal node. 200The 201.Fa v 202argument indicates which version of the 203.Nm 204node structure the caller wants. 205The application must later 206.Fn free 207this copy. 208If neither 209.Fa rnode 210nor the pointer it references are 211.Dv NULL , 212the pointer is used as the address of a tree over which the parsing is 213done. 214In this last case, the tree is not checked against the kernel, no 215refreshing of the mappings is performed, and the value given by 216.Fa v 217must agree with the version indicated by the tree. 218It is recommended that applications always use 219.Dv SYSCTL_VERSION 220as the value for 221.Fa v , 222as defined in the include file 223.Pa sys/sysctl.h . 224.Pp 225The numeric and text names of sysctl variables are described in 226.Xr sysctl 7 . 227The numeric names are defined as preprocessor macros. 228The top level names are defined with a CTL_ prefix in 229.In sys/sysctl.h . 230The next and subsequent levels down have different prefixes for each 231subtree. 232.Pp 233For example, the following retrieves the maximum number of processes allowed 234in the system - the 235.Li kern.maxproc 236variable: 237.Bd -literal -offset indent -compact 238int mib[2], maxproc; 239size_t len; 240.sp 241mib[0] = CTL_KERN; 242mib[1] = KERN_MAXPROC; 243len = sizeof(maxproc); 244sysctl(mib, 2, &maxproc, &len, NULL, 0); 245.Ed 246.sp 247To retrieve the standard search path for the system utilities - 248.Li user.cs_path : 249.Bd -literal -offset indent -compact 250int mib[2]; 251size_t len; 252char *p; 253.sp 254mib[0] = CTL_USER; 255mib[1] = USER_CS_PATH; 256sysctl(mib, 2, NULL, &len, NULL, 0); 257p = malloc(len); 258sysctl(mib, 2, p, &len, NULL, 0); 259.Ed 260.Pp 261The 262.Fn asysctl 263and 264.Fn asysctlbyname 265functions are wrappers for 266.Fn sysctl 267and 268.Fn sysctlbyname . 269They return memory allocated with 270.Xr malloc 3 271and resize the buffer in a loop until all data fits. 272.Sh DYNAMIC OPERATIONS 273Several meta-identifiers are provided to perform operations on the 274.Nm 275tree itself, or support alternate means of accessing the data 276instrumented by the 277.Nm 278tree. 279.Bl -column CTLXCREATESYMXXX 280.It Sy Name Description 281.It CTL\_QUERY Retrieve a mapping of names to numbers below a given node 282.It CTL\_CREATE Create a new node 283.It CTL\_CREATESYM Create a new node by its kernel symbol 284.It CTL\_DESTROY Destroy a node 285.It CTL\_DESCRIBE Retrieve node descriptions 286.El 287.Pp 288The core interface to all of these meta-functions is the structure 289that the kernel uses to describe the tree internally, as defined in 290.In sys/sysctl.h 291as: 292.Bd -literal 293struct sysctlnode { 294 uint32_t sysctl_flags; /* flags and type */ 295 int32_t sysctl_num; /* mib number */ 296 char sysctl_name[SYSCTL_NAMELEN]; /* node name */ 297 uint32_t sysctl_ver; /* node's version vs. rest of tree */ 298 uint32_t __rsvd; 299 union { 300 struct { 301 uint32_t suc_csize; /* size of child node array */ 302 uint32_t suc_clen; /* number of valid children */ 303 struct sysctlnode* suc_child; /* array of child nodes */ 304 } scu_child; 305 struct { 306 void *sud_data; /* pointer to external data */ 307 size_t sud_offset; /* offset to data */ 308 } scu_data; 309 int32_t scu_alias; /* node this node refers to */ 310 int32_t scu_idata; /* immediate "int" data */ 311 u_quad_t scu_qdata; /* immediate "u_quad_t" data */ 312 } sysctl_un; 313 size_t _sysctl_size; /* size of instrumented data */ 314 sysctlfn _sysctl_func; /* access helper function */ 315 struct sysctlnode *sysctl_parent; /* parent of this node */ 316 const char *sysctl_desc; /* description of node */ 317}; 318 319#define sysctl_csize sysctl_un.scu_child.suc_csize 320#define sysctl_clen sysctl_un.scu_child.suc_clen 321#define sysctl_child sysctl_un.scu_child.suc_child 322#define sysctl_data sysctl_un.scu_data.sud_data 323#define sysctl_offset sysctl_un.scu_data.sud_offset 324#define sysctl_alias sysctl_un.scu_alias 325#define sysctl_idata sysctl_un.scu_idata 326#define sysctl_qdata sysctl_un.scu_qdata 327.Ed 328.Pp 329Querying the tree to discover the name to number mapping permits 330dynamic discovery of all the data that the tree currently has 331instrumented. 332For example, to discover all the nodes below the 333.Dv CTL_VFS 334node: 335.Pp 336.Bd -literal -offset indent -compact 337struct sysctlnode query, vfs[128]; 338int mib[2]; 339size_t len; 340.sp 341mib[0] = CTL_VFS; 342mib[1] = CTL_QUERY; 343memset(&query, 0, sizeof(query)); 344query.sysctl_flags = SYSCTL_VERSION; 345len = sizeof(vfs); 346sysctl(mib, 2, &vfs[0], &len, &query, sizeof(query)); 347.Ed 348.Pp 349Note that a reference to an empty node with 350.Fa sysctl_flags 351set to 352.Dv SYSCTL_VERSION 353is passed to sysctl in order to indicate the version that the program 354is using. 355All dynamic operations passing nodes into sysctl require that the 356version be explicitly specified. 357.Pp 358Creation and destruction of nodes works by constructing part of a new 359node description (or a description of the existing node) and invoking 360.Dv CTL_CREATE 361(or 362.Dv CTL_CREATESYM ) 363or 364.Dv CTL_DESTROY 365at the parent of the new 366node, with a pointer to the new node passed via the 367.Fa new 368and 369.Fa newlen 370arguments. 371If valid values for 372.Fa old 373and 374.Fa oldlenp 375are passed, a copy of the new node once in the tree will be returned. 376If the create operation fails because a node with the same name or MIB 377number exists, a copy of the conflicting node will be returned. 378.Pp 379The minimum requirements for creating a node are setting the 380.Fa sysctl_flags 381to indicate the new node's type, 382.Fa sysctl_num 383to either the new node's number (or 384.Dv CTL_CREATE 385or 386.Dv CTL_CREATESYM 387if a 388dynamically allocated MIB number is acceptable), 389.Fa sysctl_size 390to the size of the data to be instrumented (which must agree with the 391given type), and 392.Fa sysctl_name 393must be set to the new node's name. 394Nodes that are not of type 395.Dq node 396must also have some description of the data to be instrumented, which 397will vary depending on what is to be instrumented. 398.Pp 399If existing kernel data is to be covered by this new node, its address 400should be given in 401.Fa sysctl_data 402or, if 403.Dv CTL_CREATESYM 404is used, 405.Fa sysctl_data 406should be set to a string containing its name from the kernel's symbol 407table. 408If new data is to be instrumented and an initial value is available, 409the new integer or quad type data should be placed into either 410.Fa sysctl_idata 411or 412.Fa sysctl_qdata , 413respectively, along with the 414.Dv CTLFLAG_IMMEDIATE 415flag being set, or 416.Fa sysctl_data 417should be set to point to a copy of the new data, and the 418.Dv CTLFLAG_OWNDATA 419flag must be set. 420This latter method is the only way that new string and struct type 421nodes can be initialized. 422Invalid kernel addresses are accepted, but any attempt to access those 423nodes will return an error. 424.Pp 425The 426.Fa sysctl_csize , 427.Fa sysctl_clen , 428.Fa sysctl_child , 429.Fa sysctl_parent , 430and 431.Fa sysctl_alias 432members are used by the kernel to link the tree together and must be 433.Dv NULL 434or 0. 435Nodes created in this manner cannot have helper functions, so 436.Fa sysctl_func 437must also be 438.Dv NULL . 439If the 440.Fa sysctl_ver 441member is non-zero, it must match either the version of the parent or 442the version at the root of the MIB or an error is returned. 443This can be used to ensure that nodes are only added or removed from a 444known state of the tree. 445Note: It may not be possible to determine the version at the root 446of the tree. 447.Pp 448This example creates a new subtree and adds a node to it that controls the 449.Fa audiodebug 450kernel variable, thereby making it tunable at at any time, without 451needing to use 452.Xr ddb 4 453or 454.Xr kvm 3 455to alter the kernel's memory directly. 456.Pp 457.Bd -literal -offset indent -compact 458struct sysctlnode node; 459int mib[2]; 460size_t len; 461.sp 462mib[0] = CTL_CREATE; /* create at top-level */ 463len = sizeof(node); 464memset(&node, 0, len); 465node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_NODE; 466snprintf(node.sysctl_name, sizeof(node.sysctl_name), "local"); 467node.sysctl_num = CTL_CREATE; /* request dynamic MIB number */ 468sysctl(&mib[0], 1, &node, &len, &node, len); 469.sp 470mib[0] = node.sysctl_num; /* use new MIB number */ 471mib[1] = CTL_CREATESYM; /* create at second level */ 472len = sizeof(node); 473memset(&node, 0, len); 474node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_INT; 475snprintf(node.sysctl_name, sizeof(node.sysctl_name), "audiodebug"); 476node.sysctl_num = CTL_CREATE; 477node.sysctl_data = "audiodebug"; /* kernel symbol to be used */ 478sysctl(&mib[0], 2, NULL, NULL, &node, len); 479.Ed 480.Pp 481The process for deleting nodes is similar, but less data needs to 482be supplied. 483Only the 484.Fa sysctl_num 485field 486needs to be filled in; almost all other fields must be left blank. 487The 488.Fa sysctl_name 489and/or 490.Fa sysctl_ver 491fields can be filled in with the name and version of the existing node 492as additional checks on what will be deleted. 493If all the given data fail to match any node, nothing will be deleted. 494If valid values for 495.Fa old 496and 497.Fa oldlenp 498are supplied and a node is deleted, a copy of what was in the MIB tree 499will be returned. 500.Pp 501This sample code shows the deletion of the two nodes created in the 502above example: 503.Pp 504.Bd -literal -offset indent -compact 505int mib[2]; 506.sp 507len = sizeof(node); 508memset(&node, 0, len); 509node.sysctl_flags = SYSCTL_VERSION; 510.sp 511mib[0] = 3214; /* assumed number for "local" */ 512mib[1] = CTL_DESTROY; 513node.sysctl_num = 3215; /* assumed number for "audiodebug" */ 514sysctl(&mib[0], 2, NULL, NULL, &node, len); 515.sp 516mib[0] = CTL_DESTROY; 517node.sysctl_num = 3214; /* now deleting "local" */ 518sysctl(&mib[0], 1, NULL, NULL, &node, len); 519.Ed 520.Pp 521Descriptions of each of the nodes can also be retrieved, if they are 522available. 523Descriptions can be retrieved in bulk at each level or on a per-node 524basis. 525The layout of the buffer into which the descriptions are returned is a 526series of variable length structures, each of which describes its own 527size. 528The length indicated includes the terminating 529.Sq nul 530character. 531Nodes that have no description or where the description is not 532available are indicated by an empty string. 533The 534.Fa descr_ver 535will match the 536.Fa sysctl_ver 537value for a given node, so that descriptions for nodes whose number 538have been recycled can be detected and ignored or discarded. 539.Bd -literal 540struct sysctldesc { 541 int32_t descr_num; /* mib number of node */ 542 uint32_t descr_ver; /* version of node */ 543 uint32_t descr_len; /* length of description string */ 544 char descr_str[1]; /* not really 1...see above */ 545}; 546.Ed 547.Pp 548The 549.Fn NEXT_DESCR 550macro can be used to skip to the next description in the retrieved 551list. 552.Pp 553.Bd -literal -offset indent -compact 554struct sysctlnode desc; 555struct sysctldesc *d; 556char buf[1024]; 557int mib[2]; 558size_t len; 559.sp 560/* retrieve kern-level descriptions */ 561mib[0] = CTL_KERN; 562mib[1] = CTL_DESCRIBE; 563d = (struct sysctldesc *)&buf[0]; 564len = sizeof(buf); 565sysctl(mib, 2, d, &len, NULL, 0); 566while ((caddr_t)d < (caddr_t)&buf[len]) { 567 printf("node %d: %.*s\\n", d->descr_num, d->descr_len, 568 d->descr_str); 569 d = NEXT_DESCR(d); 570} 571.sp 572/* retrieve description for kern.securelevel */ 573memset(&desc, 0, sizeof(desc)); 574desc.sysctl_flags = SYSCTL_VERSION; 575desc.sysctl_num = KERN_SECURELEVEL; 576d = (struct sysctldesc *)&buf[0]; 577len = sizeof(buf); 578sysctl(mib, 2, d, &len, &desc, sizeof(desc)); 579printf("kern.securelevel: %.*s\\n", d->descr_len, d->descr_str); 580.Ed 581.Pp 582Descriptions can also be set as follows, subject to the following rules: 583.Pp 584.Bl -bullet -compact 585.It 586The kernel securelevel is at zero or lower 587.It 588The caller has super-user privileges 589.It 590The node does not currently have a description 591.It 592The node is not marked as 593.Dq permanent 594.El 595.Pp 596.Bd -literal -offset indent -compact 597struct sysctlnode desc; 598int mib[2]; 599.sp 600/* presuming the given top-level node was just added... */ 601mib[0] = 3214; /* mib numbers taken from previous examples */ 602mib[1] = CTL_DESCRIBE; 603memset(&desc, 0, sizeof(desc)); 604desc.sysctl_flags = SYSCTL_VERSION; 605desc.sysctl_num = 3215; 606desc.sysctl_desc = "audio debug control knob"; 607sysctl(mib, 2, NULL, NULL, &desc, sizeof(desc)); 608.Ed 609.Pp 610Upon successfully setting a description, the new description will be 611returned in the space indicated by the 612.Fa oldp 613and 614.Fa oldlenp 615arguments. 616.Pp 617The 618.Fa sysctl_flags 619field in the struct sysctlnode contains the sysctl version, node type 620information, and a number of flags. 621The macros 622.Fn SYSCTL_VERS , 623.Fn SYSCTL_TYPE , 624and 625.Fn SYSCTL_FLAGS 626can be used to access the different fields. 627Valid flags are: 628.Bl -column CTLFLAGXPERMANENTXXX 629.It Sy Name Description 630.It CTLFLAG\_READONLY Node is read-only 631.It CTLFLAG\_READWRITE Node is writable by the superuser 632.It CTLFLAG\_ANYWRITE Node is writable by anyone 633.It CTLFLAG\_PRIVATE Node is readable only by the superuser 634.It CTLFLAG\_PERMANENT Node cannot be removed (cannot be set by 635processes) 636.It CTLFLAG\_OWNDATA Node owns data and does not instrument 637existing data 638.It CTLFLAG\_IMMEDIATE Node contains instrumented data and does not 639instrument existing data 640.It CTLFLAG\_HEX Node's contents should be displayed in a hexadecimal 641form 642.It CTLFLAG\_ROOT Node is the root of a tree (cannot be set at 643any time) 644.It CTLFLAG\_ANYNUMBER Node matches any MIB number (cannot be set by 645processes) 646.It CTLFLAG\_HIDDEN Node not displayed by default 647.It CTLFLAG\_ALIAS Node refers to a sibling node (cannot be set 648by processes) 649.It CTLFLAG\_OWNDESC Node owns its own description string space 650.El 651.Sh RETURN VALUES 652If the call to 653.Nm 654is successful, 0 is returned. 655Otherwise \-1 is returned and 656.Va errno 657is set appropriately. 658.Sh FILES 659.Bl -tag -width <netinet6/udp6Xvar.h> -compact 660.It Aq Pa sys/sysctl.h 661definitions for top level identifiers, second level kernel and hardware 662identifiers, and user level identifiers 663.It Aq Pa sys/socket.h 664definitions for second level network identifiers 665.It Aq Pa sys/gmon.h 666definitions for third level profiling identifiers 667.It Aq Pa uvm/uvm_param.h 668definitions for second level virtual memory identifiers 669.It Aq Pa netinet/in.h 670definitions for third level IPv4/v6 identifiers and 671fourth level IPv4/v6 identifiers 672.It Aq Pa netinet/icmp_var.h 673definitions for fourth level ICMP identifiers 674.It Aq Pa netinet/icmp6.h 675definitions for fourth level ICMPv6 identifiers 676.It Aq Pa netinet/tcp_var.h 677definitions for fourth level TCP identifiers 678.It Aq Pa netinet/udp_var.h 679definitions for fourth level UDP identifiers 680.It Aq Pa netinet6/udp6_var.h 681definitions for fourth level IPv6 UDP identifiers 682.It Aq Pa netipsec/ipsec.h 683definitions for fourth level IPsec identifiers 684.It Aq Pa netipsec/key_var.h 685definitions for third level PF_KEY identifiers 686.It Aq Pa machine/cpu.h 687definitions for second level machdep identifiers 688.El 689.Sh ERRORS 690The following errors may be reported: 691.Bl -tag -width Er 692.It Bq Er EFAULT 693The buffer 694.Fa name , 695.Fa oldp , 696.Fa newp , 697or length pointer 698.Fa oldlenp 699contains an invalid address, or the requested value is temporarily 700unavailable. 701.It Bq Er EINVAL 702The 703.Fa name 704array is zero or greater than 705.Dv CTL_MAXNAME ; 706or a non-null 707.Fa newp 708is given and its specified length in 709.Fa newlen 710is too large or too small, or the given value is not acceptable for 711the given node. 712.It Bq Er EISDIR 713The 714.Fa name 715array specifies an intermediate rather than terminal name. 716.It Bq Er ENOENT 717The 718.Fa name 719array specifies a node that does not exist in the tree; 720or an attempt was made to destroy a node that does not exist, or to 721create or destroy a node below a node that does not exist. 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 a node below a node that addresses data. 730.It Bq Er ENOTEMPTY 731An attempt was made to destroy a node that still has children. 732.It Bq Er EOPNOTSUPP 733The 734.Fa name 735array specifies a value that is unknown or a meta-operation was 736attempted that the requested node does not support. 737.It Bq Er EPERM 738An attempt is made to set a read-only value; or 739a process without appropriate privilege attempts to set a value or to 740create or destroy a node; or 741an attempt to change a value protected by the current kernel security 742level is made. 743.El 744.Sh SEE ALSO 745.Xr sysctl 7 , 746.Xr sysctl 8 , 747.Xr secmodel_securelevel 9 748.\" .Xr sysctl 9 749.Sh HISTORY 750The 751.Nm 752function first appeared in 753.Bx 4.4 . 754