sysctl.h (37157B) - Raw
1 /* 2 * Copyright (c) 2000-2021 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 29 /* 30 * Copyright (c) 1989, 1993 31 * The Regents of the University of California. All rights reserved. 32 * 33 * This code is derived from software contributed to Berkeley by 34 * Mike Karels at Berkeley Software Design, Inc. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions 38 * are met: 39 * 1. Redistributions of source code must retain the above copyright 40 * notice, this list of conditions and the following disclaimer. 41 * 2. Redistributions in binary form must reproduce the above copyright 42 * notice, this list of conditions and the following disclaimer in the 43 * documentation and/or other materials provided with the distribution. 44 * 3. All advertising materials mentioning features or use of this software 45 * must display the following acknowledgement: 46 * This product includes software developed by the University of 47 * California, Berkeley and its contributors. 48 * 4. Neither the name of the University nor the names of its contributors 49 * may be used to endorse or promote products derived from this software 50 * without specific prior written permission. 51 * 52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * SUCH DAMAGE. 63 * 64 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 65 */ 66 /* 67 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce 68 * support for mandatory and extensible security protections. This notice 69 * is included in support of clause 2.2 (b) of the Apple Public License, 70 * Version 2.0. 71 */ 72 73 #ifndef _SYS_SYSCTL_H_ 74 #define _SYS_SYSCTL_H_ 75 76 /* 77 * These are for the eproc structure defined below. 78 */ 79 #include <sys/cdefs.h> 80 81 #include <sys/appleapiopts.h> 82 #include <sys/time.h> 83 #include <sys/ucred.h> 84 85 #include <sys/proc.h> 86 #include <sys/vm.h> 87 88 /* 89 * Definitions for sysctl call. The sysctl call uses a hierarchical name 90 * for objects that can be examined or modified. The name is expressed as 91 * a sequence of integers. Like a file path name, the meaning of each 92 * component depends on its place in the hierarchy. The top-level and kern 93 * identifiers are defined here, and other identifiers are defined in the 94 * respective subsystem header files. 95 */ 96 97 #define CTL_MAXNAME 12 /* largest number of components supported */ 98 99 /* 100 * Each subsystem defined by sysctl defines a list of variables 101 * for that subsystem. Each name is either a node with further 102 * levels defined below it, or it is a leaf of some particular 103 * type given below. Each sysctl level defines a set of name/type 104 * pairs to be used by sysctl(1) in manipulating the subsystem. 105 * 106 * When declaring new sysctl names, use the CTLFLAG_LOCKED flag in the 107 * type to indicate that all necessary locking will be handled 108 * within the sysctl. 109 * 110 * Any sysctl defined without CTLFLAG_LOCKED is considered legacy 111 * and will be protected by a global mutex. 112 * 113 * Note: This is not optimal, so it is best to handle locking 114 * yourself, if you are able to do so. A simple design 115 * pattern for use to avoid in a single function known 116 * to potentially be in the paging path ot doing a DMA 117 * to physical memory in a user space process is: 118 * 119 * lock 120 * perform operation vs. local buffer 121 * unlock 122 * SYSCTL_OUT(rey, local buffer, length) 123 * 124 * ...this assumes you are not using a deep call graph 125 * or are unable to pass a local buffer address as a 126 * parameter into your deep call graph. 127 * 128 * Note that very large user buffers can fail the wire 129 * if to do so would require more physical pages than 130 * are available (the caller will get an ENOMEM error, 131 * see sysctl_mem_hold() for details). 132 */ 133 struct ctlname { 134 char *ctl_name; /* subsystem name */ 135 int ctl_type; /* type of name */ 136 }; 137 138 #define CTLTYPE 0xf /* Mask for the type */ 139 #define CTLTYPE_NODE 1 /* name is a node */ 140 #define CTLTYPE_INT 2 /* name describes an integer */ 141 #define CTLTYPE_STRING 3 /* name describes a string */ 142 #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ 143 #define CTLTYPE_OPAQUE 5 /* name describes a structure */ 144 #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ 145 146 #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ 147 #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ 148 #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) 149 #define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */ 150 #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ 151 #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ 152 #define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */ 153 #define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */ 154 #define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */ 155 #define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */ 156 #define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */ 157 #define CTLFLAG_EXPERIMENT 0x00100000 /* Allows writing w/ the trial experiment entitlement. */ 158 159 /* 160 * USE THIS instead of a hardwired number from the categories below 161 * to get dynamically assigned sysctl entries using the linker-set 162 * technology. This is the way nearly all new sysctl variables should 163 * be implemented. 164 * 165 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); 166 * 167 * Note that linker set technology will automatically register all nodes 168 * declared like this on kernel initialization, UNLESS they are defined 169 * in I/O-Kit. In this case, you have to call sysctl_register_oid() 170 * manually - just like in a KEXT. 171 */ 172 #define OID_AUTO (-1) 173 #define OID_AUTO_START 100 /* conventional */ 174 175 176 #define SYSCTL_DEF_ENABLED 177 178 #ifdef SYSCTL_DEF_ENABLED 179 /* 180 * Top-level identifiers 181 */ 182 #define CTL_UNSPEC 0 /* unused */ 183 #define CTL_KERN 1 /* "high kernel": proc, limits */ 184 #define CTL_VM 2 /* virtual memory */ 185 #define CTL_VFS 3 /* file system, mount type is next */ 186 #define CTL_NET 4 /* network, see socket.h */ 187 #define CTL_DEBUG 5 /* debugging parameters */ 188 #define CTL_HW 6 /* generic cpu/io */ 189 #define CTL_MACHDEP 7 /* machine dependent */ 190 #define CTL_USER 8 /* user-level */ 191 #define CTL_MAXID 9 /* number of valid top-level ids */ 192 193 #define CTL_NAMES { \ 194 { 0, 0 }, \ 195 { "kern", CTLTYPE_NODE }, \ 196 { "vm", CTLTYPE_NODE }, \ 197 { "vfs", CTLTYPE_NODE }, \ 198 { "net", CTLTYPE_NODE }, \ 199 { "debug", CTLTYPE_NODE }, \ 200 { "hw", CTLTYPE_NODE }, \ 201 { "machdep", CTLTYPE_NODE }, \ 202 { "user", CTLTYPE_NODE }, \ 203 } 204 205 /* 206 * CTL_KERN identifiers 207 */ 208 #define KERN_OSTYPE 1 /* string: system version */ 209 #define KERN_OSRELEASE 2 /* string: system release */ 210 #define KERN_OSREV 3 /* int: system revision */ 211 #define KERN_VERSION 4 /* string: compile time info */ 212 #define KERN_MAXVNODES 5 /* int: max vnodes */ 213 #define KERN_MAXPROC 6 /* int: max processes */ 214 #define KERN_MAXFILES 7 /* int: max open files */ 215 #define KERN_ARGMAX 8 /* int: max arguments to exec */ 216 #define KERN_SECURELVL 9 /* int: system security level */ 217 #define KERN_HOSTNAME 10 /* string: hostname */ 218 #define KERN_HOSTID 11 /* int: host identifier */ 219 #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ 220 #define KERN_VNODE 13 /* struct: vnode structures */ 221 #define KERN_PROC 14 /* struct: process entries */ 222 #define KERN_FILE 15 /* struct: file entries */ 223 #define KERN_PROF 16 /* node: kernel profiling info */ 224 #define KERN_POSIX1 17 /* int: POSIX.1 version */ 225 #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ 226 #define KERN_JOB_CONTROL 19 /* int: is job control available */ 227 #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ 228 #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ 229 #define KERN_NISDOMAINNAME 22 /* string: YP domain name */ 230 #define KERN_DOMAINNAME KERN_NISDOMAINNAME 231 #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ 232 #define KERN_KDEBUG 24 /* int: kernel trace points */ 233 #define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */ 234 #define KERN_OSRELDATE 26 /* int: OS release date */ 235 #define KERN_NTP_PLL 27 /* node: NTP PLL control */ 236 #define KERN_BOOTFILE 28 /* string: name of booted kernel */ 237 #define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */ 238 #define KERN_MAXPROCPERUID 30 /* int: max processes per uid */ 239 #define KERN_DUMPDEV 31 /* dev_t: device to dump on */ 240 #define KERN_IPC 32 /* node: anything related to IPC */ 241 #define KERN_DUMMY 33 /* unused */ 242 #define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */ 243 #define KERN_USRSTACK32 35 /* int: address of USRSTACK */ 244 #define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */ 245 #define KERN_SYMFILE 37 /* string: kernel symbol filename */ 246 #define KERN_PROCARGS 38 247 /* 39 was KERN_PCSAMPLES... now obsolete */ 248 #define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */ 249 /* 41 was KERN_PANICINFO : panic UI information (deprecated) */ 250 #define KERN_SYSV 42 /* node: System V IPC information */ 251 #define KERN_AFFINITY 43 /* xxx */ 252 #define KERN_TRANSLATE 44 /* xxx */ 253 #define KERN_CLASSIC KERN_TRANSLATE /* XXX backwards compat */ 254 #define KERN_EXEC 45 /* xxx */ 255 #define KERN_CLASSICHANDLER KERN_EXEC /* XXX backwards compatibility */ 256 #define KERN_AIOMAX 46 /* int: max aio requests */ 257 #define KERN_AIOPROCMAX 47 /* int: max aio requests per process */ 258 #define KERN_AIOTHREADS 48 /* int: max aio worker threads */ 259 #ifdef __APPLE_API_UNSTABLE 260 #define KERN_PROCARGS2 49 261 #endif /* __APPLE_API_UNSTABLE */ 262 #define KERN_COREFILE 50 /* string: corefile format string */ 263 #define KERN_COREDUMP 51 /* int: whether to coredump at all */ 264 #define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */ 265 #define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */ 266 #define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */ 267 /* 55 was KERN_PROC_LOW_PRI_IO... now deprecated */ 268 #define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */ 269 #define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */ 270 #define KERN_POSIX 58 /* node: posix tunables */ 271 #define KERN_USRSTACK64 59 /* LP64 user stack query */ 272 #define KERN_NX_PROTECTION 60 /* int: whether no-execute protection is enabled */ 273 #define KERN_TFP 61 /* Task for pid settings */ 274 #define KERN_PROCNAME 62 /* setup process program name(2*MAXCOMLEN) */ 275 #define KERN_THALTSTACK 63 /* for compat with older x86 and does nothing */ 276 #define KERN_SPECULATIVE_READS 64 /* int: whether speculative reads are disabled */ 277 #define KERN_OSVERSION 65 /* for build number i.e. 9A127 */ 278 #define KERN_SAFEBOOT 66 /* are we booted safe? */ 279 /* 67 was KERN_LCTX (login context) */ 280 #define KERN_RAGEVNODE 68 281 #define KERN_TTY 69 /* node: tty settings */ 282 #define KERN_CHECKOPENEVT 70 /* spi: check the VOPENEVT flag on vnodes at open time */ 283 #define KERN_THREADNAME 71 /* set/get thread name */ 284 #define KERN_MAXID 72 /* number of valid kern ids */ 285 /* 286 * Don't add any more sysctls like this. Instead, use the SYSCTL_*() macros 287 * and OID_AUTO. This will have the added benefit of not having to recompile 288 * sysctl(8) to pick up your changes. 289 */ 290 291 292 #if defined(__LP64__) 293 #define KERN_USRSTACK KERN_USRSTACK64 294 #else 295 #define KERN_USRSTACK KERN_USRSTACK32 296 #endif 297 298 299 /* KERN_RAGEVNODE types */ 300 #define KERN_RAGE_PROC 1 301 #define KERN_RAGE_THREAD 2 302 #define KERN_UNRAGE_PROC 3 303 #define KERN_UNRAGE_THREAD 4 304 305 /* KERN_OPENEVT types */ 306 #define KERN_OPENEVT_PROC 1 307 #define KERN_UNOPENEVT_PROC 2 308 309 /* KERN_TFP types */ 310 #define KERN_TFP_POLICY 1 311 312 /* KERN_TFP_POLICY values . All policies allow task port for self */ 313 #define KERN_TFP_POLICY_DENY 0 /* Deny Mode: None allowed except privileged */ 314 #define KERN_TFP_POLICY_DEFAULT 2 /* Default Mode: related ones allowed and upcall authentication */ 315 316 /* KERN_KDEBUG types */ 317 #define KERN_KDEFLAGS 1 318 #define KERN_KDDFLAGS 2 319 #define KERN_KDENABLE 3 320 #define KERN_KDSETBUF 4 321 #define KERN_KDGETBUF 5 322 #define KERN_KDSETUP 6 323 #define KERN_KDREMOVE 7 324 #define KERN_KDSETREG 8 325 #define KERN_KDGETREG 9 326 #define KERN_KDREADTR 10 327 #define KERN_KDPIDTR 11 328 #define KERN_KDTHRMAP 12 329 /* Don't use 13 as it is overloaded with KERN_VNODE */ 330 #define KERN_KDPIDEX 14 331 #define KERN_KDSETRTCDEC 15 /* obsolete */ 332 #define KERN_KDGETENTROPY 16 /* obsolete */ 333 #define KERN_KDWRITETR 17 334 #define KERN_KDWRITEMAP 18 335 #define KERN_KDTEST 19 336 /* 20 unused */ 337 #define KERN_KDREADCURTHRMAP 21 338 #define KERN_KDSET_TYPEFILTER 22 339 #define KERN_KDBUFWAIT 23 340 #define KERN_KDCPUMAP 24 341 #define KERN_KDCPUMAP_EXT 25 342 #define KERN_KDSET_EDM 26 343 #define KERN_KDGET_EDM 27 344 #define KERN_KDWRITETR_V3 28 345 346 #define CTL_KERN_NAMES { \ 347 { 0, 0 }, \ 348 { "ostype", CTLTYPE_STRING }, \ 349 { "osrelease", CTLTYPE_STRING }, \ 350 { "osrevision", CTLTYPE_INT }, \ 351 { "version", CTLTYPE_STRING }, \ 352 { "maxvnodes", CTLTYPE_INT }, \ 353 { "maxproc", CTLTYPE_INT }, \ 354 { "maxfiles", CTLTYPE_INT }, \ 355 { "argmax", CTLTYPE_INT }, \ 356 { "securelevel", CTLTYPE_INT }, \ 357 { "hostname", CTLTYPE_STRING }, \ 358 { "hostid", CTLTYPE_INT }, \ 359 { "clockrate", CTLTYPE_STRUCT }, \ 360 { "vnode", CTLTYPE_STRUCT }, \ 361 { "proc", CTLTYPE_STRUCT }, \ 362 { "file", CTLTYPE_STRUCT }, \ 363 { "profiling", CTLTYPE_NODE }, \ 364 { "posix1version", CTLTYPE_INT }, \ 365 { "ngroups", CTLTYPE_INT }, \ 366 { "job_control", CTLTYPE_INT }, \ 367 { "saved_ids", CTLTYPE_INT }, \ 368 { "boottime", CTLTYPE_STRUCT }, \ 369 { "nisdomainname", CTLTYPE_STRING }, \ 370 { "maxpartitions", CTLTYPE_INT }, \ 371 { "kdebug", CTLTYPE_INT }, \ 372 { "update", CTLTYPE_INT }, \ 373 { "osreldate", CTLTYPE_INT }, \ 374 { "ntp_pll", CTLTYPE_NODE }, \ 375 { "bootfile", CTLTYPE_STRING }, \ 376 { "maxfilesperproc", CTLTYPE_INT }, \ 377 { "maxprocperuid", CTLTYPE_INT }, \ 378 { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \ 379 { "ipc", CTLTYPE_NODE }, \ 380 { "dummy", CTLTYPE_INT }, \ 381 { "dummy", CTLTYPE_INT }, \ 382 { "usrstack", CTLTYPE_INT }, \ 383 { "logsigexit", CTLTYPE_INT }, \ 384 { "symfile",CTLTYPE_STRING },\ 385 { "procargs",CTLTYPE_STRUCT },\ 386 { "dummy", CTLTYPE_INT }, /* deprecated pcsamples */ \ 387 { "netboot", CTLTYPE_INT }, \ 388 { "dummy", CTLTYPE_INT }, /* deprecated: panicinfo */ \ 389 { "sysv", CTLTYPE_NODE }, \ 390 { "dummy", CTLTYPE_INT }, \ 391 { "dummy", CTLTYPE_INT }, \ 392 { "exec", CTLTYPE_NODE }, \ 393 { "aiomax", CTLTYPE_INT }, \ 394 { "aioprocmax", CTLTYPE_INT }, \ 395 { "aiothreads", CTLTYPE_INT }, \ 396 { "procargs2",CTLTYPE_STRUCT }, \ 397 { "corefile",CTLTYPE_STRING }, \ 398 { "coredump", CTLTYPE_INT }, \ 399 { "sugid_coredump", CTLTYPE_INT }, \ 400 { "delayterm", CTLTYPE_INT }, \ 401 { "shreg_private", CTLTYPE_INT }, \ 402 { "proc_low_pri_io", CTLTYPE_INT }, \ 403 { "low_pri_window", CTLTYPE_INT }, \ 404 { "low_pri_delay", CTLTYPE_INT }, \ 405 { "posix", CTLTYPE_NODE }, \ 406 { "usrstack64", CTLTYPE_QUAD }, \ 407 { "nx", CTLTYPE_INT }, \ 408 { "tfp", CTLTYPE_NODE }, \ 409 { "procname", CTLTYPE_STRING }, \ 410 { "threadsigaltstack", CTLTYPE_INT }, \ 411 { "speculative_reads_disabled", CTLTYPE_INT }, \ 412 { "osversion", CTLTYPE_STRING }, \ 413 { "safeboot", CTLTYPE_INT }, \ 414 { "dummy", CTLTYPE_INT }, /* deprecated: lctx */ \ 415 { "rage_vnode", CTLTYPE_INT }, \ 416 { "tty", CTLTYPE_NODE }, \ 417 { "check_openevt", CTLTYPE_INT }, \ 418 { "thread_name", CTLTYPE_STRING } \ 419 } 420 421 /* 422 * CTL_VFS identifiers 423 */ 424 #define CTL_VFS_NAMES { \ 425 { "vfsconf", CTLTYPE_STRUCT } \ 426 } 427 428 /* 429 * KERN_PROC subtypes 430 */ 431 #define KERN_PROC_ALL 0 /* everything */ 432 #define KERN_PROC_PID 1 /* by process id */ 433 #define KERN_PROC_PGRP 2 /* by process group id */ 434 #define KERN_PROC_SESSION 3 /* by session of pid */ 435 #define KERN_PROC_TTY 4 /* by controlling tty */ 436 #define KERN_PROC_UID 5 /* by effective uid */ 437 #define KERN_PROC_RUID 6 /* by real uid */ 438 #define KERN_PROC_LCID 7 /* by login context id */ 439 440 /* 441 * KERN_VFSNSPACE subtypes 442 */ 443 #define KERN_VFSNSPACE_HANDLE_PROC 1 444 #define KERN_VFSNSPACE_UNHANDLE_PROC 2 445 446 /* 447 * KERN_PROC subtype ops return arrays of augmented proc structures: 448 */ 449 450 struct _pcred { 451 char pc_lock[72]; /* opaque content */ 452 struct ucred *pc_ucred; /* Current credentials. */ 453 uid_t p_ruid; /* Real user id. */ 454 uid_t p_svuid; /* Saved effective user id. */ 455 gid_t p_rgid; /* Real group id. */ 456 gid_t p_svgid; /* Saved effective group id. */ 457 int p_refcnt; /* Number of references. */ 458 }; 459 460 struct _ucred { 461 int32_t cr_ref; /* reference count */ 462 uid_t cr_uid; /* effective user id */ 463 short cr_ngroups; /* number of groups */ 464 gid_t cr_groups[NGROUPS]; /* groups */ 465 }; 466 467 struct kinfo_proc { 468 struct extern_proc kp_proc; /* proc structure */ 469 struct eproc { 470 struct proc *e_paddr; /* address of proc */ 471 struct session *e_sess; /* session pointer */ 472 struct _pcred e_pcred; /* process credentials */ 473 struct _ucred e_ucred; /* current credentials */ 474 struct vmspace e_vm; /* address space */ 475 pid_t e_ppid; /* parent process id */ 476 pid_t e_pgid; /* process group id */ 477 short e_jobc; /* job control counter */ 478 dev_t e_tdev; /* controlling tty dev */ 479 pid_t e_tpgid; /* tty process group id */ 480 struct session *e_tsess; /* tty session pointer */ 481 #define WMESGLEN 7 482 char e_wmesg[WMESGLEN + 1]; /* wchan message */ 483 segsz_t e_xsize; /* text size */ 484 short e_xrssize; /* text rss */ 485 short e_xccount; /* text references */ 486 short e_xswrss; 487 int32_t e_flag; 488 #define EPROC_CTTY 0x01 /* controlling tty vnode active */ 489 #define EPROC_SLEADER 0x02 /* session leader */ 490 #define COMAPT_MAXLOGNAME 12 491 char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ 492 int32_t e_spare[4]; 493 } kp_eproc; 494 }; 495 496 497 498 /* 499 * KERN_IPC identifiers 500 */ 501 #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ 502 #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ 503 #define KIPC_SOMAXCONN 3 /* int: max length of connection q */ 504 #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ 505 #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ 506 #define KIPC_MAX_HDR 6 /* int: max total length of headers */ 507 #define KIPC_MAX_DATALEN 7 /* int: max length of data? */ 508 #define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */ 509 #define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */ 510 #define KIPC_SOQLIMITCOMPAT 10 /* int: socket queue limit */ 511 512 /* 513 * CTL_VM identifiers 514 */ 515 #define VM_METER 1 /* struct vmmeter */ 516 #define VM_LOADAVG 2 /* struct loadavg */ 517 /* 518 * Note: "3" was skipped sometime ago and should probably remain unused 519 * to avoid any new entry from being accepted by older kernels... 520 */ 521 #define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/ 522 #define VM_SWAPUSAGE 5 /* total swap usage */ 523 #define VM_MAXID 6 /* number of valid vm ids */ 524 525 #define CTL_VM_NAMES { \ 526 { 0, 0 }, \ 527 { "vmmeter", CTLTYPE_STRUCT }, \ 528 { "loadavg", CTLTYPE_STRUCT }, \ 529 { 0, 0 }, /* placeholder for "3" (see comment above) */ \ 530 { "dummy", CTLTYPE_INT }, \ 531 { "swapusage", CTLTYPE_STRUCT } \ 532 } 533 534 struct xsw_usage { 535 u_int64_t xsu_total; 536 u_int64_t xsu_avail; 537 u_int64_t xsu_used; 538 u_int32_t xsu_pagesize; 539 boolean_t xsu_encrypted; 540 }; 541 542 #ifdef __APPLE_API_PRIVATE 543 /* Load average structure. Use of fixpt_t assume <sys/types.h> in scope. */ 544 /* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */ 545 struct loadavg { 546 fixpt_t ldavg[3]; 547 long fscale; 548 }; 549 extern struct loadavg averunnable; 550 #define LSCALE 1000 /* scaling for "fixed point" arithmetic */ 551 552 #endif /* __APPLE_API_PRIVATE */ 553 554 555 /* 556 * CTL_HW identifiers 557 */ 558 #define HW_MACHINE 1 /* string: machine class (deprecated: use HW_PRODUCT) */ 559 #define HW_MODEL 2 /* string: specific machine model (deprecated: use HW_TARGET) */ 560 #define HW_NCPU 3 /* int: number of cpus */ 561 #define HW_BYTEORDER 4 /* int: machine byte order */ 562 #define HW_PHYSMEM 5 /* int: total memory */ 563 #define HW_USERMEM 6 /* int: non-kernel memory */ 564 #define HW_PAGESIZE 7 /* int: software page size */ 565 #define HW_DISKNAMES 8 /* strings: disk drive names */ 566 #define HW_DISKSTATS 9 /* struct: diskstats[] */ 567 #define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */ 568 #define HW_FLOATINGPT 11 /* int: has HW floating point? */ 569 #define HW_MACHINE_ARCH 12 /* string: machine architecture */ 570 #define HW_VECTORUNIT 13 /* int: has HW vector unit? */ 571 #define HW_BUS_FREQ 14 /* int: Bus Frequency */ 572 #define HW_CPU_FREQ 15 /* int: CPU Frequency */ 573 #define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */ 574 #define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */ 575 #define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */ 576 #define HW_L2SETTINGS 19 /* int: L2 Cache Settings */ 577 #define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */ 578 #define HW_L3SETTINGS 21 /* int: L3 Cache Settings */ 579 #define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */ 580 #define HW_TB_FREQ 23 /* int: Bus Frequency */ 581 #define HW_MEMSIZE 24 /* uint64_t: physical ram size */ 582 #define HW_AVAILCPU 25 /* int: number of available CPUs */ 583 #define HW_TARGET 26 /* string: model identifier */ 584 #define HW_PRODUCT 27 /* string: product identifier */ 585 #define HW_MAXID 28 /* number of valid hw ids */ 586 587 #define CTL_HW_NAMES { \ 588 { 0, 0 }, \ 589 { "machine", CTLTYPE_STRING }, /* Deprecated: use hw.product */ \ 590 { "model", CTLTYPE_STRING }, /* Deprecated: use hw.target */ \ 591 { "ncpu", CTLTYPE_INT }, \ 592 { "byteorder", CTLTYPE_INT }, \ 593 { "physmem", CTLTYPE_INT }, \ 594 { "usermem", CTLTYPE_INT }, \ 595 { "pagesize", CTLTYPE_INT }, \ 596 { "disknames", CTLTYPE_STRUCT }, \ 597 { "diskstats", CTLTYPE_STRUCT }, \ 598 { "epoch", CTLTYPE_INT }, \ 599 { "floatingpoint", CTLTYPE_INT }, \ 600 { "machinearch", CTLTYPE_STRING }, \ 601 { "vectorunit", CTLTYPE_INT }, \ 602 { "busfrequency", CTLTYPE_INT }, \ 603 { "cpufrequency", CTLTYPE_INT }, \ 604 { "cachelinesize", CTLTYPE_INT }, \ 605 { "l1icachesize", CTLTYPE_INT }, \ 606 { "l1dcachesize", CTLTYPE_INT }, \ 607 { "l2settings", CTLTYPE_INT }, \ 608 { "l2cachesize", CTLTYPE_INT }, \ 609 { "l3settings", CTLTYPE_INT }, \ 610 { "l3cachesize", CTLTYPE_INT }, \ 611 { "tbfrequency", CTLTYPE_INT }, \ 612 { "memsize", CTLTYPE_QUAD }, \ 613 { "availcpu", CTLTYPE_INT }, \ 614 { "target", CTLTYPE_STRING }, \ 615 { "product", CTLTYPE_STRING }, \ 616 } 617 618 /* 619 * XXX This information should be moved to the man page. 620 * 621 * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers. 622 * All other parameters are 32 bit numbers. 623 * 624 * hw.memsize - The number of bytes of physical memory in the system. 625 * 626 * hw.ncpu - The maximum number of processors that could be available this boot. 627 * Use this value for sizing of static per processor arrays; i.e. processor load statistics. 628 * 629 * hw.activecpu - The number of processors currently available for executing threads. 630 * Use this number to determine the number threads to create in SMP aware applications. 631 * This number can change when power management modes are changed. 632 * 633 * hw.physicalcpu - The number of physical processors available in the current power management mode. 634 * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot 635 * 636 * hw.logicalcpu - The number of logical processors available in the current power management mode. 637 * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot 638 * 639 * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services. 640 * In general is is better to use mach's or higher level timing services, but this value 641 * is needed to convert the PPC Time Base registers to real time. 642 * 643 * hw.cpufrequency, hw.busfrequency and their min/max versions are deprecated because frequency isn't consistent. 644 * 645 * hw.cpufrequency - (deprecated) These values provide the current, min and max cpu frequency. The min and max are for 646 * hw.cpufrequency_max - (deprecated) all power management modes. The current frequency is the max frequency in the current mode. 647 * hw.cpufrequency_min - (deprecated) All frequencies are in Hz. 648 * 649 * hw.busfrequency - (deprecated) These values provide the current, min and max bus frequency. The min and max are for 650 * hw.busfrequency_max - (deprecated) all power management modes. The current frequency is the max frequency in the current mode. 651 * hw.busfrequency_min - (deprecated) All frequencies are in Hz. 652 * 653 * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h> 654 * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that 655 * the best binary can be chosen, or the best dynamic code generated. They should not be used 656 * to determine if a given processor feature is available. 657 * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector 658 * should not be used to infer features, and only used to name the processors thread architecture. 659 * The values are defined in <mach/machine.h> 660 * 661 * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little. 662 * 663 * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system. 664 * 665 * hw.cachelinesize - Gives the size in bytes of the processor's cache lines. 666 * This value should be use to control the strides of loops that use cache control instructions 667 * like dcbz, dcbt or dcbst. 668 * 669 * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present 670 * hw.l1icachesize - then the selector will return and error. 671 * hw.l2cachesize - 672 * hw.l3cachesize - 673 * 674 * hw.nperflevels - Number of core types in the system. See the parameters below, which can be used to get 675 * - information associated with a specific perf level. 676 * 677 * The following parameters apply to perflevel N, where N is a number between 0 and the number of core types in the system minus one. 678 * perflevel 0 always refers to the highest performance core type in the system. 679 * 680 * hw.perflevelN.physicalcpu - The number of physical processors available in the current power management mode. 681 * hw.perflevelN.physicalcpumax - The maximum number of physical processors that could be available this boot. 682 * hw.perflevelN.logicalcpu - The number of logical processors available in the current power management mode. 683 * hw.perflevelN.logicalcpumax - The maximum number of logical processors that could be available this boot. 684 * 685 * hw.perflevelN.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present 686 * hw.perflevelN.l1icachesize - then the selector will return and error. 687 * hw.perflevelN.l2cachesize - 688 * hw.perflevelN.l3cachesize - 689 * 690 * hw.perflevelN.cpusperl2 - These values provide the number of CPUs of the same type that share L2 and L3 caches. 691 * hw.perflevelN.cpusperl3 - If a cache is not present then the selector will return and error. 692 * 693 * hw.perflevelN.l2perflevels - These values provide a bitmap, where bit number of CPUs of the same type that share L2 and L3 caches. 694 * hw.perflevelN.l3perflevels - If a cache is not present then the selector will return and error. 695 * 696 * hw.packages - Gives the number of processor packages. 697 * 698 * These are the selectors for optional processor features for specific processors. Selectors that return errors are not support 699 * on the system. Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help . 700 * performance. Future versions of these selectors may return larger values as necessary so it is best to test for non zero. 701 * 702 * For PowerPC: 703 * 704 * hw.optional.floatingpoint - Floating Point Instructions 705 * hw.optional.altivec - AltiVec Instructions 706 * hw.optional.graphicsops - Graphics Operations 707 * hw.optional.64bitops - 64-bit Instructions 708 * hw.optional.fsqrt - HW Floating Point Square Root Instruction 709 * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions 710 * hw.optional.dcba - Data Cache Block Allocate Instruction 711 * hw.optional.datastreams - Data Streams Instructions 712 * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form 713 * 714 * For x86 Architecture: 715 * 716 * hw.optional.floatingpoint - Floating Point Instructions 717 * hw.optional.mmx - Original MMX vector instructions 718 * hw.optional.sse - Streaming SIMD Extensions 719 * hw.optional.sse2 - Streaming SIMD Extensions 2 720 * hw.optional.sse3 - Streaming SIMD Extensions 3 721 * hw.optional.supplementalsse3 - Supplemental Streaming SIMD Extensions 3 722 * hw.optional.x86_64 - 64-bit support 723 */ 724 725 726 /* 727 * CTL_USER definitions 728 */ 729 #define USER_CS_PATH 1 /* string: _CS_PATH */ 730 #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ 731 #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ 732 #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ 733 #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ 734 #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ 735 #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ 736 #define USER_LINE_MAX 8 /* int: LINE_MAX */ 737 #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ 738 #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ 739 #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ 740 #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ 741 #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ 742 #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ 743 #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ 744 #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ 745 #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ 746 #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ 747 #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ 748 #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ 749 #define USER_MAXID 21 /* number of valid user ids */ 750 751 #define CTL_USER_NAMES { \ 752 { 0, 0 }, \ 753 { "cs_path", CTLTYPE_STRING }, \ 754 { "bc_base_max", CTLTYPE_INT }, \ 755 { "bc_dim_max", CTLTYPE_INT }, \ 756 { "bc_scale_max", CTLTYPE_INT }, \ 757 { "bc_string_max", CTLTYPE_INT }, \ 758 { "coll_weights_max", CTLTYPE_INT }, \ 759 { "expr_nest_max", CTLTYPE_INT }, \ 760 { "line_max", CTLTYPE_INT }, \ 761 { "re_dup_max", CTLTYPE_INT }, \ 762 { "posix2_version", CTLTYPE_INT }, \ 763 { "posix2_c_bind", CTLTYPE_INT }, \ 764 { "posix2_c_dev", CTLTYPE_INT }, \ 765 { "posix2_char_term", CTLTYPE_INT }, \ 766 { "posix2_fort_dev", CTLTYPE_INT }, \ 767 { "posix2_fort_run", CTLTYPE_INT }, \ 768 { "posix2_localedef", CTLTYPE_INT }, \ 769 { "posix2_sw_dev", CTLTYPE_INT }, \ 770 { "posix2_upe", CTLTYPE_INT }, \ 771 { "stream_max", CTLTYPE_INT }, \ 772 { "tzname_max", CTLTYPE_INT } \ 773 } 774 775 776 777 /* 778 * CTL_DEBUG definitions 779 * 780 * Second level identifier specifies which debug variable. 781 * Third level identifier specifies which stucture component. 782 */ 783 #define CTL_DEBUG_NAME 0 /* string: variable name */ 784 #define CTL_DEBUG_VALUE 1 /* int: variable value */ 785 #define CTL_DEBUG_MAXID 20 786 787 788 #if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 28) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20) 789 #error Use the SYSCTL_*() macros and OID_AUTO instead! 790 #endif 791 792 793 794 __BEGIN_DECLS 795 int sysctl(int *, u_int, void *__sized_by(*oldlenp), size_t *oldlenp, 796 void *__sized_by(newlen), size_t newlen); 797 int sysctlbyname(const char *, void *__sized_by(*oldlenp), size_t *oldlenp, 798 void *__sized_by(newlen), size_t newlen); 799 int sysctlnametomib(const char *, int *__counted_by(*sizep), size_t *sizep); 800 __END_DECLS 801 802 803 804 #endif /* SYSCTL_DEF_ENABLED */ 805 806 807 #endif /* !_SYS_SYSCTL_H_ */