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