gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/include/sys/sysctl.hbare sourcepermlink (0.09 seconds)

Search this content:

    1: /*      $OpenBSD: sysctl.h,v 1.121 2012/03/23 15:51:26 guenther Exp $        */
    2: /*      $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $       */
    3: 
    4: /*
    5:  * Copyright (c) 1989, 1993
    6:  *      The Regents of the University of California.  All rights reserved.
    7:  *
    8:  * This code is derived from software contributed to Berkeley by
    9:  * Mike Karels at Berkeley Software Design, Inc.
   10:  *
   11:  * Redistribution and use in source and binary forms, with or without
   12:  * modification, are permitted provided that the following conditions
   13:  * are met:
   14:  * 1. Redistributions of source code must retain the above copyright
   15:  *    notice, this list of conditions and the following disclaimer.
   16:  * 2. Redistributions in binary form must reproduce the above copyright
   17:  *    notice, this list of conditions and the following disclaimer in the
   18:  *    documentation and/or other materials provided with the distribution.
   19:  * 3. Neither the name of the University nor the names of its contributors
   20:  *    may be used to endorse or promote products derived from this software
   21:  *    without specific prior written permission.
   22:  *
   23:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33:  * SUCH DAMAGE.
   34:  *
   35:  *      @(#)sysctl.h 8.2 (Berkeley) 3/30/95
   36:  */
   37: 
   38: #ifndef _SYS_SYSCTL_H_
   39: #define _SYS_SYSCTL_H_
   40: 
   41: #ifndef _KERNEL
   42: #include <sys/proc.h>           /* for SRUN, SIDL, etc */
   43: #include <sys/resource.h>       /* for struct loadavg */
   44: #endif
   45: 
   46: #include <uvm/uvm_extern.h>
   47: 
   48: /*
   49:  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
   50:  * for objects that can be examined or modified.  The name is expressed as
   51:  * a sequence of integers.  Like a file path name, the meaning of each
   52:  * component depends on its place in the hierarchy.  The top-level and kern
   53:  * identifiers are defined here, and other identifiers are defined in the
   54:  * respective subsystem header files.
   55:  */
   56: 
   57: #define CTL_MAXNAME     12  /* largest number of components supported */
   58: 
   59: /*
   60:  * Each subsystem defined by sysctl defines a list of variables
   61:  * for that subsystem. Each name is either a node with further
   62:  * levels defined below it, or it is a leaf of some particular
   63:  * type given below. Each sysctl level defines a set of name/type
   64:  * pairs to be used by sysctl(1) in manipulating the subsystem.
   65:  */
   66: struct ctlname {
   67:         char   *ctl_name;        /* subsystem name */
   68:         int    ctl_type;  /* type of name */
   69: };
   70: #define CTLTYPE_NODE    1  /* name is a node */
   71: #define CTLTYPE_INT     2   /* name describes an integer */
   72: #define CTLTYPE_STRING  3        /* name describes a string */
   73: #define CTLTYPE_QUAD    4  /* name describes a 64-bit number */
   74: #define CTLTYPE_STRUCT  5        /* name describes a structure */
   75: 
   76: /*
   77:  * Top-level identifiers
   78:  */
   79: #define CTL_UNSPEC      0            /* unused */
   80: #define CTL_KERN        1              /* "high kernel": proc, limits */
   81: #define CTL_VM          2               /* virtual memory */
   82: #define CTL_FS          3               /* file system, mount type is next */
   83: #define CTL_NET         4              /* network, see socket.h */
   84: #define CTL_DEBUG       5             /* debugging parameters */
   85: #define CTL_HW          6               /* generic cpu/io */
   86: #define CTL_MACHDEP     7           /* machine dependent */
   87: #define CTL_USER        8              /* user-level */
   88: #define CTL_DDB         9              /* DDB user interface, see db_var.h */
   89: #define CTL_VFS         10             /* VFS sysctl's */
   90: #define CTL_MAXID       11            /* number of valid top-level ids */
   91: 
   92: #define CTL_NAMES { \
   93:         { 0, 0 }, \
   94:         { "kern", CTLTYPE_NODE }, \
   95:         { "vm", CTLTYPE_NODE }, \
   96:         { "fs", CTLTYPE_NODE }, \
   97:         { "net", CTLTYPE_NODE }, \
   98:         { "debug", CTLTYPE_NODE }, \
   99:         { "hw", CTLTYPE_NODE }, \
  100:         { "machdep", CTLTYPE_NODE }, \
  101:         { "user", CTLTYPE_NODE }, \
  102:         { "ddb", CTLTYPE_NODE }, \
  103:         { "vfs", CTLTYPE_NODE }, \
  104: }
  105: 
  106: /*
  107:  * CTL_KERN identifiers
  108:  */
  109: #define KERN_OSTYPE          1        /* string: system version */
  110: #define KERN_OSRELEASE            2     /* string: system release */
  111: #define KERN_OSREV            3 /* int: system revision */
  112: #define KERN_VERSION        4       /* string: compile time info */
  113: #define KERN_MAXVNODES            5     /* int: max vnodes */
  114: #define KERN_MAXPROC        6       /* int: max processes */
  115: #define KERN_MAXFILES      7      /* int: max open files */
  116: #define KERN_ARGMAX          8        /* int: max arguments to exec */
  117: #define KERN_SECURELVL            9     /* int: system security level */
  118: #define KERN_HOSTNAME           10       /* string: hostname */
  119: #define KERN_HOSTID             11 /* int: host identifier */
  120: #define KERN_CLOCKRATE          12      /* struct: struct clockinfo */
  121: #define KERN_VNODE              13  /* struct: vnode structures */
  122: /*define gap: was KERN_PROC     14  */
  123: #define KERN_FILE               15   /* struct: file entries */
  124: #define KERN_PROF               16   /* node: kernel profiling info */
  125: #define KERN_POSIX1             17 /* int: POSIX.1 version */
  126: #define KERN_NGROUPS            18        /* int: # of supplemental group ids */
  127: #define KERN_JOB_CONTROL        19     /* int: is job control available */
  128: #define KERN_SAVED_IDS          20      /* int: saved set-user/group-ID */
  129: #define KERN_BOOTTIME           21       /* struct: time kernel was booted */
  130: #define KERN_DOMAINNAME         22     /* string: (YP) domainname */
  131: #define KERN_MAXPARTITIONS      23   /* int: number of partitions/disk */
  132: #define KERN_RAWPARTITION       24    /* int: raw partition number */
  133: /*define gap                    25       */
  134: /*define gap                    26       */
  135: #define KERN_OSVERSION          27      /* string: kernel build version */
  136: #define KERN_SOMAXCONN          28      /* int: listen queue maximum */
  137: #define KERN_SOMINCONN          29      /* int: half-open controllable param */
  138: #define KERN_USERMOUNT          30      /* int: users may mount filesystems */
  139: #define KERN_RND                31    /* struct: rnd(4) statistics */
  140: #define KERN_NOSUIDCOREDUMP     32  /* int: no setuid coredumps ever */ 
  141: #define KERN_FSYNC              33  /* int: file synchronization support */
  142: #define KERN_SYSVMSG            34        /* int: SysV message queue suppoprt */
  143: #define KERN_SYSVSEM            35        /* int: SysV semaphore support */
  144: #define KERN_SYSVSHM            36        /* int: SysV shared memory support */
  145: #define KERN_ARND               37   /* int: random integer from arc4rnd */
  146: #define KERN_MSGBUFSIZE         38     /* int: size of message buffer */
  147: #define KERN_MALLOCSTATS        39     /* node: malloc statistics */
  148: #define KERN_CPTIME             40 /* array: cp_time */
  149: #define KERN_NCHSTATS           41       /* struct: vfs cache statistics */
  150: #define KERN_FORKSTAT           42       /* struct: fork statistics */
  151: #define KERN_NSELCOLL           43       /* int: select(2) collisions */
  152: #define KERN_TTY                44    /* node: tty information */
  153: #define KERN_CCPU               45   /* int: ccpu */
  154: #define KERN_FSCALE             46 /* int: fscale */
  155: #define KERN_NPROCS             47 /* int: number of processes */
  156: #define KERN_MSGBUF             48 /* message buffer, KERN_MSGBUFSIZE */
  157: #define KERN_POOL               49   /* struct: pool information */
  158: #define KERN_STACKGAPRANDOM     50  /* int: stackgap_random */
  159: #define KERN_SYSVIPC_INFO       51    /* struct: SysV sem/shm/msg info */
  160: #define KERN_USERCRYPTO         52     /* int: usercrypto */
  161: #define KERN_CRYPTODEVALLOWSOFT 53      /* int: cryptodevallowsoft */
  162: #define KERN_SPLASSERT          54      /* int: splassert */
  163: #define KERN_PROC_ARGS          55      /* node: proc args and env */
  164: #define KERN_NFILES             56 /* int: number of open files */
  165: #define KERN_TTYCOUNT           57       /* int: number of tty devices */
  166: #define KERN_NUMVNODES          58      /* int: number of vnodes in use */
  167: #define KERN_MBSTAT             59 /* struct: mbuf statistics */
  168: #define KERN_USERASYMCRYPTO     60  /* int: usercrypto */
  169: #define KERN_SEMINFO            61        /* struct: SysV struct seminfo */
  170: #define KERN_SHMINFO            62        /* struct: SysV struct shminfo */
  171: #define KERN_INTRCNT            63        /* node: interrupt counters */
  172: #define KERN_WATCHDOG           64       /* node: watchdog */
  173: #define KERN_EMUL               65   /* node: emuls */
  174: #define KERN_PROC               66   /* struct: process entries */
  175: #define KERN_MAXCLUSTERS        67     /* number of mclusters */
  176: #define KERN_EVCOUNT            68        /* node: event counters */
  177: #define KERN_TIMECOUNTER        69     /* node: timecounter */
  178: #define KERN_MAXLOCKSPERUID     70  /* int: locks per uid */
  179: #define KERN_CPTIME2            71        /* array: cp_time2 */
  180: #define KERN_CACHEPCT           72       /* buffer cache % of physmem */
  181: #define KERN_FILE2              73  /* struct: file entries */
  182: #define KERN_RTHREADS           74       /* kernel rthreads support enabled */
  183: #define KERN_CONSDEV            75        /* dev_t: console terminal device */
  184: #define KERN_NETLIVELOCKS       76    /* int: number of network livelocks */
  185: #define KERN_POOL_DEBUG         77     /* int: enable pool_debug */
  186: #define KERN_PROC_CWD           78      /* node: proc cwd */
  187: #define KERN_MAXID              79  /* number of valid kern ids */
  188: 
  189: #define CTL_KERN_NAMES { \
  190:         { 0, 0 }, \
  191:         { "ostype", CTLTYPE_STRING }, \
  192:         { "osrelease", CTLTYPE_STRING }, \
  193:         { "osrevision", CTLTYPE_INT }, \
  194:         { "version", CTLTYPE_STRING }, \
  195:         { "maxvnodes", CTLTYPE_INT }, \
  196:         { "maxproc", CTLTYPE_INT }, \
  197:         { "maxfiles", CTLTYPE_INT }, \
  198:         { "argmax", CTLTYPE_INT }, \
  199:         { "securelevel", CTLTYPE_INT }, \
  200:         { "hostname", CTLTYPE_STRING }, \
  201:         { "hostid", CTLTYPE_INT }, \
  202:         { "clockrate", CTLTYPE_STRUCT }, \
  203:         { "vnode", CTLTYPE_STRUCT }, \
  204:         { "gap", 0 }, \
  205:         { "file", CTLTYPE_STRUCT }, \
  206:         { "profiling", CTLTYPE_NODE }, \
  207:         { "posix1version", CTLTYPE_INT }, \
  208:         { "ngroups", CTLTYPE_INT }, \
  209:         { "job_control", CTLTYPE_INT }, \
  210:         { "saved_ids", CTLTYPE_INT }, \
  211:         { "boottime", CTLTYPE_STRUCT }, \
  212:         { "domainname", CTLTYPE_STRING }, \
  213:         { "maxpartitions", CTLTYPE_INT }, \
  214:         { "rawpartition", CTLTYPE_INT }, \
  215:         { "gap", 0 }, \
  216:         { "gap", 0 }, \
  217:         { "osversion", CTLTYPE_STRING }, \
  218:         { "somaxconn", CTLTYPE_INT }, \
  219:         { "sominconn", CTLTYPE_INT }, \
  220:         { "usermount", CTLTYPE_INT }, \
  221:         { "random", CTLTYPE_STRUCT }, \
  222:         { "nosuidcoredump", CTLTYPE_INT }, \
  223:         { "fsync", CTLTYPE_INT }, \
  224:         { "sysvmsg", CTLTYPE_INT }, \
  225:         { "sysvsem", CTLTYPE_INT }, \
  226:         { "sysvshm", CTLTYPE_INT }, \
  227:         { "arandom", CTLTYPE_INT }, \
  228:         { "msgbufsize", CTLTYPE_INT }, \
  229:         { "malloc", CTLTYPE_NODE }, \
  230:         { "cp_time", CTLTYPE_STRUCT }, \
  231:         { "nchstats", CTLTYPE_STRUCT }, \
  232:         { "forkstat", CTLTYPE_STRUCT }, \
  233:         { "nselcoll", CTLTYPE_INT }, \
  234:         { "tty", CTLTYPE_NODE }, \
  235:         { "ccpu", CTLTYPE_INT }, \
  236:         { "fscale", CTLTYPE_INT }, \
  237:         { "nprocs", CTLTYPE_INT }, \
  238:         { "msgbuf", CTLTYPE_STRUCT }, \
  239:         { "pool", CTLTYPE_NODE }, \
  240:         { "stackgap_random", CTLTYPE_INT }, \
  241:         { "sysvipc_info", CTLTYPE_INT }, \
  242:         { "usercrypto", CTLTYPE_INT }, \
  243:         { "cryptodevallowsoft", CTLTYPE_INT }, \
  244:         { "splassert", CTLTYPE_INT }, \
  245:         { "procargs", CTLTYPE_NODE }, \
  246:         { "nfiles", CTLTYPE_INT }, \
  247:         { "ttycount", CTLTYPE_INT }, \
  248:         { "numvnodes", CTLTYPE_INT }, \
  249:         { "mbstat", CTLTYPE_STRUCT }, \
  250:         { "userasymcrypto", CTLTYPE_INT }, \
  251:         { "seminfo", CTLTYPE_STRUCT }, \
  252:         { "shminfo", CTLTYPE_STRUCT }, \
  253:         { "intrcnt", CTLTYPE_NODE }, \
  254:         { "watchdog", CTLTYPE_NODE }, \
  255:         { "emul", CTLTYPE_NODE }, \
  256:         { "proc", CTLTYPE_STRUCT }, \
  257:         { "maxclusters", CTLTYPE_INT }, \
  258:         { "evcount", CTLTYPE_NODE }, \
  259:         { "timecounter", CTLTYPE_NODE }, \
  260:         { "maxlocksperuid", CTLTYPE_INT }, \
  261:         { "cp_time2", CTLTYPE_STRUCT }, \
  262:         { "bufcachepercent", CTLTYPE_INT }, \
  263:         { "file2", CTLTYPE_STRUCT }, \
  264:         { "rthreads", CTLTYPE_INT }, \
  265:         { "consdev", CTLTYPE_STRUCT }, \
  266:         { "netlivelocks", CTLTYPE_INT }, \
  267:         { "pool_debug", CTLTYPE_INT }, \
  268:         { "proc_cwd", CTLTYPE_NODE }, \
  269: }
  270: 
  271: /*
  272:  * KERN_EMUL subtypes.
  273:  */
  274: #define KERN_EMUL_NUM           0
  275: /* Fourth level sysctl names */
  276: #define KERN_EMUL_NAME          0
  277: #define KERN_EMUL_ENABLED       1
  278: 
  279: 
  280: /*
  281:  * KERN_PROC subtypes
  282:  */
  283: #define KERN_PROC_ALL           0        /* everything but kernel threads */
  284: #define KERN_PROC_PID           1        /* by process id */
  285: #define KERN_PROC_PGRP          2       /* by process group id */
  286: #define KERN_PROC_SESSION       3     /* by session of pid */
  287: #define KERN_PROC_TTY           4        /* by controlling tty */
  288: #define KERN_PROC_UID           5        /* by effective uid */
  289: #define KERN_PROC_RUID          6       /* by real uid */
  290: #define KERN_PROC_KTHREAD       7     /* also return kernel threads */
  291: 
  292: /*
  293:  * KERN_SYSVIPC_INFO subtypes
  294:  */
  295: #define KERN_SYSVIPC_MSG_INFO   1 /* msginfo and msqid_ds */
  296: #define KERN_SYSVIPC_SEM_INFO   2 /* seminfo and semid_ds */
  297: #define KERN_SYSVIPC_SHM_INFO   3 /* shminfo and shmid_ds */
  298: 
  299: /*
  300:  * KERN_PROC_ARGS subtypes
  301:  */
  302: #define KERN_PROC_ARGV          1
  303: #define KERN_PROC_NARGV         2
  304: #define KERN_PROC_ENV           3
  305: #define KERN_PROC_NENV          4
  306: 
  307: /*
  308:  * KERN_PROC subtype ops return arrays of relatively fixed size
  309:  * structures of process info.   Use 8 byte alignment, and new
  310:  * elements should only be added to the end of this structure so
  311:  * binary compatibility can be preserved.
  312:  */
  313: #define KI_NGROUPS      16
  314: #define KI_MAXCOMLEN    24 /* extra for 8 byte alignment */
  315: #define KI_WMESGLEN     8
  316: #define KI_MAXLOGNAME   32
  317: #define KI_EMULNAMELEN  8
  318: 
  319: #define KI_NOCPU        (~(u_int64_t)0)
  320: 
  321: struct kinfo_proc {
  322:         u_int64_t p_forw;              /* PTR: linked run/sleep queue. */
  323:         u_int64_t p_back;
  324:         u_int64_t p_paddr;             /* PTR: address of proc */
  325: 
  326:         u_int64_t p_addr;              /* PTR: Kernel virtual addr of u-area */
  327:         u_int64_t p_fd;                        /* PTR: Ptr to open files structure. */
  328:         u_int64_t p_stats;             /* unused, always zero. */
  329:         u_int64_t p_limit;             /* PTR: Process limits. */
  330:         u_int64_t p_vmspace;           /* PTR: Address space. */
  331:         u_int64_t p_sigacts;           /* PTR: Signal actions, state */
  332:         u_int64_t p_sess;              /* PTR: session pointer */
  333:         u_int64_t p_tsess;             /* PTR: tty session pointer */
  334:         u_int64_t p_ru;                        /* PTR: Exit information. XXX */
  335: 
  336:         int32_t        p_eflag;               /* LONG: extra kinfo_proc flags */
  337: #define EPROC_CTTY      0x01 /* controlling tty vnode active */
  338: #define EPROC_SLEADER   0x02      /* session leader */
  339:         int32_t        p_exitsig;             /* INT: signal to sent to parent on exit */
  340:         int32_t        p_flag;                        /* INT: P_* flags. */
  341: 
  342:         int32_t        p_pid;                 /* PID_T: Process identifier. */
  343:         int32_t        p_ppid;                        /* PID_T: Parent process id */
  344:         int32_t        p_sid;                 /* PID_T: session id */
  345:         int32_t        p__pgid;               /* PID_T: process group id */
  346:                                         /* XXX: <sys/proc.h> hijacks p_pgid */
  347:         int32_t        p_tpgid;               /* PID_T: tty process group id */
  348: 
  349:         u_int32_t p_uid;               /* UID_T: effective user id */
  350:         u_int32_t p_ruid;              /* UID_T: real user id */
  351:         u_int32_t p_gid;               /* GID_T: effective group id */
  352:         u_int32_t p_rgid;              /* GID_T: real group id */
  353: 
  354:         u_int32_t p_groups[KI_NGROUPS];        /* GID_T: groups */
  355:         int16_t        p_ngroups;             /* SHORT: number of groups */
  356: 
  357:         int16_t        p_jobc;                        /* SHORT: job control counter */
  358:         u_int32_t p_tdev;              /* DEV_T: controlling tty dev */
  359: 
  360:         u_int32_t p_estcpu;            /* U_INT: Time averaged value of p_cpticks. */
  361:         u_int32_t p_rtime_sec;         /* STRUCT TIMEVAL: Real time. */
  362:         u_int32_t p_rtime_usec;                /* STRUCT TIMEVAL: Real time. */
  363:         int32_t        p_cpticks;             /* INT: Ticks of cpu time. */
  364:         u_int32_t p_pctcpu;            /* FIXPT_T: %cpu for this process during p_swtime */
  365:         u_int32_t p_swtime;            /* U_INT: Time swapped in or out. */
  366:         u_int32_t p_slptime;           /* U_INT: Time since last blocked. */
  367:         int32_t        p_schedflags;          /* INT: PSCHED_* flags */
  368: 
  369:         u_int64_t p_uticks;            /* U_QUAD_T: Statclock hits in user mode. */
  370:         u_int64_t p_sticks;            /* U_QUAD_T: Statclock hits in system mode. */
  371:         u_int64_t p_iticks;            /* U_QUAD_T: Statclock hits processing intr. */
  372: 
  373:         u_int64_t p_tracep;            /* PTR: Trace to vnode or file */
  374:         int32_t        p_traceflag;           /* INT: Kernel trace points. */
  375: 
  376:         int32_t p_holdcnt;             /* INT: If non-zero, don't swap. */
  377: 
  378:         int32_t p_siglist;             /* INT: Signals arrived but not delivered. */
  379:         u_int32_t p_sigmask;           /* SIGSET_T: Current signal mask. */
  380:         u_int32_t p_sigignore;         /* SIGSET_T: Signals being ignored. */
  381:         u_int32_t p_sigcatch;          /* SIGSET_T: Signals being caught by user. */
  382: 
  383:         int8_t p_stat;                 /* CHAR: S* process status (from LWP). */
  384:         u_int8_t p_priority;           /* U_CHAR: Process priority. */
  385:         u_int8_t p_usrpri;             /* U_CHAR: User-priority based on p_cpu and ps_nice. */
  386:         u_int8_t p_nice;               /* U_CHAR: Process "nice" value. */
  387: 
  388:         u_int16_t p_xstat;             /* U_SHORT: Exit status for wait; also stop signal. */
  389:         u_int16_t p_acflag;            /* U_SHORT: Accounting flags. */
  390: 
  391:         char   p_comm[KI_MAXCOMLEN];
  392: 
  393:         char   p_wmesg[KI_WMESGLEN];     /* wchan message */
  394:         u_int64_t p_wchan;             /* PTR: sleep address. */
  395: 
  396:         char   p_login[KI_MAXLOGNAME];   /* setlogin() name */
  397: 
  398:         int32_t        p_vm_rssize;           /* SEGSZ_T: current resident set size in pages */
  399:         int32_t        p_vm_tsize;            /* SEGSZ_T: text size (pages) */
  400:         int32_t        p_vm_dsize;            /* SEGSZ_T: data size (pages) */
  401:         int32_t        p_vm_ssize;            /* SEGSZ_T: stack size (pages) */
  402: 
  403:         int64_t        p_uvalid;              /* CHAR: following p_u* members from struct user are valid */
  404:                                         /* XXX 64 bits for alignment */
  405:         u_int32_t p_ustart_sec;                /* STRUCT TIMEVAL: starting time. */
  406:         u_int32_t p_ustart_usec;       /* STRUCT TIMEVAL: starting time. */
  407: 
  408:         u_int32_t p_uutime_sec;                /* STRUCT TIMEVAL: user time. */
  409:         u_int32_t p_uutime_usec;       /* STRUCT TIMEVAL: user time. */
  410:         u_int32_t p_ustime_sec;                /* STRUCT TIMEVAL: system time. */
  411:         u_int32_t p_ustime_usec;       /* STRUCT TIMEVAL: system time. */
  412: 
  413:         u_int64_t p_uru_maxrss;                /* LONG: max resident set size. */
  414:         u_int64_t p_uru_ixrss;         /* LONG: integral shared memory size. */
  415:         u_int64_t p_uru_idrss;         /* LONG: integral unshared data ". */
  416:         u_int64_t p_uru_isrss;         /* LONG: integral unshared stack ". */
  417:         u_int64_t p_uru_minflt;                /* LONG: page reclaims. */
  418:         u_int64_t p_uru_majflt;                /* LONG: page faults. */
  419:         u_int64_t p_uru_nswap;         /* LONG: swaps. */
  420:         u_int64_t p_uru_inblock;       /* LONG: block input operations. */
  421:         u_int64_t p_uru_oublock;       /* LONG: block output operations. */
  422:         u_int64_t p_uru_msgsnd;                /* LONG: messages sent. */
  423:         u_int64_t p_uru_msgrcv;                /* LONG: messages received. */
  424:         u_int64_t p_uru_nsignals;      /* LONG: signals received. */
  425:         u_int64_t p_uru_nvcsw;         /* LONG: voluntary context switches. */
  426:         u_int64_t p_uru_nivcsw;                /* LONG: involuntary ". */
  427: 
  428:         u_int32_t p_uctime_sec;                /* STRUCT TIMEVAL: child u+s time. */
  429:         u_int32_t p_uctime_usec;       /* STRUCT TIMEVAL: child u+s time. */
  430:         u_int64_t p_realflag;          /* INT: P_* flags (not including LWPs). */
  431:         u_int32_t p_svuid;             /* UID_T: saved user id */
  432:         u_int32_t p_svgid;             /* GID_T: saved group id */
  433:         char    p_emul[KI_EMULNAMELEN];        /* syscall emulation name */
  434:         u_int64_t p_rlim_rss_cur;      /* RLIM_T: soft limit for rss */
  435:         u_int64_t p_cpuid;             /* LONG: CPU id */
  436:         u_int64_t p_vm_map_size;       /* VSIZE_T: virtual size */
  437:         int32_t   p_tid;               /* PID_T: Thread identifier. */
  438:         u_int32_t p_rtableid;          /* U_INT: Routing table identifier. */
  439: };
  440: 
  441: #if defined(_KERNEL) || defined(_LIBKVM)
  442: 
  443: /*
  444:  * Macros for filling in the bulk of a kinfo_proc structure, used
  445:  * in the kernel to implement the KERN_PROC sysctl and in userland
  446:  * in libkvm to implement reading from kernel crashes.  The macro
  447:  * arguments are all pointers; by name they are:
  448:  *      kp - target kinfo_proc structure
  449:  *      copy_str - a function or macro invoked as copy_str(dst,src,maxlen)
  450:  *          that has strlcpy or memcpy semantics; the destination is
  451:  *          pre-filled with zeros; for libkvm, src is a kvm address
  452:  *      p - source struct proc
  453:  *      pr - source struct process
  454:  *      pc - source struct pcreds
  455:  *      uc - source struct ucreds
  456:  *      pg - source struct pgrp
  457:  *      paddr - kernel address of the source struct proc
  458:  *      sess - source struct session
  459:  *      vm - source struct vmspace
  460:  *      lim - source struct plimits
  461:  *      sa - source struct sigacts
  462:  * There are some members that are not handled by these macros
  463:  * because they're too painful to generalize: p_pid, p_ppid, p_sid, p_tdev,
  464:  * p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid
  465:  */
  466: 
  467: #define PTRTOINT64(_x)  ((u_int64_t)(u_long)(_x))
  468: 
  469: #define FILL_KPROC(kp, copy_str, p, pr, pc, uc, pg, paddr, praddr, sess, vm, lim, sa) \
  470: do {                                                                    \
  471:         memset((kp), 0, sizeof(*(kp)));                                        \
  472:                                                                         \
  473:         (kp)->p_paddr = PTRTOINT64(paddr);                             \
  474:         (kp)->p_fd = PTRTOINT64((p)->p_fd);                            \
  475:         (kp)->p_stats = 0;                                             \
  476:         (kp)->p_limit = PTRTOINT64((pr)->ps_limit);                    \
  477:         (kp)->p_vmspace = PTRTOINT64((p)->p_vmspace);                  \
  478:         (kp)->p_sigacts = PTRTOINT64((p)->p_sigacts);                  \
  479:         (kp)->p_sess = PTRTOINT64((pg)->pg_session);                   \
  480:         (kp)->p_ru = PTRTOINT64((pr)->ps_ru);                          \
  481:                                                                         \
  482:         (kp)->p_exitsig = (p)->p_exitsig;                              \
  483:         (kp)->p_flag = (p)->p_flag | (pr)->ps_flags | P_INMEM;         \
  484:                                                                         \
  485:         (kp)->p__pgid = (pg)->pg_id;                                   \
  486:                                                                         \
  487:         (kp)->p_uid = (uc)->cr_uid;                                    \
  488:         (kp)->p_ruid = (pc)->p_ruid;                                   \
  489:         (kp)->p_gid = (uc)->cr_gid;                                    \
  490:         (kp)->p_rgid = (pc)->p_rgid;                                   \
  491:         (kp)->p_svuid = (pc)->p_svuid;                                 \
  492:         (kp)->p_svgid = (pc)->p_svgid;                                 \
  493:                                                                         \
  494:         memcpy((kp)->p_groups, (uc)->cr_groups,                                \
  495:             MIN(sizeof((kp)->p_groups), sizeof((uc)->cr_groups)));     \
  496:         (kp)->p_ngroups = (uc)->cr_ngroups;                            \
  497:                                                                         \
  498:         (kp)->p_jobc = (pg)->pg_jobc;                                  \
  499:                                                                         \
  500:         (kp)->p_estcpu = (p)->p_estcpu;                                        \
  501:         (kp)->p_rtime_sec = (pr)->ps_tu.tu_runtime.tv_sec;             \
  502:         (kp)->p_rtime_usec = (pr)->ps_tu.tu_runtime.tv_usec;           \
  503:         (kp)->p_cpticks = (p)->p_cpticks;                              \
  504:         (kp)->p_pctcpu = (p)->p_pctcpu;                                        \
  505:                                                                         \
  506:         (kp)->p_uticks = (p)->p_uticks;                                        \
  507:         (kp)->p_sticks = (p)->p_sticks;                                        \
  508:         (kp)->p_iticks = (p)->p_iticks;                                        \
  509:                                                                         \
  510:         (kp)->p_tracep = PTRTOINT64((pr)->ps_tracevp);                 \
  511:         (kp)->p_traceflag = (pr)->ps_traceflag;                                \
  512:                                                                         \
  513:         (kp)->p_siglist = (p)->p_siglist;                              \
  514:         (kp)->p_sigmask = (p)->p_sigmask;                              \
  515:         (kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0;             \
  516:         (kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0;               \
  517:                                                                         \
  518:         (kp)->p_stat = (p)->p_stat;                                    \
  519:         (kp)->p_nice = (pr)->ps_nice;                                  \
  520:                                                                         \
  521:         (kp)->p_xstat = (p)->p_xstat;                                  \
  522:         (kp)->p_acflag = (p)->p_acflag;                                        \
  523:                                                                         \
  524:         /* XXX depends on e_name being an array and not a pointer */   \
  525:         copy_str((kp)->p_emul, (char *)(p)->p_emul +                   \
  526:             offsetof(struct emul, e_name), sizeof((kp)->p_emul));      \
  527:         strlcpy((kp)->p_comm, (p)->p_comm, sizeof((kp)->p_comm));      \
  528:         strlcpy((kp)->p_login, (sess)->s_login,                        \
  529:             MIN(sizeof((kp)->p_login), sizeof((sess)->s_login)));      \
  530:                                                                         \
  531:         if ((sess)->s_ttyvp)                                           \
  532:                 (kp)->p_eflag |= EPROC_CTTY;                          \
  533:         if ((sess)->s_leader == (praddr))                              \
  534:                 (kp)->p_eflag |= EPROC_SLEADER;                               \
  535:                                                                         \
  536:         if ((p)->p_stat != SIDL && !P_ZOMBIE(p)) {                     \
  537:                 if ((vm) != NULL) {                                   \
  538:                         (kp)->p_vm_rssize = (vm)->vm_rssize;         \
  539:                         (kp)->p_vm_tsize = (vm)->vm_tsize;           \
  540:                         (kp)->p_vm_dsize = (vm)->vm_dused;           \
  541:                         (kp)->p_vm_ssize = (vm)->vm_ssize;           \
  542:                 }                                                     \
  543:                 (kp)->p_addr = PTRTOINT64((p)->p_addr);                       \
  544:                 (kp)->p_stat = (p)->p_stat;                           \
  545:                 (kp)->p_swtime = (p)->p_swtime;                               \
  546:                 (kp)->p_slptime = (p)->p_slptime;                     \
  547:                 (kp)->p_holdcnt = 1;                                  \
  548:                 (kp)->p_priority = (p)->p_priority;                   \
  549:                 (kp)->p_usrpri = (p)->p_usrpri;                               \
  550:                 if ((p)->p_wmesg)                                     \
  551:                         copy_str((kp)->p_wmesg, (p)->p_wmesg,                \
  552:                             sizeof((kp)->p_wmesg));                  \
  553:                 (kp)->p_wchan = PTRTOINT64((p)->p_wchan);             \
  554:         }                                                              \
  555:                                                                         \
  556:         if (lim)                                                       \
  557:                 (kp)->p_rlim_rss_cur =                                        \
  558:                     (lim)->pl_rlimit[RLIMIT_RSS].rlim_cur;            \
  559:                                                                         \
  560:         if (!P_ZOMBIE(p)) {                                            \
  561:                 struct timeval tv;                                    \
  562:                                                                         \
  563:                 (kp)->p_uvalid = 1;                                   \
  564:                                                                         \
  565:                 (kp)->p_ustart_sec = (pr)->ps_start.tv_sec;           \
  566:                 (kp)->p_ustart_usec = (pr)->ps_start.tv_usec;         \
  567:                                                                         \
  568:                 (kp)->p_uru_maxrss = (p)->p_ru.ru_maxrss;             \
  569:                 (kp)->p_uru_ixrss = (p)->p_ru.ru_ixrss;                       \
  570:                 (kp)->p_uru_idrss = (p)->p_ru.ru_idrss;                       \
  571:                 (kp)->p_uru_isrss = (p)->p_ru.ru_isrss;                       \
  572:                 (kp)->p_uru_minflt = (p)->p_ru.ru_minflt;             \
  573:                 (kp)->p_uru_majflt = (p)->p_ru.ru_majflt;             \
  574:                 (kp)->p_uru_nswap = (p)->p_ru.ru_nswap;                       \
  575:                 (kp)->p_uru_inblock = (p)->p_ru.ru_inblock;           \
  576:                 (kp)->p_uru_oublock = (p)->p_ru.ru_oublock;           \
  577:                 (kp)->p_uru_msgsnd = (p)->p_ru.ru_msgsnd;             \
  578:                 (kp)->p_uru_msgrcv = (p)->p_ru.ru_msgrcv;             \
  579:                 (kp)->p_uru_nsignals = (p)->p_ru.ru_nsignals;         \
  580:                 (kp)->p_uru_nvcsw = (p)->p_ru.ru_nvcsw;                       \
  581:                 (kp)->p_uru_nivcsw = (p)->p_ru.ru_nivcsw;             \
  582:                                                                         \
  583:                 timeradd(&(pr)->ps_cru.ru_utime,                      \
  584:                          &(pr)->ps_cru.ru_stime, &tv);                       \
  585:                 (kp)->p_uctime_sec = tv.tv_sec;                               \
  586:                 (kp)->p_uctime_usec = tv.tv_usec;                     \
  587:         }                                                              \
  588:                                                                         \
  589:         (kp)->p_cpuid = KI_NOCPU;                                      \
  590:         (kp)->p_tid = (p)->p_pid + THREAD_PID_OFFSET;                  \
  591:         (kp)->p_rtableid = (pr)->ps_rtableid;                          \
  592: } while (0)
  593: 
  594: #endif /* defined(_KERNEL) || defined(_LIBKVM) */
  595: 
  596: 
  597: /*
  598:  * kern.file2 returns an array of these structures, which are designed
  599:  * both to be immune to 32/64 bit emulation issues and to
  600:  * provide backwards compatibility.  The order differs slightly from
  601:  * that of the real struct file, and some fields are taken from other
  602:  * structures (struct vnode, struct proc) in order to make the file
  603:  * information more useful.
  604:  */
  605: #define KERN_FILE_BYFILE        1
  606: #define KERN_FILE_BYPID         2
  607: #define KERN_FILE_BYUID         3
  608: #define KERN_FILESLOP           10
  609: 
  610: #define KERN_FILE_TEXT          -1
  611: #define KERN_FILE_CDIR          -2
  612: #define KERN_FILE_RDIR          -3
  613: #define KERN_FILE_TRACE         -4
  614: 
  615: #define KI_MNAMELEN             96 /* rounded up from 90 */
  616: 
  617: struct kinfo_file2 {
  618:         uint64_t       f_fileaddr;   /* PTR: address of struct file */
  619:         uint32_t       f_flag;               /* SHORT: flags (see fcntl.h) */
  620:         uint32_t       f_iflags;     /* INT: internal flags */
  621:         uint32_t       f_type;               /* INT: descriptor type */
  622:         uint32_t       f_count;      /* UINT: reference count */
  623:         uint32_t       f_msgcount;   /* UINT: references from msg queue */
  624:         uint32_t       f_usecount;   /* INT: number active users */
  625:         uint64_t       f_ucred;      /* PTR: creds for descriptor */
  626:         uint32_t       f_uid;                /* UID_T: descriptor credentials */
  627:         uint32_t       f_gid;                /* GID_T: descriptor credentials */
  628:         uint64_t       f_ops;                /* PTR: address of fileops */
  629:         uint64_t       f_offset;     /* OFF_T: offset */
  630:         uint64_t       f_data;               /* PTR: descriptor data */
  631:         uint64_t       f_rxfer;      /* UINT64: number of read xfers */
  632:         uint64_t       f_rwfer;      /* UINT64: number of write xfers */
  633:         uint64_t       f_seek;               /* UINT64: number of seek operations */
  634:         uint64_t       f_rbytes;     /* UINT64: total bytes read */
  635:         uint64_t       f_wbytes;     /* UINT64: total bytes written */
  636: 
  637:         /* information about the vnode associated with this file */
  638:         uint64_t       v_un;         /* PTR: socket, specinfo, etc */
  639:         uint32_t       v_type;               /* ENUM: vnode type */
  640:         uint32_t       v_tag;                /* ENUM: type of underlying data */
  641:         uint32_t       v_flag;               /* UINT: vnode flags */
  642:         uint32_t       va_rdev;      /* DEV_T: raw device */
  643:         uint64_t       v_data;               /* PTR: private data for fs */
  644:         uint64_t       v_mount;      /* PTR: mount info for fs */
  645:         uint64_t       va_fileid;    /* LONG: file id */
  646:         uint64_t       va_size;      /* UINT64_T: file size in bytes */
  647:         uint32_t       va_mode;      /* MODE_T: file access mode and type */
  648:         uint32_t       va_fsid;      /* DEV_T: filesystem device */
  649:         char           f_mntonname[KI_MNAMELEN];
  650: 
  651:         /* socket information */
  652:         uint32_t       so_type;      /* SHORT: socket type */
  653:         uint32_t       so_state;     /* SHORT: socket state */
  654:         uint64_t       so_pcb;               /* PTR: socket pcb */
  655:         uint32_t       so_protocol;  /* SHORT: socket protocol type */
  656:         uint32_t       so_family;    /* INT: socket domain family */
  657:         uint64_t       inp_ppcb;     /* PTR: pointer to per-protocol pcb */
  658:         uint32_t       inp_lport;    /* SHORT: local inet port */
  659:         uint32_t       inp_laddru[4];        /* STRUCT: local inet addr */
  660:         uint32_t       inp_fport;    /* SHORT: foreign inet port */
  661:         uint32_t       inp_faddru[4];        /* STRUCT: foreign inet addr */
  662:         uint64_t       unp_conn;     /* PTR: connected socket cntrl block */
  663: 
  664:         /* pipe information */
  665:         uint64_t       pipe_peer;    /* PTR: link with other direction */
  666:         uint32_t       pipe_state;   /* UINT: pipe status info */
  667: 
  668:         /* kqueue information */
  669:         uint32_t       kq_count;     /* INT: number of pending events */
  670:         uint32_t       kq_state;     /* INT: kqueue status information */
  671: 
  672:         /* systrace information */
  673:         uint32_t       str_npolicies;        /* INT: number systrace policies */
  674: 
  675:         /* process information when retrieved via KERN_FILE_BY[PU]ID */
  676:         uint32_t       p_pid;                /* PID_T: process id */
  677:         int32_t                fd_fd;                /* INT: descriptor number */
  678:         uint32_t       fd_ofileflags;        /* CHAR: open file flags */
  679:         uint32_t       p_uid;                /* UID_T: process credentials */
  680:         uint32_t       p_gid;                /* GID_T: process credentials */
  681:         uint32_t       p_tid;                /* PID_T: thread id */
  682:         char           p_comm[KI_MAXCOMLEN];
  683: 
  684:         /* more socket information */
  685:         uint32_t       inp_rtableid; /* UINT: Routing table identifier. */
  686:         uint64_t       so_splice;    /* PTR: f_data of spliced socket */
  687:         int64_t                so_splicelen; /* OFF_T: already spliced count or */
  688:                                         /* -1 if this is target of splice */
  689: };
  690: 
  691: /*
  692:  * KERN_INTRCNT
  693:  */
  694: #define KERN_INTRCNT_NUM        1      /* int: # intrcnt */
  695: #define KERN_INTRCNT_CNT        2      /* node: intrcnt */
  696: #define KERN_INTRCNT_NAME       3     /* node: names */
  697: #define KERN_INTRCNT_VECTOR     4   /* node: interrupt vector # */
  698: #define KERN_INTRCNT_MAXID      5
  699: 
  700: #define CTL_KERN_INTRCNT_NAMES { \
  701:         { 0, 0 }, \
  702:         { "nintrcnt", CTLTYPE_INT }, \
  703:         { "intrcnt", CTLTYPE_NODE }, \
  704:         { "intrname", CTLTYPE_NODE }, \
  705: }
  706: 
  707: /*
  708:  * KERN_WATCHDOG
  709:  */
  710: #define KERN_WATCHDOG_PERIOD    1  /* int: watchdog period */
  711: #define KERN_WATCHDOG_AUTO      2    /* int: automatic tickle */
  712: #define KERN_WATCHDOG_MAXID     3
  713: 
  714: #define CTL_KERN_WATCHDOG_NAMES { \
  715:         { 0, 0 }, \
  716:         { "period", CTLTYPE_INT }, \
  717:         { "auto", CTLTYPE_INT }, \
  718: }
  719: 
  720: /*
  721:  * KERN_TIMECOUNTER
  722:  */
  723: #define KERN_TIMECOUNTER_TICK           1        /* int: number of revolutions */
  724: #define KERN_TIMECOUNTER_TIMESTEPWARNINGS 2     /* int: log a warning when time changes */
  725: #define KERN_TIMECOUNTER_HARDWARE       3     /* string: tick hardware used */
  726: #define KERN_TIMECOUNTER_CHOICE         4      /* string: tick hardware used */
  727: #define KERN_TIMECOUNTER_MAXID          5
  728: 
  729: #define CTL_KERN_TIMECOUNTER_NAMES { \
  730:         { 0, 0 }, \
  731:         { "tick", CTLTYPE_INT }, \
  732:         { "timestepwarnings", CTLTYPE_INT }, \
  733:         { "hardware", CTLTYPE_STRING }, \
  734:         { "choice", CTLTYPE_STRING }, \
  735: }
  736: 
  737: /*
  738:  * CTL_FS identifiers
  739:  */
  740: #define FS_POSIX        1              /* POSIX flags */
  741: #define FS_MAXID        2
  742: 
  743: #define CTL_FS_NAMES { \
  744:         { 0, 0 }, \
  745:         { "posix", CTLTYPE_NODE }, \
  746: }
  747: 
  748: /*
  749:  * CTL_FS identifiers
  750:  */
  751: #define FS_POSIX_SETUID 1               /* int: always clear SGID/SUID bit when owner change */
  752: #define FS_POSIX_MAXID  2
  753: 
  754: #define CTL_FS_POSIX_NAMES { \
  755:         { 0, 0 }, \
  756:         { "setuid", CTLTYPE_INT }, \
  757: }
  758: 
  759: /*
  760:  * CTL_HW identifiers
  761:  */
  762: #define HW_MACHINE               1  /* string: machine class */
  763: #define HW_MODEL                 2    /* string: specific machine model */
  764: #define HW_NCPU                  3    /* int: number of cpus being used */
  765: #define HW_BYTEORDER             4        /* int: machine byte order */
  766: #define HW_PHYSMEM               5  /* int: total memory */
  767: #define HW_USERMEM               6  /* int: non-kernel memory */
  768: #define HW_PAGESIZE              7 /* int: software page size */
  769: #define HW_DISKNAMES             8        /* strings: disk drive names */
  770: #define HW_DISKSTATS             9        /* struct: diskstats[] */
  771: #define HW_DISKCOUNT            10        /* int: number of disks */
  772: #define HW_SENSORS              11  /* node: hardware monitors */
  773: #define HW_CPUSPEED             12 /* get CPU frequency */
  774: #define HW_SETPERF              13  /* set CPU performance % */
  775: #define HW_VENDOR               14   /* string: vendor name */
  776: #define HW_PRODUCT              15  /* string: product name */
  777: #define HW_VERSION              16  /* string: hardware version */
  778: #define HW_SERIALNO             17 /* string: hardware serial number */
  779: #define HW_UUID                 18    /* string: universal unique id */
  780: #define HW_PHYSMEM64            19        /* quad: total memory */
  781: #define HW_USERMEM64            20        /* quad: non-kernel memory */
  782: #define HW_NCPUFOUND            21        /* int: number of cpus found*/
  783: #define HW_ALLOWPOWERDOWN       22    /* allow power button shutdown */
  784: #define HW_MAXID                23    /* number of valid hw ids */
  785: 
  786: #define CTL_HW_NAMES { \
  787:         { 0, 0 }, \
  788:         { "machine", CTLTYPE_STRING }, \
  789:         { "model", CTLTYPE_STRING }, \
  790:         { "ncpu", CTLTYPE_INT }, \
  791:         { "byteorder", CTLTYPE_INT }, \
  792:         { "gap", 0 }, \
  793:         { "gap", 0 }, \
  794:         { "pagesize", CTLTYPE_INT }, \
  795:         { "disknames", CTLTYPE_STRING }, \
  796:         { "diskstats", CTLTYPE_STRUCT }, \
  797:         { "diskcount", CTLTYPE_INT }, \
  798:         { "sensors", CTLTYPE_NODE}, \
  799:         { "cpuspeed", CTLTYPE_INT }, \
  800:         { "setperf", CTLTYPE_INT }, \
  801:         { "vendor", CTLTYPE_STRING }, \
  802:         { "product", CTLTYPE_STRING }, \
  803:         { "version", CTLTYPE_STRING }, \
  804:         { "serialno", CTLTYPE_STRING }, \
  805:         { "uuid", CTLTYPE_STRING }, \
  806:         { "physmem", CTLTYPE_QUAD }, \
  807:         { "usermem", CTLTYPE_QUAD }, \
  808:         { "ncpufound", CTLTYPE_INT }, \
  809:         { "allowpowerdown", CTLTYPE_INT }, \
  810: }
  811: 
  812: /*
  813:  * CTL_USER definitions
  814:  */
  815: #define USER_CS_PATH             1        /* string: _CS_PATH */
  816: #define USER_BC_BASE_MAX         2     /* int: BC_BASE_MAX */
  817: #define USER_BC_DIM_MAX          3     /* int: BC_DIM_MAX */
  818: #define USER_BC_SCALE_MAX        4    /* int: BC_SCALE_MAX */
  819: #define USER_BC_STRING_MAX       5   /* int: BC_STRING_MAX */
  820: #define USER_COLL_WEIGHTS_MAX    6        /* int: COLL_WEIGHTS_MAX */
  821: #define USER_EXPR_NEST_MAX       7   /* int: EXPR_NEST_MAX */
  822: #define USER_LINE_MAX            8       /* int: LINE_MAX */
  823: #define USER_RE_DUP_MAX          9     /* int: RE_DUP_MAX */
  824: #define USER_POSIX2_VERSION     10  /* int: POSIX2_VERSION */
  825: #define USER_POSIX2_C_BIND      11   /* int: POSIX2_C_BIND */
  826: #define USER_POSIX2_C_DEV       12    /* int: POSIX2_C_DEV */
  827: #define USER_POSIX2_CHAR_TERM   13        /* int: POSIX2_CHAR_TERM */
  828: #define USER_POSIX2_FORT_DEV    14 /* int: POSIX2_FORT_DEV */
  829: #define USER_POSIX2_FORT_RUN    15 /* int: POSIX2_FORT_RUN */
  830: #define USER_POSIX2_LOCALEDEF   16        /* int: POSIX2_LOCALEDEF */
  831: #define USER_POSIX2_SW_DEV      17   /* int: POSIX2_SW_DEV */
  832: #define USER_POSIX2_UPE         18     /* int: POSIX2_UPE */
  833: #define USER_STREAM_MAX         19     /* int: POSIX2_STREAM_MAX */
  834: #define USER_TZNAME_MAX         20     /* int: POSIX2_TZNAME_MAX */
  835: #define USER_MAXID              21  /* number of valid user ids */
  836: 
  837: #define CTL_USER_NAMES { \
  838:         { 0, 0 }, \
  839:         { "cs_path", CTLTYPE_STRING }, \
  840:         { "bc_base_max", CTLTYPE_INT }, \
  841:         { "bc_dim_max", CTLTYPE_INT }, \
  842:         { "bc_scale_max", CTLTYPE_INT }, \
  843:         { "bc_string_max", CTLTYPE_INT }, \
  844:         { "coll_weights_max", CTLTYPE_INT }, \
  845:         { "expr_nest_max", CTLTYPE_INT }, \
  846:         { "line_max", CTLTYPE_INT }, \
  847:         { "re_dup_max", CTLTYPE_INT }, \
  848:         { "posix2_version", CTLTYPE_INT }, \
  849:         { "posix2_c_bind", CTLTYPE_INT }, \
  850:         { "posix2_c_dev", CTLTYPE_INT }, \
  851:         { "posix2_char_term", CTLTYPE_INT }, \
  852:         { "posix2_fort_dev", CTLTYPE_INT }, \
  853:         { "posix2_fort_run", CTLTYPE_INT }, \
  854:         { "posix2_localedef", CTLTYPE_INT }, \
  855:         { "posix2_sw_dev", CTLTYPE_INT }, \
  856:         { "posix2_upe", CTLTYPE_INT }, \
  857:         { "stream_max", CTLTYPE_INT }, \
  858:         { "tzname_max", CTLTYPE_INT }, \
  859: }
  860: 
  861: /*
  862:  * CTL_DEBUG definitions
  863:  *
  864:  * Second level identifier specifies which debug variable.
  865:  * Third level identifier specifies which structure component.
  866:  */
  867: #define CTL_DEBUG_NAME          0       /* string: variable name */
  868: #define CTL_DEBUG_VALUE         1      /* int: variable value */
  869: #define CTL_DEBUG_MAXID         20
  870: 
  871: #ifdef  _KERNEL
  872: #ifdef  DEBUG
  873: /*
  874:  * CTL_DEBUG variables.
  875:  *
  876:  * These are declared as separate variables so that they can be
  877:  * individually initialized at the location of their associated
  878:  * variable. The loader prevents multiple use by issuing errors
  879:  * if a variable is initialized in more than one place. They are
  880:  * aggregated into an array in debug_sysctl(), so that it can
  881:  * conveniently locate them when querried. If more debugging
  882:  * variables are added, they must also be declared here and also
  883:  * entered into the array.
  884:  */
  885: struct ctldebug {
  886:         char   *debugname;       /* name of debugging variable */
  887:         int    *debugvar; /* pointer to debugging variable */
  888: };
  889: extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
  890: extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
  891: extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
  892: extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
  893: #endif  /* DEBUG */
  894: 
  895: /*
  896:  * Internal sysctl function calling convention:
  897:  *
  898:  *      (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
  899:  *
  900:  * The name parameter points at the next component of the name to be
  901:  * interpreted.  The namelen parameter is the number of integers in
  902:  * the name.
  903:  */
  904: typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
  905: 
  906: int sysctl_int(void *, size_t *, void *, size_t, int *);
  907: int sysctl_int_lower(void *, size_t *, void *, size_t, int *);
  908: int sysctl_rdint(void *, size_t *, void *, int);
  909: int sysctl_int_arr(int **, int *, u_int, void *, size_t *, void *, size_t);
  910: int sysctl_quad(void *, size_t *, void *, size_t, int64_t *);
  911: int sysctl_rdquad(void *, size_t *, void *, int64_t);
  912: int sysctl_string(void *, size_t *, void *, size_t, char *, int);
  913: int sysctl_tstring(void *, size_t *, void *, size_t, char *, int);
  914: int sysctl__string(void *, size_t *, void *, size_t, char *, int, int);
  915: int sysctl_rdstring(void *, size_t *, void *, const char *);
  916: int sysctl_rdstruct(void *, size_t *, void *, const void *, int);
  917: int sysctl_struct(void *, size_t *, void *, size_t, void *, int);
  918: int sysctl_file(char *, size_t *, struct proc *);
  919: int sysctl_file2(int *, u_int, char *, size_t *, struct proc *);
  920: int sysctl_doproc(int *, u_int, char *, size_t *);
  921: struct radix_node;
  922: struct walkarg;
  923: int sysctl_dumpentry(struct radix_node *, void *, u_int);
  924: int sysctl_iflist(int, struct walkarg *);
  925: int sysctl_rtable(int *, u_int, void *, size_t *, void *, size_t);
  926: int sysctl_clockrate(char *, size_t *, void *);
  927: int sysctl_vnode(char *, size_t *, struct proc *);
  928: #ifdef GPROF
  929: int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
  930: #endif
  931: int sysctl_dopool(int *, u_int, char *, size_t *);
  932: 
  933: void fill_file2(struct kinfo_file2 *, struct file *, struct filedesc *,
  934:     int, struct vnode *, struct proc *, struct proc *);
  935: 
  936: void fill_kproc(struct proc *, struct kinfo_proc *);
  937: 
  938: int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  939:                      struct proc *);
  940: int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  941:                    struct proc *);
  942: #ifdef DEBUG
  943: int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  944:                       struct proc *);
  945: #endif
  946: int vm_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  947:                    struct proc *);
  948: int fs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  949:                    struct proc *);
  950: int fs_posix_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  951:                          struct proc *);
  952: int net_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  953:                     struct proc *);
  954: int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  955:                     struct proc *);
  956: int vfs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  957:                     struct proc *);
  958: int sysctl_sysvipc(int *, u_int, void *, size_t *);
  959: int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t);
  960: 
  961: extern int (*cpu_cpuspeed)(int *);
  962: extern void (*cpu_setperf)(int);
  963: 
  964: int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  965: int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  966: int pipex_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  967: 
  968: #else   /* !_KERNEL */
  969: #include <sys/cdefs.h>
  970: 
  971: __BEGIN_DECLS
  972: int     sysctl(int *, u_int, void *, size_t *, void *, size_t);
  973: __END_DECLS
  974: #endif  /* _KERNEL */
  975: #endif  /* !_SYS_SYSCTL_H_ */