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


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

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

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

    1 /*      $OpenBSD: sysctl.h,v 1.232 2023/01/07 05:24:58 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 #include <sys/syslimits.h>
   42 #include <uvm/uvmexp.h>
   43 
   44 /*
   45  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
   46  * for objects that can be examined or modified.  The name is expressed as
   47  * a sequence of integers.  Like a file path name, the meaning of each
   48  * component depends on its place in the hierarchy.  The top-level and kern
   49  * identifiers are defined here, and other identifiers are defined in the
   50  * respective subsystem header files.
   51  */
   52 
   53 #define CTL_MAXNAME     12      /* largest number of components supported */
   54 
   55 /*
   56  * Each subsystem defined by sysctl defines a list of variables
   57  * for that subsystem. Each name is either a node with further
   58  * levels defined below it, or it is a leaf of some particular
   59  * type given below. Each sysctl level defines a set of name/type
   60  * pairs to be used by sysctl(1) in manipulating the subsystem.
   61  */
   62 struct ctlname {
   63         char    *ctl_name;      /* subsystem name */
   64         int     ctl_type;       /* type of name */
   65 };
   66 #define CTLTYPE_NODE    1       /* name is a node */
   67 #define CTLTYPE_INT     2       /* name describes an integer */
   68 #define CTLTYPE_STRING  3       /* name describes a string */
   69 #define CTLTYPE_QUAD    4       /* name describes a 64-bit number */
   70 #define CTLTYPE_STRUCT  5       /* name describes a structure */
   71 
   72 /*
   73  * Top-level identifiers
   74  */
   75 #define CTL_UNSPEC      0               /* unused */
   76 #define CTL_KERN        1               /* "high kernel": proc, limits */
   77 #define CTL_VM          2               /* virtual memory */
   78 #define CTL_FS          3               /* file system, mount type is next */
   79 #define CTL_NET         4               /* network, see socket.h */
   80 #define CTL_DEBUG       5               /* debugging parameters */
   81 #define CTL_HW          6               /* generic cpu/io */
   82 #define CTL_MACHDEP     7               /* machine dependent */
   83 /*define gap            8                  was CTL_USER: removed 2013-04 */
   84 #define CTL_DDB         9               /* DDB user interface, see db_var.h */
   85 #define CTL_VFS         10              /* VFS sysctl's */
   86 #define CTL_MAXID       11              /* number of valid top-level ids */
   87 
   88 #define CTL_NAMES { \
   89         { 0, 0 }, \
   90         { "kern", CTLTYPE_NODE }, \
   91         { "vm", CTLTYPE_NODE }, \
   92         { "fs", CTLTYPE_NODE }, \
   93         { "net", CTLTYPE_NODE }, \
   94         { "debug", CTLTYPE_NODE }, \
   95         { "hw", CTLTYPE_NODE }, \
   96         { "machdep", CTLTYPE_NODE }, \
   97         { "gap", 0 }, \
   98         { "ddb", CTLTYPE_NODE }, \
   99         { "vfs", CTLTYPE_NODE }, \
  100 }
  101 
  102 /*
  103  * CTL_KERN identifiers
  104  */
  105 #define KERN_OSTYPE              1      /* string: system version */
  106 #define KERN_OSRELEASE           2      /* string: system release */
  107 #define KERN_OSREV               3      /* int: system revision */
  108 #define KERN_VERSION             4      /* string: compile time info */
  109 #define KERN_MAXVNODES           5      /* int: max vnodes */
  110 #define KERN_MAXPROC             6      /* int: max processes */
  111 #define KERN_MAXFILES            7      /* int: max open files */
  112 #define KERN_ARGMAX              8      /* int: max arguments to exec */
  113 #define KERN_SECURELVL           9      /* int: system security level */
  114 #define KERN_HOSTNAME           10      /* string: hostname */
  115 #define KERN_HOSTID             11      /* int: host identifier */
  116 #define KERN_CLOCKRATE          12      /* struct: struct clockinfo */
  117 /* was KERN_DNSJACKPORT         13      */
  118 /* was KERN_PROC                14      */
  119 /* was KERN_FILE                15      */
  120 #define KERN_PROF               16      /* node: kernel profiling info */
  121 #define KERN_POSIX1             17      /* int: POSIX.1 version */
  122 #define KERN_NGROUPS            18      /* int: # of supplemental group ids */
  123 #define KERN_JOB_CONTROL        19      /* int: is job control available */
  124 #define KERN_SAVED_IDS          20      /* int: saved set-user/group-ID */
  125 #define KERN_BOOTTIME           21      /* struct: time kernel was booted */
  126 #define KERN_DOMAINNAME         22      /* string: (YP) domainname */
  127 #define KERN_MAXPARTITIONS      23      /* int: number of partitions/disk */
  128 #define KERN_RAWPARTITION       24      /* int: raw partition number */
  129 #define KERN_MAXTHREAD          25      /* int: max threads */
  130 #define KERN_NTHREADS           26      /* int: number of threads */
  131 #define KERN_OSVERSION          27      /* string: kernel build version */
  132 #define KERN_SOMAXCONN          28      /* int: listen queue maximum */
  133 #define KERN_SOMINCONN          29      /* int: half-open controllable param */
  134 /* was KERN_USERMOUNT           30      */
  135 /* was KERN_RND 31                      */
  136 #define KERN_NOSUIDCOREDUMP     32      /* int: no setuid coredumps ever */ 
  137 #define KERN_FSYNC              33      /* int: file synchronization support */
  138 #define KERN_SYSVMSG            34      /* int: SysV message queue support */
  139 #define KERN_SYSVSEM            35      /* int: SysV semaphore support */
  140 #define KERN_SYSVSHM            36      /* int: SysV shared memory support */
  141 /* was KERN_ARND                37      */
  142 #define KERN_MSGBUFSIZE         38      /* int: size of message buffer */
  143 #define KERN_MALLOCSTATS        39      /* node: malloc statistics */
  144 #define KERN_CPTIME             40      /* array: cp_time */
  145 #define KERN_NCHSTATS           41      /* struct: vfs cache statistics */
  146 #define KERN_FORKSTAT           42      /* struct: fork statistics */
  147 /* was KERN_NSELCOLL            43      */
  148 #define KERN_TTY                44      /* node: tty information */
  149 #define KERN_CCPU               45      /* int: ccpu */
  150 #define KERN_FSCALE             46      /* int: fscale */
  151 #define KERN_NPROCS             47      /* int: number of processes */
  152 #define KERN_MSGBUF             48      /* message buffer, KERN_MSGBUFSIZE */
  153 #define KERN_POOL               49      /* struct: pool information */
  154 #define KERN_STACKGAPRANDOM     50      /* int: stackgap_random */
  155 #define KERN_SYSVIPC_INFO       51      /* struct: SysV sem/shm/msg info */
  156 #define KERN_ALLOWKMEM          52      /* int: allowkmem */
  157 #define KERN_WITNESSWATCH       53      /* int: witnesswatch */
  158 #define KERN_SPLASSERT          54      /* int: splassert */
  159 #define KERN_PROC_ARGS          55      /* node: proc args and env */
  160 #define KERN_NFILES             56      /* int: number of open files */
  161 #define KERN_TTYCOUNT           57      /* int: number of tty devices */
  162 #define KERN_NUMVNODES          58      /* int: number of vnodes in use */
  163 #define KERN_MBSTAT             59      /* struct: mbuf statistics */
  164 #define KERN_WITNESS            60      /* node: witness */
  165 #define KERN_SEMINFO            61      /* struct: SysV struct seminfo */
  166 #define KERN_SHMINFO            62      /* struct: SysV struct shminfo */
  167 #define KERN_INTRCNT            63      /* node: interrupt counters */
  168 #define KERN_WATCHDOG           64      /* node: watchdog */
  169 #define KERN_ALLOWDT            65      /* int: allowdt */
  170 #define KERN_PROC               66      /* struct: process entries */
  171 #define KERN_MAXCLUSTERS        67      /* number of mclusters */
  172 #define KERN_EVCOUNT            68      /* node: event counters */
  173 #define KERN_TIMECOUNTER        69      /* node: timecounter */
  174 #define KERN_MAXLOCKSPERUID     70      /* int: locks per uid */
  175 #define KERN_CPTIME2            71      /* array: cp_time2 */
  176 #define KERN_CACHEPCT           72      /* buffer cache % of physmem */
  177 #define KERN_FILE               73      /* struct: file entries */
  178 #define KERN_WXABORT            74      /* int: w^x sigabrt & core */
  179 #define KERN_CONSDEV            75      /* dev_t: console terminal device */
  180 #define KERN_NETLIVELOCKS       76      /* int: number of network livelocks */
  181 #define KERN_POOL_DEBUG         77      /* int: enable pool_debug */
  182 #define KERN_PROC_CWD           78      /* node: proc cwd */
  183 #define KERN_PROC_NOBROADCASTKILL 79    /* node: proc no broadcast kill */
  184 #define KERN_PROC_VMMAP         80      /* node: proc vmmap */
  185 #define KERN_GLOBAL_PTRACE      81      /* allow ptrace globally */
  186 #define KERN_CONSBUFSIZE        82      /* int: console message buffer size */
  187 #define KERN_CONSBUF            83      /* console message buffer */
  188 #define KERN_AUDIO              84      /* struct: audio properties */
  189 #define KERN_CPUSTATS           85      /* struct: cpu statistics */
  190 #define KERN_PFSTATUS           86      /* struct: pf status and stats */
  191 #define KERN_TIMEOUT_STATS      87      /* struct: timeout status and stats */
  192 #define KERN_UTC_OFFSET         88      /* int: adjust RTC time to UTC */
  193 #define KERN_VIDEO              89      /* struct: video properties */
  194 #define KERN_CLOCKINTR          90      /* node: clockintr */
  195 #define KERN_AUTOCONF_SERIAL    91      /* int: kernel device tree state serial */
  196 #define KERN_MAXID              92      /* number of valid kern ids */
  197 
  198 #define CTL_KERN_NAMES { \
  199         { 0, 0 }, \
  200         { "ostype", CTLTYPE_STRING }, \
  201         { "osrelease", CTLTYPE_STRING }, \
  202         { "osrevision", CTLTYPE_INT }, \
  203         { "version", CTLTYPE_STRING }, \
  204         { "maxvnodes", CTLTYPE_INT }, \
  205         { "maxproc", CTLTYPE_INT }, \
  206         { "maxfiles", CTLTYPE_INT }, \
  207         { "argmax", CTLTYPE_INT }, \
  208         { "securelevel", CTLTYPE_INT }, \
  209         { "hostname", CTLTYPE_STRING }, \
  210         { "hostid", CTLTYPE_INT }, \
  211         { "clockrate", CTLTYPE_STRUCT }, \
  212         { "gap", 0 }, \
  213         { "gap", 0 }, \
  214         { "gap", 0 }, \
  215         { "profiling", CTLTYPE_NODE }, \
  216         { "posix1version", CTLTYPE_INT }, \
  217         { "ngroups", CTLTYPE_INT }, \
  218         { "job_control", CTLTYPE_INT }, \
  219         { "saved_ids", CTLTYPE_INT }, \
  220         { "boottime", CTLTYPE_STRUCT }, \
  221         { "domainname", CTLTYPE_STRING }, \
  222         { "maxpartitions", CTLTYPE_INT }, \
  223         { "rawpartition", CTLTYPE_INT }, \
  224         { "maxthread", CTLTYPE_INT }, \
  225         { "nthreads", CTLTYPE_INT }, \
  226         { "osversion", CTLTYPE_STRING }, \
  227         { "somaxconn", CTLTYPE_INT }, \
  228         { "sominconn", CTLTYPE_INT }, \
  229         { "gap", 0 }, \
  230         { "gap", 0 }, \
  231         { "nosuidcoredump", CTLTYPE_INT }, \
  232         { "fsync", CTLTYPE_INT }, \
  233         { "sysvmsg", CTLTYPE_INT }, \
  234         { "sysvsem", CTLTYPE_INT }, \
  235         { "sysvshm", CTLTYPE_INT }, \
  236         { "gap", 0 }, \
  237         { "msgbufsize", CTLTYPE_INT }, \
  238         { "malloc", CTLTYPE_NODE }, \
  239         { "cp_time", CTLTYPE_STRUCT }, \
  240         { "nchstats", CTLTYPE_STRUCT }, \
  241         { "forkstat", CTLTYPE_STRUCT }, \
  242         { "gap", 0 }, \
  243         { "tty", CTLTYPE_NODE }, \
  244         { "ccpu", CTLTYPE_INT }, \
  245         { "fscale", CTLTYPE_INT }, \
  246         { "nprocs", CTLTYPE_INT }, \
  247         { "msgbuf", CTLTYPE_STRUCT }, \
  248         { "pool", CTLTYPE_NODE }, \
  249         { "stackgap_random", CTLTYPE_INT }, \
  250         { "sysvipc_info", CTLTYPE_INT }, \
  251         { "allowkmem", CTLTYPE_INT }, \
  252         { "witnesswatch", CTLTYPE_INT }, \
  253         { "splassert", CTLTYPE_INT }, \
  254         { "procargs", CTLTYPE_NODE }, \
  255         { "nfiles", CTLTYPE_INT }, \
  256         { "ttycount", CTLTYPE_INT }, \
  257         { "numvnodes", CTLTYPE_INT }, \
  258         { "mbstat", CTLTYPE_STRUCT }, \
  259         { "witness", CTLTYPE_NODE }, \
  260         { "seminfo", CTLTYPE_STRUCT }, \
  261         { "shminfo", CTLTYPE_STRUCT }, \
  262         { "intrcnt", CTLTYPE_NODE }, \
  263         { "watchdog", CTLTYPE_NODE }, \
  264         { "allowdt", CTLTYPE_INT }, \
  265         { "proc", CTLTYPE_STRUCT }, \
  266         { "maxclusters", CTLTYPE_INT }, \
  267         { "evcount", CTLTYPE_NODE }, \
  268         { "timecounter", CTLTYPE_NODE }, \
  269         { "maxlocksperuid", CTLTYPE_INT }, \
  270         { "cp_time2", CTLTYPE_STRUCT }, \
  271         { "bufcachepercent", CTLTYPE_INT }, \
  272         { "file", CTLTYPE_STRUCT }, \
  273         { "wxabort", CTLTYPE_INT }, \
  274         { "consdev", CTLTYPE_STRUCT }, \
  275         { "netlivelocks", CTLTYPE_INT }, \
  276         { "pool_debug", CTLTYPE_INT }, \
  277         { "proc_cwd", CTLTYPE_NODE }, \
  278         { "proc_nobroadcastkill", CTLTYPE_NODE }, \
  279         { "proc_vmmap", CTLTYPE_NODE }, \
  280         { "global_ptrace", CTLTYPE_INT }, \
  281         { "consbufsize", CTLTYPE_INT }, \
  282         { "consbuf", CTLTYPE_STRUCT }, \
  283         { "audio", CTLTYPE_STRUCT }, \
  284         { "cpustats", CTLTYPE_STRUCT }, \
  285         { "pfstatus", CTLTYPE_STRUCT }, \
  286         { "timeout_stats", CTLTYPE_STRUCT }, \
  287         { "utc_offset", CTLTYPE_INT }, \
  288         { "video", CTLTYPE_STRUCT }, \
  289         { "clockintr", CTLTYPE_NODE }, \
  290         { "autoconf_serial", CTLTYPE_INT }, \
  291 }
  292 
  293 /*
  294  * KERN_PROC subtypes
  295  */
  296 #define KERN_PROC_ALL           0       /* everything but kernel threads */
  297 #define KERN_PROC_PID           1       /* by process id */
  298 #define KERN_PROC_PGRP          2       /* by process group id */
  299 #define KERN_PROC_SESSION       3       /* by session of pid */
  300 #define KERN_PROC_TTY           4       /* by controlling tty */
  301 #define KERN_PROC_UID           5       /* by effective uid */
  302 #define KERN_PROC_RUID          6       /* by real uid */
  303 #define KERN_PROC_KTHREAD       7       /* also return kernel threads */
  304 #define KERN_PROC_SHOW_THREADS  0x40000000/* also return normal threads */
  305 
  306 /*
  307  * KERN_SYSVIPC_INFO subtypes
  308  */
  309 #define KERN_SYSVIPC_MSG_INFO   1       /* msginfo and msqid_ds */
  310 #define KERN_SYSVIPC_SEM_INFO   2       /* seminfo and semid_ds */
  311 #define KERN_SYSVIPC_SHM_INFO   3       /* shminfo and shmid_ds */
  312 
  313 /*
  314  * KERN_PROC_ARGS subtypes
  315  */
  316 #define KERN_PROC_ARGV          1
  317 #define KERN_PROC_NARGV         2
  318 #define KERN_PROC_ENV           3
  319 #define KERN_PROC_NENV          4
  320 
  321 /*
  322  * KERN_AUDIO
  323  */
  324 #define KERN_AUDIO_RECORD       1
  325 #define KERN_AUDIO_MAXID        2
  326 
  327 #define CTL_KERN_AUDIO_NAMES { \
  328         { 0, 0 }, \
  329         { "record", CTLTYPE_INT }, \
  330 }
  331 
  332 /*
  333  * KERN_VIDEO
  334  */
  335 #define KERN_VIDEO_RECORD       1
  336 #define KERN_VIDEO_MAXID        2
  337 
  338 #define CTL_KERN_VIDEO_NAMES { \
  339         { 0, 0 }, \
  340         { "record", CTLTYPE_INT }, \
  341 }
  342 
  343 /*
  344  * KERN_WITNESS
  345  */
  346 #define KERN_WITNESS_WATCH      1       /* int: operating mode */
  347 #define KERN_WITNESS_LOCKTRACE  2       /* int: stack trace saving mode */
  348 #define KERN_WITNESS_MAXID      3
  349 
  350 #define CTL_KERN_WITNESS_NAMES { \
  351         { 0, 0 }, \
  352         { "watch", CTLTYPE_INT }, \
  353         { "locktrace", CTLTYPE_INT }, \
  354 }
  355 
  356 /*
  357  * KERN_PROC subtype ops return arrays of relatively fixed size
  358  * structures of process info.   Use 8 byte alignment, and new
  359  * elements should only be added to the end of this structure so
  360  * binary compatibility can be preserved.
  361  */
  362 #define KI_NGROUPS      16
  363 #define KI_MAXCOMLEN    _MAXCOMLEN      /* includes NUL */
  364 #define KI_WMESGLEN     8
  365 #define KI_MAXLOGNAME   32
  366 #define KI_EMULNAMELEN  8
  367 
  368 #define KI_NOCPU        (~(u_int64_t)0)
  369 
  370 struct kinfo_proc {
  371         u_int64_t p_forw;               /* PTR: linked run/sleep queue. */
  372         u_int64_t p_back;
  373         u_int64_t p_paddr;              /* PTR: address of proc */
  374 
  375         u_int64_t p_addr;               /* PTR: Kernel virtual addr of u-area */
  376         u_int64_t p_fd;                 /* PTR: Ptr to open files structure. */
  377         u_int64_t p_stats;              /* unused, always zero. */
  378         u_int64_t p_limit;              /* PTR: Process limits. */
  379         u_int64_t p_vmspace;            /* PTR: Address space. */
  380         u_int64_t p_sigacts;            /* PTR: Signal actions, state */
  381         u_int64_t p_sess;               /* PTR: session pointer */
  382         u_int64_t p_tsess;              /* PTR: tty session pointer */
  383         u_int64_t p_ru;                 /* PTR: Exit information. XXX */
  384 
  385         int32_t p_eflag;                /* LONG: extra kinfo_proc flags */
  386 #define EPROC_CTTY      0x01    /* controlling tty vnode active */
  387 #define EPROC_SLEADER   0x02    /* session leader */
  388 #define EPROC_UNVEIL    0x04    /* has unveil settings */
  389 #define EPROC_LKUNVEIL  0x08    /* unveil is locked */
  390         int32_t p_exitsig;              /* unused, always zero. */
  391         int32_t p_flag;                 /* INT: P_* flags. */
  392 
  393         int32_t p_pid;                  /* PID_T: Process identifier. */
  394         int32_t p_ppid;                 /* PID_T: Parent process id */
  395         int32_t p_sid;                  /* PID_T: session id */
  396         int32_t p__pgid;                /* PID_T: process group id */
  397                                         /* XXX: <sys/proc.h> hijacks p_pgid */
  398         int32_t p_tpgid;                /* PID_T: tty process group id */
  399 
  400         u_int32_t p_uid;                /* UID_T: effective user id */
  401         u_int32_t p_ruid;               /* UID_T: real user id */
  402         u_int32_t p_gid;                /* GID_T: effective group id */
  403         u_int32_t p_rgid;               /* GID_T: real group id */
  404 
  405         u_int32_t p_groups[KI_NGROUPS]; /* GID_T: groups */
  406         int16_t p_ngroups;              /* SHORT: number of groups */
  407 
  408         int16_t p_jobc;                 /* SHORT: job control counter */
  409         u_int32_t p_tdev;               /* DEV_T: controlling tty dev */
  410 
  411         u_int32_t p_estcpu;             /* U_INT: Time averaged value of p_cpticks. */
  412         u_int32_t p_rtime_sec;          /* STRUCT TIMEVAL: Real time. */
  413         u_int32_t p_rtime_usec;         /* STRUCT TIMEVAL: Real time. */
  414         int32_t p_cpticks;              /* INT: Ticks of cpu time. */
  415         u_int32_t p_pctcpu;             /* FIXPT_T: %cpu for this process */
  416         u_int32_t p_swtime;             /* unused, always zero */
  417         u_int32_t p_slptime;            /* U_INT: Time since last blocked. */
  418         int32_t p_schedflags;           /* INT: PSCHED_* flags */
  419 
  420         u_int64_t p_uticks;             /* U_QUAD_T: Statclock hits in user mode. */
  421         u_int64_t p_sticks;             /* U_QUAD_T: Statclock hits in system mode. */
  422         u_int64_t p_iticks;             /* U_QUAD_T: Statclock hits processing intr. */
  423 
  424         u_int64_t p_tracep;             /* PTR: Trace to vnode or file */
  425         int32_t p_traceflag;            /* INT: Kernel trace points. */
  426 
  427         int32_t p_holdcnt;              /* INT: If non-zero, don't swap. */
  428 
  429         int32_t p_siglist;              /* INT: Signals arrived but not delivered. */
  430         u_int32_t p_sigmask;            /* SIGSET_T: Current signal mask. */
  431         u_int32_t p_sigignore;          /* SIGSET_T: Signals being ignored. */
  432         u_int32_t p_sigcatch;           /* SIGSET_T: Signals being caught by user. */
  433 
  434         int8_t  p_stat;                 /* CHAR: S* process status (from LWP). */
  435         u_int8_t p_priority;            /* U_CHAR: Process priority. */
  436         u_int8_t p_usrpri;              /* U_CHAR: User-priority based on p_estcpu and ps_nice. */
  437         u_int8_t p_nice;                /* U_CHAR: Process "nice" value. */
  438 
  439         u_int16_t p_xstat;              /* U_SHORT: Exit status for wait; also stop signal. */
  440         u_int16_t p_spare;              /* U_SHORT: unused */
  441 
  442         char    p_comm[KI_MAXCOMLEN];
  443 
  444         char    p_wmesg[KI_WMESGLEN];   /* wchan message */
  445         u_int64_t p_wchan;              /* PTR: sleep address. */
  446 
  447         char    p_login[KI_MAXLOGNAME]; /* setlogin() name */
  448 
  449         int32_t p_vm_rssize;            /* SEGSZ_T: current resident set size in pages */
  450         int32_t p_vm_tsize;             /* SEGSZ_T: text size (pages) */
  451         int32_t p_vm_dsize;             /* SEGSZ_T: data size (pages) */
  452         int32_t p_vm_ssize;             /* SEGSZ_T: stack size (pages) */
  453 
  454         int64_t p_uvalid;               /* CHAR: following p_u* members from struct user are valid */
  455                                         /* XXX 64 bits for alignment */
  456         u_int64_t p_ustart_sec;         /* STRUCT TIMEVAL: starting time. */
  457         u_int32_t p_ustart_usec;        /* STRUCT TIMEVAL: starting time. */
  458 
  459         u_int32_t p_uutime_sec;         /* STRUCT TIMEVAL: user time. */
  460         u_int32_t p_uutime_usec;        /* STRUCT TIMEVAL: user time. */
  461         u_int32_t p_ustime_sec;         /* STRUCT TIMEVAL: system time. */
  462         u_int32_t p_ustime_usec;        /* STRUCT TIMEVAL: system time. */
  463 
  464         u_int64_t p_uru_maxrss;         /* LONG: max resident set size. */
  465         u_int64_t p_uru_ixrss;          /* LONG: integral shared memory size. */
  466         u_int64_t p_uru_idrss;          /* LONG: integral unshared data ". */
  467         u_int64_t p_uru_isrss;          /* LONG: integral unshared stack ". */
  468         u_int64_t p_uru_minflt;         /* LONG: page reclaims. */
  469         u_int64_t p_uru_majflt;         /* LONG: page faults. */
  470         u_int64_t p_uru_nswap;          /* LONG: swaps. */
  471         u_int64_t p_uru_inblock;        /* LONG: block input operations. */
  472         u_int64_t p_uru_oublock;        /* LONG: block output operations. */
  473         u_int64_t p_uru_msgsnd;         /* LONG: messages sent. */
  474         u_int64_t p_uru_msgrcv;         /* LONG: messages received. */
  475         u_int64_t p_uru_nsignals;       /* LONG: signals received. */
  476         u_int64_t p_uru_nvcsw;          /* LONG: voluntary context switches. */
  477         u_int64_t p_uru_nivcsw;         /* LONG: involuntary ". */
  478 
  479         u_int32_t p_uctime_sec;         /* STRUCT TIMEVAL: child u+s time. */
  480         u_int32_t p_uctime_usec;        /* STRUCT TIMEVAL: child u+s time. */
  481         u_int32_t p_psflags;            /* UINT: PS_* flags on the process. */
  482         u_int32_t p_acflag;             /* UINT: Accounting flags. */
  483         u_int32_t p_svuid;              /* UID_T: saved user id */
  484         u_int32_t p_svgid;              /* GID_T: saved group id */
  485         char    p_emul[KI_EMULNAMELEN]; /* syscall emulation name */
  486         u_int64_t p_rlim_rss_cur;       /* RLIM_T: soft limit for rss */
  487         u_int64_t p_cpuid;              /* LONG: CPU id */
  488         u_int64_t p_vm_map_size;        /* VSIZE_T: virtual size */
  489         int32_t   p_tid;                /* PID_T: Thread identifier. */
  490         u_int32_t p_rtableid;           /* U_INT: Routing table identifier. */
  491 
  492         u_int64_t p_pledge;             /* U_INT64_T: Pledge flags. */
  493         char    p_name[KI_MAXCOMLEN];   /* thread name */
  494 };
  495 
  496 /*
  497  * VM address range entry, matching struct vm_map_entry.  Useful for
  498  * debuggers to know process's addresses.
  499  *
  500  * To iterate entries, set the last kve_end as the base address into
  501  * kve_start.
  502  */
  503 struct kinfo_vmentry {
  504         u_long kve_start;               /* vaddr_t */
  505         u_long kve_end;                 /* vaddr_t */
  506         u_long kve_guard;               /* vsize_t */
  507         u_long kve_fspace;              /* vsize_t */
  508         u_long kve_fspace_augment;      /* vsize_t */
  509         u_int64_t kve_offset;           /* voff_t */
  510         int kve_wired_count;
  511         int kve_etype;
  512         int kve_protection;
  513         int kve_max_protection;
  514         int kve_advice;
  515         int kve_inheritance;
  516         u_int8_t kve_flags;             /* u_int8_t */
  517 };
  518 
  519 /* keep in sync with UVM_ET_* */
  520 #define KVE_ET_OBJ              0x00000001
  521 #define KVE_ET_SUBMAP           0x00000002
  522 #define KVE_ET_COPYONWRITE      0x00000004
  523 #define KVE_ET_NEEDSCOPY        0x00000008
  524 #define KVE_ET_HOLE             0x00000010
  525 #define KVE_ET_NOFAULT          0x00000020
  526 #define KVE_ET_STACK            0x00000040
  527 #define KVE_ET_WC               0x00000080
  528 #define KVE_ET_CONCEAL          0x00000100
  529 #define KVE_ET_SYSCALL          0x00000200
  530 #define KVE_ET_FREEMAPPED       0x00000800
  531 
  532 #define KVE_PROT_NONE           0x00000000
  533 #define KVE_PROT_READ           0x00000001
  534 #define KVE_PROT_WRITE          0x00000002
  535 #define KVE_PROT_EXEC           0x00000004
  536 
  537 #define KVE_ADV_NORMAL          0x00000000
  538 #define KVE_ADV_RANDOM          0x00000001
  539 #define KVE_ADV_SEQUENTIAL      0x00000002
  540 
  541 #define KVE_INH_SHARE           0x00000000
  542 #define KVE_INH_COPY            0x00000010
  543 #define KVE_INH_NONE            0x00000020
  544 #define KVE_INH_ZERO            0x00000030
  545 
  546 #define KVE_F_STATIC            0x01
  547 #define KVE_F_KMEM              0x02
  548 
  549 #if defined(_KERNEL) || defined(_LIBKVM)
  550 
  551 /*
  552  * Macros for filling in the bulk of a kinfo_proc structure, used
  553  * in the kernel to implement the KERN_PROC sysctl and in userland
  554  * in libkvm to implement reading from kernel crashes.  The macro
  555  * arguments are all pointers; by name they are:
  556  *      kp - target kinfo_proc structure
  557  *      copy_str - a function or macro invoked as copy_str(dst,src,maxlen)
  558  *          that has strlcpy or memcpy semantics; the destination is
  559  *          pre-filled with zeros; for libkvm, src is a kvm address
  560  *      p - source struct proc
  561  *      pr - source struct process
  562  *      uc - source struct ucreds
  563  *      pg - source struct pgrp
  564  *      paddr - kernel address of the source struct proc
  565  *      praddr - kernel address of the source struct process
  566  *      sess - source struct session
  567  *      vm - source struct vmspace
  568  *      lim - source struct plimits
  569  *      sa - source struct sigacts
  570  * There are some members that are not handled by these macros
  571  * because they're too painful to generalize: p_ppid, p_sid, p_tdev,
  572  * p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid
  573  */
  574 
  575 #if defined(_KERNEL)
  576 #define PR_LOCK(pr)     mtx_enter(&(pr)->ps_mtx)
  577 #define PR_UNLOCK(pr)   mtx_leave(&(pr)->ps_mtx)
  578 #else
  579 #define PR_LOCK(pr)     /* nothing */
  580 #define PR_UNLOCK(pr)   /* nothing */
  581 #endif
  582 
  583 #define _getcompatprio(_p)                                              \
  584         ((_p)->p_stat == SRUN ? (_p)->p_runpri :                        \
  585             ((_p)->p_stat == SSLEEP) ? (_p)->p_slppri : (_p)->p_usrpri)
  586 
  587 #define PTRTOINT64(_x)  ((u_int64_t)(u_long)(_x))
  588 
  589 #define _FILL_KPROC_MIN(a,b) (((a)<(b))?(a):(b))
  590 
  591 #define FILL_KPROC(kp, copy_str, p, pr, uc, pg, paddr, \
  592     praddr, sess, vm, lim, sa, isthread, show_addresses) \
  593 do {                                                                    \
  594         memset((kp), 0, sizeof(*(kp)));                                 \
  595                                                                         \
  596         if (show_addresses) {                                           \
  597                 (kp)->p_paddr = PTRTOINT64(paddr);                      \
  598                 (kp)->p_fd = PTRTOINT64((pr)->ps_fd);                   \
  599                 (kp)->p_limit = PTRTOINT64((pr)->ps_limit);             \
  600                 (kp)->p_vmspace = PTRTOINT64((pr)->ps_vmspace);         \
  601                 (kp)->p_sigacts = PTRTOINT64((pr)->ps_sigacts);         \
  602                 (kp)->p_sess = PTRTOINT64((pg)->pg_session);            \
  603                 (kp)->p_ru = PTRTOINT64((pr)->ps_ru);                   \
  604         }                                                               \
  605         (kp)->p_stats = 0;                                              \
  606         (kp)->p_exitsig = 0;                                            \
  607         (kp)->p_flag = (p)->p_flag;                                     \
  608         (kp)->p_pid = (pr)->ps_pid;                                     \
  609         (kp)->p_psflags = (pr)->ps_flags;                               \
  610                                                                         \
  611         (kp)->p__pgid = (pg)->pg_id;                                    \
  612                                                                         \
  613         (kp)->p_uid = (uc)->cr_uid;                                     \
  614         (kp)->p_ruid = (uc)->cr_ruid;                                   \
  615         (kp)->p_gid = (uc)->cr_gid;                                     \
  616         (kp)->p_rgid = (uc)->cr_rgid;                                   \
  617         (kp)->p_svuid = (uc)->cr_svuid;                                 \
  618         (kp)->p_svgid = (uc)->cr_svgid;                                 \
  619                                                                         \
  620         memcpy((kp)->p_groups, (uc)->cr_groups,                         \
  621             _FILL_KPROC_MIN(sizeof((kp)->p_groups), sizeof((uc)->cr_groups))); \
  622         (kp)->p_ngroups = (uc)->cr_ngroups;                             \
  623                                                                         \
  624         (kp)->p_jobc = (pg)->pg_jobc;                                   \
  625                                                                         \
  626         (kp)->p_estcpu = (p)->p_estcpu;                                 \
  627         if (isthread) {                                                 \
  628                 (kp)->p_rtime_sec = (p)->p_tu.tu_runtime.tv_sec;        \
  629                 (kp)->p_rtime_usec = (p)->p_tu.tu_runtime.tv_nsec/1000; \
  630                 (kp)->p_tid = (p)->p_tid + THREAD_PID_OFFSET;           \
  631                 (kp)->p_uticks = (p)->p_tu.tu_uticks;                   \
  632                 (kp)->p_sticks = (p)->p_tu.tu_sticks;                   \
  633                 (kp)->p_iticks = (p)->p_tu.tu_iticks;                   \
  634                 strlcpy((kp)->p_name, (p)->p_name, sizeof((kp)->p_name)); \
  635         } else {                                                        \
  636                 (kp)->p_rtime_sec = (pr)->ps_tu.tu_runtime.tv_sec;      \
  637                 (kp)->p_rtime_usec = (pr)->ps_tu.tu_runtime.tv_nsec/1000; \
  638                 (kp)->p_tid = -1;                                       \
  639                 (kp)->p_uticks = (pr)->ps_tu.tu_uticks;                 \
  640                 (kp)->p_sticks = (pr)->ps_tu.tu_sticks;                 \
  641                 (kp)->p_iticks = (pr)->ps_tu.tu_iticks;                 \
  642         }                                                               \
  643         (kp)->p_cpticks = (p)->p_cpticks;                               \
  644                                                                         \
  645         if (show_addresses)                                             \
  646                 (kp)->p_tracep = PTRTOINT64((pr)->ps_tracevp);          \
  647         (kp)->p_traceflag = (pr)->ps_traceflag;                         \
  648                                                                         \
  649         (kp)->p_siglist = (p)->p_siglist | (pr)->ps_siglist;            \
  650         (kp)->p_sigmask = (p)->p_sigmask;                               \
  651                                                                         \
  652         PR_LOCK(pr);                                                    \
  653         (kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0;              \
  654         (kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0;                \
  655                                                                         \
  656         if (lim)                                                        \
  657                 (kp)->p_rlim_rss_cur =                                  \
  658                     (lim)->pl_rlimit[RLIMIT_RSS].rlim_cur;              \
  659         PR_UNLOCK(pr);                                                  \
  660                                                                         \
  661         (kp)->p_stat = (p)->p_stat;                                     \
  662         (kp)->p_nice = (pr)->ps_nice;                                   \
  663                                                                         \
  664         (kp)->p_xstat = W_EXITCODE((pr)->ps_xexit, (pr)->ps_xsig);      \
  665         (kp)->p_acflag = (pr)->ps_acflag;                               \
  666         (kp)->p_pledge = (pr)->ps_pledge;                               \
  667                                                                         \
  668         strlcpy((kp)->p_emul, "native", sizeof((kp)->p_emul));          \
  669         strlcpy((kp)->p_comm, (pr)->ps_comm, sizeof((kp)->p_comm));     \
  670         strlcpy((kp)->p_login, (sess)->s_login,                         \
  671             _FILL_KPROC_MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \
  672                                                                         \
  673         if ((sess)->s_ttyvp)                                            \
  674                 (kp)->p_eflag |= EPROC_CTTY;                            \
  675         if ((pr)->ps_uvpaths)                                           \
  676                 (kp)->p_eflag |= EPROC_UNVEIL;                          \
  677         if ((pr)->ps_uvdone ||                                          \
  678             (((pr)->ps_flags & PS_PLEDGE) &&                            \
  679              ((pr)->ps_pledge & PLEDGE_UNVEIL) == 0))                   \
  680                 (kp)->p_eflag |= EPROC_LKUNVEIL;                        \
  681                                                                         \
  682         if (((pr)->ps_flags & (PS_EMBRYO | PS_ZOMBIE)) == 0) {          \
  683                 if ((vm) != NULL) {                                     \
  684                         (kp)->p_vm_rssize = (vm)->vm_rssize;            \
  685                         (kp)->p_vm_tsize = (vm)->vm_tsize;              \
  686                         (kp)->p_vm_dsize = (vm)->vm_dused;              \
  687                         (kp)->p_vm_ssize = (vm)->vm_ssize;              \
  688                 }                                                       \
  689                 (kp)->p_addr = PTRTOINT64((p)->p_addr);                 \
  690                 (kp)->p_stat = (p)->p_stat;                             \
  691                 (kp)->p_slptime = (p)->p_slptime;                       \
  692                 (kp)->p_holdcnt = 1;                                    \
  693                 (kp)->p_priority = _getcompatprio(p);                   \
  694                 (kp)->p_usrpri = (p)->p_usrpri;                         \
  695                 if ((p)->p_wchan && (p)->p_wmesg)                       \
  696                         copy_str((kp)->p_wmesg, (p)->p_wmesg,           \
  697                             sizeof((kp)->p_wmesg));                     \
  698                 if (show_addresses)                                     \
  699                         (kp)->p_wchan = PTRTOINT64((p)->p_wchan);       \
  700         }                                                               \
  701                                                                         \
  702         if (((pr)->ps_flags & PS_ZOMBIE) == 0) {                        \
  703                 struct timeval __tv;                                    \
  704                                                                         \
  705                 (kp)->p_uvalid = 1;                                     \
  706                                                                         \
  707                 (kp)->p_uru_maxrss = (p)->p_ru.ru_maxrss;               \
  708                 (kp)->p_uru_ixrss = (p)->p_ru.ru_ixrss;                 \
  709                 (kp)->p_uru_idrss = (p)->p_ru.ru_idrss;                 \
  710                 (kp)->p_uru_isrss = (p)->p_ru.ru_isrss;                 \
  711                 (kp)->p_uru_minflt = (p)->p_ru.ru_minflt;               \
  712                 (kp)->p_uru_majflt = (p)->p_ru.ru_majflt;               \
  713                 (kp)->p_uru_nswap = (p)->p_ru.ru_nswap;                 \
  714                 (kp)->p_uru_inblock = (p)->p_ru.ru_inblock;             \
  715                 (kp)->p_uru_oublock = (p)->p_ru.ru_oublock;             \
  716                 (kp)->p_uru_msgsnd = (p)->p_ru.ru_msgsnd;               \
  717                 (kp)->p_uru_msgrcv = (p)->p_ru.ru_msgrcv;               \
  718                 (kp)->p_uru_nsignals = (p)->p_ru.ru_nsignals;           \
  719                 (kp)->p_uru_nvcsw = (p)->p_ru.ru_nvcsw;                 \
  720                 (kp)->p_uru_nivcsw = (p)->p_ru.ru_nivcsw;               \
  721                                                                         \
  722                 timeradd(&(pr)->ps_cru.ru_utime,                        \
  723                          &(pr)->ps_cru.ru_stime, &__tv);                \
  724                 (kp)->p_uctime_sec = __tv.tv_sec;                       \
  725                 (kp)->p_uctime_usec = __tv.tv_usec;                     \
  726         }                                                               \
  727                                                                         \
  728         (kp)->p_cpuid = KI_NOCPU;                                       \
  729         (kp)->p_rtableid = (pr)->ps_rtableid;                           \
  730 } while (0)
  731 
  732 #endif /* defined(_KERNEL) || defined(_LIBKVM) */
  733 
  734 
  735 /*
  736  * kern.file returns an array of these structures, which are designed
  737  * both to be immune to 32/64 bit emulation issues and to
  738  * provide backwards compatibility.  The order differs slightly from
  739  * that of the real struct file, and some fields are taken from other
  740  * structures (struct vnode, struct proc) in order to make the file
  741  * information more useful.
  742  */
  743 #define KERN_FILE_BYFILE        1
  744 #define KERN_FILE_BYPID         2
  745 #define KERN_FILE_BYUID         3
  746 #define KERN_FILESLOP           10
  747 
  748 #define KERN_FILE_TEXT          -1
  749 #define KERN_FILE_CDIR          -2
  750 #define KERN_FILE_RDIR          -3
  751 #define KERN_FILE_TRACE         -4
  752 
  753 #define KI_MNAMELEN             96      /* rounded up from 90 */
  754 #define KI_UNPPATHLEN           104
  755 
  756 struct kinfo_file {
  757         uint64_t        f_fileaddr;     /* PTR: address of struct file */
  758         uint32_t        f_flag;         /* UINT: flags (see fcntl.h) */
  759         uint32_t        f_iflags;       /* UINT: internal flags */
  760         uint32_t        f_type;         /* INT: descriptor type */
  761         uint32_t        f_count;        /* UINT: reference count */
  762         uint32_t        f_msgcount;     /* UINT: references from msg queue */
  763         uint32_t        f_usecount;     /* INT: number active users */
  764         uint64_t        f_ucred;        /* PTR: creds for descriptor */
  765         uint32_t        f_uid;          /* UID_T: descriptor credentials */
  766         uint32_t        f_gid;          /* GID_T: descriptor credentials */
  767         uint64_t        f_ops;          /* PTR: address of fileops */
  768         uint64_t        f_offset;       /* OFF_T: offset */
  769         uint64_t        f_data;         /* PTR: descriptor data */
  770         uint64_t        f_rxfer;        /* UINT64: number of read xfers */
  771         uint64_t        f_rwfer;        /* UINT64: number of write xfers */
  772         uint64_t        f_seek;         /* UINT64: number of seek operations */
  773         uint64_t        f_rbytes;       /* UINT64: total bytes read */
  774         uint64_t        f_wbytes;       /* UINT64: total bytes written */
  775 
  776         /* information about the vnode associated with this file */
  777         uint64_t        v_un;           /* PTR: socket, specinfo, etc */
  778         uint32_t        v_type;         /* ENUM: vnode type */
  779         uint32_t        v_tag;          /* ENUM: type of underlying data */
  780         uint32_t        v_flag;         /* UINT: vnode flags */
  781         uint32_t        va_rdev;        /* DEV_T: raw device */
  782         uint64_t        v_data;         /* PTR: private data for fs */
  783         uint64_t        v_mount;        /* PTR: mount info for fs */
  784         uint64_t        va_fileid;      /* LONG: file id */
  785         uint64_t        va_size;        /* UINT64_T: file size in bytes */
  786         uint32_t        va_mode;        /* MODE_T: file access mode and type */
  787         uint32_t        va_fsid;        /* DEV_T: filesystem device */
  788         char            f_mntonname[KI_MNAMELEN];
  789 
  790         /* socket information */
  791         uint32_t        so_type;        /* SHORT: socket type */
  792         uint32_t        so_state;       /* SHORT: socket state */
  793         uint64_t        so_pcb;         /* PTR: socket pcb */
  794                                         /* for non-root: -1 if not NULL */
  795         uint32_t        so_protocol;    /* SHORT: socket protocol type */
  796         uint32_t        so_family;      /* INT: socket domain family */
  797         uint64_t        inp_ppcb;       /* PTR: pointer to per-protocol pcb */
  798         uint32_t        inp_lport;      /* SHORT: local inet port */
  799         uint32_t        inp_laddru[4];  /* STRUCT: local inet addr */
  800         uint32_t        inp_fport;      /* SHORT: foreign inet port */
  801         uint32_t        inp_faddru[4];  /* STRUCT: foreign inet addr */
  802         uint64_t        unp_conn;       /* PTR: connected socket cntrl block */
  803 
  804         /* pipe information */
  805         uint64_t        pipe_peer;      /* PTR: link with other direction */
  806         uint32_t        pipe_state;     /* UINT: pipe status info */
  807 
  808         /* kqueue information */
  809         uint32_t        kq_count;       /* INT: number of pending events */
  810         uint32_t        kq_state;       /* INT: kqueue status information */
  811 
  812         uint32_t        __unused1;      /* INT: unused */
  813 
  814         /* process information when retrieved via KERN_FILE_BY[PU]ID */
  815         uint32_t        p_pid;          /* PID_T: process id */
  816         int32_t         fd_fd;          /* INT: descriptor number */
  817         uint32_t        fd_ofileflags;  /* CHAR: open file flags */
  818         uint32_t        p_uid;          /* UID_T: process credentials */
  819         uint32_t        p_gid;          /* GID_T: process credentials */
  820         uint32_t        p_tid;          /* PID_T: thread id */
  821         char            p_comm[KI_MAXCOMLEN];
  822 
  823         /* more socket information */
  824         uint32_t        inp_rtableid;   /* UINT: Routing table identifier. */
  825         uint64_t        so_splice;      /* PTR: f_data of spliced socket */
  826         int64_t         so_splicelen;   /* OFF_T: already spliced count or */
  827                                         /* -1 if this is target of splice */
  828         uint64_t        so_rcv_cc;      /* LONG: chars in receive buf */
  829         uint64_t        so_snd_cc;      /* LONG: chars in send buf */
  830         uint64_t        unp_refs;       /* PTR: connected sockets */
  831         uint64_t        unp_nextref;    /* PTR: link to next connected socket */
  832         uint64_t        unp_addr;       /* PTR: address of the socket address */
  833         char            unp_path[KI_UNPPATHLEN];
  834         uint32_t        inp_proto;      /* CHAR: raw protocol id */
  835         uint32_t        t_state;        /* SHORT: tcp state */
  836         uint64_t        t_rcv_wnd;      /* ULONG: tcp receive window */
  837         uint64_t        t_snd_wnd;      /* ULONG: tcp send window */
  838         uint64_t        t_snd_cwnd;     /* ULONG: congestion-controlled win */
  839 
  840         uint32_t        va_nlink;       /* NLINK_T: number of references to file */
  841 };
  842 
  843 /*
  844  * KERN_INTRCNT
  845  */
  846 #define KERN_INTRCNT_NUM        1       /* int: # intrcnt */
  847 #define KERN_INTRCNT_CNT        2       /* node: intrcnt */
  848 #define KERN_INTRCNT_NAME       3       /* node: names */
  849 #define KERN_INTRCNT_VECTOR     4       /* node: interrupt vector # */
  850 #define KERN_INTRCNT_MAXID      5
  851 
  852 #define CTL_KERN_INTRCNT_NAMES { \
  853         { 0, 0 }, \
  854         { "nintrcnt", CTLTYPE_INT }, \
  855         { "intrcnt", CTLTYPE_NODE }, \
  856         { "intrname", CTLTYPE_NODE }, \
  857 }
  858 
  859 /*
  860  * KERN_WATCHDOG
  861  */
  862 #define KERN_WATCHDOG_PERIOD    1       /* int: watchdog period */
  863 #define KERN_WATCHDOG_AUTO      2       /* int: automatic tickle */
  864 #define KERN_WATCHDOG_MAXID     3
  865 
  866 #define CTL_KERN_WATCHDOG_NAMES { \
  867         { 0, 0 }, \
  868         { "period", CTLTYPE_INT }, \
  869         { "auto", CTLTYPE_INT }, \
  870 }
  871 
  872 /*
  873  * KERN_TIMECOUNTER
  874  */
  875 #define KERN_TIMECOUNTER_TICK           1       /* int: number of revolutions */
  876 #define KERN_TIMECOUNTER_TIMESTEPWARNINGS 2     /* int: log a warning when time changes */
  877 #define KERN_TIMECOUNTER_HARDWARE       3       /* string: tick hardware used */
  878 #define KERN_TIMECOUNTER_CHOICE         4       /* string: tick hardware used */
  879 #define KERN_TIMECOUNTER_MAXID          5
  880 
  881 #define CTL_KERN_TIMECOUNTER_NAMES { \
  882         { 0, 0 }, \
  883         { "tick", CTLTYPE_INT }, \
  884         { "timestepwarnings", CTLTYPE_INT }, \
  885         { "hardware", CTLTYPE_STRING }, \
  886         { "choice", CTLTYPE_STRING }, \
  887 }
  888 
  889 /*
  890  * KERN_CLOCKINTR
  891  */
  892 #define KERN_CLOCKINTR_STATS            1       /* struct: stats */
  893 #define KERN_CLOCKINTR_MAXID            2
  894 
  895 #define CTL_KERN_CLOCKINTR_NAMES { \
  896         { 0, 0 }, \
  897         { "stats", CTLTYPE_STRUCT }, \
  898 }
  899 
  900 /*
  901  * CTL_FS identifiers
  902  */
  903 #define FS_POSIX        1               /* POSIX flags */
  904 #define FS_MAXID        2
  905 
  906 #define CTL_FS_NAMES { \
  907         { 0, 0 }, \
  908         { "posix", CTLTYPE_NODE }, \
  909 }
  910 
  911 /*
  912  * CTL_FS identifiers
  913  */
  914 #define FS_POSIX_SETUID 1               /* int: always clear SGID/SUID bit when owner change */
  915 #define FS_POSIX_MAXID  2
  916 
  917 #define CTL_FS_POSIX_NAMES { \
  918         { 0, 0 }, \
  919         { "setuid", CTLTYPE_INT }, \
  920 }
  921 
  922 /*
  923  * CTL_HW identifiers
  924  */
  925 #define HW_MACHINE               1      /* string: machine class */
  926 #define HW_MODEL                 2      /* string: specific machine model */
  927 #define HW_NCPU                  3      /* int: number of configured cpus */
  928 #define HW_BYTEORDER             4      /* int: machine byte order */
  929 #define HW_PHYSMEM               5      /* int: total memory */
  930 #define HW_USERMEM               6      /* int: non-kernel memory */
  931 #define HW_PAGESIZE              7      /* int: software page size */
  932 #define HW_DISKNAMES             8      /* strings: disk drive names */
  933 #define HW_DISKSTATS             9      /* struct: diskstats[] */
  934 #define HW_DISKCOUNT            10      /* int: number of disks */
  935 #define HW_SENSORS              11      /* node: hardware monitors */
  936 #define HW_CPUSPEED             12      /* get CPU frequency */
  937 #define HW_SETPERF              13      /* set CPU performance % */
  938 #define HW_VENDOR               14      /* string: vendor name */
  939 #define HW_PRODUCT              15      /* string: product name */
  940 #define HW_VERSION              16      /* string: hardware version */
  941 #define HW_SERIALNO             17      /* string: hardware serial number */
  942 #define HW_UUID                 18      /* string: universal unique id */
  943 #define HW_PHYSMEM64            19      /* quad: total memory */
  944 #define HW_USERMEM64            20      /* quad: non-kernel memory */
  945 #define HW_NCPUFOUND            21      /* int: number of cpus found */
  946 #define HW_ALLOWPOWERDOWN       22      /* allow power button shutdown */
  947 #define HW_PERFPOLICY           23      /* set performance policy */
  948 #define HW_SMT                  24      /* int: enable SMT/HT/CMT */
  949 #define HW_NCPUONLINE           25      /* int: number of cpus being used */
  950 #define HW_POWER                26      /* int: machine has wall-power */
  951 #define HW_MAXID                27      /* number of valid hw ids */
  952 
  953 #define CTL_HW_NAMES { \
  954         { 0, 0 }, \
  955         { "machine", CTLTYPE_STRING }, \
  956         { "model", CTLTYPE_STRING }, \
  957         { "ncpu", CTLTYPE_INT }, \
  958         { "byteorder", CTLTYPE_INT }, \
  959         { "gap", 0 }, \
  960         { "gap", 0 }, \
  961         { "pagesize", CTLTYPE_INT }, \
  962         { "disknames", CTLTYPE_STRING }, \
  963         { "diskstats", CTLTYPE_STRUCT }, \
  964         { "diskcount", CTLTYPE_INT }, \
  965         { "sensors", CTLTYPE_NODE}, \
  966         { "cpuspeed", CTLTYPE_INT }, \
  967         { "setperf", CTLTYPE_INT }, \
  968         { "vendor", CTLTYPE_STRING }, \
  969         { "product", CTLTYPE_STRING }, \
  970         { "version", CTLTYPE_STRING }, \
  971         { "serialno", CTLTYPE_STRING }, \
  972         { "uuid", CTLTYPE_STRING }, \
  973         { "physmem", CTLTYPE_QUAD }, \
  974         { "usermem", CTLTYPE_QUAD }, \
  975         { "ncpufound", CTLTYPE_INT }, \
  976         { "allowpowerdown", CTLTYPE_INT }, \
  977         { "perfpolicy", CTLTYPE_STRING }, \
  978         { "smt", CTLTYPE_INT }, \
  979         { "ncpuonline", CTLTYPE_INT }, \
  980         { "power", CTLTYPE_INT }, \
  981 }
  982 
  983 /*
  984  * CTL_DEBUG definitions
  985  *
  986  * Second level identifier specifies which debug variable.
  987  * Third level identifier specifies which structure component.
  988  */
  989 #define CTL_DEBUG_NAME          0       /* string: variable name */
  990 #define CTL_DEBUG_VALUE         1       /* int: variable value */
  991 #define CTL_DEBUG_MAXID         20
  992 
  993 #ifdef  _KERNEL
  994 #ifdef DEBUG_SYSCTL
  995 /*
  996  * CTL_DEBUG variables.
  997  *
  998  * These are declared as separate variables so that they can be
  999  * individually initialized at the location of their associated
 1000  * variable. The loader prevents multiple use by issuing errors
 1001  * if a variable is initialized in more than one place. They are
 1002  * aggregated into an array in debug_sysctl(), so that it can
 1003  * conveniently locate them when queried. If more debugging
 1004  * variables are added, they must also be declared here and also
 1005  * entered into the array.
 1006  */
 1007 struct ctldebug {
 1008         char    *debugname;     /* name of debugging variable */
 1009         int     *debugvar;      /* pointer to debugging variable */
 1010 };
 1011 #endif  /* DEBUG_SYSCTL */
 1012 
 1013 /*
 1014  * Exported sysctl variable with valid bounds. Both bounds are inclusive to
 1015  * allow full range of values.
 1016  */
 1017 struct sysctl_bounded_args {
 1018         int mib;     /* identifier shared with userspace as a CTL_ #define */
 1019         int *var;    /* never NULL */
 1020         int minimum; /* checking is disabled if minimum == maximum  */
 1021         int maximum; /* read-only variable if minimum > maximum */
 1022 };
 1023 
 1024 /* Special case minimum,maximum marker for sysctl_bounded_args. */
 1025 #define SYSCTL_INT_READONLY     1,0
 1026 
 1027 /*
 1028  * Internal sysctl function calling convention:
 1029  *
 1030  *      (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
 1031  *
 1032  * The name parameter points at the next component of the name to be
 1033  * interpreted.  The namelen parameter is the number of integers in
 1034  * the name.
 1035  */
 1036 typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
 1037 
 1038 int sysctl_int_lower(void *, size_t *, void *, size_t, int *);
 1039 int sysctl_int(void *, size_t *, void *, size_t, int *);
 1040 int sysctl_rdint(void *, size_t *, void *, int);
 1041 int sysctl_securelevel_int(void *, size_t *, void *, size_t, int *);
 1042 int sysctl_int_bounded(void *, size_t *, void *, size_t, int *, int, int);
 1043 int sysctl_bounded_arr(const struct sysctl_bounded_args *, u_int,
 1044     int *, u_int, void *, size_t *, void *, size_t);
 1045 int sysctl_quad(void *, size_t *, void *, size_t, int64_t *);
 1046 int sysctl_rdquad(void *, size_t *, void *, int64_t);
 1047 int sysctl_string(void *, size_t *, void *, size_t, char *, size_t);
 1048 int sysctl_tstring(void *, size_t *, void *, size_t, char *, size_t);
 1049 int sysctl__string(void *, size_t *, void *, size_t, char *, size_t, int);
 1050 int sysctl_rdstring(void *, size_t *, void *, const char *);
 1051 int sysctl_rdstruct(void *, size_t *, void *, const void *, size_t);
 1052 int sysctl_struct(void *, size_t *, void *, size_t, void *, size_t);
 1053 int sysctl_file(int *, u_int, char *, size_t *, struct proc *);
 1054 int sysctl_doproc(int *, u_int, char *, size_t *);
 1055 struct mbuf_queue;
 1056 int sysctl_mq(int *, u_int, void *, size_t *, void *, size_t,
 1057     struct mbuf_queue *);
 1058 struct rtentry;
 1059 struct walkarg;
 1060 int sysctl_dumpentry(struct rtentry *, void *, unsigned int);
 1061 int sysctl_rtable(int *, u_int, void *, size_t *, void *, size_t);
 1062 int sysctl_clockrate(char *, size_t *, void *);
 1063 int sysctl_vnode(char *, size_t *, struct proc *);
 1064 #if defined(GPROF) || defined(DDBPROF)
 1065 int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
 1066 #endif
 1067 int sysctl_dopool(int *, u_int, char *, size_t *);
 1068 
 1069 int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1070                      struct proc *);
 1071 int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1072                    struct proc *);
 1073 #ifdef DEBUG_SYSCTL
 1074 int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1075                       struct proc *);
 1076 #endif
 1077 int vm_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1078                    struct proc *);
 1079 int fs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1080                    struct proc *);
 1081 int fs_posix_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1082                          struct proc *);
 1083 int net_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1084                     struct proc *);
 1085 int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1086                     struct proc *);
 1087 int vfs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
 1088                     struct proc *);
 1089 int sysctl_sysvipc(int *, u_int, void *, size_t *);
 1090 int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t);
 1091 
 1092 extern int (*cpu_cpuspeed)(int *);
 1093 extern void (*cpu_setperf)(int);
 1094 
 1095 int net_ifiq_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1096 int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1097 int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1098 int pipex_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1099 int mpls_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1100 int pf_sysctl(void *, size_t *, void *, size_t);
 1101 int uipc_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 1102 
 1103 #else   /* !_KERNEL */
 1104 
 1105 __BEGIN_DECLS
 1106 int     sysctl(const int *, u_int, void *, size_t *, void *, size_t);
 1107 __END_DECLS
 1108 #endif  /* _KERNEL */
 1109 #endif  /* !_SYS_SYSCTL_H_ */

Cache object: 00608345213054805d7bbe098ad6266b


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