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/user.h

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

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 1982, 1986, 1989, 1991, 1993
    5  *      The Regents of the University of California.
    6  * Copyright (c) 2007 Robert N. M. Watson
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 3. Neither the name of the University nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  *
   33  *      @(#)user.h      8.2 (Berkeley) 9/23/93
   34  * $FreeBSD: releng/12.0/sys/sys/user.h 338916 2018-09-24 18:20:38Z jhb $
   35  */
   36 
   37 #ifndef _SYS_USER_H_
   38 #define _SYS_USER_H_
   39 
   40 #include <machine/pcb.h>
   41 #ifndef _KERNEL
   42 /* stuff that *used* to be included by user.h, or is now needed */
   43 #include <sys/errno.h>
   44 #include <sys/time.h>
   45 #include <sys/resource.h>
   46 #include <sys/ucred.h>
   47 #include <sys/uio.h>
   48 #include <sys/queue.h>
   49 #include <sys/_lock.h>
   50 #include <sys/_mutex.h>
   51 #include <sys/proc.h>
   52 #include <vm/vm.h>              /* XXX */
   53 #include <vm/vm_param.h>        /* XXX */
   54 #include <vm/pmap.h>            /* XXX */
   55 #include <vm/vm_map.h>          /* XXX */
   56 #endif /* !_KERNEL */
   57 #ifndef _SYS_RESOURCEVAR_H_
   58 #include <sys/resourcevar.h>
   59 #endif
   60 #ifndef _SYS_SIGNALVAR_H_
   61 #include <sys/signalvar.h>
   62 #endif
   63 #ifndef _SYS_SOCKET_VAR_H_
   64 #include <sys/socket.h>
   65 #endif
   66 #include <sys/caprights.h>
   67 
   68 /*
   69  * KERN_PROC subtype ops return arrays of selected proc structure entries:
   70  *
   71  * This struct includes several arrays of spare space, with different arrays
   72  * for different standard C-types.  When adding new variables to this struct,
   73  * the space for byte-aligned data should be taken from the ki_sparestring,
   74  * pointers from ki_spareptrs, word-aligned data from ki_spareints, and
   75  * doubleword-aligned data from ki_sparelongs.  Make sure the space for new
   76  * variables come from the array which matches the size and alignment of
   77  * those variables on ALL hardware platforms, and then adjust the appropriate
   78  * KI_NSPARE_* value(s) to match.
   79  *
   80  * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all
   81  * platforms after you have added new variables.  Note that if you change
   82  * the value of KINFO_PROC_SIZE, then many userland programs will stop
   83  * working until they are recompiled!
   84  *
   85  * Once you have added the new field, you will need to add code to initialize
   86  * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
   87  * function kvm_proclist in lib/libkvm/kvm_proc.c .
   88  */
   89 #define KI_NSPARE_INT   2
   90 #define KI_NSPARE_LONG  12
   91 #define KI_NSPARE_PTR   6
   92 
   93 #ifndef _KERNEL
   94 #ifndef KINFO_PROC_SIZE
   95 #error "Unknown architecture"
   96 #endif
   97 #endif /* !_KERNEL */
   98 
   99 #define WMESGLEN        8               /* size of returned wchan message */
  100 #define LOCKNAMELEN     8               /* size of returned lock name */
  101 #define TDNAMLEN        16              /* size of returned thread name */
  102 #define COMMLEN         19              /* size of returned ki_comm name */
  103 #define KI_EMULNAMELEN  16              /* size of returned ki_emul */
  104 #define KI_NGROUPS      16              /* number of groups in ki_groups */
  105 #define LOGNAMELEN      17              /* size of returned ki_login */
  106 #define LOGINCLASSLEN   17              /* size of returned ki_loginclass */
  107 
  108 #ifndef BURN_BRIDGES
  109 #define OCOMMLEN        TDNAMLEN        
  110 #define ki_ocomm        ki_tdname
  111 #endif
  112 
  113 /* Flags for the process credential. */
  114 #define KI_CRF_CAPABILITY_MODE  0x00000001
  115 /*
  116  * Steal a bit from ki_cr_flags to indicate that the cred had more than
  117  * KI_NGROUPS groups.
  118  */
  119 #define KI_CRF_GRP_OVERFLOW     0x80000000
  120 
  121 struct kinfo_proc {
  122         int     ki_structsize;          /* size of this structure */
  123         int     ki_layout;              /* reserved: layout identifier */
  124         struct  pargs *ki_args;         /* address of command arguments */
  125         struct  proc *ki_paddr;         /* address of proc */
  126         struct  user *ki_addr;          /* kernel virtual addr of u-area */
  127         struct  vnode *ki_tracep;       /* pointer to trace file */
  128         struct  vnode *ki_textvp;       /* pointer to executable file */
  129         struct  filedesc *ki_fd;        /* pointer to open file info */
  130         struct  vmspace *ki_vmspace;    /* pointer to kernel vmspace struct */
  131         void    *ki_wchan;              /* sleep address */
  132         pid_t   ki_pid;                 /* Process identifier */
  133         pid_t   ki_ppid;                /* parent process id */
  134         pid_t   ki_pgid;                /* process group id */
  135         pid_t   ki_tpgid;               /* tty process group id */
  136         pid_t   ki_sid;                 /* Process session ID */
  137         pid_t   ki_tsid;                /* Terminal session ID */
  138         short   ki_jobc;                /* job control counter */
  139         short   ki_spare_short1;        /* unused (just here for alignment) */
  140         uint32_t ki_tdev_freebsd11;     /* controlling tty dev */
  141         sigset_t ki_siglist;            /* Signals arrived but not delivered */
  142         sigset_t ki_sigmask;            /* Current signal mask */
  143         sigset_t ki_sigignore;          /* Signals being ignored */
  144         sigset_t ki_sigcatch;           /* Signals being caught by user */
  145         uid_t   ki_uid;                 /* effective user id */
  146         uid_t   ki_ruid;                /* Real user id */
  147         uid_t   ki_svuid;               /* Saved effective user id */
  148         gid_t   ki_rgid;                /* Real group id */
  149         gid_t   ki_svgid;               /* Saved effective group id */
  150         short   ki_ngroups;             /* number of groups */
  151         short   ki_spare_short2;        /* unused (just here for alignment) */
  152         gid_t   ki_groups[KI_NGROUPS];  /* groups */
  153         vm_size_t ki_size;              /* virtual size */
  154         segsz_t ki_rssize;              /* current resident set size in pages */
  155         segsz_t ki_swrss;               /* resident set size before last swap */
  156         segsz_t ki_tsize;               /* text size (pages) XXX */
  157         segsz_t ki_dsize;               /* data size (pages) XXX */
  158         segsz_t ki_ssize;               /* stack size (pages) */
  159         u_short ki_xstat;               /* Exit status for wait & stop signal */
  160         u_short ki_acflag;              /* Accounting flags */
  161         fixpt_t ki_pctcpu;              /* %cpu for process during ki_swtime */
  162         u_int   ki_estcpu;              /* Time averaged value of ki_cpticks */
  163         u_int   ki_slptime;             /* Time since last blocked */
  164         u_int   ki_swtime;              /* Time swapped in or out */
  165         u_int   ki_cow;                 /* number of copy-on-write faults */
  166         u_int64_t ki_runtime;           /* Real time in microsec */
  167         struct  timeval ki_start;       /* starting time */
  168         struct  timeval ki_childtime;   /* time used by process children */
  169         long    ki_flag;                /* P_* flags */
  170         long    ki_kiflag;              /* KI_* flags (below) */
  171         int     ki_traceflag;           /* Kernel trace points */
  172         char    ki_stat;                /* S* process status */
  173         signed char ki_nice;            /* Process "nice" value */
  174         char    ki_lock;                /* Process lock (prevent swap) count */
  175         char    ki_rqindex;             /* Run queue index */
  176         u_char  ki_oncpu_old;           /* Which cpu we are on (legacy) */
  177         u_char  ki_lastcpu_old;         /* Last cpu we were on (legacy) */
  178         char    ki_tdname[TDNAMLEN+1];  /* thread name */
  179         char    ki_wmesg[WMESGLEN+1];   /* wchan message */
  180         char    ki_login[LOGNAMELEN+1]; /* setlogin name */
  181         char    ki_lockname[LOCKNAMELEN+1]; /* lock name */
  182         char    ki_comm[COMMLEN+1];     /* command name */
  183         char    ki_emul[KI_EMULNAMELEN+1];  /* emulation name */
  184         char    ki_loginclass[LOGINCLASSLEN+1]; /* login class */
  185         char    ki_moretdname[MAXCOMLEN-TDNAMLEN+1];    /* more thread name */
  186         /*
  187          * When adding new variables, take space for char-strings from the
  188          * front of ki_sparestrings, and ints from the end of ki_spareints.
  189          * That way the spare room from both arrays will remain contiguous.
  190          */
  191         char    ki_sparestrings[46];    /* spare string space */
  192         int     ki_spareints[KI_NSPARE_INT];    /* spare room for growth */
  193         uint64_t ki_tdev;               /* controlling tty dev */
  194         int     ki_oncpu;               /* Which cpu we are on */
  195         int     ki_lastcpu;             /* Last cpu we were on */
  196         int     ki_tracer;              /* Pid of tracing process */
  197         int     ki_flag2;               /* P2_* flags */
  198         int     ki_fibnum;              /* Default FIB number */
  199         u_int   ki_cr_flags;            /* Credential flags */
  200         int     ki_jid;                 /* Process jail ID */
  201         int     ki_numthreads;          /* XXXKSE number of threads in total */
  202         lwpid_t ki_tid;                 /* XXXKSE thread id */
  203         struct  priority ki_pri;        /* process priority */
  204         struct  rusage ki_rusage;       /* process rusage statistics */
  205         /* XXX - most fields in ki_rusage_ch are not (yet) filled in */
  206         struct  rusage ki_rusage_ch;    /* rusage of children processes */
  207         struct  pcb *ki_pcb;            /* kernel virtual addr of pcb */
  208         void    *ki_kstack;             /* kernel virtual addr of stack */
  209         void    *ki_udata;              /* User convenience pointer */
  210         struct  thread *ki_tdaddr;      /* address of thread */
  211         /*
  212          * When adding new variables, take space for pointers from the
  213          * front of ki_spareptrs, and longs from the end of ki_sparelongs.
  214          * That way the spare room from both arrays will remain contiguous.
  215          */
  216         void    *ki_spareptrs[KI_NSPARE_PTR];   /* spare room for growth */
  217         long    ki_sparelongs[KI_NSPARE_LONG];  /* spare room for growth */
  218         long    ki_sflag;               /* PS_* flags */
  219         long    ki_tdflags;             /* XXXKSE kthread flag */
  220 };
  221 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
  222 /* XXX - the following two defines are temporary */
  223 #define ki_childstime   ki_rusage_ch.ru_stime
  224 #define ki_childutime   ki_rusage_ch.ru_utime
  225 
  226 /*
  227  *  Legacy PS_ flag.  This moved to p_flag but is maintained for
  228  *  compatibility.
  229  */
  230 #define PS_INMEM        0x00001         /* Loaded into memory. */
  231 
  232 /* ki_sessflag values */
  233 #define KI_CTTY         0x00000001      /* controlling tty vnode active */
  234 #define KI_SLEADER      0x00000002      /* session leader */
  235 #define KI_LOCKBLOCK    0x00000004      /* proc blocked on lock ki_lockname */
  236 
  237 /*
  238  * This used to be the per-process structure containing data that
  239  * isn't needed in core when the process is swapped out, but now it
  240  * remains only for the benefit of a.out core dumps.
  241  */
  242 struct user {
  243         struct  pstats u_stats;         /* *p_stats */
  244         struct  kinfo_proc u_kproc;     /* eproc */
  245 };
  246 
  247 /*
  248  * The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
  249  * array of another process.
  250  */
  251 #define KF_ATTR_VALID   0x0001
  252 
  253 #define KF_TYPE_NONE    0
  254 #define KF_TYPE_VNODE   1
  255 #define KF_TYPE_SOCKET  2
  256 #define KF_TYPE_PIPE    3
  257 #define KF_TYPE_FIFO    4
  258 #define KF_TYPE_KQUEUE  5
  259 #define KF_TYPE_CRYPTO  6
  260 #define KF_TYPE_MQUEUE  7
  261 #define KF_TYPE_SHM     8
  262 #define KF_TYPE_SEM     9
  263 #define KF_TYPE_PTS     10
  264 #define KF_TYPE_PROCDESC        11
  265 #define KF_TYPE_UNKNOWN 255
  266 
  267 #define KF_VTYPE_VNON   0
  268 #define KF_VTYPE_VREG   1
  269 #define KF_VTYPE_VDIR   2
  270 #define KF_VTYPE_VBLK   3
  271 #define KF_VTYPE_VCHR   4
  272 #define KF_VTYPE_VLNK   5
  273 #define KF_VTYPE_VSOCK  6
  274 #define KF_VTYPE_VFIFO  7
  275 #define KF_VTYPE_VBAD   8
  276 #define KF_VTYPE_UNKNOWN        255
  277 
  278 #define KF_FD_TYPE_CWD  -1      /* Current working directory */
  279 #define KF_FD_TYPE_ROOT -2      /* Root directory */
  280 #define KF_FD_TYPE_JAIL -3      /* Jail directory */
  281 #define KF_FD_TYPE_TRACE        -4      /* Ktrace vnode */
  282 #define KF_FD_TYPE_TEXT -5      /* Text vnode */
  283 #define KF_FD_TYPE_CTTY -6      /* Controlling terminal */
  284 
  285 #define KF_FLAG_READ            0x00000001
  286 #define KF_FLAG_WRITE           0x00000002
  287 #define KF_FLAG_APPEND          0x00000004
  288 #define KF_FLAG_ASYNC           0x00000008
  289 #define KF_FLAG_FSYNC           0x00000010
  290 #define KF_FLAG_NONBLOCK        0x00000020
  291 #define KF_FLAG_DIRECT          0x00000040
  292 #define KF_FLAG_HASLOCK         0x00000080
  293 #define KF_FLAG_SHLOCK          0x00000100
  294 #define KF_FLAG_EXLOCK          0x00000200
  295 #define KF_FLAG_NOFOLLOW        0x00000400
  296 #define KF_FLAG_CREAT           0x00000800
  297 #define KF_FLAG_TRUNC           0x00001000
  298 #define KF_FLAG_EXCL            0x00002000
  299 #define KF_FLAG_EXEC            0x00004000
  300 
  301 /*
  302  * Old format.  Has variable hidden padding due to alignment.
  303  * This is a compatibility hack for pre-build 7.1 packages.
  304  */
  305 #if defined(__amd64__)
  306 #define KINFO_OFILE_SIZE        1328
  307 #endif
  308 #if defined(__i386__)
  309 #define KINFO_OFILE_SIZE        1324
  310 #endif
  311 
  312 struct kinfo_ofile {
  313         int     kf_structsize;                  /* Size of kinfo_file. */
  314         int     kf_type;                        /* Descriptor type. */
  315         int     kf_fd;                          /* Array index. */
  316         int     kf_ref_count;                   /* Reference count. */
  317         int     kf_flags;                       /* Flags. */
  318         /* XXX Hidden alignment padding here on amd64 */
  319         off_t   kf_offset;                      /* Seek location. */
  320         int     kf_vnode_type;                  /* Vnode type. */
  321         int     kf_sock_domain;                 /* Socket domain. */
  322         int     kf_sock_type;                   /* Socket type. */
  323         int     kf_sock_protocol;               /* Socket protocol. */
  324         char    kf_path[PATH_MAX];      /* Path to file, if any. */
  325         struct sockaddr_storage kf_sa_local;    /* Socket address. */
  326         struct sockaddr_storage kf_sa_peer;     /* Peer address. */
  327 };
  328 
  329 #if defined(__amd64__) || defined(__i386__)
  330 /*
  331  * This size should never be changed. If you really need to, you must provide
  332  * backward ABI compatibility by allocating a new sysctl MIB that will return
  333  * the new structure. The current structure has to be returned by the current
  334  * sysctl MIB. See how it is done for the kinfo_ofile structure.
  335  */
  336 #define KINFO_FILE_SIZE 1392
  337 #endif
  338 
  339 struct kinfo_file {
  340         int             kf_structsize;          /* Variable size of record. */
  341         int             kf_type;                /* Descriptor type. */
  342         int             kf_fd;                  /* Array index. */
  343         int             kf_ref_count;           /* Reference count. */
  344         int             kf_flags;               /* Flags. */
  345         int             kf_pad0;                /* Round to 64 bit alignment. */
  346         int64_t         kf_offset;              /* Seek location. */
  347         union {
  348                 struct {
  349                         /* API compatiblity with FreeBSD < 12. */
  350                         int             kf_vnode_type;
  351                         int             kf_sock_domain;
  352                         int             kf_sock_type;
  353                         int             kf_sock_protocol;
  354                         struct sockaddr_storage kf_sa_local;
  355                         struct sockaddr_storage kf_sa_peer;
  356                 };
  357                 union {
  358                         struct {
  359                                 /* Sendq size */
  360                                 uint32_t        kf_sock_sendq;
  361                                 /* Socket domain. */
  362                                 int             kf_sock_domain0;
  363                                 /* Socket type. */
  364                                 int             kf_sock_type0;
  365                                 /* Socket protocol. */
  366                                 int             kf_sock_protocol0;
  367                                 /* Socket address. */
  368                                 struct sockaddr_storage kf_sa_local;
  369                                 /* Peer address. */
  370                                 struct sockaddr_storage kf_sa_peer;
  371                                 /* Address of so_pcb. */
  372                                 uint64_t        kf_sock_pcb;
  373                                 /* Address of inp_ppcb. */
  374                                 uint64_t        kf_sock_inpcb;
  375                                 /* Address of unp_conn. */
  376                                 uint64_t        kf_sock_unpconn;
  377                                 /* Send buffer state. */
  378                                 uint16_t        kf_sock_snd_sb_state;
  379                                 /* Receive buffer state. */
  380                                 uint16_t        kf_sock_rcv_sb_state;
  381                                 /* Recvq size. */
  382                                 uint32_t        kf_sock_recvq;
  383                         } kf_sock;
  384                         struct {
  385                                 /* Vnode type. */
  386                                 int             kf_file_type;
  387                                 /* Space for future use */
  388                                 int             kf_spareint[3];
  389                                 uint64_t        kf_spareint64[30];
  390                                 /* Vnode filesystem id. */
  391                                 uint64_t        kf_file_fsid;
  392                                 /* File device. */
  393                                 uint64_t        kf_file_rdev;
  394                                 /* Global file id. */
  395                                 uint64_t        kf_file_fileid;
  396                                 /* File size. */
  397                                 uint64_t        kf_file_size;
  398                                 /* Vnode filesystem id, FreeBSD 11 compat. */
  399                                 uint32_t        kf_file_fsid_freebsd11;
  400                                 /* File device, FreeBSD 11 compat. */
  401                                 uint32_t        kf_file_rdev_freebsd11;
  402                                 /* File mode. */
  403                                 uint16_t        kf_file_mode;
  404                                 /* Round to 64 bit alignment. */
  405                                 uint16_t        kf_file_pad0;
  406                                 uint32_t        kf_file_pad1;
  407                         } kf_file;
  408                         struct {
  409                                 uint32_t        kf_spareint[4];
  410                                 uint64_t        kf_spareint64[32];
  411                                 uint32_t        kf_sem_value;
  412                                 uint16_t        kf_sem_mode;
  413                         } kf_sem;
  414                         struct {
  415                                 uint32_t        kf_spareint[4];
  416                                 uint64_t        kf_spareint64[32];
  417                                 uint64_t        kf_pipe_addr;
  418                                 uint64_t        kf_pipe_peer;
  419                                 uint32_t        kf_pipe_buffer_cnt;
  420                                 /* Round to 64 bit alignment. */
  421                                 uint32_t        kf_pipe_pad0[3];
  422                         } kf_pipe;
  423                         struct {
  424                                 uint32_t        kf_spareint[4];
  425                                 uint64_t        kf_spareint64[32];
  426                                 uint32_t        kf_pts_dev_freebsd11;
  427                                 uint32_t        kf_pts_pad0;
  428                                 uint64_t        kf_pts_dev;
  429                                 /* Round to 64 bit alignment. */
  430                                 uint32_t        kf_pts_pad1[4];
  431                         } kf_pts;
  432                         struct {
  433                                 uint32_t        kf_spareint[4];
  434                                 uint64_t        kf_spareint64[32];
  435                                 pid_t           kf_pid;
  436                         } kf_proc;
  437                 } kf_un;
  438         };
  439         uint16_t        kf_status;              /* Status flags. */
  440         uint16_t        kf_pad1;                /* Round to 32 bit alignment. */
  441         int             _kf_ispare0;            /* Space for more stuff. */
  442         cap_rights_t    kf_cap_rights;          /* Capability rights. */
  443         uint64_t        _kf_cap_spare;          /* Space for future cap_rights_t. */
  444         /* Truncated before copyout in sysctl */
  445         char            kf_path[PATH_MAX];      /* Path to file, if any. */
  446 };
  447 
  448 /*
  449  * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of
  450  * another process as a series of entries.
  451  */
  452 #define KVME_TYPE_NONE          0
  453 #define KVME_TYPE_DEFAULT       1
  454 #define KVME_TYPE_VNODE         2
  455 #define KVME_TYPE_SWAP          3
  456 #define KVME_TYPE_DEVICE        4
  457 #define KVME_TYPE_PHYS          5
  458 #define KVME_TYPE_DEAD          6
  459 #define KVME_TYPE_SG            7
  460 #define KVME_TYPE_MGTDEVICE     8
  461 #define KVME_TYPE_UNKNOWN       255
  462 
  463 #define KVME_PROT_READ          0x00000001
  464 #define KVME_PROT_WRITE         0x00000002
  465 #define KVME_PROT_EXEC          0x00000004
  466 
  467 #define KVME_FLAG_COW           0x00000001
  468 #define KVME_FLAG_NEEDS_COPY    0x00000002
  469 #define KVME_FLAG_NOCOREDUMP    0x00000004
  470 #define KVME_FLAG_SUPER         0x00000008
  471 #define KVME_FLAG_GROWS_UP      0x00000010
  472 #define KVME_FLAG_GROWS_DOWN    0x00000020
  473 
  474 #if defined(__amd64__)
  475 #define KINFO_OVMENTRY_SIZE     1168
  476 #endif
  477 #if defined(__i386__)
  478 #define KINFO_OVMENTRY_SIZE     1128
  479 #endif
  480 
  481 struct kinfo_ovmentry {
  482         int      kve_structsize;                /* Size of kinfo_vmmapentry. */
  483         int      kve_type;                      /* Type of map entry. */
  484         void    *kve_start;                     /* Starting address. */
  485         void    *kve_end;                       /* Finishing address. */
  486         int      kve_flags;                     /* Flags on map entry. */
  487         int      kve_resident;                  /* Number of resident pages. */
  488         int      kve_private_resident;          /* Number of private pages. */
  489         int      kve_protection;                /* Protection bitmask. */
  490         int      kve_ref_count;                 /* VM obj ref count. */
  491         int      kve_shadow_count;              /* VM obj shadow count. */
  492         char     kve_path[PATH_MAX];            /* Path to VM obj, if any. */
  493         void    *_kve_pspare[8];                /* Space for more stuff. */
  494         off_t    kve_offset;                    /* Mapping offset in object */
  495         uint64_t kve_fileid;                    /* inode number if vnode */
  496         uint32_t kve_fsid;                      /* dev_t of vnode location */
  497         int      _kve_ispare[3];                /* Space for more stuff. */
  498 };
  499 
  500 #if defined(__amd64__) || defined(__i386__)
  501 #define KINFO_VMENTRY_SIZE      1160
  502 #endif
  503 
  504 struct kinfo_vmentry {
  505         int      kve_structsize;                /* Variable size of record. */
  506         int      kve_type;                      /* Type of map entry. */
  507         uint64_t kve_start;                     /* Starting address. */
  508         uint64_t kve_end;                       /* Finishing address. */
  509         uint64_t kve_offset;                    /* Mapping offset in object */
  510         uint64_t kve_vn_fileid;                 /* inode number if vnode */
  511         uint32_t kve_vn_fsid_freebsd11;         /* dev_t of vnode location */
  512         int      kve_flags;                     /* Flags on map entry. */
  513         int      kve_resident;                  /* Number of resident pages. */
  514         int      kve_private_resident;          /* Number of private pages. */
  515         int      kve_protection;                /* Protection bitmask. */
  516         int      kve_ref_count;                 /* VM obj ref count. */
  517         int      kve_shadow_count;              /* VM obj shadow count. */
  518         int      kve_vn_type;                   /* Vnode type. */
  519         uint64_t kve_vn_size;                   /* File size. */
  520         uint32_t kve_vn_rdev_freebsd11;         /* Device id if device. */
  521         uint16_t kve_vn_mode;                   /* File mode. */
  522         uint16_t kve_status;                    /* Status flags. */
  523         uint64_t kve_vn_fsid;                   /* dev_t of vnode location */
  524         uint64_t kve_vn_rdev;                   /* Device id if device. */
  525         int      _kve_ispare[8];                /* Space for more stuff. */
  526         /* Truncated before copyout in sysctl */
  527         char     kve_path[PATH_MAX];            /* Path to VM obj, if any. */
  528 };
  529 
  530 /*
  531  * The "vm.objects" sysctl provides a list of all VM objects in the system
  532  * via an array of these entries.
  533  */
  534 struct kinfo_vmobject {
  535         int     kvo_structsize;                 /* Variable size of record. */
  536         int     kvo_type;                       /* Object type: KVME_TYPE_*. */
  537         uint64_t kvo_size;                      /* Object size in pages. */
  538         uint64_t kvo_vn_fileid;                 /* inode number if vnode. */
  539         uint32_t kvo_vn_fsid_freebsd11;         /* dev_t of vnode location. */
  540         int     kvo_ref_count;                  /* Reference count. */
  541         int     kvo_shadow_count;               /* Shadow count. */
  542         int     kvo_memattr;                    /* Memory attribute. */
  543         uint64_t kvo_resident;                  /* Number of resident pages. */
  544         uint64_t kvo_active;                    /* Number of active pages. */
  545         uint64_t kvo_inactive;                  /* Number of inactive pages. */
  546         uint64_t kvo_vn_fsid;
  547         uint64_t _kvo_qspare[7];
  548         uint32_t _kvo_ispare[8];
  549         char    kvo_path[PATH_MAX];             /* Pathname, if any. */
  550 };
  551 
  552 /*
  553  * The KERN_PROC_KSTACK sysctl allows a process to dump the kernel stacks of
  554  * another process as a series of entries.  Each stack is represented by a
  555  * series of symbol names and offsets as generated by stack_sbuf_print(9).
  556  */
  557 #define KKST_MAXLEN     1024
  558 
  559 #define KKST_STATE_STACKOK      0               /* Stack is valid. */
  560 #define KKST_STATE_SWAPPED      1               /* Stack swapped out. */
  561 #define KKST_STATE_RUNNING      2               /* Stack ephemeral. */
  562 
  563 #if defined(__amd64__) || defined(__i386__)
  564 #define KINFO_KSTACK_SIZE       1096
  565 #endif
  566 
  567 struct kinfo_kstack {
  568         lwpid_t  kkst_tid;                      /* ID of thread. */
  569         int      kkst_state;                    /* Validity of stack. */
  570         char     kkst_trace[KKST_MAXLEN];       /* String representing stack. */
  571         int      _kkst_ispare[16];              /* Space for more stuff. */
  572 };
  573 
  574 struct kinfo_sigtramp {
  575         void    *ksigtramp_start;
  576         void    *ksigtramp_end;
  577         void    *ksigtramp_spare[4];
  578 };
  579 
  580 #ifdef _KERNEL
  581 /* Flags for kern_proc_out function. */
  582 #define KERN_PROC_NOTHREADS     0x1
  583 #define KERN_PROC_MASK32        0x2
  584 
  585 /* Flags for kern_proc_filedesc_out. */
  586 #define KERN_FILEDESC_PACK_KINFO        0x00000001U
  587 
  588 /* Flags for kern_proc_vmmap_out. */
  589 #define KERN_VMMAP_PACK_KINFO           0x00000001U
  590 struct sbuf;
  591 
  592 /*
  593  * The kern_proc out functions are helper functions to dump process
  594  * miscellaneous kinfo structures to sbuf.  The main consumers are KERN_PROC
  595  * sysctls but they may also be used by other kernel subsystems.
  596  *
  597  * The functions manipulate the process locking state and expect the process
  598  * to be locked on enter.  On return the process is unlocked.
  599  */
  600 
  601 int     kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen,
  602         int flags);
  603 int     kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen);
  604 int     kern_proc_out(struct proc *p, struct sbuf *sb, int flags);
  605 int     kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen,
  606         int flags);
  607 
  608 int     vntype_to_kinfo(int vtype);
  609 #endif /* !_KERNEL */
  610 
  611 #endif

Cache object: 11574c6707533c28191997f3df6a1893


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