]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/sysctl.h
xnu-201.5.tar.gz
[apple/xnu.git] / bsd / sys / sysctl.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
23 /*
24 * Copyright (c) 1989, 1993
25 * The Regents of the University of California. All rights reserved.
26 *
27 * This code is derived from software contributed to Berkeley by
28 * Mike Karels at Berkeley Software Design, Inc.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by the University of
41 * California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
59 */
60
61 #ifndef _SYS_SYSCTL_H_
62 #define _SYS_SYSCTL_H_
63
64 /*
65 * These are for the eproc structure defined below.
66 */
67 #ifndef KERNEL
68 #include <sys/time.h>
69 #include <sys/ucred.h>
70
71
72 #endif
73
74 #include <sys/vm.h>
75 #include <sys/proc.h>
76 #include <sys/linker_set.h>
77
78 /*
79 * Definitions for sysctl call. The sysctl call uses a hierarchical name
80 * for objects that can be examined or modified. The name is expressed as
81 * a sequence of integers. Like a file path name, the meaning of each
82 * component depends on its place in the hierarchy. The top-level and kern
83 * identifiers are defined here, and other identifiers are defined in the
84 * respective subsystem header files.
85 */
86
87 #define CTL_MAXNAME 12 /* largest number of components supported */
88
89 /*
90 * Each subsystem defined by sysctl defines a list of variables
91 * for that subsystem. Each name is either a node with further
92 * levels defined below it, or it is a leaf of some particular
93 * type given below. Each sysctl level defines a set of name/type
94 * pairs to be used by sysctl(1) in manipulating the subsystem.
95 */
96 struct ctlname {
97 char *ctl_name; /* subsystem name */
98 int ctl_type; /* type of name */
99 };
100
101 #define CTLTYPE 0xf /* Mask for the type */
102 #define CTLTYPE_NODE 1 /* name is a node */
103 #define CTLTYPE_INT 2 /* name describes an integer */
104 #define CTLTYPE_STRING 3 /* name describes a string */
105 #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
106 #define CTLTYPE_OPAQUE 5 /* name describes a structure */
107 #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
108
109 #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
110 #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
111 #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
112 #define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
113 #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
114 #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
115
116 /*
117 * USE THIS instead of a hardwired number from the categories below
118 * to get dynamically assigned sysctl entries using the linker-set
119 * technology. This is the way nearly all new sysctl variables should
120 * be implemented.
121 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
122 */
123 #define OID_AUTO (-1)
124
125 #ifdef KERNEL
126 #define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \
127 struct sysctl_req *req)
128
129 /*
130 * This describes the access space for a sysctl request. This is needed
131 * so that we can use the interface from the kernel or from user-space.
132 */
133 struct sysctl_req {
134 struct proc *p;
135 int lock;
136 void *oldptr;
137 size_t oldlen;
138 size_t oldidx;
139 int (*oldfunc)(struct sysctl_req *, const void *, size_t);
140 void *newptr;
141 size_t newlen;
142 size_t newidx;
143 int (*newfunc)(struct sysctl_req *, void *, size_t);
144 };
145
146 SLIST_HEAD(sysctl_oid_list, sysctl_oid);
147
148 /*
149 * This describes one "oid" in the MIB tree. Potentially more nodes can
150 * be hidden behind it, expanded by the handler.
151 */
152 struct sysctl_oid {
153 struct sysctl_oid_list *oid_parent;
154 SLIST_ENTRY(sysctl_oid) oid_link;
155 int oid_number;
156 int oid_kind;
157 void *oid_arg1;
158 int oid_arg2;
159 const char *oid_name;
160 int (*oid_handler) SYSCTL_HANDLER_ARGS;
161 const char *oid_fmt;
162 };
163
164 #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
165 #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
166
167 int sysctl_handle_int SYSCTL_HANDLER_ARGS;
168 int sysctl_handle_long SYSCTL_HANDLER_ARGS;
169 int sysctl_handle_intptr SYSCTL_HANDLER_ARGS;
170 int sysctl_handle_string SYSCTL_HANDLER_ARGS;
171 int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
172
173 /*
174 * These functions are used to add/remove an oid from the mib.
175 */
176 void sysctl_register_oid(struct sysctl_oid *oidp);
177 void sysctl_unregister_oid(struct sysctl_oid *oidp);
178
179 /* Declare an oid to allow child oids to be added to it. */
180 #define SYSCTL_DECL(name) \
181 extern struct sysctl_oid_list sysctl_##name##_children
182
183 /* This constructs a "raw" MIB oid. */
184 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
185 struct sysctl_oid sysctl_##parent##_##name## = { \
186 &sysctl_##parent##_children, { 0 }, \
187 nbr, kind, a1, a2, #name, handler, fmt };
188
189
190 /* This constructs a node from which other oids can hang. */
191 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \
192 struct sysctl_oid_list sysctl_##parent##_##name##_children; \
193 SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access, \
194 (void*)&sysctl_##parent##_##name##_children, 0, handler, \
195 "N", descr);
196
197 /* Oid for a string. len can be 0 to indicate '\0' termination. */
198 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
199 SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \
200 arg, len, sysctl_handle_string, "A", descr)
201
202 /* Oid for an int. If ptr is NULL, val is returned. */
203 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
204 SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
205 ptr, val, sysctl_handle_int, "I", descr)
206
207 /* Oid for a long. The pointer must be non NULL. */
208 #define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \
209 SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
210 ptr, 0, sysctl_handle_long, "L", descr)
211
212 /* Oid for an opaque object. Specified by a pointer and a length. */
213 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
214 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
215 ptr, len, sysctl_handle_opaque, fmt, descr)
216
217 /* Oid for a struct. Specified by a pointer and a type. */
218 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
219 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
220 ptr, sizeof(struct type), sysctl_handle_opaque, \
221 "S," #type, descr)
222
223 /* Oid for a procedure. Specified by a pointer and an arg. */
224 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
225 SYSCTL_OID(parent, nbr, name, access, \
226 ptr, arg, handler, fmt, descr)
227 #endif /* KERNEL */
228
229 /*
230 * Top-level identifiers
231 */
232 #define CTL_UNSPEC 0 /* unused */
233 #define CTL_KERN 1 /* "high kernel": proc, limits */
234 #define CTL_VM 2 /* virtual memory */
235 #define CTL_VFS 3 /* file system, mount type is next */
236 #define CTL_NET 4 /* network, see socket.h */
237 #define CTL_DEBUG 5 /* debugging parameters */
238 #define CTL_HW 6 /* generic cpu/io */
239 #define CTL_MACHDEP 7 /* machine dependent */
240 #define CTL_USER 8 /* user-level */
241 #define CTL_MAXID 9 /* number of valid top-level ids */
242
243 #define CTL_NAMES { \
244 { 0, 0 }, \
245 { "kern", CTLTYPE_NODE }, \
246 { "vm", CTLTYPE_NODE }, \
247 { "vfs", CTLTYPE_NODE }, \
248 { "net", CTLTYPE_NODE }, \
249 { "debug", CTLTYPE_NODE }, \
250 { "hw", CTLTYPE_NODE }, \
251 { "machdep", CTLTYPE_NODE }, \
252 { "user", CTLTYPE_NODE }, \
253 }
254
255 /*
256 * CTL_KERN identifiers
257 */
258 #define KERN_OSTYPE 1 /* string: system version */
259 #define KERN_OSRELEASE 2 /* string: system release */
260 #define KERN_OSREV 3 /* int: system revision */
261 #define KERN_VERSION 4 /* string: compile time info */
262 #define KERN_MAXVNODES 5 /* int: max vnodes */
263 #define KERN_MAXPROC 6 /* int: max processes */
264 #define KERN_MAXFILES 7 /* int: max open files */
265 #define KERN_ARGMAX 8 /* int: max arguments to exec */
266 #define KERN_SECURELVL 9 /* int: system security level */
267 #define KERN_HOSTNAME 10 /* string: hostname */
268 #define KERN_HOSTID 11 /* int: host identifier */
269 #define KERN_CLOCKRATE 12 /* struct: struct clockrate */
270 #define KERN_VNODE 13 /* struct: vnode structures */
271 #define KERN_PROC 14 /* struct: process entries */
272 #define KERN_FILE 15 /* struct: file entries */
273 #define KERN_PROF 16 /* node: kernel profiling info */
274 #define KERN_POSIX1 17 /* int: POSIX.1 version */
275 #define KERN_NGROUPS 18 /* int: # of supplemental group ids */
276 #define KERN_JOB_CONTROL 19 /* int: is job control available */
277 #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
278 #define KERN_BOOTTIME 21 /* struct: time kernel was booted */
279 #define KERN_NISDOMAINNAME 22 /* string: YP domain name */
280 #define KERN_DOMAINNAME KERN_NISDOMAINNAME
281 #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
282 #define KERN_KDEBUG 24 /* int: kernel trace points */
283 #define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */
284 #define KERN_OSRELDATE 26 /* int: OS release date */
285 #define KERN_NTP_PLL 27 /* node: NTP PLL control */
286 #define KERN_BOOTFILE 28 /* string: name of booted kernel */
287 #define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */
288 #define KERN_MAXPROCPERUID 30 /* int: max processes per uid */
289 #define KERN_DUMPDEV 31 /* dev_t: device to dump on */
290 #define KERN_IPC 32 /* node: anything related to IPC */
291 #define KERN_DUMMY 33 /* unused */
292 #define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */
293 #define KERN_USRSTACK 35 /* int: address of USRSTACK */
294 #define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */
295 #define KERN_SYMFILE 37 /* string: kernel symbol filename */
296 #define KERN_PROCARGS 38
297 #define KERN_PCSAMPLES 39 /* int: pc sampling */
298 #define KERN_MAXID 40 /* number of valid kern ids */
299
300
301 /* KERN_KDEBUG types */
302 #define KERN_KDEFLAGS 1
303 #define KERN_KDDFLAGS 2
304 #define KERN_KDENABLE 3
305 #define KERN_KDSETBUF 4
306 #define KERN_KDGETBUF 5
307 #define KERN_KDSETUP 6
308 #define KERN_KDREMOVE 7
309 #define KERN_KDSETREG 8
310 #define KERN_KDGETREG 9
311 #define KERN_KDREADTR 10
312 #define KERN_KDPIDTR 11
313 #define KERN_KDTHRMAP 12
314 /* Don't use 13 as it is overloaded with KERN_VNODE */
315 #define KERN_KDPIDEX 14
316 #define KERN_KDSETRTCDEC 15
317
318 /* KERN_PCSAMPLES types */
319 #define KERN_PCDISABLE 1
320 #define KERN_PCSETBUF 2
321 #define KERN_PCGETBUF 3
322 #define KERN_PCSETUP 4
323 #define KERN_PCREMOVE 5
324 #define KERN_PCREADBUF 6
325 #define KERN_PCSETREG 7
326 #define KERN_PCCOMM 8
327
328 #define CTL_KERN_NAMES { \
329 { 0, 0 }, \
330 { "ostype", CTLTYPE_STRING }, \
331 { "osrelease", CTLTYPE_STRING }, \
332 { "osrevision", CTLTYPE_INT }, \
333 { "version", CTLTYPE_STRING }, \
334 { "maxvnodes", CTLTYPE_INT }, \
335 { "maxproc", CTLTYPE_INT }, \
336 { "maxfiles", CTLTYPE_INT }, \
337 { "argmax", CTLTYPE_INT }, \
338 { "securelevel", CTLTYPE_INT }, \
339 { "hostname", CTLTYPE_STRING }, \
340 { "hostid", CTLTYPE_INT }, \
341 { "clockrate", CTLTYPE_STRUCT }, \
342 { "vnode", CTLTYPE_STRUCT }, \
343 { "proc", CTLTYPE_STRUCT }, \
344 { "file", CTLTYPE_STRUCT }, \
345 { "profiling", CTLTYPE_NODE }, \
346 { "posix1version", CTLTYPE_INT }, \
347 { "ngroups", CTLTYPE_INT }, \
348 { "job_control", CTLTYPE_INT }, \
349 { "saved_ids", CTLTYPE_INT }, \
350 { "boottime", CTLTYPE_STRUCT }, \
351 { "nisdomainname", CTLTYPE_STRING }, \
352 { "maxpartitions", CTLTYPE_INT }, \
353 { "kdebug", CTLTYPE_INT }, \
354 { "update", CTLTYPE_INT }, \
355 { "osreldate", CTLTYPE_INT }, \
356 { "ntp_pll", CTLTYPE_NODE }, \
357 { "bootfile", CTLTYPE_STRING }, \
358 { "maxfilesperproc", CTLTYPE_INT }, \
359 { "maxprocperuid", CTLTYPE_INT }, \
360 { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
361 { "ipc", CTLTYPE_NODE }, \
362 { "dummy", CTLTYPE_INT }, \
363 { "ps_strings", CTLTYPE_INT }, \
364 { "usrstack", CTLTYPE_INT }, \
365 { "logsigexit", CTLTYPE_INT }, \
366 { "symfile",CTLTYPE_STRING },\
367 }
368
369 /*
370 * CTL_VFS identifiers
371 */
372 #define CTL_VFS_NAMES { \
373 { "vfsconf", CTLTYPE_STRUCT }, \
374 }
375
376 /*
377 * KERN_PROC subtypes
378 */
379 #define KERN_PROC_ALL 0 /* everything */
380 #define KERN_PROC_PID 1 /* by process id */
381 #define KERN_PROC_PGRP 2 /* by process group id */
382 #define KERN_PROC_SESSION 3 /* by session of pid */
383 #define KERN_PROC_TTY 4 /* by controlling tty */
384 #define KERN_PROC_UID 5 /* by effective uid */
385 #define KERN_PROC_RUID 6 /* by real uid */
386
387 /*
388 * KERN_PROC subtype ops return arrays of augmented proc structures:
389 */
390 struct kinfo_proc {
391 struct extern_proc kp_proc; /* proc structure */
392 struct eproc {
393 struct proc *e_paddr; /* address of proc */
394 struct session *e_sess; /* session pointer */
395 struct pcred e_pcred; /* process credentials */
396 struct ucred e_ucred; /* current credentials */
397 #ifdef sparc
398 struct {
399 segsz_t vm_rssize; /* resident set size */
400 segsz_t vm_tsize; /* text size */
401 segsz_t vm_dsize; /* data size */
402 segsz_t vm_ssize; /* stack size */
403 } e_vm;
404 #else
405 struct vmspace e_vm; /* address space */
406 #endif
407 pid_t e_ppid; /* parent process id */
408 pid_t e_pgid; /* process group id */
409 short e_jobc; /* job control counter */
410 dev_t e_tdev; /* controlling tty dev */
411 pid_t e_tpgid; /* tty process group id */
412 struct session *e_tsess; /* tty session pointer */
413 #define WMESGLEN 7
414 char e_wmesg[WMESGLEN+1]; /* wchan message */
415 segsz_t e_xsize; /* text size */
416 short e_xrssize; /* text rss */
417 short e_xccount; /* text references */
418 short e_xswrss;
419 long e_flag;
420 #define EPROC_CTTY 0x01 /* controlling tty vnode active */
421 #define EPROC_SLEADER 0x02 /* session leader */
422 char e_login[MAXLOGNAME]; /* setlogin() name */
423 long e_spare[4];
424 } kp_eproc;
425 };
426
427 /*
428 * KERN_IPC identifiers
429 */
430 #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */
431 #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */
432 #define KIPC_SOMAXCONN 3 /* int: max length of connection q */
433 #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */
434 #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */
435 #define KIPC_MAX_HDR 6 /* int: max total length of headers */
436 #define KIPC_MAX_DATALEN 7 /* int: max length of data? */
437 #define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */
438 #define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */
439
440 /*
441 * CTL_VM identifiers
442 */
443 #define VM_METER 1 /* struct vmmeter */
444 #define VM_LOADAVG 2 /* struct loadavg */
445 #define VM_MAXID 3 /* number of valid vm ids */
446 #define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/
447
448 #define CTL_VM_NAMES { \
449 { 0, 0 }, \
450 { "vmmeter", CTLTYPE_STRUCT }, \
451 { "loadavg", CTLTYPE_STRUCT }, \
452 }
453
454 /*
455 * CTL_HW identifiers
456 */
457 #define HW_MACHINE 1 /* string: machine class */
458 #define HW_MODEL 2 /* string: specific machine model */
459 #define HW_NCPU 3 /* int: number of cpus */
460 #define HW_BYTEORDER 4 /* int: machine byte order */
461 #define HW_PHYSMEM 5 /* int: total memory */
462 #define HW_USERMEM 6 /* int: non-kernel memory */
463 #define HW_PAGESIZE 7 /* int: software page size */
464 #define HW_DISKNAMES 8 /* strings: disk drive names */
465 #define HW_DISKSTATS 9 /* struct: diskstats[] */
466 #define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */
467 #define HW_FLOATINGPT 11 /* int: has HW floating point? */
468 #define HW_MACHINE_ARCH 12 /* string: machine architecture */
469 #define HW_VECTORUNIT 13 /* int: has HW vector unit? */
470 #define HW_BUS_FREQ 14 /* int: Bus Frequency */
471 #define HW_CPU_FREQ 15 /* int: CPU Frequency */
472 #define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */
473 #define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */
474 #define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */
475 #define HW_L2SETTINGS 19 /* int: L2 Cache Settings */
476 #define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */
477 #define HW_L3SETTINGS 21 /* int: L3 Cache Settings */
478 #define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */
479 #define HW_MAXID 23 /* number of valid hw ids */
480
481 #define CTL_HW_NAMES { \
482 { 0, 0 }, \
483 { "machine", CTLTYPE_STRING }, \
484 { "model", CTLTYPE_STRING }, \
485 { "ncpu", CTLTYPE_INT }, \
486 { "byteorder", CTLTYPE_INT }, \
487 { "physmem", CTLTYPE_INT }, \
488 { "usermem", CTLTYPE_INT }, \
489 { "pagesize", CTLTYPE_INT }, \
490 { "disknames", CTLTYPE_STRUCT }, \
491 { "diskstats", CTLTYPE_STRUCT }, \
492 { "epoch", CTLTYPE_INT }, \
493 { "floatingpoint", CTLTYPE_INT }, \
494 { "machinearch", CTLTYPE_STRING }, \
495 { "vectorunit", CTLTYPE_INT }, \
496 { "busfrequency", CTLTYPE_INT }, \
497 { "cpufrequency", CTLTYPE_INT }, \
498 { "cachelinesize", CTLTYPE_INT }, \
499 { "l1icachesize", CTLTYPE_INT }, \
500 { "l1dcachesize", CTLTYPE_INT }, \
501 { "l2settings", CTLTYPE_INT }, \
502 { "l2cachesize", CTLTYPE_INT }, \
503 { "l3settings", CTLTYPE_INT }, \
504 { "l3cachesize", CTLTYPE_INT }, \
505 }
506
507 /*
508 * CTL_USER definitions
509 */
510 #define USER_CS_PATH 1 /* string: _CS_PATH */
511 #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
512 #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
513 #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
514 #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
515 #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
516 #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
517 #define USER_LINE_MAX 8 /* int: LINE_MAX */
518 #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
519 #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
520 #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
521 #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
522 #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
523 #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
524 #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
525 #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
526 #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
527 #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
528 #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
529 #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
530 #define USER_MAXID 21 /* number of valid user ids */
531
532 #define CTL_USER_NAMES { \
533 { 0, 0 }, \
534 { "cs_path", CTLTYPE_STRING }, \
535 { "bc_base_max", CTLTYPE_INT }, \
536 { "bc_dim_max", CTLTYPE_INT }, \
537 { "bc_scale_max", CTLTYPE_INT }, \
538 { "bc_string_max", CTLTYPE_INT }, \
539 { "coll_weights_max", CTLTYPE_INT }, \
540 { "expr_nest_max", CTLTYPE_INT }, \
541 { "line_max", CTLTYPE_INT }, \
542 { "re_dup_max", CTLTYPE_INT }, \
543 { "posix2_version", CTLTYPE_INT }, \
544 { "posix2_c_bind", CTLTYPE_INT }, \
545 { "posix2_c_dev", CTLTYPE_INT }, \
546 { "posix2_char_term", CTLTYPE_INT }, \
547 { "posix2_fort_dev", CTLTYPE_INT }, \
548 { "posix2_fort_run", CTLTYPE_INT }, \
549 { "posix2_localedef", CTLTYPE_INT }, \
550 { "posix2_sw_dev", CTLTYPE_INT }, \
551 { "posix2_upe", CTLTYPE_INT }, \
552 { "stream_max", CTLTYPE_INT }, \
553 { "tzname_max", CTLTYPE_INT }, \
554 }
555
556
557
558 /*
559 * CTL_DEBUG definitions
560 *
561 * Second level identifier specifies which debug variable.
562 * Third level identifier specifies which stucture component.
563 */
564 #define CTL_DEBUG_NAME 0 /* string: variable name */
565 #define CTL_DEBUG_VALUE 1 /* int: variable value */
566 #define CTL_DEBUG_MAXID 20
567
568 #ifdef KERNEL
569
570 extern struct sysctl_oid_list sysctl__children;
571 SYSCTL_DECL(_kern);
572 SYSCTL_DECL(_sysctl);
573 SYSCTL_DECL(_vm);
574 SYSCTL_DECL(_vfs);
575 SYSCTL_DECL(_net);
576 SYSCTL_DECL(_debug);
577 SYSCTL_DECL(_hw);
578 SYSCTL_DECL(_machdep);
579 SYSCTL_DECL(_user);
580
581
582 #ifdef DEBUG
583 /*
584 * CTL_DEBUG variables.
585 *
586 * These are declared as separate variables so that they can be
587 * individually initialized at the location of their associated
588 * variable. The loader prevents multiple use by issuing errors
589 * if a variable is initialized in more than one place. They are
590 * aggregated into an array in debug_sysctl(), so that it can
591 * conveniently locate them when querried. If more debugging
592 * variables are added, they must also be declared here and also
593 * entered into the array.
594 */
595 struct ctldebug {
596 char *debugname; /* name of debugging variable */
597 int *debugvar; /* pointer to debugging variable */
598 };
599 extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
600 extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
601 extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
602 extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
603 #endif /* DEBUG */
604
605 extern char machine[];
606 extern char osrelease[];
607 extern char ostype[];
608
609 struct linker_set;
610
611 void sysctl_register_set(struct linker_set *lsp);
612 void sysctl_unregister_set(struct linker_set *lsp);
613 int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old,
614 size_t *oldlenp, void *new, size_t newlen,
615 size_t *retval);
616 int userland_sysctl(struct proc *p, int *name, u_int namelen, void *old,
617 size_t *oldlenp, int inkernel, void *new, size_t newlen,
618 size_t *retval);
619 /*
620 * Internal sysctl function calling convention:
621 *
622 * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
623 *
624 * The name parameter points at the next component of the name to be
625 * interpreted. The namelen parameter is the number of integers in
626 * the name.
627 */
628 typedef int (sysctlfn)
629 __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
630
631 int sysctl_int __P((void *, size_t *, void *, size_t, int *));
632 int sysctl_rdint __P((void *, size_t *, void *, int));
633 int sysctl_string __P((void *, size_t *, void *, size_t, char *, int));
634 int sysctl_rdstring __P((void *, size_t *, void *, char *));
635 int sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
636 void fill_eproc __P((struct proc *, struct eproc *));
637
638 #else /* !KERNEL */
639 #include <sys/cdefs.h>
640
641 __BEGIN_DECLS
642 int sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
643 int sysctlbyname __P((const char *, void *, size_t *, void *, size_t));
644 __END_DECLS
645 #endif /* KERNEL */
646 #endif /* !_SYS_SYSCTL_H_ */