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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

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

Cache object: 48d9da5680f794138b1717af09cb66fb


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