]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
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 | */ | |
2d21ac55 A |
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 | */ | |
1c79356b A |
72 | |
73 | #ifndef _SYS_SYSCTL_H_ | |
74 | #define _SYS_SYSCTL_H_ | |
75 | ||
76 | /* | |
77 | * These are for the eproc structure defined below. | |
78 | */ | |
91447636 A |
79 | #include <sys/cdefs.h> |
80 | ||
9bccf70c | 81 | #include <sys/appleapiopts.h> |
1c79356b A |
82 | #ifndef KERNEL |
83 | #include <sys/time.h> | |
84 | #include <sys/ucred.h> | |
91447636 A |
85 | #else |
86 | #include <libkern/sysctl.h> | |
1c79356b | 87 | #endif |
1c79356b | 88 | #include <sys/proc.h> |
91447636 A |
89 | #include <sys/vm.h> |
90 | ||
2d21ac55 | 91 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 92 | #include <sys/linker_set.h> |
91447636 | 93 | #endif |
1c79356b A |
94 | |
95 | /* | |
96 | * Definitions for sysctl call. The sysctl call uses a hierarchical name | |
97 | * for objects that can be examined or modified. The name is expressed as | |
98 | * a sequence of integers. Like a file path name, the meaning of each | |
99 | * component depends on its place in the hierarchy. The top-level and kern | |
100 | * identifiers are defined here, and other identifiers are defined in the | |
101 | * respective subsystem header files. | |
102 | */ | |
103 | ||
104 | #define CTL_MAXNAME 12 /* largest number of components supported */ | |
105 | ||
106 | /* | |
107 | * Each subsystem defined by sysctl defines a list of variables | |
108 | * for that subsystem. Each name is either a node with further | |
109 | * levels defined below it, or it is a leaf of some particular | |
110 | * type given below. Each sysctl level defines a set of name/type | |
111 | * pairs to be used by sysctl(1) in manipulating the subsystem. | |
2d21ac55 | 112 | * |
6d2010ae A |
113 | * When declaring new sysctl names, unless your sysctl is callable |
114 | * from the paging path, please use the CTLFLAG_LOCKED flag in the | |
115 | * type to indicate that all necessary locking will be handled | |
116 | * within the sysctl. | |
117 | * | |
118 | * Any sysctl defined without CTLFLAG_LOCKED is considered legacy | |
119 | * and will be protected by both wiring the user process pages and, | |
120 | * if it is a 32 bit legacy KEXT, by the obsolete kernel funnel. | |
121 | * | |
122 | * Note: This is not optimal, so it is best to handle locking | |
123 | * yourself, if you are able to do so. A simple design | |
124 | * pattern for use to avoid in a single function known | |
125 | * to potentially be in the paging path ot doing a DMA | |
126 | * to physical memory in a user space process is: | |
127 | * | |
128 | * lock | |
129 | * perform operation vs. local buffer | |
130 | * unlock | |
131 | * SYSCTL_OUT(rey, local buffer, length) | |
132 | * | |
133 | * ...this assumes you are not using a deep call graph | |
134 | * or are unable to pass a local buffer address as a | |
135 | * parameter into your deep call graph. | |
136 | * | |
137 | * Note that very large user buffers can fail the wire | |
138 | * if to do so would require more physical pages than | |
139 | * are available (the caller will get an ENOMEM error, | |
140 | * see sysctl_mem_hold() for details). | |
1c79356b A |
141 | */ |
142 | struct ctlname { | |
143 | char *ctl_name; /* subsystem name */ | |
144 | int ctl_type; /* type of name */ | |
145 | }; | |
146 | ||
147 | #define CTLTYPE 0xf /* Mask for the type */ | |
148 | #define CTLTYPE_NODE 1 /* name is a node */ | |
149 | #define CTLTYPE_INT 2 /* name describes an integer */ | |
150 | #define CTLTYPE_STRING 3 /* name describes a string */ | |
151 | #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ | |
152 | #define CTLTYPE_OPAQUE 5 /* name describes a structure */ | |
153 | #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ | |
154 | ||
155 | #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ | |
156 | #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ | |
157 | #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) | |
158 | #define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */ | |
159 | #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ | |
160 | #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ | |
43866e37 A |
161 | #define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */ |
162 | #define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */ | |
163 | #define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */ | |
6d2010ae A |
164 | #define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */ |
165 | #define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */ | |
1c79356b A |
166 | |
167 | /* | |
168 | * USE THIS instead of a hardwired number from the categories below | |
169 | * to get dynamically assigned sysctl entries using the linker-set | |
170 | * technology. This is the way nearly all new sysctl variables should | |
171 | * be implemented. | |
2d21ac55 | 172 | * |
1c79356b | 173 | * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); |
2d21ac55 A |
174 | * |
175 | * Note that linker set technology will automatically register all nodes | |
176 | * declared like this on kernel initialization, UNLESS they are defined | |
177 | * in I/O-Kit. In this case, you have to call sysctl_register_oid() | |
178 | * manually - just like in a KEXT. | |
179 | */ | |
1c79356b | 180 | #define OID_AUTO (-1) |
2d21ac55 | 181 | #define OID_AUTO_START 100 /* conventional */ |
1c79356b A |
182 | |
183 | #ifdef KERNEL | |
184 | #define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \ | |
185 | struct sysctl_req *req) | |
186 | ||
2d21ac55 | 187 | |
1c79356b A |
188 | /* |
189 | * This describes the access space for a sysctl request. This is needed | |
190 | * so that we can use the interface from the kernel or from user-space. | |
191 | */ | |
192 | struct sysctl_req { | |
193 | struct proc *p; | |
6d2010ae A |
194 | int lock; |
195 | user_addr_t oldptr; /* pointer to user supplied buffer */ | |
196 | size_t oldlen; /* user buffer length (also returned) */ | |
197 | size_t oldidx; /* total data iteratively copied out */ | |
198 | int (*oldfunc)(struct sysctl_req *, const void *, size_t); | |
199 | user_addr_t newptr; /* buffer containing new value */ | |
200 | size_t newlen; /* length of new value */ | |
201 | size_t newidx; /* total data iteratively copied in */ | |
202 | int (*newfunc)(struct sysctl_req *, void *, size_t); | |
1c79356b A |
203 | }; |
204 | ||
205 | SLIST_HEAD(sysctl_oid_list, sysctl_oid); | |
206 | ||
6d2010ae A |
207 | #define SYSCTL_OID_VERSION 1 /* current OID structure version */ |
208 | ||
1c79356b A |
209 | /* |
210 | * This describes one "oid" in the MIB tree. Potentially more nodes can | |
211 | * be hidden behind it, expanded by the handler. | |
6d2010ae A |
212 | * |
213 | * NOTES: We implement binary comparibility between CTLFLAG_OID2 and | |
214 | * pre-CTLFLAG_OID2 structure in sysctl_register_oid() and in | |
215 | * sysctl_unregister_oid() using the fact that the fields up | |
216 | * to oid_fmt are unchanged, and that the field immediately | |
217 | * following is on an alignment boundary following a pointer | |
218 | * type and is also a pointer. This lets us get the previous | |
219 | * size of the structure, and the copy-cut-off point, using | |
220 | * the offsetof() language primitive, and these values are | |
221 | * used in conjunction with the fact that earlier and future | |
222 | * statically compiled sysctl_oid structures are declared via | |
223 | * macros. This lets us overload the macros so that the addition | |
224 | * of the CTLFLAG_OID2 in newly compiled code containing sysctl | |
225 | * node declarations, subsequently allowing us to to avoid | |
226 | * changing the KPI used for non-static (un)registration in | |
227 | * KEXTs. | |
228 | * | |
229 | * This depends on the fact that people declare SYSCTLs, | |
230 | * rather than declaring sysctl_oid structures. All new code | |
231 | * should avoid declaring struct sysctl_oid's directly without | |
232 | * the macros; the current risk for this is limited to losing | |
233 | * your description field and ending up with a malloc'ed copy, | |
234 | * as if it were a legacy binary static declaration via SYSCTL; | |
235 | * in the future, we may deprecate access to a named structure | |
236 | * type in third party code. Use the macros, or our code will | |
237 | * end up with compile errors when that happens. | |
238 | * | |
239 | * Please try to include a long description of the field in any | |
240 | * new sysctl declarations (all the macros support this). This | |
241 | * field may be the only human readable documentation your users | |
242 | * get for your sysctl. | |
1c79356b A |
243 | */ |
244 | struct sysctl_oid { | |
245 | struct sysctl_oid_list *oid_parent; | |
246 | SLIST_ENTRY(sysctl_oid) oid_link; | |
247 | int oid_number; | |
248 | int oid_kind; | |
249 | void *oid_arg1; | |
250 | int oid_arg2; | |
251 | const char *oid_name; | |
252 | int (*oid_handler) SYSCTL_HANDLER_ARGS; | |
253 | const char *oid_fmt; | |
6d2010ae A |
254 | const char *oid_descr; /* offsetof() field / long description */ |
255 | int oid_version; | |
256 | int oid_refcnt; | |
1c79356b A |
257 | }; |
258 | ||
259 | #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) | |
260 | #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) | |
261 | ||
2d21ac55 A |
262 | typedef int (* sysctl_handler_t) SYSCTL_HANDLER_ARGS; |
263 | ||
91447636 A |
264 | __BEGIN_DECLS |
265 | ||
2d21ac55 | 266 | /* old interface */ |
1c79356b A |
267 | int sysctl_handle_int SYSCTL_HANDLER_ARGS; |
268 | int sysctl_handle_long SYSCTL_HANDLER_ARGS; | |
43866e37 A |
269 | int sysctl_handle_quad SYSCTL_HANDLER_ARGS; |
270 | int sysctl_handle_int2quad SYSCTL_HANDLER_ARGS; | |
1c79356b A |
271 | int sysctl_handle_string SYSCTL_HANDLER_ARGS; |
272 | int sysctl_handle_opaque SYSCTL_HANDLER_ARGS; | |
2d21ac55 A |
273 | /* new interface */ |
274 | int sysctl_io_number(struct sysctl_req *req, long long bigValue, size_t valueSize, void *pValue, int *changed); | |
275 | int sysctl_io_string(struct sysctl_req *req, char *pValue, size_t valueSize, int trunc, int *changed); | |
276 | int sysctl_io_opaque(struct sysctl_req *req, void *pValue, size_t valueSize, int *changed); | |
1c79356b A |
277 | |
278 | /* | |
279 | * These functions are used to add/remove an oid from the mib. | |
280 | */ | |
281 | void sysctl_register_oid(struct sysctl_oid *oidp); | |
282 | void sysctl_unregister_oid(struct sysctl_oid *oidp); | |
283 | ||
2d21ac55 A |
284 | /* Not exported */ |
285 | void sysctl_register_fixed(void); | |
286 | ||
91447636 A |
287 | __END_DECLS |
288 | ||
1c79356b A |
289 | /* Declare an oid to allow child oids to be added to it. */ |
290 | #define SYSCTL_DECL(name) \ | |
291 | extern struct sysctl_oid_list sysctl_##name##_children | |
292 | ||
2d21ac55 A |
293 | #ifdef XNU_KERNEL_PRIVATE |
294 | #define SYSCTL_LINKER_SET_ENTRY LINKER_SET_ENTRY | |
295 | #else | |
296 | #define SYSCTL_LINKER_SET_ENTRY(a, b) | |
297 | #endif | |
1c79356b A |
298 | /* This constructs a "raw" MIB oid. */ |
299 | #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | |
2d21ac55 | 300 | struct sysctl_oid sysctl_##parent##_##name = { \ |
1c79356b | 301 | &sysctl_##parent##_children, { 0 }, \ |
39236c6e | 302 | nbr, (int)(kind|CTLFLAG_OID2), a1, (int)(a2), #name, handler, fmt, descr, SYSCTL_OID_VERSION, 0 }; \ |
2d21ac55 | 303 | SYSCTL_LINKER_SET_ENTRY(__sysctl_set, sysctl_##parent##_##name) |
1c79356b A |
304 | |
305 | /* This constructs a node from which other oids can hang. */ | |
306 | #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ | |
307 | struct sysctl_oid_list sysctl_##parent##_##name##_children; \ | |
308 | SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access, \ | |
309 | (void*)&sysctl_##parent##_##name##_children, 0, handler, \ | |
310 | "N", descr); | |
311 | ||
312 | /* Oid for a string. len can be 0 to indicate '\0' termination. */ | |
313 | #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | |
314 | SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \ | |
315 | arg, len, sysctl_handle_string, "A", descr) | |
316 | ||
b0d623f7 A |
317 | #define SYSCTL_COMPAT_INT(parent, nbr, name, access, ptr, val, descr) \ |
318 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
319 | ptr, val, sysctl_handle_int, "I", descr) | |
320 | ||
321 | #define SYSCTL_COMPAT_UINT(parent, nbr, name, access, ptr, val, descr) \ | |
322 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
323 | ptr, val, sysctl_handle_int, "IU", descr) | |
324 | ||
1c79356b A |
325 | /* Oid for an int. If ptr is NULL, val is returned. */ |
326 | #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ | |
327 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
b0d623f7 A |
328 | ptr, val, sysctl_handle_int, "I", descr); \ |
329 | typedef char _sysctl_##parent##_##name##_size_check[(__builtin_constant_p(ptr) || sizeof(*(ptr)) == sizeof(int)) ? 0 : -1]; | |
1c79356b | 330 | |
55e303ae A |
331 | /* Oid for an unsigned int. If ptr is NULL, val is returned. */ |
332 | #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ | |
333 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
b0d623f7 A |
334 | ptr, val, sysctl_handle_int, "IU", descr); \ |
335 | typedef char _sysctl_##parent##_##name##_size_check[(__builtin_constant_p(ptr) || sizeof(*(ptr)) == sizeof(unsigned int)) ? 0 : -1]; | |
55e303ae | 336 | |
1c79356b A |
337 | /* Oid for a long. The pointer must be non NULL. */ |
338 | #define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \ | |
339 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
b0d623f7 A |
340 | ptr, 0, sysctl_handle_long, "L", descr); \ |
341 | typedef char _sysctl_##parent##_##name##_size_check[(__builtin_constant_p(ptr) || sizeof(*(ptr)) == sizeof(long)) ? 0 : -1]; | |
1c79356b | 342 | |
43866e37 A |
343 | /* Oid for a quad. The pointer must be non NULL. */ |
344 | #define SYSCTL_QUAD(parent, nbr, name, access, ptr, descr) \ | |
345 | SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \ | |
b0d623f7 A |
346 | ptr, 0, sysctl_handle_quad, "Q", descr); \ |
347 | typedef char _sysctl_##parent##_##name##_size_check[(__builtin_constant_p(ptr) || sizeof(*(ptr)) == sizeof(long long)) ? 0 : -1]; | |
43866e37 | 348 | |
1c79356b A |
349 | /* Oid for an opaque object. Specified by a pointer and a length. */ |
350 | #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ | |
351 | SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \ | |
352 | ptr, len, sysctl_handle_opaque, fmt, descr) | |
353 | ||
354 | /* Oid for a struct. Specified by a pointer and a type. */ | |
355 | #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ | |
356 | SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \ | |
357 | ptr, sizeof(struct type), sysctl_handle_opaque, \ | |
358 | "S," #type, descr) | |
359 | ||
360 | /* Oid for a procedure. Specified by a pointer and an arg. */ | |
361 | #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | |
362 | SYSCTL_OID(parent, nbr, name, access, \ | |
363 | ptr, arg, handler, fmt, descr) | |
91447636 A |
364 | |
365 | ||
366 | extern struct sysctl_oid_list sysctl__children; | |
367 | SYSCTL_DECL(_kern); | |
368 | SYSCTL_DECL(_sysctl); | |
369 | SYSCTL_DECL(_vm); | |
370 | SYSCTL_DECL(_vfs); | |
371 | SYSCTL_DECL(_net); | |
372 | SYSCTL_DECL(_debug); | |
373 | SYSCTL_DECL(_hw); | |
374 | SYSCTL_DECL(_machdep); | |
375 | SYSCTL_DECL(_user); | |
376 | ||
1c79356b A |
377 | #endif /* KERNEL */ |
378 | ||
91447636 A |
379 | #ifdef XNU_KERNEL_PRIVATE |
380 | #define SYSCTL_DEF_ENABLED | |
381 | #else | |
382 | #ifndef KERNEL | |
383 | #define SYSCTL_DEF_ENABLED | |
384 | #endif | |
385 | #endif | |
386 | ||
387 | #ifdef SYSCTL_DEF_ENABLED | |
1c79356b A |
388 | /* |
389 | * Top-level identifiers | |
390 | */ | |
391 | #define CTL_UNSPEC 0 /* unused */ | |
392 | #define CTL_KERN 1 /* "high kernel": proc, limits */ | |
393 | #define CTL_VM 2 /* virtual memory */ | |
394 | #define CTL_VFS 3 /* file system, mount type is next */ | |
395 | #define CTL_NET 4 /* network, see socket.h */ | |
396 | #define CTL_DEBUG 5 /* debugging parameters */ | |
397 | #define CTL_HW 6 /* generic cpu/io */ | |
398 | #define CTL_MACHDEP 7 /* machine dependent */ | |
399 | #define CTL_USER 8 /* user-level */ | |
400 | #define CTL_MAXID 9 /* number of valid top-level ids */ | |
401 | ||
402 | #define CTL_NAMES { \ | |
403 | { 0, 0 }, \ | |
404 | { "kern", CTLTYPE_NODE }, \ | |
405 | { "vm", CTLTYPE_NODE }, \ | |
406 | { "vfs", CTLTYPE_NODE }, \ | |
407 | { "net", CTLTYPE_NODE }, \ | |
408 | { "debug", CTLTYPE_NODE }, \ | |
409 | { "hw", CTLTYPE_NODE }, \ | |
410 | { "machdep", CTLTYPE_NODE }, \ | |
411 | { "user", CTLTYPE_NODE }, \ | |
412 | } | |
413 | ||
414 | /* | |
415 | * CTL_KERN identifiers | |
416 | */ | |
417 | #define KERN_OSTYPE 1 /* string: system version */ | |
418 | #define KERN_OSRELEASE 2 /* string: system release */ | |
419 | #define KERN_OSREV 3 /* int: system revision */ | |
420 | #define KERN_VERSION 4 /* string: compile time info */ | |
421 | #define KERN_MAXVNODES 5 /* int: max vnodes */ | |
422 | #define KERN_MAXPROC 6 /* int: max processes */ | |
423 | #define KERN_MAXFILES 7 /* int: max open files */ | |
424 | #define KERN_ARGMAX 8 /* int: max arguments to exec */ | |
425 | #define KERN_SECURELVL 9 /* int: system security level */ | |
426 | #define KERN_HOSTNAME 10 /* string: hostname */ | |
427 | #define KERN_HOSTID 11 /* int: host identifier */ | |
428 | #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ | |
429 | #define KERN_VNODE 13 /* struct: vnode structures */ | |
430 | #define KERN_PROC 14 /* struct: process entries */ | |
431 | #define KERN_FILE 15 /* struct: file entries */ | |
432 | #define KERN_PROF 16 /* node: kernel profiling info */ | |
433 | #define KERN_POSIX1 17 /* int: POSIX.1 version */ | |
434 | #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ | |
435 | #define KERN_JOB_CONTROL 19 /* int: is job control available */ | |
436 | #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ | |
437 | #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ | |
438 | #define KERN_NISDOMAINNAME 22 /* string: YP domain name */ | |
439 | #define KERN_DOMAINNAME KERN_NISDOMAINNAME | |
440 | #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ | |
55e303ae | 441 | #define KERN_KDEBUG 24 /* int: kernel trace points */ |
1c79356b A |
442 | #define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */ |
443 | #define KERN_OSRELDATE 26 /* int: OS release date */ | |
444 | #define KERN_NTP_PLL 27 /* node: NTP PLL control */ | |
445 | #define KERN_BOOTFILE 28 /* string: name of booted kernel */ | |
446 | #define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */ | |
447 | #define KERN_MAXPROCPERUID 30 /* int: max processes per uid */ | |
448 | #define KERN_DUMPDEV 31 /* dev_t: device to dump on */ | |
91447636 A |
449 | #define KERN_IPC 32 /* node: anything related to IPC */ |
450 | #define KERN_DUMMY 33 /* unused */ | |
451 | #define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */ | |
452 | #define KERN_USRSTACK32 35 /* int: address of USRSTACK */ | |
453 | #define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */ | |
1c79356b A |
454 | #define KERN_SYMFILE 37 /* string: kernel symbol filename */ |
455 | #define KERN_PROCARGS 38 | |
2d21ac55 | 456 | /* 39 was KERN_PCSAMPLES... now deprecated */ |
9bccf70c | 457 | #define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */ |
39236c6e | 458 | /* 41 was KERN_PANICINFO : panic UI information (deprecated) */ |
91447636 | 459 | #define KERN_SYSV 42 /* node: System V IPC information */ |
55e303ae | 460 | #define KERN_AFFINITY 43 /* xxx */ |
0c530ab8 A |
461 | #define KERN_TRANSLATE 44 /* xxx */ |
462 | #define KERN_CLASSIC KERN_TRANSLATE /* XXX backwards compat */ | |
463 | #define KERN_EXEC 45 /* xxx */ | |
464 | #define KERN_CLASSICHANDLER KERN_EXEC /* XXX backwards compatibility */ | |
91447636 | 465 | #define KERN_AIOMAX 46 /* int: max aio requests */ |
55e303ae A |
466 | #define KERN_AIOPROCMAX 47 /* int: max aio requests per process */ |
467 | #define KERN_AIOTHREADS 48 /* int: max aio worker threads */ | |
468 | #ifdef __APPLE_API_UNSTABLE | |
e5568f75 | 469 | #define KERN_PROCARGS2 49 |
55e303ae | 470 | #endif /* __APPLE_API_UNSTABLE */ |
e5568f75 A |
471 | #define KERN_COREFILE 50 /* string: corefile format string */ |
472 | #define KERN_COREDUMP 51 /* int: whether to coredump at all */ | |
473 | #define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */ | |
91447636 A |
474 | #define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */ |
475 | #define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */ | |
b0d623f7 | 476 | /* 55 was KERN_PROC_LOW_PRI_IO... now deprecated */ |
91447636 A |
477 | #define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */ |
478 | #define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */ | |
479 | #define KERN_POSIX 58 /* node: posix tunables */ | |
0c530ab8 A |
480 | #define KERN_USRSTACK64 59 /* LP64 user stack query */ |
481 | #define KERN_NX_PROTECTION 60 /* int: whether no-execute protection is enabled */ | |
482 | #define KERN_TFP 61 /* Task for pid settings */ | |
483 | #define KERN_PROCNAME 62 /* setup process program name(2*MAXCOMLEN) */ | |
2d21ac55 A |
484 | #define KERN_THALTSTACK 63 /* for compat with older x86 and does nothing */ |
485 | #define KERN_SPECULATIVE_READS 64 /* int: whether speculative reads are disabled */ | |
486 | #define KERN_OSVERSION 65 /* for build number i.e. 9A127 */ | |
487 | #define KERN_SAFEBOOT 66 /* are we booted safe? */ | |
488 | #define KERN_LCTX 67 /* node: login context */ | |
489 | #define KERN_RAGEVNODE 68 | |
490 | #define KERN_TTY 69 /* node: tty settings */ | |
491 | #define KERN_CHECKOPENEVT 70 /* spi: check the VOPENEVT flag on vnodes at open time */ | |
b0d623f7 A |
492 | #define KERN_THREADNAME 71 /* set/get thread name */ |
493 | #define KERN_MAXID 72 /* number of valid kern ids */ | |
2d21ac55 A |
494 | /* |
495 | * Don't add any more sysctls like this. Instead, use the SYSCTL_*() macros | |
496 | * and OID_AUTO. This will have the added benefit of not having to recompile | |
497 | * sysctl(8) to pick up your changes. | |
498 | */ | |
499 | ||
500 | #if COUNT_SYSCALLS && defined(KERNEL) | |
501 | #define KERN_COUNT_SYSCALLS (KERN_OSTYPE + 1000) /* keep called count for each bsd syscall */ | |
502 | #endif | |
91447636 A |
503 | |
504 | #if defined(__LP64__) | |
505 | #define KERN_USRSTACK KERN_USRSTACK64 | |
506 | #else | |
507 | #define KERN_USRSTACK KERN_USRSTACK32 | |
508 | #endif | |
1c79356b | 509 | |
2d21ac55 A |
510 | |
511 | /* KERN_RAGEVNODE types */ | |
512 | #define KERN_RAGE_PROC 1 | |
513 | #define KERN_RAGE_THREAD 2 | |
514 | #define KERN_UNRAGE_PROC 3 | |
515 | #define KERN_UNRAGE_THREAD 4 | |
516 | ||
517 | /* KERN_OPENEVT types */ | |
518 | #define KERN_OPENEVT_PROC 1 | |
519 | #define KERN_UNOPENEVT_PROC 2 | |
520 | ||
0c530ab8 A |
521 | /* KERN_TFP types */ |
522 | #define KERN_TFP_POLICY 1 | |
0c530ab8 A |
523 | |
524 | /* KERN_TFP_POLICY values . All policies allow task port for self */ | |
525 | #define KERN_TFP_POLICY_DENY 0 /* Deny Mode: None allowed except privileged */ | |
2d21ac55 | 526 | #define KERN_TFP_POLICY_DEFAULT 2 /* Default Mode: related ones allowed and upcall authentication */ |
0c530ab8 | 527 | |
1c79356b A |
528 | /* KERN_KDEBUG types */ |
529 | #define KERN_KDEFLAGS 1 | |
530 | #define KERN_KDDFLAGS 2 | |
531 | #define KERN_KDENABLE 3 | |
532 | #define KERN_KDSETBUF 4 | |
533 | #define KERN_KDGETBUF 5 | |
534 | #define KERN_KDSETUP 6 | |
535 | #define KERN_KDREMOVE 7 | |
536 | #define KERN_KDSETREG 8 | |
537 | #define KERN_KDGETREG 9 | |
538 | #define KERN_KDREADTR 10 | |
39236c6e | 539 | #define KERN_KDPIDTR 11 |
1c79356b A |
540 | #define KERN_KDTHRMAP 12 |
541 | /* Don't use 13 as it is overloaded with KERN_VNODE */ | |
542 | #define KERN_KDPIDEX 14 | |
543 | #define KERN_KDSETRTCDEC 15 | |
9bccf70c | 544 | #define KERN_KDGETENTROPY 16 |
6d2010ae A |
545 | #define KERN_KDWRITETR 17 |
546 | #define KERN_KDWRITEMAP 18 | |
316670eb A |
547 | #define KERN_KDENABLE_BG_TRACE 19 |
548 | #define KERN_KDDISABLE_BG_TRACE 20 | |
39236c6e | 549 | #define KERN_KDREADCURTHRMAP 21 |
316670eb | 550 | #define KERN_KDSET_TYPEFILTER 22 |
39236c6e A |
551 | #define KERN_KDBUFWAIT 23 |
552 | #define KERN_KDCPUMAP 24 | |
9bccf70c | 553 | |
1c79356b A |
554 | #define CTL_KERN_NAMES { \ |
555 | { 0, 0 }, \ | |
556 | { "ostype", CTLTYPE_STRING }, \ | |
557 | { "osrelease", CTLTYPE_STRING }, \ | |
558 | { "osrevision", CTLTYPE_INT }, \ | |
559 | { "version", CTLTYPE_STRING }, \ | |
560 | { "maxvnodes", CTLTYPE_INT }, \ | |
561 | { "maxproc", CTLTYPE_INT }, \ | |
562 | { "maxfiles", CTLTYPE_INT }, \ | |
563 | { "argmax", CTLTYPE_INT }, \ | |
564 | { "securelevel", CTLTYPE_INT }, \ | |
565 | { "hostname", CTLTYPE_STRING }, \ | |
566 | { "hostid", CTLTYPE_INT }, \ | |
567 | { "clockrate", CTLTYPE_STRUCT }, \ | |
568 | { "vnode", CTLTYPE_STRUCT }, \ | |
569 | { "proc", CTLTYPE_STRUCT }, \ | |
570 | { "file", CTLTYPE_STRUCT }, \ | |
571 | { "profiling", CTLTYPE_NODE }, \ | |
572 | { "posix1version", CTLTYPE_INT }, \ | |
573 | { "ngroups", CTLTYPE_INT }, \ | |
574 | { "job_control", CTLTYPE_INT }, \ | |
575 | { "saved_ids", CTLTYPE_INT }, \ | |
576 | { "boottime", CTLTYPE_STRUCT }, \ | |
577 | { "nisdomainname", CTLTYPE_STRING }, \ | |
578 | { "maxpartitions", CTLTYPE_INT }, \ | |
579 | { "kdebug", CTLTYPE_INT }, \ | |
580 | { "update", CTLTYPE_INT }, \ | |
581 | { "osreldate", CTLTYPE_INT }, \ | |
9bccf70c | 582 | { "ntp_pll", CTLTYPE_NODE }, \ |
1c79356b A |
583 | { "bootfile", CTLTYPE_STRING }, \ |
584 | { "maxfilesperproc", CTLTYPE_INT }, \ | |
585 | { "maxprocperuid", CTLTYPE_INT }, \ | |
586 | { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \ | |
587 | { "ipc", CTLTYPE_NODE }, \ | |
588 | { "dummy", CTLTYPE_INT }, \ | |
91447636 | 589 | { "dummy", CTLTYPE_INT }, \ |
1c79356b A |
590 | { "usrstack", CTLTYPE_INT }, \ |
591 | { "logsigexit", CTLTYPE_INT }, \ | |
9bccf70c A |
592 | { "symfile",CTLTYPE_STRING },\ |
593 | { "procargs",CTLTYPE_STRUCT },\ | |
2d21ac55 | 594 | { "dummy", CTLTYPE_INT }, /* deprecated pcsamples */ \ |
9bccf70c | 595 | { "netboot", CTLTYPE_INT }, \ |
39236c6e | 596 | { "dummy", CTLTYPE_INT }, /* deprecated: panicinfo */ \ |
55e303ae A |
597 | { "sysv", CTLTYPE_NODE }, \ |
598 | { "dummy", CTLTYPE_INT }, \ | |
599 | { "dummy", CTLTYPE_INT }, \ | |
0c530ab8 | 600 | { "exec", CTLTYPE_NODE }, \ |
55e303ae A |
601 | { "aiomax", CTLTYPE_INT }, \ |
602 | { "aioprocmax", CTLTYPE_INT }, \ | |
603 | { "aiothreads", CTLTYPE_INT }, \ | |
e5568f75 A |
604 | { "procargs2",CTLTYPE_STRUCT }, \ |
605 | { "corefile",CTLTYPE_STRING }, \ | |
606 | { "coredump", CTLTYPE_INT }, \ | |
91447636 A |
607 | { "sugid_coredump", CTLTYPE_INT }, \ |
608 | { "delayterm", CTLTYPE_INT }, \ | |
609 | { "shreg_private", CTLTYPE_INT }, \ | |
610 | { "proc_low_pri_io", CTLTYPE_INT }, \ | |
611 | { "low_pri_window", CTLTYPE_INT }, \ | |
612 | { "low_pri_delay", CTLTYPE_INT }, \ | |
0c530ab8 A |
613 | { "posix", CTLTYPE_NODE }, \ |
614 | { "usrstack64", CTLTYPE_QUAD }, \ | |
615 | { "nx", CTLTYPE_INT }, \ | |
616 | { "tfp", CTLTYPE_NODE }, \ | |
617 | { "procname", CTLTYPE_STRING }, \ | |
2d21ac55 A |
618 | { "threadsigaltstack", CTLTYPE_INT }, \ |
619 | { "speculative_reads_disabled", CTLTYPE_INT }, \ | |
620 | { "osversion", CTLTYPE_STRING }, \ | |
621 | { "safeboot", CTLTYPE_INT }, \ | |
622 | { "lctx", CTLTYPE_NODE }, \ | |
623 | { "rage_vnode", CTLTYPE_INT }, \ | |
624 | { "tty", CTLTYPE_NODE }, \ | |
b0d623f7 A |
625 | { "check_openevt", CTLTYPE_INT }, \ |
626 | { "thread_name", CTLTYPE_STRING } \ | |
1c79356b A |
627 | } |
628 | ||
629 | /* | |
630 | * CTL_VFS identifiers | |
631 | */ | |
632 | #define CTL_VFS_NAMES { \ | |
9bccf70c | 633 | { "vfsconf", CTLTYPE_STRUCT } \ |
1c79356b A |
634 | } |
635 | ||
636 | /* | |
637 | * KERN_PROC subtypes | |
638 | */ | |
639 | #define KERN_PROC_ALL 0 /* everything */ | |
640 | #define KERN_PROC_PID 1 /* by process id */ | |
641 | #define KERN_PROC_PGRP 2 /* by process group id */ | |
642 | #define KERN_PROC_SESSION 3 /* by session of pid */ | |
643 | #define KERN_PROC_TTY 4 /* by controlling tty */ | |
644 | #define KERN_PROC_UID 5 /* by effective uid */ | |
645 | #define KERN_PROC_RUID 6 /* by real uid */ | |
2d21ac55 A |
646 | #define KERN_PROC_LCID 7 /* by login context id */ |
647 | ||
648 | /* | |
649 | * KERN_LCTX subtypes | |
650 | */ | |
651 | #define KERN_LCTX_ALL 0 /* everything */ | |
652 | #define KERN_LCTX_LCID 1 /* by login context id */ | |
1c79356b | 653 | |
b0d623f7 A |
654 | |
655 | #if defined(XNU_KERNEL_PRIVATE) || !defined(KERNEL) | |
1c79356b A |
656 | /* |
657 | * KERN_PROC subtype ops return arrays of augmented proc structures: | |
658 | */ | |
91447636 A |
659 | |
660 | struct _pcred { | |
661 | char pc_lock[72]; /* opaque content */ | |
662 | struct ucred *pc_ucred; /* Current credentials. */ | |
663 | uid_t p_ruid; /* Real user id. */ | |
664 | uid_t p_svuid; /* Saved effective user id. */ | |
665 | gid_t p_rgid; /* Real group id. */ | |
666 | gid_t p_svgid; /* Saved effective group id. */ | |
667 | int p_refcnt; /* Number of references. */ | |
668 | }; | |
669 | ||
670 | struct _ucred { | |
671 | int32_t cr_ref; /* reference count */ | |
672 | uid_t cr_uid; /* effective user id */ | |
673 | short cr_ngroups; /* number of groups */ | |
674 | gid_t cr_groups[NGROUPS]; /* groups */ | |
675 | }; | |
676 | ||
1c79356b A |
677 | struct kinfo_proc { |
678 | struct extern_proc kp_proc; /* proc structure */ | |
679 | struct eproc { | |
680 | struct proc *e_paddr; /* address of proc */ | |
681 | struct session *e_sess; /* session pointer */ | |
91447636 A |
682 | struct _pcred e_pcred; /* process credentials */ |
683 | struct _ucred e_ucred; /* current credentials */ | |
9bccf70c | 684 | struct vmspace e_vm; /* address space */ |
1c79356b A |
685 | pid_t e_ppid; /* parent process id */ |
686 | pid_t e_pgid; /* process group id */ | |
687 | short e_jobc; /* job control counter */ | |
688 | dev_t e_tdev; /* controlling tty dev */ | |
689 | pid_t e_tpgid; /* tty process group id */ | |
690 | struct session *e_tsess; /* tty session pointer */ | |
691 | #define WMESGLEN 7 | |
692 | char e_wmesg[WMESGLEN+1]; /* wchan message */ | |
693 | segsz_t e_xsize; /* text size */ | |
694 | short e_xrssize; /* text rss */ | |
695 | short e_xccount; /* text references */ | |
696 | short e_xswrss; | |
91447636 | 697 | int32_t e_flag; |
1c79356b A |
698 | #define EPROC_CTTY 0x01 /* controlling tty vnode active */ |
699 | #define EPROC_SLEADER 0x02 /* session leader */ | |
9bccf70c A |
700 | #define COMAPT_MAXLOGNAME 12 |
701 | char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ | |
2d21ac55 A |
702 | #if CONFIG_LCTX |
703 | pid_t e_lcid; | |
704 | int32_t e_spare[3]; | |
705 | #else | |
91447636 | 706 | int32_t e_spare[4]; |
2d21ac55 | 707 | #endif |
1c79356b A |
708 | } kp_eproc; |
709 | }; | |
91447636 | 710 | |
2d21ac55 A |
711 | struct kinfo_lctx { |
712 | pid_t id; /* Login Context ID */ | |
713 | int mc; /* Member Count */ | |
714 | }; | |
715 | ||
b0d623f7 A |
716 | #endif /* defined(XNU_KERNEL_PRIVATE) || !defined(KERNEL) */ |
717 | ||
91447636 A |
718 | #ifdef BSD_KERNEL_PRIVATE |
719 | #include <sys/proc_internal.h> | |
720 | ||
91447636 A |
721 | /* LP64 version of _pcred. all pointers |
722 | * grow when we're dealing with a 64-bit process. | |
723 | * WARNING - keep in sync with _pcred | |
724 | */ | |
725 | ||
b0d623f7 A |
726 | struct user32_pcred { |
727 | char pc_lock[72]; /* opaque content */ | |
728 | user32_addr_t pc_ucred; /* Current credentials. */ | |
729 | uid_t p_ruid; /* Real user id. */ | |
730 | uid_t p_svuid; /* Saved effective user id. */ | |
731 | gid_t p_rgid; /* Real group id. */ | |
732 | gid_t p_svgid; /* Saved effective group id. */ | |
733 | int p_refcnt; /* Number of references. */ | |
734 | }; | |
735 | struct user64_pcred { | |
91447636 | 736 | char pc_lock[72]; /* opaque content */ |
b0d623f7 | 737 | user64_addr_t pc_ucred; /* Current credentials. */ |
91447636 A |
738 | uid_t p_ruid; /* Real user id. */ |
739 | uid_t p_svuid; /* Saved effective user id. */ | |
740 | gid_t p_rgid; /* Real group id. */ | |
741 | gid_t p_svgid; /* Saved effective group id. */ | |
b0d623f7 | 742 | int p_refcnt; /* Number of references. */ |
91447636 A |
743 | }; |
744 | ||
745 | /* LP64 version of kinfo_proc. all pointers | |
746 | * grow when we're dealing with a 64-bit process. | |
747 | * WARNING - keep in sync with kinfo_proc | |
748 | */ | |
b0d623f7 A |
749 | struct user32_kinfo_proc { |
750 | struct user32_extern_proc kp_proc; /* proc structure */ | |
751 | struct user32_eproc { | |
752 | user32_addr_t e_paddr; /* address of proc */ | |
753 | user32_addr_t e_sess; /* session pointer */ | |
754 | struct user32_pcred e_pcred; /* process credentials */ | |
755 | struct _ucred e_ucred; /* current credentials */ | |
756 | struct user32_vmspace e_vm; /* address space */ | |
757 | pid_t e_ppid; /* parent process id */ | |
758 | pid_t e_pgid; /* process group id */ | |
759 | short e_jobc; /* job control counter */ | |
760 | dev_t e_tdev; /* controlling tty dev */ | |
761 | pid_t e_tpgid; /* tty process group id */ | |
762 | user32_addr_t e_tsess; /* tty session pointer */ | |
763 | char e_wmesg[WMESGLEN+1]; /* wchan message */ | |
764 | segsz_t e_xsize; /* text size */ | |
765 | short e_xrssize; /* text rss */ | |
766 | short e_xccount; /* text references */ | |
767 | short e_xswrss; | |
768 | int32_t e_flag; | |
769 | char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ | |
770 | #if CONFIG_LCTX | |
771 | pid_t e_lcid; | |
772 | int32_t e_spare[3]; | |
773 | #else | |
774 | int32_t e_spare[4]; | |
775 | #endif | |
776 | } kp_eproc; | |
777 | }; | |
778 | struct user64_kinfo_proc { | |
779 | struct user64_extern_proc kp_proc; /* proc structure */ | |
780 | struct user64_eproc { | |
91447636 A |
781 | user_addr_t e_paddr; /* address of proc */ |
782 | user_addr_t e_sess; /* session pointer */ | |
b0d623f7 | 783 | struct user64_pcred e_pcred; /* process credentials */ |
91447636 A |
784 | struct _ucred e_ucred; /* current credentials */ |
785 | struct user_vmspace e_vm; /* address space */ | |
786 | pid_t e_ppid; /* parent process id */ | |
787 | pid_t e_pgid; /* process group id */ | |
788 | short e_jobc; /* job control counter */ | |
789 | dev_t e_tdev; /* controlling tty dev */ | |
790 | pid_t e_tpgid; /* tty process group id */ | |
b0d623f7 | 791 | user64_addr_t e_tsess __attribute((aligned(8))); /* tty session pointer */ |
91447636 A |
792 | char e_wmesg[WMESGLEN+1]; /* wchan message */ |
793 | segsz_t e_xsize; /* text size */ | |
794 | short e_xrssize; /* text rss */ | |
795 | short e_xccount; /* text references */ | |
796 | short e_xswrss; | |
797 | int32_t e_flag; | |
798 | char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ | |
2d21ac55 A |
799 | #if CONFIG_LCTX |
800 | pid_t e_lcid; | |
801 | int32_t e_spare[3]; | |
802 | #else | |
91447636 | 803 | int32_t e_spare[4]; |
2d21ac55 | 804 | #endif |
91447636 A |
805 | } kp_eproc; |
806 | }; | |
807 | ||
91447636 A |
808 | #endif /* BSD_KERNEL_PRIVATE */ |
809 | ||
1c79356b A |
810 | /* |
811 | * KERN_IPC identifiers | |
812 | */ | |
813 | #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ | |
814 | #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ | |
815 | #define KIPC_SOMAXCONN 3 /* int: max length of connection q */ | |
816 | #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ | |
817 | #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ | |
818 | #define KIPC_MAX_HDR 6 /* int: max total length of headers */ | |
819 | #define KIPC_MAX_DATALEN 7 /* int: max length of data? */ | |
820 | #define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */ | |
821 | #define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */ | |
2d21ac55 | 822 | #define KIPC_SOQLIMITCOMPAT 10 /* int: socket queue limit */ |
1c79356b A |
823 | |
824 | /* | |
825 | * CTL_VM identifiers | |
826 | */ | |
827 | #define VM_METER 1 /* struct vmmeter */ | |
828 | #define VM_LOADAVG 2 /* struct loadavg */ | |
91447636 A |
829 | /* |
830 | * Note: "3" was skipped sometime ago and should probably remain unused | |
831 | * to avoid any new entry from being accepted by older kernels... | |
832 | */ | |
1c79356b | 833 | #define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/ |
91447636 A |
834 | #define VM_SWAPUSAGE 5 /* total swap usage */ |
835 | #define VM_MAXID 6 /* number of valid vm ids */ | |
1c79356b A |
836 | |
837 | #define CTL_VM_NAMES { \ | |
838 | { 0, 0 }, \ | |
839 | { "vmmeter", CTLTYPE_STRUCT }, \ | |
91447636 A |
840 | { "loadavg", CTLTYPE_STRUCT }, \ |
841 | { 0, 0 }, /* placeholder for "3" (see comment above) */ \ | |
2d21ac55 | 842 | { "dummy", CTLTYPE_INT }, \ |
91447636 | 843 | { "swapusage", CTLTYPE_STRUCT } \ |
1c79356b A |
844 | } |
845 | ||
91447636 A |
846 | struct xsw_usage { |
847 | u_int64_t xsu_total; | |
848 | u_int64_t xsu_avail; | |
849 | u_int64_t xsu_used; | |
850 | u_int32_t xsu_pagesize; | |
851 | boolean_t xsu_encrypted; | |
852 | }; | |
853 | ||
854 | #ifdef __APPLE_API_PRIVATE | |
855 | /* Load average structure. Use of fixpt_t assume <sys/types.h> in scope. */ | |
856 | /* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */ | |
857 | struct loadavg { | |
858 | fixpt_t ldavg[3]; | |
859 | long fscale; | |
860 | }; | |
861 | extern struct loadavg averunnable; | |
862 | #define LSCALE 1000 /* scaling for "fixed point" arithmetic */ | |
863 | ||
91447636 A |
864 | #ifdef BSD_KERNEL_PRIVATE |
865 | ||
b0d623f7 A |
866 | struct user32_loadavg { |
867 | fixpt_t ldavg[3]; | |
868 | user32_long_t fscale; | |
869 | }; | |
870 | ||
871 | struct user64_loadavg { | |
91447636 | 872 | fixpt_t ldavg[3]; |
b0d623f7 | 873 | user64_long_t fscale; |
91447636 A |
874 | }; |
875 | ||
91447636 A |
876 | #endif /* BSD_KERNEL_PRIVATE */ |
877 | #endif /* __APPLE_API_PRIVATE */ | |
878 | ||
879 | ||
1c79356b A |
880 | /* |
881 | * CTL_HW identifiers | |
882 | */ | |
883 | #define HW_MACHINE 1 /* string: machine class */ | |
884 | #define HW_MODEL 2 /* string: specific machine model */ | |
885 | #define HW_NCPU 3 /* int: number of cpus */ | |
886 | #define HW_BYTEORDER 4 /* int: machine byte order */ | |
887 | #define HW_PHYSMEM 5 /* int: total memory */ | |
888 | #define HW_USERMEM 6 /* int: non-kernel memory */ | |
889 | #define HW_PAGESIZE 7 /* int: software page size */ | |
890 | #define HW_DISKNAMES 8 /* strings: disk drive names */ | |
891 | #define HW_DISKSTATS 9 /* struct: diskstats[] */ | |
892 | #define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */ | |
893 | #define HW_FLOATINGPT 11 /* int: has HW floating point? */ | |
894 | #define HW_MACHINE_ARCH 12 /* string: machine architecture */ | |
895 | #define HW_VECTORUNIT 13 /* int: has HW vector unit? */ | |
896 | #define HW_BUS_FREQ 14 /* int: Bus Frequency */ | |
897 | #define HW_CPU_FREQ 15 /* int: CPU Frequency */ | |
898 | #define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */ | |
899 | #define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */ | |
900 | #define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */ | |
901 | #define HW_L2SETTINGS 19 /* int: L2 Cache Settings */ | |
902 | #define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */ | |
903 | #define HW_L3SETTINGS 21 /* int: L3 Cache Settings */ | |
904 | #define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */ | |
90556fb8 | 905 | #define HW_TB_FREQ 23 /* int: Bus Frequency */ |
43866e37 A |
906 | #define HW_MEMSIZE 24 /* uint64_t: physical ram size */ |
907 | #define HW_AVAILCPU 25 /* int: number of available CPUs */ | |
908 | #define HW_MAXID 26 /* number of valid hw ids */ | |
1c79356b A |
909 | |
910 | #define CTL_HW_NAMES { \ | |
911 | { 0, 0 }, \ | |
912 | { "machine", CTLTYPE_STRING }, \ | |
913 | { "model", CTLTYPE_STRING }, \ | |
914 | { "ncpu", CTLTYPE_INT }, \ | |
915 | { "byteorder", CTLTYPE_INT }, \ | |
916 | { "physmem", CTLTYPE_INT }, \ | |
917 | { "usermem", CTLTYPE_INT }, \ | |
918 | { "pagesize", CTLTYPE_INT }, \ | |
919 | { "disknames", CTLTYPE_STRUCT }, \ | |
920 | { "diskstats", CTLTYPE_STRUCT }, \ | |
921 | { "epoch", CTLTYPE_INT }, \ | |
922 | { "floatingpoint", CTLTYPE_INT }, \ | |
923 | { "machinearch", CTLTYPE_STRING }, \ | |
924 | { "vectorunit", CTLTYPE_INT }, \ | |
925 | { "busfrequency", CTLTYPE_INT }, \ | |
926 | { "cpufrequency", CTLTYPE_INT }, \ | |
927 | { "cachelinesize", CTLTYPE_INT }, \ | |
928 | { "l1icachesize", CTLTYPE_INT }, \ | |
929 | { "l1dcachesize", CTLTYPE_INT }, \ | |
930 | { "l2settings", CTLTYPE_INT }, \ | |
931 | { "l2cachesize", CTLTYPE_INT }, \ | |
932 | { "l3settings", CTLTYPE_INT }, \ | |
90556fb8 | 933 | { "l3cachesize", CTLTYPE_INT }, \ |
43866e37 A |
934 | { "tbfrequency", CTLTYPE_INT }, \ |
935 | { "memsize", CTLTYPE_QUAD }, \ | |
936 | { "availcpu", CTLTYPE_INT } \ | |
1c79356b A |
937 | } |
938 | ||
43866e37 | 939 | /* |
2d21ac55 A |
940 | * XXX This information should be moved to the man page. |
941 | * | |
91447636 | 942 | * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers. |
43866e37 A |
943 | * All other parameters are 32 bit numbers. |
944 | * | |
945 | * hw.memsize - The number of bytes of physical memory in the system. | |
946 | * | |
91447636 | 947 | * hw.ncpu - The maximum number of processors that could be available this boot. |
43866e37 A |
948 | * Use this value for sizing of static per processor arrays; i.e. processor load statistics. |
949 | * | |
91447636 | 950 | * hw.activecpu - The number of processors currently available for executing threads. |
43866e37 A |
951 | * Use this number to determine the number threads to create in SMP aware applications. |
952 | * This number can change when power management modes are changed. | |
91447636 A |
953 | * |
954 | * hw.physicalcpu - The number of physical processors available in the current power management mode. | |
955 | * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot | |
956 | * | |
957 | * hw.logicalcpu - The number of logical processors available in the current power management mode. | |
958 | * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot | |
959 | * | |
43866e37 A |
960 | * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services. |
961 | * In general is is better to use mach's or higher level timing services, but this value | |
962 | * is needed to convert the PPC Time Base registers to real time. | |
963 | * | |
964 | * hw.cpufrequency - These values provide the current, min and max cpu frequency. The min and max are for | |
965 | * hw.cpufrequency_max - all power management modes. The current frequency is the max frequency in the current mode. | |
966 | * hw.cpufrequency_min - All frequencies are in Hz. | |
967 | * | |
968 | * hw.busfrequency - These values provide the current, min and max bus frequency. The min and max are for | |
969 | * hw.busfrequency_max - all power management modes. The current frequency is the max frequency in the current mode. | |
970 | * hw.busfrequency_min - All frequencies are in Hz. | |
971 | * | |
972 | * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h> | |
973 | * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that | |
974 | * the best binary can be chosen, or the best dynamic code generated. They should not be used | |
975 | * to determine if a given processor feature is available. | |
91447636 A |
976 | * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector |
977 | * should not be used to infer features, and only used to name the processors thread architecture. | |
978 | * The values are defined in <mach/machine.h> | |
43866e37 A |
979 | * |
980 | * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little. | |
981 | * | |
982 | * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system. | |
983 | * | |
984 | * hw.cachelinesize - Gives the size in bytes of the processor's cache lines. | |
985 | * This value should be use to control the strides of loops that use cache control instructions | |
986 | * like dcbz, dcbt or dcbst. | |
987 | * | |
988 | * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present | |
989 | * hw.l1icachesize - then the selector will return and error. | |
990 | * hw.l2cachesize - | |
991 | * hw.l3cachesize - | |
992 | * | |
2d21ac55 | 993 | * hw.packages - Gives the number of processor packages. |
43866e37 | 994 | * |
0c530ab8 A |
995 | * These are the selectors for optional processor features for specific processors. Selectors that return errors are not support |
996 | * on the system. Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help . | |
997 | * performance. Future versions of these selectors may return larger values as necessary so it is best to test for non zero. | |
998 | * | |
999 | * For PowerPC: | |
43866e37 A |
1000 | * |
1001 | * hw.optional.floatingpoint - Floating Point Instructions | |
1002 | * hw.optional.altivec - AltiVec Instructions | |
1003 | * hw.optional.graphicsops - Graphics Operations | |
1004 | * hw.optional.64bitops - 64-bit Instructions | |
1005 | * hw.optional.fsqrt - HW Floating Point Square Root Instruction | |
1006 | * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions | |
1007 | * hw.optional.dcba - Data Cache Block Allocate Instruction | |
1008 | * hw.optional.datastreams - Data Streams Instructions | |
1009 | * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form | |
1010 | * | |
0c530ab8 A |
1011 | * For x86 Architecture: |
1012 | * | |
2d21ac55 A |
1013 | * hw.optional.floatingpoint - Floating Point Instructions |
1014 | * hw.optional.mmx - Original MMX vector instructions | |
1015 | * hw.optional.sse - Streaming SIMD Extensions | |
1016 | * hw.optional.sse2 - Streaming SIMD Extensions 2 | |
1017 | * hw.optional.sse3 - Streaming SIMD Extensions 3 | |
1018 | * hw.optional.supplementalsse3 - Supplemental Streaming SIMD Extensions 3 | |
1019 | * hw.optional.x86_64 - 64-bit support | |
43866e37 A |
1020 | */ |
1021 | ||
1022 | ||
1c79356b A |
1023 | /* |
1024 | * CTL_USER definitions | |
1025 | */ | |
1026 | #define USER_CS_PATH 1 /* string: _CS_PATH */ | |
1027 | #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ | |
1028 | #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ | |
1029 | #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ | |
1030 | #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ | |
1031 | #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ | |
1032 | #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ | |
1033 | #define USER_LINE_MAX 8 /* int: LINE_MAX */ | |
1034 | #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ | |
1035 | #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ | |
1036 | #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ | |
1037 | #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ | |
1038 | #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ | |
1039 | #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ | |
1040 | #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ | |
1041 | #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ | |
1042 | #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ | |
1043 | #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ | |
1044 | #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ | |
1045 | #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ | |
1046 | #define USER_MAXID 21 /* number of valid user ids */ | |
1047 | ||
1048 | #define CTL_USER_NAMES { \ | |
1049 | { 0, 0 }, \ | |
1050 | { "cs_path", CTLTYPE_STRING }, \ | |
1051 | { "bc_base_max", CTLTYPE_INT }, \ | |
1052 | { "bc_dim_max", CTLTYPE_INT }, \ | |
1053 | { "bc_scale_max", CTLTYPE_INT }, \ | |
1054 | { "bc_string_max", CTLTYPE_INT }, \ | |
1055 | { "coll_weights_max", CTLTYPE_INT }, \ | |
1056 | { "expr_nest_max", CTLTYPE_INT }, \ | |
1057 | { "line_max", CTLTYPE_INT }, \ | |
1058 | { "re_dup_max", CTLTYPE_INT }, \ | |
1059 | { "posix2_version", CTLTYPE_INT }, \ | |
1060 | { "posix2_c_bind", CTLTYPE_INT }, \ | |
1061 | { "posix2_c_dev", CTLTYPE_INT }, \ | |
1062 | { "posix2_char_term", CTLTYPE_INT }, \ | |
1063 | { "posix2_fort_dev", CTLTYPE_INT }, \ | |
1064 | { "posix2_fort_run", CTLTYPE_INT }, \ | |
1065 | { "posix2_localedef", CTLTYPE_INT }, \ | |
1066 | { "posix2_sw_dev", CTLTYPE_INT }, \ | |
1067 | { "posix2_upe", CTLTYPE_INT }, \ | |
1068 | { "stream_max", CTLTYPE_INT }, \ | |
9bccf70c | 1069 | { "tzname_max", CTLTYPE_INT } \ |
1c79356b A |
1070 | } |
1071 | ||
1072 | ||
1073 | ||
1074 | /* | |
1075 | * CTL_DEBUG definitions | |
1076 | * | |
1077 | * Second level identifier specifies which debug variable. | |
1078 | * Third level identifier specifies which stucture component. | |
1079 | */ | |
1080 | #define CTL_DEBUG_NAME 0 /* string: variable name */ | |
1081 | #define CTL_DEBUG_VALUE 1 /* int: variable value */ | |
1082 | #define CTL_DEBUG_MAXID 20 | |
1083 | ||
2d21ac55 | 1084 | |
b0d623f7 | 1085 | #if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 26) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20) |
2d21ac55 A |
1086 | #error Use the SYSCTL_*() macros and OID_AUTO instead! |
1087 | #endif | |
1088 | ||
1089 | ||
1c79356b | 1090 | #ifdef KERNEL |
b0d623f7 | 1091 | #if DEBUG |
1c79356b A |
1092 | /* |
1093 | * CTL_DEBUG variables. | |
1094 | * | |
1095 | * These are declared as separate variables so that they can be | |
1096 | * individually initialized at the location of their associated | |
1097 | * variable. The loader prevents multiple use by issuing errors | |
1098 | * if a variable is initialized in more than one place. They are | |
1099 | * aggregated into an array in debug_sysctl(), so that it can | |
1100 | * conveniently locate them when querried. If more debugging | |
1101 | * variables are added, they must also be declared here and also | |
1102 | * entered into the array. | |
1103 | */ | |
1104 | struct ctldebug { | |
1105 | char *debugname; /* name of debugging variable */ | |
1106 | int *debugvar; /* pointer to debugging variable */ | |
1107 | }; | |
1108 | extern struct ctldebug debug0, debug1, debug2, debug3, debug4; | |
1109 | extern struct ctldebug debug5, debug6, debug7, debug8, debug9; | |
1110 | extern struct ctldebug debug10, debug11, debug12, debug13, debug14; | |
1111 | extern struct ctldebug debug15, debug16, debug17, debug18, debug19; | |
1112 | #endif /* DEBUG */ | |
1113 | ||
91447636 | 1114 | #ifdef BSD_KERNEL_PRIVATE |
1c79356b A |
1115 | extern char machine[]; |
1116 | extern char osrelease[]; | |
1117 | extern char ostype[]; | |
2d21ac55 | 1118 | extern char osversion[]; |
1c79356b A |
1119 | |
1120 | struct linker_set; | |
1121 | ||
2d21ac55 A |
1122 | void sysctl_register_set(const char *set); |
1123 | void sysctl_unregister_set(const char *set); | |
39236c6e | 1124 | void sysctl_mib_init(void); |
1c79356b | 1125 | int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, |
43866e37 | 1126 | size_t *oldlenp, void *newp, size_t newlen); |
91447636 | 1127 | int userland_sysctl(struct proc *p, int *name, u_int namelen, user_addr_t old, |
b0d623f7 | 1128 | size_t *oldlenp, user_addr_t newp, size_t newlen, |
1c79356b | 1129 | size_t *retval); |
43866e37 | 1130 | |
1c79356b A |
1131 | /* |
1132 | * Internal sysctl function calling convention: | |
1133 | * | |
1134 | * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); | |
1135 | * | |
1136 | * The name parameter points at the next component of the name to be | |
1137 | * interpreted. The namelen parameter is the number of integers in | |
1138 | * the name. | |
1139 | */ | |
1140 | typedef int (sysctlfn) | |
91447636 A |
1141 | (int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, struct proc *); |
1142 | ||
1143 | int sysctl_int(user_addr_t, size_t *, user_addr_t, size_t, int *); | |
1144 | int sysctl_rdint(user_addr_t, size_t *, user_addr_t, int); | |
1145 | int sysctl_quad(user_addr_t, size_t *, user_addr_t, size_t, quad_t *); | |
2d21ac55 | 1146 | int sysctl_rdquad(user_addr_t, size_t *, user_addr_t, quad_t); |
91447636 A |
1147 | int sysctl_string(user_addr_t, size_t *, user_addr_t, size_t, char *, int); |
1148 | int sysctl_trstring(user_addr_t, size_t *, user_addr_t, size_t, char *, int); | |
1149 | int sysctl_rdstring(user_addr_t, size_t *, user_addr_t, char *); | |
1150 | int sysctl_rdstruct(user_addr_t, size_t *, user_addr_t, void *, int); | |
1151 | ||
2d21ac55 A |
1152 | /* XXX should be in <sys/sysproto.h>, but not a real system call */ |
1153 | struct sysctl_args; | |
1154 | int new_sysctl(struct proc *, struct sysctl_args *); | |
1155 | ||
1156 | void sysctl_register_all(void); | |
1157 | ||
91447636 | 1158 | #endif /* BSD_KERNEL_PRIVATE */ |
1c79356b | 1159 | #else /* !KERNEL */ |
1c79356b A |
1160 | |
1161 | __BEGIN_DECLS | |
91447636 A |
1162 | int sysctl(int *, u_int, void *, size_t *, void *, size_t); |
1163 | int sysctlbyname(const char *, void *, size_t *, void *, size_t); | |
1164 | int sysctlnametomib(const char *, int *, size_t *); | |
1c79356b | 1165 | __END_DECLS |
91447636 | 1166 | |
1c79356b | 1167 | #endif /* KERNEL */ |
91447636 A |
1168 | |
1169 | ||
1170 | #endif /* SYSCTL_DEF_ENABLED */ | |
1171 | ||
1172 | ||
1c79356b | 1173 | #endif /* !_SYS_SYSCTL_H_ */ |