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