The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/sysctl.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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  * 4. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)sysctl.h    8.1 (Berkeley) 6/2/93
   33  * $FreeBSD$
   34  */
   35 
   36 #ifndef _SYS_SYSCTL_H_
   37 #define _SYS_SYSCTL_H_
   38 
   39 #include <sys/queue.h>
   40 
   41 struct thread;
   42 /*
   43  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
   44  * for objects that can be examined or modified.  The name is expressed as
   45  * a sequence of integers.  Like a file path name, the meaning of each
   46  * component depends on its place in the hierarchy.  The top-level and kern
   47  * identifiers are defined here, and other identifiers are defined in the
   48  * respective subsystem header files.
   49  */
   50 
   51 #define CTL_MAXNAME     24      /* largest number of components supported */
   52 
   53 /*
   54  * Each subsystem defined by sysctl defines a list of variables
   55  * for that subsystem. Each name is either a node with further
   56  * levels defined below it, or it is a leaf of some particular
   57  * type given below. Each sysctl level defines a set of name/type
   58  * pairs to be used by sysctl(8) in manipulating the subsystem.
   59  */
   60 struct ctlname {
   61         char    *ctl_name;      /* subsystem name */
   62         int     ctl_type;       /* type of name */
   63 };
   64 
   65 #define CTLTYPE         0xf     /* Mask for the type */
   66 #define CTLTYPE_NODE    1       /* name is a node */
   67 #define CTLTYPE_INT     2       /* name describes an integer */
   68 #define CTLTYPE_STRING  3       /* name describes a string */
   69 #define CTLTYPE_S64     4       /* name describes a signed 64-bit number */
   70 #define CTLTYPE_OPAQUE  5       /* name describes a structure */
   71 #define CTLTYPE_STRUCT  CTLTYPE_OPAQUE  /* name describes a structure */
   72 #define CTLTYPE_UINT    6       /* name describes an unsigned integer */
   73 #define CTLTYPE_LONG    7       /* name describes a long */
   74 #define CTLTYPE_ULONG   8       /* name describes an unsigned long */
   75 #define CTLTYPE_U64     9       /* name describes an unsigned 64-bit number */
   76 
   77 #define CTLFLAG_RD      0x80000000      /* Allow reads of variable */
   78 #define CTLFLAG_WR      0x40000000      /* Allow writes to the variable */
   79 #define CTLFLAG_RW      (CTLFLAG_RD|CTLFLAG_WR)
   80 #define CTLFLAG_ANYBODY 0x10000000      /* All users can set this var */
   81 #define CTLFLAG_SECURE  0x08000000      /* Permit set only if securelevel<=0 */
   82 #define CTLFLAG_PRISON  0x04000000      /* Prisoned roots can fiddle */
   83 #define CTLFLAG_DYN     0x02000000      /* Dynamic oid - can be freed */
   84 #define CTLFLAG_SKIP    0x01000000      /* Skip this sysctl when listing */
   85 #define CTLMASK_SECURE  0x00F00000      /* Secure level */
   86 #define CTLFLAG_TUN     0x00080000      /* Tunable variable */
   87 #define CTLFLAG_RDTUN   (CTLFLAG_RD|CTLFLAG_TUN)
   88 #define CTLFLAG_RWTUN   (CTLFLAG_RW|CTLFLAG_TUN)
   89 #define CTLFLAG_MPSAFE  0x00040000      /* Handler is MP safe */
   90 #define CTLFLAG_VNET    0x00020000      /* Prisons with vnet can fiddle */
   91 #define CTLFLAG_DYING   0x00010000      /* oid is being removed */
   92 #define CTLFLAG_CAPRD   0x00008000      /* Can be read in capability mode */
   93 #define CTLFLAG_CAPWR   0x00004000      /* Can be written in capability mode */
   94 #define CTLFLAG_CAPRW   (CTLFLAG_CAPRD|CTLFLAG_CAPWR)
   95 
   96 /*
   97  * Secure level.   Note that CTLFLAG_SECURE == CTLFLAG_SECURE1.  
   98  *
   99  * Secure when the securelevel is raised to at least N.
  100  */
  101 #define CTLSHIFT_SECURE 20
  102 #define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE))
  103 #define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE))
  104 #define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE))
  105 
  106 /*
  107  * USE THIS instead of a hardwired number from the categories below
  108  * to get dynamically assigned sysctl entries using the linker-set
  109  * technology. This is the way nearly all new sysctl variables should
  110  * be implemented.
  111  * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
  112  */ 
  113 #define OID_AUTO        (-1)
  114 
  115 /*
  116  * The starting number for dynamically-assigned entries.  WARNING!
  117  * ALL static sysctl entries should have numbers LESS than this!
  118  */
  119 #define CTL_AUTO_START  0x100
  120 
  121 #ifdef _KERNEL
  122 #include <sys/linker_set.h>
  123 
  124 #ifdef KLD_MODULE
  125 /* XXX allow overspecification of type in external kernel modules */
  126 #define SYSCTL_CT_ASSERT_MASK CTLTYPE
  127 #else
  128 #define SYSCTL_CT_ASSERT_MASK 0
  129 #endif
  130 
  131 #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1,        \
  132         intptr_t arg2, struct sysctl_req *req
  133 
  134 /* definitions for sysctl_req 'lock' member */
  135 #define REQ_UNWIRED     1
  136 #define REQ_WIRED       2
  137 
  138 /* definitions for sysctl_req 'flags' member */
  139 #if defined(__amd64__) || defined(__ia64__) || defined(__powerpc64__)
  140 #define SCTL_MASK32     1       /* 32 bit emulation */
  141 #endif
  142 
  143 /*
  144  * This describes the access space for a sysctl request.  This is needed
  145  * so that we can use the interface from the kernel or from user-space.
  146  */
  147 struct sysctl_req {
  148         struct thread   *td;            /* used for access checking */
  149         int             lock;           /* wiring state */
  150         void            *oldptr;
  151         size_t          oldlen;
  152         size_t          oldidx;
  153         int             (*oldfunc)(struct sysctl_req *, const void *, size_t);
  154         void            *newptr;
  155         size_t          newlen;
  156         size_t          newidx;
  157         int             (*newfunc)(struct sysctl_req *, void *, size_t);
  158         size_t          validlen;
  159         int             flags;
  160 };
  161 
  162 SLIST_HEAD(sysctl_oid_list, sysctl_oid);
  163 
  164 /*
  165  * This describes one "oid" in the MIB tree.  Potentially more nodes can
  166  * be hidden behind it, expanded by the handler.
  167  */
  168 struct sysctl_oid {
  169         struct sysctl_oid_list *oid_parent;
  170         SLIST_ENTRY(sysctl_oid) oid_link;
  171         int             oid_number;
  172         u_int           oid_kind;
  173         void            *oid_arg1;
  174         intptr_t        oid_arg2;
  175         const char      *oid_name;
  176         int             (*oid_handler)(SYSCTL_HANDLER_ARGS);
  177         const char      *oid_fmt;
  178         int             oid_refcnt;
  179         u_int           oid_running;
  180         const char      *oid_descr;
  181 };
  182 
  183 #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
  184 #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
  185 
  186 int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
  187 int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
  188 int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
  189 int sysctl_handle_64(SYSCTL_HANDLER_ARGS);
  190 int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
  191 int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
  192 
  193 int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS);
  194 int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS);
  195 int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS);
  196 
  197 /*
  198  * These functions are used to add/remove an oid from the mib.
  199  */
  200 void sysctl_register_oid(struct sysctl_oid *oidp);
  201 void sysctl_unregister_oid(struct sysctl_oid *oidp);
  202 
  203 /* Declare a static oid to allow child oids to be added to it. */
  204 #define SYSCTL_DECL(name)                                       \
  205         extern struct sysctl_oid_list sysctl_##name##_children
  206 
  207 /* Hide these in macros */
  208 #define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \
  209         (oid_ptr)->oid_arg1
  210 #define SYSCTL_CHILDREN_SET(oid_ptr, val) \
  211         (oid_ptr)->oid_arg1 = (val);
  212 #define SYSCTL_STATIC_CHILDREN(oid_name) \
  213         (&sysctl_##oid_name##_children)
  214 
  215 /* === Structs and macros related to context handling === */
  216 
  217 /* All dynamically created sysctls can be tracked in a context list. */
  218 struct sysctl_ctx_entry {
  219         struct sysctl_oid *entry;
  220         TAILQ_ENTRY(sysctl_ctx_entry) link;
  221 };
  222 
  223 TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
  224 
  225 #define SYSCTL_NODE_CHILDREN(parent, name) \
  226         sysctl_##parent##_##name##_children
  227 
  228 #ifndef NO_SYSCTL_DESCR
  229 #define __DESCR(d) d
  230 #else
  231 #define __DESCR(d) ""
  232 #endif
  233 
  234 /* This constructs a "raw" MIB oid. */
  235 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
  236         static struct sysctl_oid sysctl__##parent##_##name = {           \
  237                 &sysctl_##parent##_children, { NULL }, nbr, kind,        \
  238                 a1, a2, #name, handler, fmt, 0, 0, __DESCR(descr) };     \
  239         DATA_SET(sysctl_set, sysctl__##parent##_##name)
  240 
  241 #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
  242         sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr))
  243 
  244 /* This constructs a root node from which other nodes can hang. */
  245 #define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr)             \
  246         SYSCTL_NODE(, nbr, name, access, handler, descr)
  247 
  248 /* This constructs a node from which other oids can hang. */
  249 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr)              \
  250         struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name);          \
  251         SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access),                \
  252             (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr); \
  253         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  254             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE)
  255 
  256 #define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \
  257         SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(), nbr, name, access, handler, descr)
  258 
  259 #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
  260 ({                                                                      \
  261         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  262             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE);        \
  263         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access),   \
  264             NULL, 0, handler, "N", __DESCR(descr));                     \
  265 })
  266 
  267 /* Oid for a string.  len can be 0 to indicate '\0' termination. */
  268 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)       \
  269         SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access),          \
  270             arg, len, sysctl_handle_string, "A", descr);                \
  271         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  272             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING)
  273 
  274 #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \
  275 ({                                                                      \
  276         char *__arg = (arg);                                            \
  277         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  278             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING);      \
  279         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \
  280             __arg, len, sysctl_handle_string, "A", __DESCR(descr));     \
  281 })
  282 
  283 /* Oid for an int.  If ptr is SYSCTL_NULL_INT_PTR, val is returned. */
  284 #define SYSCTL_NULL_INT_PTR ((int *)NULL)
  285 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)  \
  286         SYSCTL_OID(parent, nbr, name,                           \
  287             CTLTYPE_INT | CTLFLAG_MPSAFE | (access),            \
  288             ptr, val, sysctl_handle_int, "I", descr);           \
  289         CTASSERT((((access) & CTLTYPE) == 0 ||                  \
  290             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \
  291             sizeof(int) == sizeof(*(ptr)))
  292 
  293 #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
  294 ({                                                                      \
  295         int *__ptr = (ptr);                                             \
  296         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  297             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT);         \
  298         sysctl_add_oid(ctx, parent, nbr, name,                          \
  299             CTLTYPE_INT | CTLFLAG_MPSAFE | (access),                    \
  300             __ptr, val, sysctl_handle_int, "I", __DESCR(descr));        \
  301 })
  302 
  303 /* Oid for an unsigned int.  If ptr is NULL, val is returned. */
  304 #define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL)
  305 #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
  306         SYSCTL_OID(parent, nbr, name,                           \
  307             CTLTYPE_UINT | CTLFLAG_MPSAFE | (access),           \
  308             ptr, val, sysctl_handle_int, "IU", descr);          \
  309         CTASSERT((((access) & CTLTYPE) == 0 ||                  \
  310             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT) && \
  311             sizeof(unsigned) == sizeof(*(ptr)))
  312 
  313 #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \
  314 ({                                                                      \
  315         unsigned *__ptr = (ptr);                                        \
  316         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  317             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT);        \
  318         sysctl_add_oid(ctx, parent, nbr, name,                          \
  319             CTLTYPE_UINT | CTLFLAG_MPSAFE | (access),                   \
  320             __ptr, val, sysctl_handle_int, "IU", __DESCR(descr));       \
  321 })
  322 
  323 /* Oid for a long.  The pointer must be non NULL. */
  324 #define SYSCTL_NULL_LONG_PTR ((long *)NULL)
  325 #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
  326         SYSCTL_OID(parent, nbr, name,                           \
  327             CTLTYPE_LONG | CTLFLAG_MPSAFE | (access),           \
  328             ptr, val, sysctl_handle_long, "L", descr);          \
  329         CTASSERT((((access) & CTLTYPE) == 0 ||                  \
  330             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG) && \
  331             sizeof(long) == sizeof(*(ptr)))
  332 
  333 #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr)     \
  334 ({                                                                      \
  335         long *__ptr = (ptr);                                            \
  336         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  337             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG);        \
  338         sysctl_add_oid(ctx, parent, nbr, name,                          \
  339             CTLTYPE_LONG | CTLFLAG_MPSAFE | (access),                   \
  340             __ptr, 0, sysctl_handle_long, "L", __DESCR(descr));         \
  341 })
  342 
  343 /* Oid for an unsigned long.  The pointer must be non NULL. */
  344 #define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL)
  345 #define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr)        \
  346         SYSCTL_OID(parent, nbr, name,                                   \
  347             CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access),                  \
  348             ptr, val, sysctl_handle_long, "LU", descr);                 \
  349         CTASSERT((((access) & CTLTYPE) == 0 ||                          \
  350             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG) &&     \
  351             sizeof(unsigned long) == sizeof(*(ptr)))
  352 
  353 #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)    \
  354 ({                                                                      \
  355         unsigned long *__ptr = (ptr);                                   \
  356         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  357             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG);       \
  358         sysctl_add_oid(ctx, parent, nbr, name,                          \
  359             CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access),                  \
  360             __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr));        \
  361 })
  362 
  363 /* Oid for a quad.  The pointer must be non NULL. */
  364 #define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL)
  365 #define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \
  366         SYSCTL_OID(parent, nbr, name,                           \
  367             CTLTYPE_S64 | CTLFLAG_MPSAFE | (access),            \
  368             ptr, val, sysctl_handle_64, "Q", descr);            \
  369         CTASSERT((((access) & CTLTYPE) == 0 ||                  \
  370             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \
  371             sizeof(int64_t) == sizeof(*(ptr)))
  372 
  373 #define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr)     \
  374 ({                                                                      \
  375         int64_t *__ptr = (ptr);                                         \
  376         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  377             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64);         \
  378         sysctl_add_oid(ctx, parent, nbr, name,                          \
  379             CTLTYPE_S64 | CTLFLAG_MPSAFE | (access),                    \
  380             __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr));           \
  381 })
  382 
  383 #define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL)
  384 #define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr)        \
  385         SYSCTL_OID(parent, nbr, name,                                   \
  386             CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                    \
  387              ptr, val, sysctl_handle_64, "QU", descr);                  \
  388         CTASSERT((((access) & CTLTYPE) == 0 ||                          \
  389             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) &&       \
  390             sizeof(uint64_t) == sizeof(*(ptr)))
  391 
  392 #define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr)    \
  393 ({                                                                      \
  394         uint64_t *__ptr = (ptr);                                        \
  395         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  396             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64);         \
  397         sysctl_add_oid(ctx, parent, nbr, name,                          \
  398             CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                    \
  399             __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr));          \
  400 })
  401 
  402 /* Oid for a 64-bit unsigned counter(9).  The pointer must be non NULL. */
  403 #define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr)       \
  404         SYSCTL_ASSERT_TYPE(UINT64, ptr, parent, name);                  \
  405         SYSCTL_OID(parent, nbr, name,                                   \
  406             CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                    \
  407             ptr, 0, sysctl_handle_counter_u64, "QU", descr)
  408 
  409 #define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr)\
  410         sysctl_add_oid(ctx, parent, nbr, name,                          \
  411             CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                    \
  412             SYSCTL_ADD_ASSERT_TYPE(UINT64, ptr), 0,                     \
  413             sysctl_handle_counter_u64, "QU", __DESCR(descr))
  414 
  415 /* Oid for a CPU dependant variable */
  416 #define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr)    \
  417 ({                                                                      \
  418         struct sysctl_oid *__ret;                                       \
  419         CTASSERT((sizeof(uint64_t) == sizeof(*(ptr)) ||                 \
  420             sizeof(unsigned) == sizeof(*(ptr))) &&                      \
  421             ((access) & CTLTYPE) == 0);                                 \
  422         if (sizeof(uint64_t) == sizeof(*(ptr))) {                       \
  423                 __ret = sysctl_add_oid(ctx, parent, nbr, name,          \
  424                     CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),            \
  425                     (ptr), 0, sysctl_handle_64, "QU",                   \
  426                     __DESCR(descr));                                    \
  427         } else {                                                        \
  428                 __ret = sysctl_add_oid(ctx, parent, nbr, name,          \
  429                     CTLTYPE_UINT | CTLFLAG_MPSAFE | (access),           \
  430                     (ptr), 0, sysctl_handle_int, "IU",                  \
  431                     __DESCR(descr));                                    \
  432         }                                                               \
  433         __ret;                                                          \
  434 })
  435 
  436 /* Oid for an opaque object.  Specified by a pointer and a length. */
  437 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)  \
  438         SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access),          \
  439             ptr, len, sysctl_handle_opaque, fmt, descr);                \
  440         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  441             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE)
  442 
  443 #define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \
  444 ({                                                                      \
  445         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  446             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE);      \
  447         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
  448             ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr));       \
  449 })
  450 
  451 /* Oid for a struct.  Specified by a pointer and a type. */
  452 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr)      \
  453         SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access),          \
  454             ptr, sizeof(struct type), sysctl_handle_opaque,             \
  455             "S," #type, descr);                                         \
  456         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  457             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE)
  458 
  459 #define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
  460 ({                                                                      \
  461         CTASSERT(((access) & CTLTYPE) == 0 ||                           \
  462             ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE);      \
  463         sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
  464             (ptr), sizeof(struct type),                                 \
  465             sysctl_handle_opaque, "S," #type, __DESCR(descr));          \
  466 })
  467 
  468 /* Oid for a procedure.  Specified by a pointer and an arg. */
  469 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
  470         SYSCTL_OID(parent, nbr, name, (access),                         \
  471             ptr, arg, handler, fmt, descr);                             \
  472         CTASSERT(((access) & CTLTYPE) != 0)
  473 
  474 #define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
  475 ({                                                                      \
  476         CTASSERT(((access) & CTLTYPE) != 0);                            \
  477         sysctl_add_oid(ctx, parent, nbr, name, (access),                \
  478             (ptr), (arg), (handler), (fmt), __DESCR(descr));            \
  479 })
  480 
  481 /*
  482  * A macro to generate a read-only sysctl to indicate the presense of optional
  483  * kernel features.
  484  */
  485 #define FEATURE(name, desc)                                             \
  486         SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \
  487             SYSCTL_NULL_INT_PTR, 1, desc)
  488 
  489 #endif /* _KERNEL */
  490 
  491 /*
  492  * Top-level identifiers
  493  */
  494 #define CTL_UNSPEC      0               /* unused */
  495 #define CTL_KERN        1               /* "high kernel": proc, limits */
  496 #define CTL_VM          2               /* virtual memory */
  497 #define CTL_VFS         3               /* filesystem, mount type is next */
  498 #define CTL_NET         4               /* network, see socket.h */
  499 #define CTL_DEBUG       5               /* debugging parameters */
  500 #define CTL_HW          6               /* generic cpu/io */
  501 #define CTL_MACHDEP     7               /* machine dependent */
  502 #define CTL_USER        8               /* user-level */
  503 #define CTL_P1003_1B    9               /* POSIX 1003.1B */
  504 #define CTL_MAXID       10              /* number of valid top-level ids */
  505 
  506 #define CTL_NAMES { \
  507         { 0, 0 }, \
  508         { "kern", CTLTYPE_NODE }, \
  509         { "vm", CTLTYPE_NODE }, \
  510         { "vfs", CTLTYPE_NODE }, \
  511         { "net", CTLTYPE_NODE }, \
  512         { "debug", CTLTYPE_NODE }, \
  513         { "hw", CTLTYPE_NODE }, \
  514         { "machdep", CTLTYPE_NODE }, \
  515         { "user", CTLTYPE_NODE }, \
  516         { "p1003_1b", CTLTYPE_NODE }, \
  517 }
  518 
  519 /*
  520  * CTL_KERN identifiers
  521  */
  522 #define KERN_OSTYPE              1      /* string: system version */
  523 #define KERN_OSRELEASE           2      /* string: system release */
  524 #define KERN_OSREV               3      /* int: system revision */
  525 #define KERN_VERSION             4      /* string: compile time info */
  526 #define KERN_MAXVNODES           5      /* int: max vnodes */
  527 #define KERN_MAXPROC             6      /* int: max processes */
  528 #define KERN_MAXFILES            7      /* int: max open files */
  529 #define KERN_ARGMAX              8      /* int: max arguments to exec */
  530 #define KERN_SECURELVL           9      /* int: system security level */
  531 #define KERN_HOSTNAME           10      /* string: hostname */
  532 #define KERN_HOSTID             11      /* int: host identifier */
  533 #define KERN_CLOCKRATE          12      /* struct: struct clockrate */
  534 #define KERN_VNODE              13      /* struct: vnode structures */
  535 #define KERN_PROC               14      /* struct: process entries */
  536 #define KERN_FILE               15      /* struct: file entries */
  537 #define KERN_PROF               16      /* node: kernel profiling info */
  538 #define KERN_POSIX1             17      /* int: POSIX.1 version */
  539 #define KERN_NGROUPS            18      /* int: # of supplemental group ids */
  540 #define KERN_JOB_CONTROL        19      /* int: is job control available */
  541 #define KERN_SAVED_IDS          20      /* int: saved set-user/group-ID */
  542 #define KERN_BOOTTIME           21      /* struct: time kernel was booted */
  543 #define KERN_NISDOMAINNAME      22      /* string: YP domain name */
  544 #define KERN_UPDATEINTERVAL     23      /* int: update process sleep time */
  545 #define KERN_OSRELDATE          24      /* int: kernel release date */
  546 #define KERN_NTP_PLL            25      /* node: NTP PLL control */
  547 #define KERN_BOOTFILE           26      /* string: name of booted kernel */
  548 #define KERN_MAXFILESPERPROC    27      /* int: max open files per proc */
  549 #define KERN_MAXPROCPERUID      28      /* int: max processes per uid */
  550 #define KERN_DUMPDEV            29      /* struct cdev *: device to dump on */
  551 #define KERN_IPC                30      /* node: anything related to IPC */
  552 #define KERN_DUMMY              31      /* unused */
  553 #define KERN_PS_STRINGS         32      /* int: address of PS_STRINGS */
  554 #define KERN_USRSTACK           33      /* int: address of USRSTACK */
  555 #define KERN_LOGSIGEXIT         34      /* int: do we log sigexit procs? */
  556 #define KERN_IOV_MAX            35      /* int: value of UIO_MAXIOV */
  557 #define KERN_HOSTUUID           36      /* string: host UUID identifier */
  558 #define KERN_ARND               37      /* int: from arc4rand() */
  559 #define KERN_MAXID              38      /* number of valid kern ids */
  560 
  561 #define CTL_KERN_NAMES { \
  562         { 0, 0 }, \
  563         { "ostype", CTLTYPE_STRING }, \
  564         { "osrelease", CTLTYPE_STRING }, \
  565         { "osrevision", CTLTYPE_INT }, \
  566         { "version", CTLTYPE_STRING }, \
  567         { "maxvnodes", CTLTYPE_INT }, \
  568         { "maxproc", CTLTYPE_INT }, \
  569         { "maxfiles", CTLTYPE_INT }, \
  570         { "argmax", CTLTYPE_INT }, \
  571         { "securelevel", CTLTYPE_INT }, \
  572         { "hostname", CTLTYPE_STRING }, \
  573         { "hostid", CTLTYPE_UINT }, \
  574         { "clockrate", CTLTYPE_STRUCT }, \
  575         { "vnode", CTLTYPE_STRUCT }, \
  576         { "proc", CTLTYPE_STRUCT }, \
  577         { "file", CTLTYPE_STRUCT }, \
  578         { "profiling", CTLTYPE_NODE }, \
  579         { "posix1version", CTLTYPE_INT }, \
  580         { "ngroups", CTLTYPE_INT }, \
  581         { "job_control", CTLTYPE_INT }, \
  582         { "saved_ids", CTLTYPE_INT }, \
  583         { "boottime", CTLTYPE_STRUCT }, \
  584         { "nisdomainname", CTLTYPE_STRING }, \
  585         { "update", CTLTYPE_INT }, \
  586         { "osreldate", CTLTYPE_INT }, \
  587         { "ntp_pll", CTLTYPE_NODE }, \
  588         { "bootfile", CTLTYPE_STRING }, \
  589         { "maxfilesperproc", CTLTYPE_INT }, \
  590         { "maxprocperuid", CTLTYPE_INT }, \
  591         { "ipc", CTLTYPE_NODE }, \
  592         { "dummy", CTLTYPE_INT }, \
  593         { "ps_strings", CTLTYPE_INT }, \
  594         { "usrstack", CTLTYPE_INT }, \
  595         { "logsigexit", CTLTYPE_INT }, \
  596         { "iov_max", CTLTYPE_INT }, \
  597         { "hostuuid", CTLTYPE_STRING }, \
  598         { "arc4rand", CTLTYPE_OPAQUE }, \
  599 }
  600 
  601 /*
  602  * CTL_VFS identifiers
  603  */
  604 #define CTL_VFS_NAMES { \
  605         { "vfsconf", CTLTYPE_STRUCT }, \
  606 }
  607 
  608 /*
  609  * KERN_PROC subtypes
  610  */
  611 #define KERN_PROC_ALL           0       /* everything */
  612 #define KERN_PROC_PID           1       /* by process id */
  613 #define KERN_PROC_PGRP          2       /* by process group id */
  614 #define KERN_PROC_SESSION       3       /* by session of pid */
  615 #define KERN_PROC_TTY           4       /* by controlling tty */
  616 #define KERN_PROC_UID           5       /* by effective uid */
  617 #define KERN_PROC_RUID          6       /* by real uid */
  618 #define KERN_PROC_ARGS          7       /* get/set arguments/proctitle */
  619 #define KERN_PROC_PROC          8       /* only return procs */
  620 #define KERN_PROC_SV_NAME       9       /* get syscall vector name */
  621 #define KERN_PROC_RGID          10      /* by real group id */
  622 #define KERN_PROC_GID           11      /* by effective group id */
  623 #define KERN_PROC_PATHNAME      12      /* path to executable */
  624 #define KERN_PROC_OVMMAP        13      /* Old VM map entries for process */
  625 #define KERN_PROC_OFILEDESC     14      /* Old file descriptors for process */
  626 #define KERN_PROC_KSTACK        15      /* Kernel stacks for process */
  627 #define KERN_PROC_INC_THREAD    0x10    /*
  628                                          * modifier for pid, pgrp, tty,
  629                                          * uid, ruid, gid, rgid and proc
  630                                          * This effectively uses 16-31
  631                                          */
  632 #define KERN_PROC_VMMAP         32      /* VM map entries for process */
  633 #define KERN_PROC_FILEDESC      33      /* File descriptors for process */
  634 #define KERN_PROC_GROUPS        34      /* process groups */
  635 #define KERN_PROC_ENV           35      /* get environment */
  636 #define KERN_PROC_AUXV          36      /* get ELF auxiliary vector */
  637 #define KERN_PROC_RLIMIT        37      /* process resource limits */
  638 #define KERN_PROC_PS_STRINGS    38      /* get ps_strings location */
  639 #define KERN_PROC_UMASK         39      /* process umask */
  640 #define KERN_PROC_OSREL         40      /* osreldate for process binary */
  641 #define KERN_PROC_SIGTRAMP      41      /* signal trampoline location */
  642 
  643 /*
  644  * KERN_IPC identifiers
  645  */
  646 #define KIPC_MAXSOCKBUF         1       /* int: max size of a socket buffer */
  647 #define KIPC_SOCKBUF_WASTE      2       /* int: wastage factor in sockbuf */
  648 #define KIPC_SOMAXCONN          3       /* int: max length of connection q */
  649 #define KIPC_MAX_LINKHDR        4       /* int: max length of link header */
  650 #define KIPC_MAX_PROTOHDR       5       /* int: max length of network header */
  651 #define KIPC_MAX_HDR            6       /* int: max total length of headers */
  652 #define KIPC_MAX_DATALEN        7       /* int: max length of data? */
  653 
  654 /*
  655  * CTL_HW identifiers
  656  */
  657 #define HW_MACHINE       1              /* string: machine class */
  658 #define HW_MODEL         2              /* string: specific machine model */
  659 #define HW_NCPU          3              /* int: number of cpus */
  660 #define HW_BYTEORDER     4              /* int: machine byte order */
  661 #define HW_PHYSMEM       5              /* int: total memory */
  662 #define HW_USERMEM       6              /* int: non-kernel memory */
  663 #define HW_PAGESIZE      7              /* int: software page size */
  664 #define HW_DISKNAMES     8              /* strings: disk drive names */
  665 #define HW_DISKSTATS     9              /* struct: diskstats[] */
  666 #define HW_FLOATINGPT   10              /* int: has HW floating point? */
  667 #define HW_MACHINE_ARCH 11              /* string: machine architecture */
  668 #define HW_REALMEM      12              /* int: 'real' memory */
  669 #define HW_MAXID        13              /* number of valid hw ids */
  670 
  671 #define CTL_HW_NAMES { \
  672         { 0, 0 }, \
  673         { "machine", CTLTYPE_STRING }, \
  674         { "model", CTLTYPE_STRING }, \
  675         { "ncpu", CTLTYPE_INT }, \
  676         { "byteorder", CTLTYPE_INT }, \
  677         { "physmem", CTLTYPE_ULONG }, \
  678         { "usermem", CTLTYPE_ULONG }, \
  679         { "pagesize", CTLTYPE_INT }, \
  680         { "disknames", CTLTYPE_STRUCT }, \
  681         { "diskstats", CTLTYPE_STRUCT }, \
  682         { "floatingpoint", CTLTYPE_INT }, \
  683         { "machine_arch", CTLTYPE_STRING }, \
  684         { "realmem", CTLTYPE_ULONG }, \
  685 }
  686 
  687 /*
  688  * CTL_USER definitions
  689  */
  690 #define USER_CS_PATH             1      /* string: _CS_PATH */
  691 #define USER_BC_BASE_MAX         2      /* int: BC_BASE_MAX */
  692 #define USER_BC_DIM_MAX          3      /* int: BC_DIM_MAX */
  693 #define USER_BC_SCALE_MAX        4      /* int: BC_SCALE_MAX */
  694 #define USER_BC_STRING_MAX       5      /* int: BC_STRING_MAX */
  695 #define USER_COLL_WEIGHTS_MAX    6      /* int: COLL_WEIGHTS_MAX */
  696 #define USER_EXPR_NEST_MAX       7      /* int: EXPR_NEST_MAX */
  697 #define USER_LINE_MAX            8      /* int: LINE_MAX */
  698 #define USER_RE_DUP_MAX          9      /* int: RE_DUP_MAX */
  699 #define USER_POSIX2_VERSION     10      /* int: POSIX2_VERSION */
  700 #define USER_POSIX2_C_BIND      11      /* int: POSIX2_C_BIND */
  701 #define USER_POSIX2_C_DEV       12      /* int: POSIX2_C_DEV */
  702 #define USER_POSIX2_CHAR_TERM   13      /* int: POSIX2_CHAR_TERM */
  703 #define USER_POSIX2_FORT_DEV    14      /* int: POSIX2_FORT_DEV */
  704 #define USER_POSIX2_FORT_RUN    15      /* int: POSIX2_FORT_RUN */
  705 #define USER_POSIX2_LOCALEDEF   16      /* int: POSIX2_LOCALEDEF */
  706 #define USER_POSIX2_SW_DEV      17      /* int: POSIX2_SW_DEV */
  707 #define USER_POSIX2_UPE         18      /* int: POSIX2_UPE */
  708 #define USER_STREAM_MAX         19      /* int: POSIX2_STREAM_MAX */
  709 #define USER_TZNAME_MAX         20      /* int: POSIX2_TZNAME_MAX */
  710 #define USER_MAXID              21      /* number of valid user ids */
  711 
  712 #define CTL_USER_NAMES { \
  713         { 0, 0 }, \
  714         { "cs_path", CTLTYPE_STRING }, \
  715         { "bc_base_max", CTLTYPE_INT }, \
  716         { "bc_dim_max", CTLTYPE_INT }, \
  717         { "bc_scale_max", CTLTYPE_INT }, \
  718         { "bc_string_max", CTLTYPE_INT }, \
  719         { "coll_weights_max", CTLTYPE_INT }, \
  720         { "expr_nest_max", CTLTYPE_INT }, \
  721         { "line_max", CTLTYPE_INT }, \
  722         { "re_dup_max", CTLTYPE_INT }, \
  723         { "posix2_version", CTLTYPE_INT }, \
  724         { "posix2_c_bind", CTLTYPE_INT }, \
  725         { "posix2_c_dev", CTLTYPE_INT }, \
  726         { "posix2_char_term", CTLTYPE_INT }, \
  727         { "posix2_fort_dev", CTLTYPE_INT }, \
  728         { "posix2_fort_run", CTLTYPE_INT }, \
  729         { "posix2_localedef", CTLTYPE_INT }, \
  730         { "posix2_sw_dev", CTLTYPE_INT }, \
  731         { "posix2_upe", CTLTYPE_INT }, \
  732         { "stream_max", CTLTYPE_INT }, \
  733         { "tzname_max", CTLTYPE_INT }, \
  734 }
  735 
  736 #define CTL_P1003_1B_ASYNCHRONOUS_IO            1       /* boolean */
  737 #define CTL_P1003_1B_MAPPED_FILES               2       /* boolean */
  738 #define CTL_P1003_1B_MEMLOCK                    3       /* boolean */
  739 #define CTL_P1003_1B_MEMLOCK_RANGE              4       /* boolean */
  740 #define CTL_P1003_1B_MEMORY_PROTECTION          5       /* boolean */
  741 #define CTL_P1003_1B_MESSAGE_PASSING            6       /* boolean */
  742 #define CTL_P1003_1B_PRIORITIZED_IO             7       /* boolean */
  743 #define CTL_P1003_1B_PRIORITY_SCHEDULING        8       /* boolean */
  744 #define CTL_P1003_1B_REALTIME_SIGNALS           9       /* boolean */
  745 #define CTL_P1003_1B_SEMAPHORES                 10      /* boolean */
  746 #define CTL_P1003_1B_FSYNC                      11      /* boolean */
  747 #define CTL_P1003_1B_SHARED_MEMORY_OBJECTS      12      /* boolean */
  748 #define CTL_P1003_1B_SYNCHRONIZED_IO            13      /* boolean */
  749 #define CTL_P1003_1B_TIMERS                     14      /* boolean */
  750 #define CTL_P1003_1B_AIO_LISTIO_MAX             15      /* int */
  751 #define CTL_P1003_1B_AIO_MAX                    16      /* int */
  752 #define CTL_P1003_1B_AIO_PRIO_DELTA_MAX         17      /* int */
  753 #define CTL_P1003_1B_DELAYTIMER_MAX             18      /* int */
  754 #define CTL_P1003_1B_MQ_OPEN_MAX                19      /* int */
  755 #define CTL_P1003_1B_PAGESIZE                   20      /* int */
  756 #define CTL_P1003_1B_RTSIG_MAX                  21      /* int */
  757 #define CTL_P1003_1B_SEM_NSEMS_MAX              22      /* int */
  758 #define CTL_P1003_1B_SEM_VALUE_MAX              23      /* int */
  759 #define CTL_P1003_1B_SIGQUEUE_MAX               24      /* int */
  760 #define CTL_P1003_1B_TIMER_MAX                  25      /* int */
  761 
  762 #define CTL_P1003_1B_MAXID              26
  763 
  764 #define CTL_P1003_1B_NAMES { \
  765         { 0, 0 }, \
  766         { "asynchronous_io", CTLTYPE_INT }, \
  767         { "mapped_files", CTLTYPE_INT }, \
  768         { "memlock", CTLTYPE_INT }, \
  769         { "memlock_range", CTLTYPE_INT }, \
  770         { "memory_protection", CTLTYPE_INT }, \
  771         { "message_passing", CTLTYPE_INT }, \
  772         { "prioritized_io", CTLTYPE_INT }, \
  773         { "priority_scheduling", CTLTYPE_INT }, \
  774         { "realtime_signals", CTLTYPE_INT }, \
  775         { "semaphores", CTLTYPE_INT }, \
  776         { "fsync", CTLTYPE_INT }, \
  777         { "shared_memory_objects", CTLTYPE_INT }, \
  778         { "synchronized_io", CTLTYPE_INT }, \
  779         { "timers", CTLTYPE_INT }, \
  780         { "aio_listio_max", CTLTYPE_INT }, \
  781         { "aio_max", CTLTYPE_INT }, \
  782         { "aio_prio_delta_max", CTLTYPE_INT }, \
  783         { "delaytimer_max", CTLTYPE_INT }, \
  784         { "mq_open_max", CTLTYPE_INT }, \
  785         { "pagesize", CTLTYPE_INT }, \
  786         { "rtsig_max", CTLTYPE_INT }, \
  787         { "nsems_max", CTLTYPE_INT }, \
  788         { "sem_value_max", CTLTYPE_INT }, \
  789         { "sigqueue_max", CTLTYPE_INT }, \
  790         { "timer_max", CTLTYPE_INT }, \
  791 }
  792 
  793 #ifdef _KERNEL
  794 
  795 /*
  796  * Declare some common oids.
  797  */
  798 extern struct sysctl_oid_list sysctl__children;
  799 SYSCTL_DECL(_kern);
  800 SYSCTL_DECL(_kern_features);
  801 SYSCTL_DECL(_kern_ipc);
  802 SYSCTL_DECL(_kern_proc);
  803 SYSCTL_DECL(_kern_sched);
  804 SYSCTL_DECL(_kern_sched_stats);
  805 SYSCTL_DECL(_sysctl);
  806 SYSCTL_DECL(_vm);
  807 SYSCTL_DECL(_vm_stats);
  808 SYSCTL_DECL(_vm_stats_misc);
  809 SYSCTL_DECL(_vfs);
  810 SYSCTL_DECL(_net);
  811 SYSCTL_DECL(_debug);
  812 SYSCTL_DECL(_debug_sizeof);
  813 SYSCTL_DECL(_dev);
  814 SYSCTL_DECL(_hw);
  815 SYSCTL_DECL(_hw_bus);
  816 SYSCTL_DECL(_hw_bus_devices);
  817 SYSCTL_DECL(_hw_bus_info);
  818 SYSCTL_DECL(_machdep);
  819 SYSCTL_DECL(_user);
  820 SYSCTL_DECL(_compat);
  821 SYSCTL_DECL(_regression);
  822 SYSCTL_DECL(_security);
  823 SYSCTL_DECL(_security_bsd);
  824 
  825 extern char     machine[];
  826 extern char     osrelease[];
  827 extern char     ostype[];
  828 extern char     kern_ident[];
  829 
  830 /* Dynamic oid handling */
  831 struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
  832                 struct sysctl_oid_list *parent, int nbr, const char *name,
  833                 int kind, void *arg1, intptr_t arg2,
  834                 int (*handler) (SYSCTL_HANDLER_ARGS),
  835                 const char *fmt, const char *descr);
  836 int     sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del,
  837                 int recurse);
  838 void    sysctl_rename_oid(struct sysctl_oid *oidp, const char *name);
  839 int     sysctl_move_oid(struct sysctl_oid *oidp,
  840                 struct sysctl_oid_list *parent);
  841 int     sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
  842 int     sysctl_ctx_init(struct sysctl_ctx_list *clist);
  843 int     sysctl_ctx_free(struct sysctl_ctx_list *clist);
  844 struct  sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist,
  845                 struct sysctl_oid *oidp);
  846 struct  sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist,
  847                 struct sysctl_oid *oidp);
  848 int     sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
  849                 struct sysctl_oid *oidp);
  850 
  851 int     kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
  852                       size_t *oldlenp, void *new, size_t newlen,
  853                       size_t *retval, int flags);
  854 int     kernel_sysctlbyname(struct thread *td, char *name,
  855                 void *old, size_t *oldlenp, void *new, size_t newlen,
  856                 size_t *retval, int flags);
  857 int     userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
  858                         size_t *oldlenp, int inkernel, void *new, size_t newlen,
  859                         size_t *retval, int flags);
  860 int     sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
  861                         int *nindx, struct sysctl_req *req);
  862 void    sysctl_lock(void);
  863 void    sysctl_unlock(void);
  864 int     sysctl_wire_old_buffer(struct sysctl_req *req, size_t len);
  865 
  866 struct sbuf;
  867 struct sbuf     *sbuf_new_for_sysctl(struct sbuf *, char *, int,
  868                     struct sysctl_req *);
  869 #else   /* !_KERNEL */
  870 #include <sys/cdefs.h>
  871 
  872 __BEGIN_DECLS
  873 int     sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
  874 int     sysctlbyname(const char *, void *, size_t *, const void *, size_t);
  875 int     sysctlnametomib(const char *, int *, size_t *);
  876 __END_DECLS
  877 #endif  /* _KERNEL */
  878 
  879 #endif  /* !_SYS_SYSCTL_H_ */

Cache object: 453e70ed37b415d277d6bf38f6d7c258


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.