Document MAKEOBJDIRPREFIX.
[dragonfly.git] / sys / sys / sysctl.h
1 /*
2  * Copyright (c) 1989, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Mike Karels at Berkeley Software Design, Inc.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the University of
19  *      California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *      @(#)sysctl.h    8.1 (Berkeley) 6/2/93
37  * $FreeBSD: src/sys/sys/sysctl.h,v 1.81.2.10 2003/05/01 22:48:09 trhodes Exp $
38  * $DragonFly: src/sys/sys/sysctl.h,v 1.16 2005/08/07 03:17:37 hmp Exp $
39  */
40
41 #ifndef _SYS_SYSCTL_H_
42 #define _SYS_SYSCTL_H_
43
44 #include <sys/_posix.h>
45 #include <sys/queue.h>
46
47 /*
48  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
49  * for objects that can be examined or modified.  The name is expressed as
50  * a sequence of integers.  Like a file path name, the meaning of each
51  * component depends on its place in the hierarchy.  The top-level and kern
52  * identifiers are defined here, and other identifiers are defined in the
53  * respective subsystem header files.
54  */
55
56 #define CTL_MAXNAME     12      /* largest number of components supported */
57
58 /*
59  * Each subsystem defined by sysctl defines a list of variables
60  * for that subsystem. Each name is either a node with further
61  * levels defined below it, or it is a leaf of some particular
62  * type given below. Each sysctl level defines a set of name/type
63  * pairs to be used by sysctl(1) in manipulating the subsystem.
64  */
65 struct ctlname {
66         char    *ctl_name;      /* subsystem name */
67         int     ctl_type;       /* type of name */
68 };
69
70 #define CTLTYPE         0xf     /* Mask for the type */
71 #define CTLTYPE_NODE    1       /* name is a node */
72 #define CTLTYPE_INT     2       /* name describes an integer */
73 #define CTLTYPE_STRING  3       /* name describes a string */
74 #define CTLTYPE_QUAD    4       /* name describes a 64-bit number */
75 #define CTLTYPE_OPAQUE  5       /* name describes a structure */
76 #define CTLTYPE_STRUCT  CTLTYPE_OPAQUE  /* name describes a structure */
77 #define CTLTYPE_UINT    6       /* name describes an unsigned integer */
78 #define CTLTYPE_LONG    7       /* name describes a long */
79 #define CTLTYPE_ULONG   8       /* name describes an unsigned long */
80 #define CTLTYPE_UQUAD   9       /* name describes an unsigned 64-bit number */
81
82 #define CTLFLAG_RD      0x80000000      /* Allow reads of variable */
83 #define CTLFLAG_WR      0x40000000      /* Allow writes to the variable */
84 #define CTLFLAG_RW      (CTLFLAG_RD|CTLFLAG_WR)
85 #define CTLFLAG_NOLOCK  0x20000000      /* XXX Don't Lock */
86 #define CTLFLAG_ANYBODY 0x10000000      /* All users can set this var */
87 #define CTLFLAG_SECURE  0x08000000      /* Permit set only if securelevel<=0 */
88 #define CTLFLAG_PRISON  0x04000000      /* Prisoned roots can fiddle */
89 #define CTLFLAG_DYN     0x02000000      /* Dynamic oid - can be freed */
90
91 /*
92  * USE THIS instead of a hardwired number from the categories below
93  * to get dynamically assigned sysctl entries using the linker-set
94  * technology. This is the way nearly all new sysctl variables should
95  * be implemented.
96  * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
97  */ 
98 #define OID_AUTO        (-1)
99
100 #ifdef _KERNEL
101 #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
102         struct sysctl_req *req
103
104 /*
105  * This describes the access space for a sysctl request.  This is needed
106  * so that we can use the interface from the kernel or from user-space.
107  */
108 struct sysctl_req {
109         struct thread   *td;
110         int             lock;
111         void            *oldptr;
112         size_t          oldlen;
113         size_t          oldidx;
114         int             (*oldfunc)(struct sysctl_req *, const void *, size_t);
115         void            *newptr;
116         size_t          newlen;
117         size_t          newidx;
118         int             (*newfunc)(struct sysctl_req *, void *, size_t);
119 };
120
121 SLIST_HEAD(sysctl_oid_list, sysctl_oid);
122
123 /*
124  * This describes one "oid" in the MIB tree.  Potentially more nodes can
125  * be hidden behind it, expanded by the handler.
126  */
127 struct sysctl_oid {
128         struct sysctl_oid_list *oid_parent;
129         SLIST_ENTRY(sysctl_oid) oid_link;
130         int             oid_number;
131         int             oid_kind;
132         void            *oid_arg1;
133         int             oid_arg2;
134         const char      *oid_name;
135         int             (*oid_handler)(SYSCTL_HANDLER_ARGS);
136         const char      *oid_fmt;
137         int             oid_refcnt;
138         const char      *oid_descr;
139 };
140
141 #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
142 #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
143
144 int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
145 int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
146 int sysctl_handle_quad(SYSCTL_HANDLER_ARGS);
147 int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS);
148 int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
149 int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
150
151 /*
152  * These functions are used to add/remove an oid from the mib.
153  */
154 void sysctl_register_oid(struct sysctl_oid *oidp);
155 void sysctl_unregister_oid(struct sysctl_oid *oidp);
156
157 /* Declare a static oid to allow child oids to be added to it. */
158 #define SYSCTL_DECL(name)                                       \
159         extern struct sysctl_oid_list sysctl_##name##_children
160
161 /* Hide these in macros */
162 #define SYSCTL_SET_CHILDREN(oid_ptr, children) do {                     \
163         (oid_ptr)->oid_arg1 = (children);                               \
164 } while(0)
165 #define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \
166         (oid_ptr)->oid_arg1
167 #define SYSCTL_STATIC_CHILDREN(oid_name) \
168         (&sysctl_##oid_name##_children)
169
170 /* === Structs and macros related to context handling === */
171
172 /* All dynamically created sysctls can be tracked in a context list. */
173 struct sysctl_ctx_entry {
174         struct sysctl_oid *entry;
175         TAILQ_ENTRY(sysctl_ctx_entry) link;
176 };
177
178 TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
179
180 #define SYSCTL_NODE_CHILDREN(parent, name) \
181         sysctl_##parent##_##name##_children
182
183 /* This constructs a "raw" MIB oid. */
184 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
185         static struct sysctl_oid sysctl__##parent##_##name = {           \
186                 &sysctl_##parent##_children, { 0 },                      \
187                 nbr, kind, a1, a2, #name, handler, fmt, 0, descr };              \
188         DATA_SET(sysctl_set, sysctl__##parent##_##name);
189
190 #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
191         sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr);
192
193 /* This constructs a node from which other oids can hang. */
194 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr)              \
195         struct sysctl_oid_list sysctl_##parent##_##name##_children;         \
196         SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access,                  \
197                    (void*)&sysctl_##parent##_##name##_children, 0, handler, \
198                    "N", descr);
199
200 #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr)     \
201         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|access,         \
202         0, 0, handler, "N", descr);
203
204 /* Oid for a string.  len can be 0 to indicate '\0' termination. */
205 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
206         SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \
207                 arg, len, sysctl_handle_string, "A", descr)
208
209 #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr)  \
210         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|access,       \
211         arg, len, sysctl_handle_string, "A", descr);
212
213 /* Oid for an int.  If ptr is NULL, val is returned. */
214 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
215         SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
216                 ptr, val, sysctl_handle_int, "I", descr)
217
218 #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr)     \
219         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|access,          \
220         ptr, val, sysctl_handle_int, "I", descr);
221
222 /* Oid for a quad.  If ptr is NULL, val is returned. */
223 #define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \
224         SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
225                 ptr, val, sysctl_handle_quad, "Q", descr)
226
227 #define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, val, descr)    \
228         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|access,         \
229         ptr, val, sysctl_handle_quad, "Q", descr);
230
231 /* Oid for an unsigned quad.  If ptr is NULL, val is returned. */
232 #define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr)            \
233         SYSCTL_OID(parent, nbr, name, CTLTYPE_UQUAD|access,                 \
234                 ptr, val, sysctl_handle_quad, "QU", descr)
235
236 #define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, val, descr)   \
237         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UQUAD|access,        \
238         ptr, val, sysctl_handle_quad, "QU", descr);
239
240 /* Oid for an unsigned int.  If ptr is NULL, val is returned. */
241 #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
242         SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|access, \
243                 ptr, val, sysctl_handle_int, "IU", descr)
244
245 #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
246         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|access,         \
247         ptr, val, sysctl_handle_int, "IU", descr);
248
249 /* Oid for a long.  The pointer must be non NULL. */
250 #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
251         SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|access, \
252                 ptr, val, sysctl_handle_long, "L", descr)
253
254 #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr)         \
255         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|access,         \
256         ptr, 0, sysctl_handle_long, "L", descr);
257
258 /* Oid for a long.  The pointer must be non NULL. */
259 #define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \
260         SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|access, \
261                 ptr, val, sysctl_handle_long, "LU", descr)
262
263 #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)        \
264         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|access,        \
265         ptr, 0, sysctl_handle_long, "LU", descr);
266
267 /* Oid for an opaque object.  Specified by a pointer and a length. */
268 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
269         SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
270                 ptr, len, sysctl_handle_opaque, fmt, descr)
271
272 #define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\
273         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|access,       \
274         ptr, len, sysctl_handle_opaque, fmt, descr);
275
276 /* Oid for a struct.  Specified by a pointer and a type. */
277 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
278         SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
279                 ptr, sizeof(struct type), sysctl_handle_opaque, \
280                 "S," #type, descr)
281
282 #define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
283         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|access,       \
284         ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, descr);
285
286 /* Oid for a procedure.  Specified by a pointer and an arg. */
287 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
288         SYSCTL_OID(parent, nbr, name, access, \
289                 ptr, arg, handler, fmt, descr)
290
291 #define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
292         sysctl_add_oid(ctx, parent, nbr, name, access,                      \
293         ptr, arg, handler, fmt, descr);
294
295 #endif /* _KERNEL */
296
297 /*
298  * Top-level identifiers
299  */
300 #define CTL_UNSPEC      0               /* unused */
301 #define CTL_KERN        1               /* "high kernel": proc, limits */
302 #define CTL_VM          2               /* virtual memory */
303 #define CTL_VFS         3               /* file system, mount type is next */
304 #define CTL_NET         4               /* network, see socket.h */
305 #define CTL_DEBUG       5               /* debugging parameters */
306 #define CTL_HW          6               /* generic cpu/io */
307 #define CTL_MACHDEP     7               /* machine dependent */
308 #define CTL_USER        8               /* user-level */
309 #define CTL_P1003_1B    9               /* POSIX 1003.1B */
310 #define CTL_LWKT        10              /* light weight kernel threads */
311 #define CTL_MAXID       11              /* number of valid top-level ids */
312
313 #define CTL_NAMES { \
314         { 0, 0 }, \
315         { "kern", CTLTYPE_NODE }, \
316         { "vm", CTLTYPE_NODE }, \
317         { "vfs", CTLTYPE_NODE }, \
318         { "net", CTLTYPE_NODE }, \
319         { "debug", CTLTYPE_NODE }, \
320         { "hw", CTLTYPE_NODE }, \
321         { "machdep", CTLTYPE_NODE }, \
322         { "user", CTLTYPE_NODE }, \
323         { "p1003_1b", CTLTYPE_NODE }, \
324         { "lwkt", CTLTYPE_NODE }, \
325 }
326
327 /*
328  * CTL_KERN identifiers
329  */
330 #define KERN_OSTYPE              1      /* string: system version */
331 #define KERN_OSRELEASE           2      /* string: system release */
332 #define KERN_OSREV               3      /* int: system revision */
333 #define KERN_VERSION             4      /* string: compile time info */
334 #define KERN_MAXVNODES           5      /* int: max vnodes */
335 #define KERN_MAXPROC             6      /* int: max processes */
336 #define KERN_MAXFILES            7      /* int: max open files */
337 #define KERN_ARGMAX              8      /* int: max arguments to exec */
338 #define KERN_SECURELVL           9      /* int: system security level */
339 #define KERN_HOSTNAME           10      /* string: hostname */
340 #define KERN_HOSTID             11      /* int: host identifier */
341 #define KERN_CLOCKRATE          12      /* struct: struct clockrate */
342 #define KERN_VNODE              13      /* struct: vnode structures */
343 #define KERN_PROC               14      /* struct: process entries */
344 #define KERN_FILE               15      /* struct: file entries */
345 #define KERN_PROF               16      /* node: kernel profiling info */
346 #define KERN_POSIX1             17      /* int: POSIX.1 version */
347 #define KERN_NGROUPS            18      /* int: # of supplemental group ids */
348 #define KERN_JOB_CONTROL        19      /* int: is job control available */
349 #define KERN_SAVED_IDS          20      /* int: saved set-user/group-ID */
350 #define KERN_BOOTTIME           21      /* struct: time kernel was booted */
351 #define KERN_NISDOMAINNAME      22      /* string: YP domain name */
352 #define KERN_UPDATEINTERVAL     23      /* int: update process sleep time */
353 #define KERN_OSRELDATE          24      /* int: OS release date */
354 #define KERN_NTP_PLL            25      /* node: NTP PLL control */
355 #define KERN_BOOTFILE           26      /* string: name of booted kernel */
356 #define KERN_MAXFILESPERPROC    27      /* int: max open files per proc */
357 #define KERN_MAXPROCPERUID      28      /* int: max processes per uid */
358 #define KERN_DUMPDEV            29      /* dev_t: device to dump on */
359 #define KERN_IPC                30      /* node: anything related to IPC */
360 #define KERN_DUMMY              31      /* unused */
361 #define KERN_PS_STRINGS         32      /* int: address of PS_STRINGS */
362 #define KERN_USRSTACK           33      /* int: address of USRSTACK */
363 #define KERN_LOGSIGEXIT         34      /* int: do we log sigexit procs? */
364 #define KERN_IOV_MAX            35      /* int: value of UIO_MAXIOV */
365 #define KERN_MAXPOSIXLOCKSPERUID 36     /* int: max POSIX locks per uid */
366 #define KERN_MAXID              37      /* number of valid kern ids */
367
368 #define CTL_KERN_NAMES { \
369         { 0, 0 }, \
370         { "ostype", CTLTYPE_STRING }, \
371         { "osrelease", CTLTYPE_STRING }, \
372         { "osrevision", CTLTYPE_INT }, \
373         { "version", CTLTYPE_STRING }, \
374         { "maxvnodes", CTLTYPE_INT }, \
375         { "maxproc", CTLTYPE_INT }, \
376         { "maxfiles", CTLTYPE_INT }, \
377         { "argmax", CTLTYPE_INT }, \
378         { "securelevel", CTLTYPE_INT }, \
379         { "hostname", CTLTYPE_STRING }, \
380         { "hostid", CTLTYPE_UINT }, \
381         { "clockrate", CTLTYPE_STRUCT }, \
382         { "vnode", CTLTYPE_STRUCT }, \
383         { "proc", CTLTYPE_STRUCT }, \
384         { "file", CTLTYPE_STRUCT }, \
385         { "profiling", CTLTYPE_NODE }, \
386         { "posix1version", CTLTYPE_INT }, \
387         { "ngroups", CTLTYPE_INT }, \
388         { "job_control", CTLTYPE_INT }, \
389         { "saved_ids", CTLTYPE_INT }, \
390         { "boottime", CTLTYPE_STRUCT }, \
391         { "nisdomainname", CTLTYPE_STRING }, \
392         { "update", CTLTYPE_INT }, \
393         { "osreldate", CTLTYPE_INT }, \
394         { "ntp_pll", CTLTYPE_NODE }, \
395         { "bootfile", CTLTYPE_STRING }, \
396         { "maxfilesperproc", CTLTYPE_INT }, \
397         { "maxprocperuid", CTLTYPE_INT }, \
398         { "maxposixlocksperuid", CTLTYPE_INT }, \
399         { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
400         { "ipc", CTLTYPE_NODE }, \
401         { "dummy", CTLTYPE_INT }, \
402         { "ps_strings", CTLTYPE_INT }, \
403         { "usrstack", CTLTYPE_INT }, \
404         { "logsigexit", CTLTYPE_INT }, \
405         { "iov_max", CTLTYPE_INT }, \
406 }
407
408 /*
409  * CTL_VFS identifiers
410  */
411 #define CTL_VFS_NAMES { \
412         { "vfsconf", CTLTYPE_STRUCT }, \
413 }
414
415 /*
416  * KERN_PROC subtypes
417  */
418 #define KERN_PROC_ALL           0       /* everything */
419 #define KERN_PROC_PID           1       /* by process id */
420 #define KERN_PROC_PGRP          2       /* by process group id */
421 #define KERN_PROC_SESSION       3       /* by session of pid */
422 #define KERN_PROC_TTY           4       /* by controlling tty */
423 #define KERN_PROC_UID           5       /* by effective uid */
424 #define KERN_PROC_RUID          6       /* by real uid */
425 #define KERN_PROC_ARGS          7       /* get/set arguments/proctitle */
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_HW identifiers
442  */
443 #define HW_MACHINE       1              /* string: machine class */
444 #define HW_MODEL         2              /* string: specific machine model */
445 #define HW_NCPU          3              /* int: number of cpus */
446 #define HW_BYTEORDER     4              /* int: machine byte order */
447 #define HW_PHYSMEM       5              /* int: total memory */
448 #define HW_USERMEM       6              /* int: non-kernel memory */
449 #define HW_PAGESIZE      7              /* int: software page size */
450 #define HW_DISKNAMES     8              /* strings: disk drive names */
451 #define HW_DISKSTATS     9              /* struct: diskstats[] */
452 #define HW_FLOATINGPT   10              /* int: has HW floating point? */
453 #define HW_MACHINE_ARCH 11              /* string: machine architecture */
454 #define HW_MAXID        12              /* number of valid hw ids */
455
456 #define CTL_HW_NAMES { \
457         { 0, 0 }, \
458         { "machine", CTLTYPE_STRING }, \
459         { "model", CTLTYPE_STRING }, \
460         { "ncpu", CTLTYPE_INT }, \
461         { "byteorder", CTLTYPE_INT }, \
462         { "physmem", CTLTYPE_UINT }, \
463         { "usermem", CTLTYPE_UINT }, \
464         { "pagesize", CTLTYPE_INT }, \
465         { "disknames", CTLTYPE_STRUCT }, \
466         { "diskstats", CTLTYPE_STRUCT }, \
467         { "floatingpoint", CTLTYPE_INT }, \
468 }
469
470 /*
471  * CTL_USER definitions
472  */
473 #define USER_CS_PATH             1      /* string: _CS_PATH */
474 #define USER_BC_BASE_MAX         2      /* int: BC_BASE_MAX */
475 #define USER_BC_DIM_MAX          3      /* int: BC_DIM_MAX */
476 #define USER_BC_SCALE_MAX        4      /* int: BC_SCALE_MAX */
477 #define USER_BC_STRING_MAX       5      /* int: BC_STRING_MAX */
478 #define USER_COLL_WEIGHTS_MAX    6      /* int: COLL_WEIGHTS_MAX */
479 #define USER_EXPR_NEST_MAX       7      /* int: EXPR_NEST_MAX */
480 #define USER_LINE_MAX            8      /* int: LINE_MAX */
481 #define USER_RE_DUP_MAX          9      /* int: RE_DUP_MAX */
482 #define USER_POSIX2_VERSION     10      /* int: POSIX2_VERSION */
483 #define USER_POSIX2_C_BIND      11      /* int: POSIX2_C_BIND */
484 #define USER_POSIX2_C_DEV       12      /* int: POSIX2_C_DEV */
485 #define USER_POSIX2_CHAR_TERM   13      /* int: POSIX2_CHAR_TERM */
486 #define USER_POSIX2_FORT_DEV    14      /* int: POSIX2_FORT_DEV */
487 #define USER_POSIX2_FORT_RUN    15      /* int: POSIX2_FORT_RUN */
488 #define USER_POSIX2_LOCALEDEF   16      /* int: POSIX2_LOCALEDEF */
489 #define USER_POSIX2_SW_DEV      17      /* int: POSIX2_SW_DEV */
490 #define USER_POSIX2_UPE         18      /* int: POSIX2_UPE */
491 #define USER_STREAM_MAX         19      /* int: POSIX2_STREAM_MAX */
492 #define USER_TZNAME_MAX         20      /* int: POSIX2_TZNAME_MAX */
493 #define USER_MAXID              21      /* number of valid user ids */
494
495 #define CTL_USER_NAMES { \
496         { 0, 0 }, \
497         { "cs_path", CTLTYPE_STRING }, \
498         { "bc_base_max", CTLTYPE_INT }, \
499         { "bc_dim_max", CTLTYPE_INT }, \
500         { "bc_scale_max", CTLTYPE_INT }, \
501         { "bc_string_max", CTLTYPE_INT }, \
502         { "coll_weights_max", CTLTYPE_INT }, \
503         { "expr_nest_max", CTLTYPE_INT }, \
504         { "line_max", CTLTYPE_INT }, \
505         { "re_dup_max", CTLTYPE_INT }, \
506         { "posix2_version", CTLTYPE_INT }, \
507         { "posix2_c_bind", CTLTYPE_INT }, \
508         { "posix2_c_dev", CTLTYPE_INT }, \
509         { "posix2_char_term", CTLTYPE_INT }, \
510         { "posix2_fort_dev", CTLTYPE_INT }, \
511         { "posix2_fort_run", CTLTYPE_INT }, \
512         { "posix2_localedef", CTLTYPE_INT }, \
513         { "posix2_sw_dev", CTLTYPE_INT }, \
514         { "posix2_upe", CTLTYPE_INT }, \
515         { "stream_max", CTLTYPE_INT }, \
516         { "tzname_max", CTLTYPE_INT }, \
517 }
518
519 #define CTL_P1003_1B_ASYNCHRONOUS_IO            1       /* boolean */
520 #define CTL_P1003_1B_MAPPED_FILES               2       /* boolean */
521 #define CTL_P1003_1B_MEMLOCK                    3       /* boolean */
522 #define CTL_P1003_1B_MEMLOCK_RANGE              4       /* boolean */
523 #define CTL_P1003_1B_MEMORY_PROTECTION          5       /* boolean */
524 #define CTL_P1003_1B_MESSAGE_PASSING            6       /* boolean */
525 #define CTL_P1003_1B_PRIORITIZED_IO             7       /* boolean */
526 #define CTL_P1003_1B_PRIORITY_SCHEDULING        8       /* boolean */
527 #define CTL_P1003_1B_REALTIME_SIGNALS           9       /* boolean */
528 #define CTL_P1003_1B_SEMAPHORES                 10      /* boolean */
529 #define CTL_P1003_1B_FSYNC                      11      /* boolean */
530 #define CTL_P1003_1B_SHARED_MEMORY_OBJECTS      12      /* boolean */
531 #define CTL_P1003_1B_SYNCHRONIZED_IO            13      /* boolean */
532 #define CTL_P1003_1B_TIMERS                     14      /* boolean */
533 #define CTL_P1003_1B_AIO_LISTIO_MAX             15      /* int */
534 #define CTL_P1003_1B_AIO_MAX                    16      /* int */
535 #define CTL_P1003_1B_AIO_PRIO_DELTA_MAX         17      /* int */
536 #define CTL_P1003_1B_DELAYTIMER_MAX             18      /* int */
537 #define CTL_P1003_1B_MQ_OPEN_MAX                19      /* int */
538 #define CTL_P1003_1B_PAGESIZE                   20      /* int */
539 #define CTL_P1003_1B_RTSIG_MAX                  21      /* int */
540 #define CTL_P1003_1B_SEM_NSEMS_MAX              22      /* int */
541 #define CTL_P1003_1B_SEM_VALUE_MAX              23      /* int */
542 #define CTL_P1003_1B_SIGQUEUE_MAX               24      /* int */
543 #define CTL_P1003_1B_TIMER_MAX                  25      /* int */
544
545 #define CTL_P1003_1B_MAXID              26
546
547 #define CTL_P1003_1B_NAMES { \
548         { 0, 0 }, \
549         { "asynchronous_io", CTLTYPE_INT }, \
550         { "mapped_files", CTLTYPE_INT }, \
551         { "memlock", CTLTYPE_INT }, \
552         { "memlock_range", CTLTYPE_INT }, \
553         { "memory_protection", CTLTYPE_INT }, \
554         { "message_passing", CTLTYPE_INT }, \
555         { "prioritized_io", CTLTYPE_INT }, \
556         { "priority_scheduling", CTLTYPE_INT }, \
557         { "realtime_signals", CTLTYPE_INT }, \
558         { "semaphores", CTLTYPE_INT }, \
559         { "fsync", CTLTYPE_INT }, \
560         { "shared_memory_objects", CTLTYPE_INT }, \
561         { "synchronized_io", CTLTYPE_INT }, \
562         { "timers", CTLTYPE_INT }, \
563         { "aio_listio_max", CTLTYPE_INT }, \
564         { "aio_max", CTLTYPE_INT }, \
565         { "aio_prio_delta_max", CTLTYPE_INT }, \
566         { "delaytimer_max", CTLTYPE_INT }, \
567         { "mq_open_max", CTLTYPE_INT }, \
568         { "pagesize", CTLTYPE_INT }, \
569         { "rtsig_max", CTLTYPE_INT }, \
570         { "nsems_max", CTLTYPE_INT }, \
571         { "sem_value_max", CTLTYPE_INT }, \
572         { "sigqueue_max", CTLTYPE_INT }, \
573         { "timer_max", CTLTYPE_INT }, \
574 }
575
576 #ifdef _KERNEL
577
578 /*
579  * Declare some common oids.
580  */
581 extern struct sysctl_oid_list sysctl__children;
582 SYSCTL_DECL(_kern);
583 SYSCTL_DECL(_sysctl);
584 SYSCTL_DECL(_vm);
585 SYSCTL_DECL(_vfs);
586 SYSCTL_DECL(_net);
587 SYSCTL_DECL(_debug);
588 SYSCTL_DECL(_debug_sizeof);
589 SYSCTL_DECL(_hw);
590 SYSCTL_DECL(_machdep);
591 SYSCTL_DECL(_user);
592 SYSCTL_DECL(_compat);
593 SYSCTL_DECL(_lwkt);
594
595 /*
596  * Common second-level oids.
597  */
598 SYSCTL_DECL(_kern_ipc);
599
600 extern char     machine[];
601 extern char     osrelease[];
602 extern char     ostype[];
603 extern char     kern_ident[];
604
605 /* Dynamic oid handling */
606 struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
607                 struct sysctl_oid_list *parent, int nbr, const char *name,
608                 int kind, void *arg1, int arg2,
609                 int (*handler) (SYSCTL_HANDLER_ARGS),
610                 const char *fmt, const char *descr);
611 int     sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
612 int     sysctl_ctx_init(struct sysctl_ctx_list *clist);
613 int     sysctl_ctx_free(struct sysctl_ctx_list *clist);
614 struct  sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist,
615                 struct sysctl_oid *oidp);
616 struct  sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist,
617                 struct sysctl_oid *oidp);
618 int     sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
619                 struct sysctl_oid *oidp);
620
621 int     kernel_sysctl(int *name, u_int namelen, void *old,
622                       size_t *oldlenp, void *new, size_t newlen,
623                       size_t *retval);
624 int     kernel_sysctlbyname(char *name,
625                 void *old, size_t *oldlenp, void *new, size_t newlen,
626                 size_t *retval);
627 int     userland_sysctl(int *name, u_int namelen, void *old,
628                         size_t *oldlenp, int inkernel, void *new, size_t newlen,
629                         size_t *retval);
630 int     sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
631                         int *nindx, struct sysctl_req *req);
632
633 #else   /* !_KERNEL */
634 #include <sys/cdefs.h>
635
636 __BEGIN_DECLS
637 int     sysctl (int *, u_int, void *, size_t *, void *, size_t);
638 int     sysctlbyname (const char *, void *, size_t *, void *, size_t);
639 int     sysctlnametomib (const char *, int *, size_t *);
640 __END_DECLS
641 #endif  /* _KERNEL */
642
643 #endif  /* !_SYS_SYSCTL_H_ */