Annotation of kernel/bsd/sys/sysctl.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     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.2 (Berkeley) 3/30/95
                     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: #ifndef _KERNEL
                     71: #include <sys/time.h>
                     72: #include <sys/ucred.h>
                     73: #include <sys/proc.h>
                     74: #include <sys/vm.h>
                     75: #endif
                     76: 
                     77: /*
                     78:  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
                     79:  * for objects that can be examined or modified.  The name is expressed as
                     80:  * a sequence of integers.  Like a file path name, the meaning of each
                     81:  * component depends on its place in the hierarchy.  The top-level and kern
                     82:  * identifiers are defined here, and other identifiers are defined in the
                     83:  * respective subsystem header files.
                     84:  */
                     85: 
                     86: #define CTL_MAXNAME    12      /* largest number of components supported */
                     87: 
                     88: /*
                     89:  * Each subsystem defined by sysctl defines a list of variables
                     90:  * for that subsystem. Each name is either a node with further 
                     91:  * levels defined below it, or it is a leaf of some particular
                     92:  * type given below. Each sysctl level defines a set of name/type
                     93:  * pairs to be used by sysctl(1) in manipulating the subsystem.
                     94:  */
                     95: struct ctlname {
                     96:        char    *ctl_name;      /* subsystem name */
                     97:        int     ctl_type;       /* type of name */
                     98: };
                     99: #define        CTLTYPE_NODE    1       /* name is a node */
                    100: #define        CTLTYPE_INT     2       /* name describes an integer */
                    101: #define        CTLTYPE_STRING  3       /* name describes a string */
                    102: #define        CTLTYPE_QUAD    4       /* name describes a 64-bit number */
                    103: #define        CTLTYPE_STRUCT  5       /* name describes a structure */
                    104: 
                    105: /*
                    106:  * Top-level identifiers
                    107:  */
                    108: #define        CTL_UNSPEC      0               /* unused */
                    109: #define        CTL_KERN        1               /* "high kernel": proc, limits */
                    110: #define        CTL_VM          2               /* virtual memory */
                    111: #define        CTL_VFS         3               /* file system, mount type is next */
                    112: #define        CTL_NET         4               /* network, see socket.h */
                    113: #define        CTL_DEBUG       5               /* debugging parameters */
                    114: #define        CTL_HW          6               /* generic cpu/io */
                    115: #define        CTL_MACHDEP     7               /* machine dependent */
                    116: #define        CTL_USER        8               /* user-level */
                    117: #define        CTL_MAXID       9               /* number of valid top-level ids */
                    118: 
                    119: #define CTL_NAMES { \
                    120:        { 0, 0 }, \
                    121:        { "kern", CTLTYPE_NODE }, \
                    122:        { "vm", CTLTYPE_NODE }, \
                    123:        { "vfs", CTLTYPE_NODE }, \
                    124:        { "net", CTLTYPE_NODE }, \
                    125:        { "debug", CTLTYPE_NODE }, \
                    126:        { "hw", CTLTYPE_NODE }, \
                    127:        { "machdep", CTLTYPE_NODE }, \
                    128:        { "user", CTLTYPE_NODE }, \
                    129: }
                    130: 
                    131: /*
                    132:  * CTL_KERN identifiers
                    133:  */
                    134: #define        KERN_OSTYPE              1      /* string: system version */
                    135: #define        KERN_OSRELEASE           2      /* string: system release */
                    136: #define        KERN_OSREV               3      /* int: system revision */
                    137: #define        KERN_VERSION             4      /* string: compile time info */
                    138: #define        KERN_MAXVNODES           5      /* int: max vnodes */
                    139: #define        KERN_MAXPROC             6      /* int: max processes */
                    140: #define        KERN_MAXFILES            7      /* int: max open files */
                    141: #define        KERN_ARGMAX              8      /* int: max arguments to exec */
                    142: #define        KERN_SECURELVL           9      /* int: system security level */
                    143: #define        KERN_HOSTNAME           10      /* string: hostname */
                    144: #define        KERN_HOSTID             11      /* int: host identifier */
                    145: #define        KERN_CLOCKRATE          12      /* struct: struct clockrate */
                    146: #define        KERN_VNODE              13      /* struct: vnode structures */
                    147: #define        KERN_PROC               14      /* struct: process entries */
                    148: #define        KERN_FILE               15      /* struct: file entries */
                    149: #define        KERN_PROF               16      /* node: kernel profiling info */
                    150: #define        KERN_POSIX1             17      /* int: POSIX.1 version */
                    151: #define        KERN_NGROUPS            18      /* int: # of supplemental group ids */
                    152: #define        KERN_JOB_CONTROL        19      /* int: is job control available */
                    153: #define        KERN_SAVED_IDS          20      /* int: saved set-user/group-ID */
                    154: #define        KERN_BOOTTIME           21      /* struct: time kernel was booted */
                    155: #define        KERN_DOMAINNAME         22      /* string: (YP) domainname */
                    156: #define        KERN_MAXPARTITIONS      23      /* int: number of partitions/disk */
                    157: #define        KERN_KDEBUG             24      /* int: kernel trace points */
                    158: #define        KERN_MAXID              25      /* number of valid kern ids */
                    159: 
                    160: /* KERN_KDEBUG types */
                    161: #define KERN_KDEFLAGS          1
                    162: #define KERN_KDDFLAGS          2
                    163: #define KERN_KDENABLE          3
                    164: #define KERN_KDSETBUF          4
                    165: #define KERN_KDGETBUF          5
                    166: #define KERN_KDSETUP           6
                    167: #define KERN_KDREMOVE          7
                    168: #define KERN_KDSETREG          8
                    169: #define KERN_KDGETREG          9
                    170: #define KERN_KDREADTR          10
                    171: /* Don't use 13 as it is overloaded with KERN_VNODE */
                    172: 
                    173: #define CTL_KERN_NAMES { \
                    174:        { 0, 0 }, \
                    175:        { "ostype", CTLTYPE_STRING }, \
                    176:        { "osrelease", CTLTYPE_STRING }, \
                    177:        { "osrevision", CTLTYPE_INT }, \
                    178:        { "version", CTLTYPE_STRING }, \
                    179:        { "maxvnodes", CTLTYPE_INT }, \
                    180:        { "maxproc", CTLTYPE_INT }, \
                    181:        { "maxfiles", CTLTYPE_INT }, \
                    182:        { "argmax", CTLTYPE_INT }, \
                    183:        { "securelevel", CTLTYPE_INT }, \
                    184:        { "hostname", CTLTYPE_STRING }, \
                    185:        { "hostid", CTLTYPE_INT }, \
                    186:        { "clockrate", CTLTYPE_STRUCT }, \
                    187:        { "vnode", CTLTYPE_STRUCT }, \
                    188:        { "proc", CTLTYPE_STRUCT }, \
                    189:        { "file", CTLTYPE_STRUCT }, \
                    190:        { "profiling", CTLTYPE_NODE }, \
                    191:        { "posix1version", CTLTYPE_INT }, \
                    192:        { "ngroups", CTLTYPE_INT }, \
                    193:        { "job_control", CTLTYPE_INT }, \
                    194:        { "saved_ids", CTLTYPE_INT }, \
                    195:        { "boottime", CTLTYPE_STRUCT }, \
                    196:        { "domainname", CTLTYPE_STRING }, \
                    197:        { "maxpartitions", CTLTYPE_INT }, \
                    198: }
                    199: 
                    200: /* 
                    201:  * KERN_PROC subtypes
                    202:  */
                    203: #define KERN_PROC_ALL          0       /* everything */
                    204: #define        KERN_PROC_PID           1       /* by process id */
                    205: #define        KERN_PROC_PGRP          2       /* by process group id */
                    206: #define        KERN_PROC_SESSION       3       /* by session of pid */
                    207: #define        KERN_PROC_TTY           4       /* by controlling tty */
                    208: #define        KERN_PROC_UID           5       /* by effective uid */
                    209: #define        KERN_PROC_RUID          6       /* by real uid */
                    210: 
                    211: /* 
                    212:  * KERN_PROC subtype ops return arrays of augmented proc structures:
                    213:  */
                    214: struct kinfo_proc {
                    215:        struct  extern_proc kp_proc;                    /* proc structure */
                    216:        struct  eproc {
                    217:                struct  proc *e_paddr;          /* address of proc */
                    218:                struct  session *e_sess;        /* session pointer */
                    219:                struct  pcred e_pcred;          /* process credentials */
                    220:                struct  ucred e_ucred;          /* current credentials */
                    221: #ifdef sparc
                    222:                struct {
                    223:                        segsz_t vm_rssize;      /* resident set size */
                    224:                        segsz_t vm_tsize;       /* text size */
                    225:                        segsz_t vm_dsize;       /* data size */
                    226:                        segsz_t vm_ssize;       /* stack size */
                    227:                } e_vm;
                    228: #else
                    229:                struct  vmspace e_vm;           /* address space */
                    230: #endif
                    231:                pid_t   e_ppid;                 /* parent process id */
                    232:                pid_t   e_pgid;                 /* process group id */
                    233:                short   e_jobc;                 /* job control counter */
                    234:                dev_t   e_tdev;                 /* controlling tty dev */
                    235:                pid_t   e_tpgid;                /* tty process group id */
                    236:                struct  session *e_tsess;       /* tty session pointer */
                    237: #define        WMESGLEN        7
                    238:                char    e_wmesg[WMESGLEN+1];    /* wchan message */
                    239:                segsz_t e_xsize;                /* text size */
                    240:                short   e_xrssize;              /* text rss */
                    241:                short   e_xccount;              /* text references */
                    242:                short   e_xswrss;
                    243:                long    e_flag;
                    244: #define        EPROC_CTTY      0x01    /* controlling tty vnode active */
                    245: #define        EPROC_SLEADER   0x02    /* session leader */
                    246:                char    e_login[MAXLOGNAME];    /* setlogin() name */
                    247:                long    e_spare[4];
                    248:        } kp_eproc;
                    249: };
                    250: 
                    251: /*
                    252:  * CTL_VM identifiers
                    253:  */
                    254: #define        VM_METER        1               /* struct vmmeter */
                    255: #define        VM_LOADAVG      2               /* struct loadavg */
                    256: #define        VM_MAXID        3               /* number of valid vm ids */
                    257: #define        VM_MACHFACTOR   4               /* struct loadavg with mach factor*/
                    258: 
                    259: #define        CTL_VM_NAMES { \
                    260:        { 0, 0 }, \
                    261:        { "vmmeter", CTLTYPE_STRUCT }, \
                    262:        { "loadavg", CTLTYPE_STRUCT }, \
                    263: }
                    264: 
                    265: /*
                    266:  * CTL_HW identifiers
                    267:  */
                    268: #define        HW_MACHINE       1              /* string: machine class */
                    269: #define        HW_MODEL         2              /* string: specific machine model */
                    270: #define        HW_NCPU          3              /* int: number of cpus */
                    271: #define        HW_BYTEORDER     4              /* int: machine byte order */
                    272: #define        HW_PHYSMEM       5              /* int: total memory */
                    273: #define        HW_USERMEM       6              /* int: non-kernel memory */
                    274: #define        HW_PAGESIZE      7              /* int: software page size */
                    275: #define        HW_DISKNAMES     8              /* strings: disk drive names */
                    276: #define        HW_DISKSTATS     9              /* struct: diskstats[] */
                    277: #define        HW_NEWWORLD     10              /* int: 0 for Legacy, else NewWorld */
                    278: #define        HW_MAXID        11              /* number of valid hw ids */
                    279: 
                    280: #define CTL_HW_NAMES { \
                    281:        { 0, 0 }, \
                    282:        { "machine", CTLTYPE_STRING }, \
                    283:        { "model", CTLTYPE_STRING }, \
                    284:        { "ncpu", CTLTYPE_INT }, \
                    285:        { "byteorder", CTLTYPE_INT }, \
                    286:        { "physmem", CTLTYPE_INT }, \
                    287:        { "usermem", CTLTYPE_INT }, \
                    288:        { "pagesize", CTLTYPE_INT }, \
                    289:        { "disknames", CTLTYPE_STRUCT }, \
                    290:        { "diskstats", CTLTYPE_STRUCT }, \
                    291:        { "newworld", CTLTYPE_INT }, \
                    292: }
                    293: 
                    294: /*
                    295:  * CTL_USER definitions
                    296:  */
                    297: #define        USER_CS_PATH             1      /* string: _CS_PATH */
                    298: #define        USER_BC_BASE_MAX         2      /* int: BC_BASE_MAX */
                    299: #define        USER_BC_DIM_MAX          3      /* int: BC_DIM_MAX */
                    300: #define        USER_BC_SCALE_MAX        4      /* int: BC_SCALE_MAX */
                    301: #define        USER_BC_STRING_MAX       5      /* int: BC_STRING_MAX */
                    302: #define        USER_COLL_WEIGHTS_MAX    6      /* int: COLL_WEIGHTS_MAX */
                    303: #define        USER_EXPR_NEST_MAX       7      /* int: EXPR_NEST_MAX */
                    304: #define        USER_LINE_MAX            8      /* int: LINE_MAX */
                    305: #define        USER_RE_DUP_MAX          9      /* int: RE_DUP_MAX */
                    306: #define        USER_POSIX2_VERSION     10      /* int: POSIX2_VERSION */
                    307: #define        USER_POSIX2_C_BIND      11      /* int: POSIX2_C_BIND */
                    308: #define        USER_POSIX2_C_DEV       12      /* int: POSIX2_C_DEV */
                    309: #define        USER_POSIX2_CHAR_TERM   13      /* int: POSIX2_CHAR_TERM */
                    310: #define        USER_POSIX2_FORT_DEV    14      /* int: POSIX2_FORT_DEV */
                    311: #define        USER_POSIX2_FORT_RUN    15      /* int: POSIX2_FORT_RUN */
                    312: #define        USER_POSIX2_LOCALEDEF   16      /* int: POSIX2_LOCALEDEF */
                    313: #define        USER_POSIX2_SW_DEV      17      /* int: POSIX2_SW_DEV */
                    314: #define        USER_POSIX2_UPE         18      /* int: POSIX2_UPE */
                    315: #define        USER_STREAM_MAX         19      /* int: POSIX2_STREAM_MAX */
                    316: #define        USER_TZNAME_MAX         20      /* int: POSIX2_TZNAME_MAX */
                    317: #define        USER_MAXID              21      /* number of valid user ids */
                    318: 
                    319: #define        CTL_USER_NAMES { \
                    320:        { 0, 0 }, \
                    321:        { "cs_path", CTLTYPE_STRING }, \
                    322:        { "bc_base_max", CTLTYPE_INT }, \
                    323:        { "bc_dim_max", CTLTYPE_INT }, \
                    324:        { "bc_scale_max", CTLTYPE_INT }, \
                    325:        { "bc_string_max", CTLTYPE_INT }, \
                    326:        { "coll_weights_max", CTLTYPE_INT }, \
                    327:        { "expr_nest_max", CTLTYPE_INT }, \
                    328:        { "line_max", CTLTYPE_INT }, \
                    329:        { "re_dup_max", CTLTYPE_INT }, \
                    330:        { "posix2_version", CTLTYPE_INT }, \
                    331:        { "posix2_c_bind", CTLTYPE_INT }, \
                    332:        { "posix2_c_dev", CTLTYPE_INT }, \
                    333:        { "posix2_char_term", CTLTYPE_INT }, \
                    334:        { "posix2_fort_dev", CTLTYPE_INT }, \
                    335:        { "posix2_fort_run", CTLTYPE_INT }, \
                    336:        { "posix2_localedef", CTLTYPE_INT }, \
                    337:        { "posix2_sw_dev", CTLTYPE_INT }, \
                    338:        { "posix2_upe", CTLTYPE_INT }, \
                    339:        { "stream_max", CTLTYPE_INT }, \
                    340:        { "tzname_max", CTLTYPE_INT }, \
                    341: }
                    342: 
                    343: /*
                    344:  * CTL_DEBUG definitions
                    345:  *
                    346:  * Second level identifier specifies which debug variable.
                    347:  * Third level identifier specifies which stucture component.
                    348:  */
                    349: #define        CTL_DEBUG_NAME          0       /* string: variable name */
                    350: #define        CTL_DEBUG_VALUE         1       /* int: variable value */
                    351: #define        CTL_DEBUG_MAXID         20
                    352: 
                    353: #ifdef _KERNEL
                    354: #ifdef DEBUG
                    355: /*
                    356:  * CTL_DEBUG variables.
                    357:  *
                    358:  * These are declared as separate variables so that they can be
                    359:  * individually initialized at the location of their associated
                    360:  * variable. The loader prevents multiple use by issuing errors
                    361:  * if a variable is initialized in more than one place. They are
                    362:  * aggregated into an array in debug_sysctl(), so that it can
                    363:  * conveniently locate them when querried. If more debugging
                    364:  * variables are added, they must also be declared here and also
                    365:  * entered into the array.
                    366:  */
                    367: struct ctldebug {
                    368:        char    *debugname;     /* name of debugging variable */
                    369:        int     *debugvar;      /* pointer to debugging variable */
                    370: };
                    371: extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
                    372: extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
                    373: extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
                    374: extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
                    375: #endif /* DEBUG */
                    376: 
                    377: /*
                    378:  * Internal sysctl function calling convention:
                    379:  *
                    380:  *     (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
                    381:  *
                    382:  * The name parameter points at the next component of the name to be
                    383:  * interpreted.  The namelen parameter is the number of integers in
                    384:  * the name.
                    385:  */
                    386: typedef int (sysctlfn)
                    387:     __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
                    388: 
                    389: int sysctl_int __P((void *, size_t *, void *, size_t, int *));
                    390: int sysctl_rdint __P((void *, size_t *, void *, int));
                    391: int sysctl_string __P((void *, size_t *, void *, size_t, char *, int));
                    392: int sysctl_rdstring __P((void *, size_t *, void *, char *));
                    393: int sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
                    394: void fill_eproc __P((struct proc *, struct eproc *));
                    395: 
                    396: #else  /* !_KERNEL */
                    397: #include <sys/cdefs.h>
                    398: 
                    399: __BEGIN_DECLS
                    400: int    sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
                    401: __END_DECLS
                    402: #endif /* _KERNEL */
                    403: #endif /* !_SYS_SYSCTL_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.