2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved.
35 * This code is derived from software contributed to Berkeley by
36 * Mike Karels at Berkeley Software Design, Inc.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
69 #ifndef _SYS_SYSCTL_H_
70 #define _SYS_SYSCTL_H_
73 * These are for the eproc structure defined below.
75 #include <sys/cdefs.h>
77 #include <sys/appleapiopts.h>
80 #include <sys/ucred.h>
82 #include <libkern/sysctl.h>
87 #ifdef BSD_KERNEL_PRIVATE
88 #include <sys/linker_set.h>
92 * Definitions for sysctl call. The sysctl call uses a hierarchical name
93 * for objects that can be examined or modified. The name is expressed as
94 * a sequence of integers. Like a file path name, the meaning of each
95 * component depends on its place in the hierarchy. The top-level and kern
96 * identifiers are defined here, and other identifiers are defined in the
97 * respective subsystem header files.
100 #define CTL_MAXNAME 12 /* largest number of components supported */
103 * Each subsystem defined by sysctl defines a list of variables
104 * for that subsystem. Each name is either a node with further
105 * levels defined below it, or it is a leaf of some particular
106 * type given below. Each sysctl level defines a set of name/type
107 * pairs to be used by sysctl(1) in manipulating the subsystem.
110 char *ctl_name
; /* subsystem name */
111 int ctl_type
; /* type of name */
114 #define CTLTYPE 0xf /* Mask for the type */
115 #define CTLTYPE_NODE 1 /* name is a node */
116 #define CTLTYPE_INT 2 /* name describes an integer */
117 #define CTLTYPE_STRING 3 /* name describes a string */
118 #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
119 #define CTLTYPE_OPAQUE 5 /* name describes a structure */
120 #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
122 #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
123 #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
124 #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
125 #define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
126 #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
127 #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
128 #define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */
129 #define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */
130 #define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */
133 * USE THIS instead of a hardwired number from the categories below
134 * to get dynamically assigned sysctl entries using the linker-set
135 * technology. This is the way nearly all new sysctl variables should
137 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
139 #define OID_AUTO (-1)
142 #define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \
143 struct sysctl_req *req)
146 * This describes the access space for a sysctl request. This is needed
147 * so that we can use the interface from the kernel or from user-space.
155 int (*oldfunc
)(struct sysctl_req
*, const void *, size_t);
159 int (*newfunc
)(struct sysctl_req
*, void *, size_t);
162 SLIST_HEAD(sysctl_oid_list
, sysctl_oid
);
165 * This describes one "oid" in the MIB tree. Potentially more nodes can
166 * be hidden behind it, expanded by the handler.
169 struct sysctl_oid_list
*oid_parent
;
170 SLIST_ENTRY(sysctl_oid
) oid_link
;
175 const char *oid_name
;
176 int (*oid_handler
) SYSCTL_HANDLER_ARGS
;
180 #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
181 #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
185 int sysctl_handle_int SYSCTL_HANDLER_ARGS
;
186 int sysctl_handle_long SYSCTL_HANDLER_ARGS
;
187 int sysctl_handle_quad SYSCTL_HANDLER_ARGS
;
188 int sysctl_handle_int2quad SYSCTL_HANDLER_ARGS
;
189 /*int sysctl_handle_intptr SYSCTL_HANDLER_ARGS; XXX not implemented */
190 int sysctl_handle_string SYSCTL_HANDLER_ARGS
;
191 int sysctl_handle_opaque SYSCTL_HANDLER_ARGS
;
194 * These functions are used to add/remove an oid from the mib.
196 void sysctl_register_oid(struct sysctl_oid
*oidp
);
197 void sysctl_unregister_oid(struct sysctl_oid
*oidp
);
201 /* Declare an oid to allow child oids to be added to it. */
202 #define SYSCTL_DECL(name) \
203 extern struct sysctl_oid_list sysctl_##name##_children
205 /* This constructs a "raw" MIB oid. */
206 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
207 struct sysctl_oid sysctl_##parent##_##name = { \
208 &sysctl_##parent##_children, { 0 }, \
209 nbr, kind, a1, a2, #name, handler, fmt };
212 /* This constructs a node from which other oids can hang. */
213 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \
214 struct sysctl_oid_list sysctl_##parent##_##name##_children; \
215 SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access, \
216 (void*)&sysctl_##parent##_##name##_children, 0, handler, \
219 /* Oid for a string. len can be 0 to indicate '\0' termination. */
220 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
221 SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \
222 arg, len, sysctl_handle_string, "A", descr)
224 /* Oid for an int. If ptr is NULL, val is returned. */
225 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
226 SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
227 ptr, val, sysctl_handle_int, "I", descr)
229 /* Oid for an unsigned int. If ptr is NULL, val is returned. */
230 #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
231 SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
232 ptr, val, sysctl_handle_int, "IU", descr)
234 /* Oid for a long. The pointer must be non NULL. */
235 #define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \
236 SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
237 ptr, 0, sysctl_handle_long, "L", descr)
239 /* Oid for a quad. The pointer must be non NULL. */
240 #define SYSCTL_QUAD(parent, nbr, name, access, ptr, descr) \
241 SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
242 ptr, 0, sysctl_handle_quad, "Q", descr)
244 /* Oid for a int returned as quad. The pointer must be non NULL. */
245 #define SYSCTL_INT2QUAD(parent, nbr, name, access, ptr, descr) \
246 SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
247 ptr, 0, sysctl_handle_int2quad, "Q", descr)
249 /* Oid for an opaque object. Specified by a pointer and a length. */
250 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
251 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
252 ptr, len, sysctl_handle_opaque, fmt, descr)
254 /* Oid for a struct. Specified by a pointer and a type. */
255 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
256 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
257 ptr, sizeof(struct type), sysctl_handle_opaque, \
260 /* Oid for a procedure. Specified by a pointer and an arg. */
261 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
262 SYSCTL_OID(parent, nbr, name, access, \
263 ptr, arg, handler, fmt, descr)
266 extern struct sysctl_oid_list sysctl__children
;
268 SYSCTL_DECL(_sysctl
);
274 SYSCTL_DECL(_machdep
);
279 #ifdef XNU_KERNEL_PRIVATE
280 #define SYSCTL_DEF_ENABLED
283 #define SYSCTL_DEF_ENABLED
287 #ifdef SYSCTL_DEF_ENABLED
289 * Top-level identifiers
291 #define CTL_UNSPEC 0 /* unused */
292 #define CTL_KERN 1 /* "high kernel": proc, limits */
293 #define CTL_VM 2 /* virtual memory */
294 #define CTL_VFS 3 /* file system, mount type is next */
295 #define CTL_NET 4 /* network, see socket.h */
296 #define CTL_DEBUG 5 /* debugging parameters */
297 #define CTL_HW 6 /* generic cpu/io */
298 #define CTL_MACHDEP 7 /* machine dependent */
299 #define CTL_USER 8 /* user-level */
300 #define CTL_MAXID 9 /* number of valid top-level ids */
302 #define CTL_NAMES { \
304 { "kern", CTLTYPE_NODE }, \
305 { "vm", CTLTYPE_NODE }, \
306 { "vfs", CTLTYPE_NODE }, \
307 { "net", CTLTYPE_NODE }, \
308 { "debug", CTLTYPE_NODE }, \
309 { "hw", CTLTYPE_NODE }, \
310 { "machdep", CTLTYPE_NODE }, \
311 { "user", CTLTYPE_NODE }, \
315 * CTL_KERN identifiers
317 #define KERN_OSTYPE 1 /* string: system version */
318 #define KERN_OSRELEASE 2 /* string: system release */
319 #define KERN_OSREV 3 /* int: system revision */
320 #define KERN_VERSION 4 /* string: compile time info */
321 #define KERN_MAXVNODES 5 /* int: max vnodes */
322 #define KERN_MAXPROC 6 /* int: max processes */
323 #define KERN_MAXFILES 7 /* int: max open files */
324 #define KERN_ARGMAX 8 /* int: max arguments to exec */
325 #define KERN_SECURELVL 9 /* int: system security level */
326 #define KERN_HOSTNAME 10 /* string: hostname */
327 #define KERN_HOSTID 11 /* int: host identifier */
328 #define KERN_CLOCKRATE 12 /* struct: struct clockrate */
329 #define KERN_VNODE 13 /* struct: vnode structures */
330 #define KERN_PROC 14 /* struct: process entries */
331 #define KERN_FILE 15 /* struct: file entries */
332 #define KERN_PROF 16 /* node: kernel profiling info */
333 #define KERN_POSIX1 17 /* int: POSIX.1 version */
334 #define KERN_NGROUPS 18 /* int: # of supplemental group ids */
335 #define KERN_JOB_CONTROL 19 /* int: is job control available */
336 #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
337 #define KERN_BOOTTIME 21 /* struct: time kernel was booted */
338 #define KERN_NISDOMAINNAME 22 /* string: YP domain name */
339 #define KERN_DOMAINNAME KERN_NISDOMAINNAME
340 #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
341 #define KERN_KDEBUG 24 /* int: kernel trace points */
342 #define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */
343 #define KERN_OSRELDATE 26 /* int: OS release date */
344 #define KERN_NTP_PLL 27 /* node: NTP PLL control */
345 #define KERN_BOOTFILE 28 /* string: name of booted kernel */
346 #define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */
347 #define KERN_MAXPROCPERUID 30 /* int: max processes per uid */
348 #define KERN_DUMPDEV 31 /* dev_t: device to dump on */
349 #define KERN_IPC 32 /* node: anything related to IPC */
350 #define KERN_DUMMY 33 /* unused */
351 #define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */
352 #define KERN_USRSTACK32 35 /* int: address of USRSTACK */
353 #define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */
354 #define KERN_SYMFILE 37 /* string: kernel symbol filename */
355 #define KERN_PROCARGS 38
356 #define KERN_PCSAMPLES 39 /* node: pc sampling */
357 #define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */
358 #define KERN_PANICINFO 41 /* node: panic UI information */
359 #define KERN_SYSV 42 /* node: System V IPC information */
360 #define KERN_AFFINITY 43 /* xxx */
361 #define KERN_CLASSIC 44 /* xxx */
362 #define KERN_CLASSICHANDLER 45 /* xxx */
363 #define KERN_AIOMAX 46 /* int: max aio requests */
364 #define KERN_AIOPROCMAX 47 /* int: max aio requests per process */
365 #define KERN_AIOTHREADS 48 /* int: max aio worker threads */
366 #ifdef __APPLE_API_UNSTABLE
367 #define KERN_PROCARGS2 49
368 #endif /* __APPLE_API_UNSTABLE */
369 #define KERN_COREFILE 50 /* string: corefile format string */
370 #define KERN_COREDUMP 51 /* int: whether to coredump at all */
371 #define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */
372 #define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */
373 #define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */
374 #define KERN_PROC_LOW_PRI_IO 55 /* int: set/reset current proc for low priority I/O */
375 #define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */
376 #define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */
377 #define KERN_POSIX 58 /* node: posix tunables */
378 #define KERN_USRSTACK64 59 /* LP64 user stack query */
379 #define KERN_MAXID 60 /* number of valid kern ids */
381 #if defined(__LP64__)
382 #define KERN_USRSTACK KERN_USRSTACK64
384 #define KERN_USRSTACK KERN_USRSTACK32
387 /* KERN_KDEBUG types */
388 #define KERN_KDEFLAGS 1
389 #define KERN_KDDFLAGS 2
390 #define KERN_KDENABLE 3
391 #define KERN_KDSETBUF 4
392 #define KERN_KDGETBUF 5
393 #define KERN_KDSETUP 6
394 #define KERN_KDREMOVE 7
395 #define KERN_KDSETREG 8
396 #define KERN_KDGETREG 9
397 #define KERN_KDREADTR 10
398 #define KERN_KDPIDTR 11
399 #define KERN_KDTHRMAP 12
400 /* Don't use 13 as it is overloaded with KERN_VNODE */
401 #define KERN_KDPIDEX 14
402 #define KERN_KDSETRTCDEC 15
403 #define KERN_KDGETENTROPY 16
405 /* KERN_PCSAMPLES types */
406 #define KERN_PCDISABLE 1
407 #define KERN_PCSETBUF 2
408 #define KERN_PCGETBUF 3
409 #define KERN_PCSETUP 4
410 #define KERN_PCREMOVE 5
411 #define KERN_PCREADBUF 6
412 #define KERN_PCSETREG 7
413 #define KERN_PCCOMM 8
415 /* KERN_PANICINFO types */
416 #define KERN_PANICINFO_MAXSIZE 1 /* quad: panic UI image size limit */
417 #define KERN_PANICINFO_IMAGE 2 /* panic UI in 8-bit kraw format */
420 * KERN_SYSV identifiers
422 #define KSYSV_SHMMAX 1 /* int: max shared memory segment size (bytes) */
423 #define KSYSV_SHMMIN 2 /* int: min shared memory segment size (bytes) */
424 #define KSYSV_SHMMNI 3 /* int: max number of shared memory identifiers */
425 #define KSYSV_SHMSEG 4 /* int: max shared memory segments per process */
426 #define KSYSV_SHMALL 5 /* int: max amount of shared memory (pages) */
427 #define KSYSV_SEMMNI 6 /* int: max num of semaphore identifiers */
428 #define KSYSV_SEMMNS 7 /* int: max num of semaphores in system */
429 #define KSYSV_SEMMNU 8 /* int: max num of undo structures in system */
430 #define KSYSV_SEMMSL 9 /* int: max num of semaphores per id */
431 #define KSYSV_SEMUNE 10 /* int: max num of undo entries per process */
434 #define CTL_KERN_NAMES { \
436 { "ostype", CTLTYPE_STRING }, \
437 { "osrelease", CTLTYPE_STRING }, \
438 { "osrevision", CTLTYPE_INT }, \
439 { "version", CTLTYPE_STRING }, \
440 { "maxvnodes", CTLTYPE_INT }, \
441 { "maxproc", CTLTYPE_INT }, \
442 { "maxfiles", CTLTYPE_INT }, \
443 { "argmax", CTLTYPE_INT }, \
444 { "securelevel", CTLTYPE_INT }, \
445 { "hostname", CTLTYPE_STRING }, \
446 { "hostid", CTLTYPE_INT }, \
447 { "clockrate", CTLTYPE_STRUCT }, \
448 { "vnode", CTLTYPE_STRUCT }, \
449 { "proc", CTLTYPE_STRUCT }, \
450 { "file", CTLTYPE_STRUCT }, \
451 { "profiling", CTLTYPE_NODE }, \
452 { "posix1version", CTLTYPE_INT }, \
453 { "ngroups", CTLTYPE_INT }, \
454 { "job_control", CTLTYPE_INT }, \
455 { "saved_ids", CTLTYPE_INT }, \
456 { "boottime", CTLTYPE_STRUCT }, \
457 { "nisdomainname", CTLTYPE_STRING }, \
458 { "maxpartitions", CTLTYPE_INT }, \
459 { "kdebug", CTLTYPE_INT }, \
460 { "update", CTLTYPE_INT }, \
461 { "osreldate", CTLTYPE_INT }, \
462 { "ntp_pll", CTLTYPE_NODE }, \
463 { "bootfile", CTLTYPE_STRING }, \
464 { "maxfilesperproc", CTLTYPE_INT }, \
465 { "maxprocperuid", CTLTYPE_INT }, \
466 { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
467 { "ipc", CTLTYPE_NODE }, \
468 { "dummy", CTLTYPE_INT }, \
469 { "dummy", CTLTYPE_INT }, \
470 { "usrstack", CTLTYPE_INT }, \
471 { "logsigexit", CTLTYPE_INT }, \
472 { "symfile",CTLTYPE_STRING },\
473 { "procargs",CTLTYPE_STRUCT },\
474 { "pcsamples",CTLTYPE_STRUCT },\
475 { "netboot", CTLTYPE_INT }, \
476 { "panicinfo", CTLTYPE_NODE }, \
477 { "sysv", CTLTYPE_NODE }, \
478 { "dummy", CTLTYPE_INT }, \
479 { "dummy", CTLTYPE_INT }, \
480 { "dummy", CTLTYPE_INT }, \
481 { "aiomax", CTLTYPE_INT }, \
482 { "aioprocmax", CTLTYPE_INT }, \
483 { "aiothreads", CTLTYPE_INT }, \
484 { "procargs2",CTLTYPE_STRUCT }, \
485 { "corefile",CTLTYPE_STRING }, \
486 { "coredump", CTLTYPE_INT }, \
487 { "sugid_coredump", CTLTYPE_INT }, \
488 { "delayterm", CTLTYPE_INT }, \
489 { "shreg_private", CTLTYPE_INT }, \
490 { "proc_low_pri_io", CTLTYPE_INT }, \
491 { "low_pri_window", CTLTYPE_INT }, \
492 { "low_pri_delay", CTLTYPE_INT }, \
493 { "posix", CTLTYPE_NODE } \
497 * CTL_VFS identifiers
499 #define CTL_VFS_NAMES { \
500 { "vfsconf", CTLTYPE_STRUCT } \
506 #define KERN_PROC_ALL 0 /* everything */
507 #define KERN_PROC_PID 1 /* by process id */
508 #define KERN_PROC_PGRP 2 /* by process group id */
509 #define KERN_PROC_SESSION 3 /* by session of pid */
510 #define KERN_PROC_TTY 4 /* by controlling tty */
511 #define KERN_PROC_UID 5 /* by effective uid */
512 #define KERN_PROC_RUID 6 /* by real uid */
515 * KERN_PROC subtype ops return arrays of augmented proc structures:
517 #ifdef __APPLE_API_UNSTABLE
520 char pc_lock
[72]; /* opaque content */
521 struct ucred
*pc_ucred
; /* Current credentials. */
522 uid_t p_ruid
; /* Real user id. */
523 uid_t p_svuid
; /* Saved effective user id. */
524 gid_t p_rgid
; /* Real group id. */
525 gid_t p_svgid
; /* Saved effective group id. */
526 int p_refcnt
; /* Number of references. */
530 int32_t cr_ref
; /* reference count */
531 uid_t cr_uid
; /* effective user id */
532 short cr_ngroups
; /* number of groups */
533 gid_t cr_groups
[NGROUPS
]; /* groups */
537 struct extern_proc kp_proc
; /* proc structure */
539 struct proc
*e_paddr
; /* address of proc */
540 struct session
*e_sess
; /* session pointer */
541 struct _pcred e_pcred
; /* process credentials */
542 struct _ucred e_ucred
; /* current credentials */
543 struct vmspace e_vm
; /* address space */
544 pid_t e_ppid
; /* parent process id */
545 pid_t e_pgid
; /* process group id */
546 short e_jobc
; /* job control counter */
547 dev_t e_tdev
; /* controlling tty dev */
548 pid_t e_tpgid
; /* tty process group id */
549 struct session
*e_tsess
; /* tty session pointer */
551 char e_wmesg
[WMESGLEN
+1]; /* wchan message */
552 segsz_t e_xsize
; /* text size */
553 short e_xrssize
; /* text rss */
554 short e_xccount
; /* text references */
557 #define EPROC_CTTY 0x01 /* controlling tty vnode active */
558 #define EPROC_SLEADER 0x02 /* session leader */
559 #define COMAPT_MAXLOGNAME 12
560 char e_login
[COMAPT_MAXLOGNAME
]; /* short setlogin() name */
565 #ifdef BSD_KERNEL_PRIVATE
566 #include <sys/proc_internal.h>
568 // LP64todo - should this move?
570 /* LP64 version of _pcred. all pointers
571 * grow when we're dealing with a 64-bit process.
572 * WARNING - keep in sync with _pcred
575 #if __DARWIN_ALIGN_NATURAL
576 #pragma options align=natural
580 char pc_lock
[72]; /* opaque content */
581 user_addr_t pc_ucred
; /* Current credentials. */
582 uid_t p_ruid
; /* Real user id. */
583 uid_t p_svuid
; /* Saved effective user id. */
584 gid_t p_rgid
; /* Real group id. */
585 gid_t p_svgid
; /* Saved effective group id. */
586 int p_refcnt
; /* Number of references. */
589 /* LP64 version of kinfo_proc. all pointers
590 * grow when we're dealing with a 64-bit process.
591 * WARNING - keep in sync with kinfo_proc
593 struct user_kinfo_proc
{
594 struct user_extern_proc kp_proc
; /* proc structure */
596 user_addr_t e_paddr
; /* address of proc */
597 user_addr_t e_sess
; /* session pointer */
598 struct user_pcred e_pcred
; /* process credentials */
599 struct _ucred e_ucred
; /* current credentials */
600 struct user_vmspace e_vm
; /* address space */
601 pid_t e_ppid
; /* parent process id */
602 pid_t e_pgid
; /* process group id */
603 short e_jobc
; /* job control counter */
604 dev_t e_tdev
; /* controlling tty dev */
605 pid_t e_tpgid
; /* tty process group id */
606 user_addr_t e_tsess
; /* tty session pointer */
607 char e_wmesg
[WMESGLEN
+1]; /* wchan message */
608 segsz_t e_xsize
; /* text size */
609 short e_xrssize
; /* text rss */
610 short e_xccount
; /* text references */
613 char e_login
[COMAPT_MAXLOGNAME
]; /* short setlogin() name */
618 #if __DARWIN_ALIGN_NATURAL
619 #pragma options align=reset
622 #endif /* BSD_KERNEL_PRIVATE */
624 #endif /* __APPLE_API_UNSTABLE */
627 * KERN_IPC identifiers
629 #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */
630 #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */
631 #define KIPC_SOMAXCONN 3 /* int: max length of connection q */
632 #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */
633 #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */
634 #define KIPC_MAX_HDR 6 /* int: max total length of headers */
635 #define KIPC_MAX_DATALEN 7 /* int: max length of data? */
636 #define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */
637 #define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */
642 #define VM_METER 1 /* struct vmmeter */
643 #define VM_LOADAVG 2 /* struct loadavg */
645 * Note: "3" was skipped sometime ago and should probably remain unused
646 * to avoid any new entry from being accepted by older kernels...
648 #define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/
649 #define VM_SWAPUSAGE 5 /* total swap usage */
650 #define VM_MAXID 6 /* number of valid vm ids */
652 #define CTL_VM_NAMES { \
654 { "vmmeter", CTLTYPE_STRUCT }, \
655 { "loadavg", CTLTYPE_STRUCT }, \
656 { 0, 0 }, /* placeholder for "3" (see comment above) */ \
657 { "machfactor", CTLTYPE_STRUCT }, \
658 { "swapusage", CTLTYPE_STRUCT } \
665 u_int32_t xsu_pagesize
;
666 boolean_t xsu_encrypted
;
669 #ifdef __APPLE_API_PRIVATE
670 /* Load average structure. Use of fixpt_t assume <sys/types.h> in scope. */
671 /* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */
676 extern struct loadavg averunnable
;
677 #define LSCALE 1000 /* scaling for "fixed point" arithmetic */
679 // LP64todo - should this move?
680 #ifdef BSD_KERNEL_PRIVATE
682 #if __DARWIN_ALIGN_NATURAL
683 #pragma options align=natural
685 struct user_loadavg
{
690 #if __DARWIN_ALIGN_NATURAL
691 #pragma options align=reset
694 #endif /* BSD_KERNEL_PRIVATE */
695 #endif /* __APPLE_API_PRIVATE */
701 #define HW_MACHINE 1 /* string: machine class */
702 #define HW_MODEL 2 /* string: specific machine model */
703 #define HW_NCPU 3 /* int: number of cpus */
704 #define HW_BYTEORDER 4 /* int: machine byte order */
705 #define HW_PHYSMEM 5 /* int: total memory */
706 #define HW_USERMEM 6 /* int: non-kernel memory */
707 #define HW_PAGESIZE 7 /* int: software page size */
708 #define HW_DISKNAMES 8 /* strings: disk drive names */
709 #define HW_DISKSTATS 9 /* struct: diskstats[] */
710 #define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */
711 #define HW_FLOATINGPT 11 /* int: has HW floating point? */
712 #define HW_MACHINE_ARCH 12 /* string: machine architecture */
713 #define HW_VECTORUNIT 13 /* int: has HW vector unit? */
714 #define HW_BUS_FREQ 14 /* int: Bus Frequency */
715 #define HW_CPU_FREQ 15 /* int: CPU Frequency */
716 #define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */
717 #define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */
718 #define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */
719 #define HW_L2SETTINGS 19 /* int: L2 Cache Settings */
720 #define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */
721 #define HW_L3SETTINGS 21 /* int: L3 Cache Settings */
722 #define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */
723 #define HW_TB_FREQ 23 /* int: Bus Frequency */
724 #define HW_MEMSIZE 24 /* uint64_t: physical ram size */
725 #define HW_AVAILCPU 25 /* int: number of available CPUs */
726 #define HW_MAXID 26 /* number of valid hw ids */
728 #define CTL_HW_NAMES { \
730 { "machine", CTLTYPE_STRING }, \
731 { "model", CTLTYPE_STRING }, \
732 { "ncpu", CTLTYPE_INT }, \
733 { "byteorder", CTLTYPE_INT }, \
734 { "physmem", CTLTYPE_INT }, \
735 { "usermem", CTLTYPE_INT }, \
736 { "pagesize", CTLTYPE_INT }, \
737 { "disknames", CTLTYPE_STRUCT }, \
738 { "diskstats", CTLTYPE_STRUCT }, \
739 { "epoch", CTLTYPE_INT }, \
740 { "floatingpoint", CTLTYPE_INT }, \
741 { "machinearch", CTLTYPE_STRING }, \
742 { "vectorunit", CTLTYPE_INT }, \
743 { "busfrequency", CTLTYPE_INT }, \
744 { "cpufrequency", CTLTYPE_INT }, \
745 { "cachelinesize", CTLTYPE_INT }, \
746 { "l1icachesize", CTLTYPE_INT }, \
747 { "l1dcachesize", CTLTYPE_INT }, \
748 { "l2settings", CTLTYPE_INT }, \
749 { "l2cachesize", CTLTYPE_INT }, \
750 { "l3settings", CTLTYPE_INT }, \
751 { "l3cachesize", CTLTYPE_INT }, \
752 { "tbfrequency", CTLTYPE_INT }, \
753 { "memsize", CTLTYPE_QUAD }, \
754 { "availcpu", CTLTYPE_INT } \
758 * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers.
759 * All other parameters are 32 bit numbers.
761 * hw.memsize - The number of bytes of physical memory in the system.
763 * hw.ncpu - The maximum number of processors that could be available this boot.
764 * Use this value for sizing of static per processor arrays; i.e. processor load statistics.
766 * hw.activecpu - The number of processors currently available for executing threads.
767 * Use this number to determine the number threads to create in SMP aware applications.
768 * This number can change when power management modes are changed.
770 * hw.physicalcpu - The number of physical processors available in the current power management mode.
771 * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot
773 * hw.logicalcpu - The number of logical processors available in the current power management mode.
774 * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot
776 * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services.
777 * In general is is better to use mach's or higher level timing services, but this value
778 * is needed to convert the PPC Time Base registers to real time.
780 * hw.cpufrequency - These values provide the current, min and max cpu frequency. The min and max are for
781 * hw.cpufrequency_max - all power management modes. The current frequency is the max frequency in the current mode.
782 * hw.cpufrequency_min - All frequencies are in Hz.
784 * hw.busfrequency - These values provide the current, min and max bus frequency. The min and max are for
785 * hw.busfrequency_max - all power management modes. The current frequency is the max frequency in the current mode.
786 * hw.busfrequency_min - All frequencies are in Hz.
788 * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h>
789 * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that
790 * the best binary can be chosen, or the best dynamic code generated. They should not be used
791 * to determine if a given processor feature is available.
792 * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector
793 * should not be used to infer features, and only used to name the processors thread architecture.
794 * The values are defined in <mach/machine.h>
796 * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little.
798 * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system.
800 * hw.cachelinesize - Gives the size in bytes of the processor's cache lines.
801 * This value should be use to control the strides of loops that use cache control instructions
802 * like dcbz, dcbt or dcbst.
804 * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present
805 * hw.l1icachesize - then the selector will return and error.
810 * These are the selectors for optional processor features. Selectors that return errors are not support on the system.
811 * Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help performance.
812 * Future versions of these selectors may return larger values as necessary so it is best to test for non zero.
814 * hw.optional.floatingpoint - Floating Point Instructions
815 * hw.optional.altivec - AltiVec Instructions
816 * hw.optional.graphicsops - Graphics Operations
817 * hw.optional.64bitops - 64-bit Instructions
818 * hw.optional.fsqrt - HW Floating Point Square Root Instruction
819 * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions
820 * hw.optional.dcba - Data Cache Block Allocate Instruction
821 * hw.optional.datastreams - Data Streams Instructions
822 * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form
828 * CTL_USER definitions
830 #define USER_CS_PATH 1 /* string: _CS_PATH */
831 #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
832 #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
833 #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
834 #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
835 #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
836 #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
837 #define USER_LINE_MAX 8 /* int: LINE_MAX */
838 #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
839 #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
840 #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
841 #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
842 #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
843 #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
844 #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
845 #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
846 #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
847 #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
848 #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
849 #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
850 #define USER_MAXID 21 /* number of valid user ids */
852 #define CTL_USER_NAMES { \
854 { "cs_path", CTLTYPE_STRING }, \
855 { "bc_base_max", CTLTYPE_INT }, \
856 { "bc_dim_max", CTLTYPE_INT }, \
857 { "bc_scale_max", CTLTYPE_INT }, \
858 { "bc_string_max", CTLTYPE_INT }, \
859 { "coll_weights_max", CTLTYPE_INT }, \
860 { "expr_nest_max", CTLTYPE_INT }, \
861 { "line_max", CTLTYPE_INT }, \
862 { "re_dup_max", CTLTYPE_INT }, \
863 { "posix2_version", CTLTYPE_INT }, \
864 { "posix2_c_bind", CTLTYPE_INT }, \
865 { "posix2_c_dev", CTLTYPE_INT }, \
866 { "posix2_char_term", CTLTYPE_INT }, \
867 { "posix2_fort_dev", CTLTYPE_INT }, \
868 { "posix2_fort_run", CTLTYPE_INT }, \
869 { "posix2_localedef", CTLTYPE_INT }, \
870 { "posix2_sw_dev", CTLTYPE_INT }, \
871 { "posix2_upe", CTLTYPE_INT }, \
872 { "stream_max", CTLTYPE_INT }, \
873 { "tzname_max", CTLTYPE_INT } \
879 * CTL_DEBUG definitions
881 * Second level identifier specifies which debug variable.
882 * Third level identifier specifies which stucture component.
884 #define CTL_DEBUG_NAME 0 /* string: variable name */
885 #define CTL_DEBUG_VALUE 1 /* int: variable value */
886 #define CTL_DEBUG_MAXID 20
891 * CTL_DEBUG variables.
893 * These are declared as separate variables so that they can be
894 * individually initialized at the location of their associated
895 * variable. The loader prevents multiple use by issuing errors
896 * if a variable is initialized in more than one place. They are
897 * aggregated into an array in debug_sysctl(), so that it can
898 * conveniently locate them when querried. If more debugging
899 * variables are added, they must also be declared here and also
900 * entered into the array.
903 char *debugname
; /* name of debugging variable */
904 int *debugvar
; /* pointer to debugging variable */
906 extern struct ctldebug debug0
, debug1
, debug2
, debug3
, debug4
;
907 extern struct ctldebug debug5
, debug6
, debug7
, debug8
, debug9
;
908 extern struct ctldebug debug10
, debug11
, debug12
, debug13
, debug14
;
909 extern struct ctldebug debug15
, debug16
, debug17
, debug18
, debug19
;
912 #ifdef BSD_KERNEL_PRIVATE
913 extern char machine
[];
914 extern char osrelease
[];
915 extern char ostype
[];
919 void sysctl_register_set(struct linker_set
*lsp
);
920 void sysctl_unregister_set(struct linker_set
*lsp
);
921 void sysctl_mib_init(void);
922 int kernel_sysctl(struct proc
*p
, int *name
, u_int namelen
, void *old
,
923 size_t *oldlenp
, void *newp
, size_t newlen
);
924 int userland_sysctl(struct proc
*p
, int *name
, u_int namelen
, user_addr_t old
,
925 size_t *oldlenp
, int inkernel
, user_addr_t newp
, size_t newlen
,
929 * Internal sysctl function calling convention:
931 * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
933 * The name parameter points at the next component of the name to be
934 * interpreted. The namelen parameter is the number of integers in
937 typedef int (sysctlfn
)
938 (int *, u_int
, user_addr_t
, size_t *, user_addr_t
, size_t, struct proc
*);
940 int sysctl_int(user_addr_t
, size_t *, user_addr_t
, size_t, int *);
941 int sysctl_rdint(user_addr_t
, size_t *, user_addr_t
, int);
942 int sysctl_quad(user_addr_t
, size_t *, user_addr_t
, size_t, quad_t
*);
943 int sysctl_rdquad(void *, size_t *, void *, quad_t
);
944 int sysctl_string(user_addr_t
, size_t *, user_addr_t
, size_t, char *, int);
945 int sysctl_trstring(user_addr_t
, size_t *, user_addr_t
, size_t, char *, int);
946 int sysctl_rdstring(user_addr_t
, size_t *, user_addr_t
, char *);
947 int sysctl_rdstruct(user_addr_t
, size_t *, user_addr_t
, void *, int);
949 #endif /* BSD_KERNEL_PRIVATE */
953 int sysctl(int *, u_int
, void *, size_t *, void *, size_t);
954 int sysctlbyname(const char *, void *, size_t *, void *, size_t);
955 int sysctlnametomib(const char *, int *, size_t *);
961 #endif /* SYSCTL_DEF_ENABLED */
964 #endif /* !_SYS_SYSCTL_H_ */