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

Cache object: 27ba77d03ad843d7699fdf16ea52c201


[ 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.