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  * 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: releng/8.0/sys/sys/user.h 195843 2009-07-24 15:03:10Z brooks $
   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 
   65 /*
   66  * KERN_PROC subtype ops return arrays of selected proc structure entries:
   67  *
   68  * This struct includes several arrays of spare space, with different arrays
   69  * for different standard C-types.  When adding new variables to this struct,
   70  * the space for byte-aligned data should be taken from the ki_sparestring,
   71  * pointers from ki_spareptrs, word-aligned data from ki_spareints, and
   72  * doubleword-aligned data from ki_sparelongs.  Make sure the space for new
   73  * variables come from the array which matches the size and alignment of
   74  * those variables on ALL hardware platforms, and then adjust the appropriate
   75  * KI_NSPARE_* value(s) to match.
   76  *
   77  * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all
   78  * platforms after you have added new variables.  Note that if you change
   79  * the value of KINFO_PROC_SIZE, then many userland programs will stop
   80  * working until they are recompiled!
   81  *
   82  * Once you have added the new field, you will need to add code to initialize
   83  * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
   84  * function kvm_proclist in lib/libkvm/kvm_proc.c .
   85  */
   86 #define KI_NSPARE_INT   9
   87 #define KI_NSPARE_LONG  12
   88 #define KI_NSPARE_PTR   7
   89 
   90 #ifdef __amd64__
   91 #define KINFO_PROC_SIZE 1088
   92 #endif
   93 #ifdef __arm__
   94 #define KINFO_PROC_SIZE 792
   95 #endif
   96 #ifdef __ia64__
   97 #define KINFO_PROC_SIZE 1088
   98 #endif
   99 #ifdef __i386__
  100 #define KINFO_PROC_SIZE 768
  101 #endif
  102 #ifdef __mips__
  103 #define KINFO_PROC_SIZE 816
  104 #endif
  105 #ifdef __powerpc__
  106 #define KINFO_PROC_SIZE 768
  107 #endif
  108 #ifdef __sparc64__
  109 #define KINFO_PROC_SIZE 1088
  110 #endif
  111 #ifndef KINFO_PROC_SIZE
  112 #error "Unknown architecture"
  113 #endif
  114 
  115 #define WMESGLEN        8               /* size of returned wchan message */
  116 #define LOCKNAMELEN     8               /* size of returned lock name */
  117 #define OCOMMLEN        16              /* size of returned thread name */
  118 #define COMMLEN         19              /* size of returned ki_comm name */
  119 #define KI_EMULNAMELEN  16              /* size of returned ki_emul */
  120 #define KI_NGROUPS      16              /* number of groups in ki_groups */
  121 #define LOGNAMELEN      17              /* size of returned ki_login */
  122 
  123 /*
  124  * Steal a bit from ki_cr_flags (cr_flags is never used) to indicate
  125  * that the cred had more than KI_NGROUPS groups.
  126  */
  127 #define KI_CRF_GRP_OVERFLOW     0x80000000
  128 
  129 struct kinfo_proc {
  130         int     ki_structsize;          /* size of this structure */
  131         int     ki_layout;              /* reserved: layout identifier */
  132         struct  pargs *ki_args;         /* address of command arguments */
  133         struct  proc *ki_paddr;         /* address of proc */
  134         struct  user *ki_addr;          /* kernel virtual addr of u-area */
  135         struct  vnode *ki_tracep;       /* pointer to trace file */
  136         struct  vnode *ki_textvp;       /* pointer to executable file */
  137         struct  filedesc *ki_fd;        /* pointer to open file info */
  138         struct  vmspace *ki_vmspace;    /* pointer to kernel vmspace struct */
  139         void    *ki_wchan;              /* sleep address */
  140         pid_t   ki_pid;                 /* Process identifier */
  141         pid_t   ki_ppid;                /* parent process id */
  142         pid_t   ki_pgid;                /* process group id */
  143         pid_t   ki_tpgid;               /* tty process group id */
  144         pid_t   ki_sid;                 /* Process session ID */
  145         pid_t   ki_tsid;                /* Terminal session ID */
  146         short   ki_jobc;                /* job control counter */
  147         short   ki_spare_short1;        /* unused (just here for alignment) */
  148         dev_t   ki_tdev;                /* controlling tty dev */
  149         sigset_t ki_siglist;            /* Signals arrived but not delivered */
  150         sigset_t ki_sigmask;            /* Current signal mask */
  151         sigset_t ki_sigignore;          /* Signals being ignored */
  152         sigset_t ki_sigcatch;           /* Signals being caught by user */
  153         uid_t   ki_uid;                 /* effective user id */
  154         uid_t   ki_ruid;                /* Real user id */
  155         uid_t   ki_svuid;               /* Saved effective user id */
  156         gid_t   ki_rgid;                /* Real group id */
  157         gid_t   ki_svgid;               /* Saved effective group id */
  158         short   ki_ngroups;             /* number of groups */
  159         short   ki_spare_short2;        /* unused (just here for alignment) */
  160         gid_t   ki_groups[KI_NGROUPS];  /* groups */
  161         vm_size_t ki_size;              /* virtual size */
  162         segsz_t ki_rssize;              /* current resident set size in pages */
  163         segsz_t ki_swrss;               /* resident set size before last swap */
  164         segsz_t ki_tsize;               /* text size (pages) XXX */
  165         segsz_t ki_dsize;               /* data size (pages) XXX */
  166         segsz_t ki_ssize;               /* stack size (pages) */
  167         u_short ki_xstat;               /* Exit status for wait & stop signal */
  168         u_short ki_acflag;              /* Accounting flags */
  169         fixpt_t ki_pctcpu;              /* %cpu for process during ki_swtime */
  170         u_int   ki_estcpu;              /* Time averaged value of ki_cpticks */
  171         u_int   ki_slptime;             /* Time since last blocked */
  172         u_int   ki_swtime;              /* Time swapped in or out */
  173         int     ki_spareint1;           /* unused (just here for alignment) */
  174         u_int64_t ki_runtime;           /* Real time in microsec */
  175         struct  timeval ki_start;       /* starting time */
  176         struct  timeval ki_childtime;   /* time used by process children */
  177         long    ki_flag;                /* P_* flags */
  178         long    ki_kiflag;              /* KI_* flags (below) */
  179         int     ki_traceflag;           /* Kernel trace points */
  180         char    ki_stat;                /* S* process status */
  181         signed char ki_nice;            /* Process "nice" value */
  182         char    ki_lock;                /* Process lock (prevent swap) count */
  183         char    ki_rqindex;             /* Run queue index */
  184         u_char  ki_oncpu;               /* Which cpu we are on */
  185         u_char  ki_lastcpu;             /* Last cpu we were on */
  186         char    ki_ocomm[OCOMMLEN+1];   /* thread name */
  187         char    ki_wmesg[WMESGLEN+1];   /* wchan message */
  188         char    ki_login[LOGNAMELEN+1]; /* setlogin name */
  189         char    ki_lockname[LOCKNAMELEN+1]; /* lock name */
  190         char    ki_comm[COMMLEN+1];     /* command name */
  191         char    ki_emul[KI_EMULNAMELEN+1];  /* emulation name */
  192         /*
  193          * When adding new variables, take space for char-strings from the
  194          * front of ki_sparestrings, and ints from the end of ki_spareints.
  195          * That way the spare room from both arrays will remain contiguous.
  196          */
  197         char    ki_sparestrings[68];    /* spare string space */
  198         int     ki_spareints[KI_NSPARE_INT];    /* spare room for growth */
  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         /*
  211          * When adding new variables, take space for pointers from the
  212          * front of ki_spareptrs, and longs from the end of ki_sparelongs.
  213          * That way the spare room from both arrays will remain contiguous.
  214          */
  215         void    *ki_spareptrs[KI_NSPARE_PTR];   /* spare room for growth */
  216         long    ki_sparelongs[KI_NSPARE_LONG];  /* spare room for growth */
  217         long    ki_sflag;               /* PS_* flags */
  218         long    ki_tdflags;             /* XXXKSE kthread flag */
  219 };
  220 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
  221 /* XXX - the following two defines are temporary */
  222 #define ki_childstime   ki_rusage_ch.ru_stime
  223 #define ki_childutime   ki_rusage_ch.ru_utime
  224 
  225 /*
  226  *  Legacy PS_ flag.  This moved to p_flag but is maintained for
  227  *  compatibility.
  228  */
  229 #define PS_INMEM        0x00001         /* Loaded into memory. */
  230 
  231 /* ki_sessflag values */
  232 #define KI_CTTY         0x00000001      /* controlling tty vnode active */
  233 #define KI_SLEADER      0x00000002      /* session leader */
  234 #define KI_LOCKBLOCK    0x00000004      /* proc blocked on lock ki_lockname */
  235 
  236 /*
  237  * This used to be the per-process structure containing data that
  238  * isn't needed in core when the process is swapped out, but now it
  239  * remains only for the benefit of a.out core dumps.
  240  */
  241 struct user {
  242         struct  pstats u_stats;         /* *p_stats */
  243         struct  kinfo_proc u_kproc;     /* eproc */
  244 };
  245 
  246 /*
  247  * The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
  248  * array of another process.
  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_UNKNOWN 255
  262 
  263 #define KF_VTYPE_VNON   0
  264 #define KF_VTYPE_VREG   1
  265 #define KF_VTYPE_VDIR   2
  266 #define KF_VTYPE_VBLK   3
  267 #define KF_VTYPE_VCHR   4
  268 #define KF_VTYPE_VLNK   5
  269 #define KF_VTYPE_VSOCK  6
  270 #define KF_VTYPE_VFIFO  7
  271 #define KF_VTYPE_VBAD   8
  272 #define KF_VTYPE_UNKNOWN        255
  273 
  274 #define KF_FD_TYPE_CWD  -1      /* Current working directory */
  275 #define KF_FD_TYPE_ROOT -2      /* Root directory */
  276 #define KF_FD_TYPE_JAIL -3      /* Jail directory */
  277 
  278 #define KF_FLAG_READ            0x00000001
  279 #define KF_FLAG_WRITE           0x00000002
  280 #define KF_FLAG_APPEND          0x00000004
  281 #define KF_FLAG_ASYNC           0x00000008
  282 #define KF_FLAG_FSYNC           0x00000010
  283 #define KF_FLAG_NONBLOCK        0x00000020
  284 #define KF_FLAG_DIRECT          0x00000040
  285 #define KF_FLAG_HASLOCK         0x00000080
  286 
  287 /*
  288  * Old format.  Has variable hidden padding due to alignment.
  289  * This is a compatability hack for pre-build 7.1 packages.
  290  */
  291 #if defined(__amd64__)
  292 #define KINFO_OFILE_SIZE        1328
  293 #endif
  294 #if defined(__i386__)
  295 #define KINFO_OFILE_SIZE        1324
  296 #endif
  297 
  298 struct kinfo_ofile {
  299         int     kf_structsize;                  /* Size of kinfo_file. */
  300         int     kf_type;                        /* Descriptor type. */
  301         int     kf_fd;                          /* Array index. */
  302         int     kf_ref_count;                   /* Reference count. */
  303         int     kf_flags;                       /* Flags. */
  304         /* XXX Hidden alignment padding here on amd64 */
  305         off_t   kf_offset;                      /* Seek location. */
  306         int     kf_vnode_type;                  /* Vnode type. */
  307         int     kf_sock_domain;                 /* Socket domain. */
  308         int     kf_sock_type;                   /* Socket type. */
  309         int     kf_sock_protocol;               /* Socket protocol. */
  310         char    kf_path[PATH_MAX];      /* Path to file, if any. */
  311         struct sockaddr_storage kf_sa_local;    /* Socket address. */
  312         struct sockaddr_storage kf_sa_peer;     /* Peer address. */
  313 };
  314 
  315 #if defined(__amd64__) || defined(__i386__)
  316 #define KINFO_FILE_SIZE 1392
  317 #endif
  318 
  319 struct kinfo_file {
  320         int     kf_structsize;                  /* Variable size of record. */
  321         int     kf_type;                        /* Descriptor type. */
  322         int     kf_fd;                          /* Array index. */
  323         int     kf_ref_count;                   /* Reference count. */
  324         int     kf_flags;                       /* Flags. */
  325         int     _kf_pad0;                       /* Round to 64 bit alignment */
  326         int64_t kf_offset;                      /* Seek location. */
  327         int     kf_vnode_type;                  /* Vnode type. */
  328         int     kf_sock_domain;                 /* Socket domain. */
  329         int     kf_sock_type;                   /* Socket type. */
  330         int     kf_sock_protocol;               /* Socket protocol. */
  331         struct sockaddr_storage kf_sa_local;    /* Socket address. */
  332         struct sockaddr_storage kf_sa_peer;     /* Peer address. */
  333         int     _kf_ispare[16];                 /* Space for more stuff. */
  334         /* Truncated before copyout in sysctl */
  335         char    kf_path[PATH_MAX];              /* Path to file, if any. */
  336 };
  337 
  338 /*
  339  * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of
  340  * another process as a series of entries.
  341  */
  342 #define KVME_TYPE_NONE          0
  343 #define KVME_TYPE_DEFAULT       1
  344 #define KVME_TYPE_VNODE         2
  345 #define KVME_TYPE_SWAP          3
  346 #define KVME_TYPE_DEVICE        4
  347 #define KVME_TYPE_PHYS          5
  348 #define KVME_TYPE_DEAD          6
  349 #define KVME_TYPE_SG            7
  350 #define KVME_TYPE_UNKNOWN       255
  351 
  352 #define KVME_PROT_READ          0x00000001
  353 #define KVME_PROT_WRITE         0x00000002
  354 #define KVME_PROT_EXEC          0x00000004
  355 
  356 #define KVME_FLAG_COW           0x00000001
  357 #define KVME_FLAG_NEEDS_COPY    0x00000002
  358 
  359 #if defined(__amd64__)
  360 #define KINFO_OVMENTRY_SIZE     1168
  361 #endif
  362 #if defined(__i386__)
  363 #define KINFO_OVMENTRY_SIZE     1128
  364 #endif
  365 
  366 struct kinfo_ovmentry {
  367         int      kve_structsize;                /* Size of kinfo_vmmapentry. */
  368         int      kve_type;                      /* Type of map entry. */
  369         void    *kve_start;                     /* Starting address. */
  370         void    *kve_end;                       /* Finishing address. */
  371         int      kve_flags;                     /* Flags on map entry. */
  372         int      kve_resident;                  /* Number of resident pages. */
  373         int      kve_private_resident;          /* Number of private pages. */
  374         int      kve_protection;                /* Protection bitmask. */
  375         int      kve_ref_count;                 /* VM obj ref count. */
  376         int      kve_shadow_count;              /* VM obj shadow count. */
  377         char     kve_path[PATH_MAX];            /* Path to VM obj, if any. */
  378         void    *_kve_pspare[8];                /* Space for more stuff. */
  379         off_t    kve_offset;                    /* Mapping offset in object */
  380         uint64_t kve_fileid;                    /* inode number if vnode */
  381         dev_t    kve_fsid;                      /* dev_t of vnode location */
  382         int      _kve_ispare[3];                /* Space for more stuff. */
  383 };
  384 
  385 #if defined(__amd64__) || defined(__i386__)
  386 #define KINFO_VMENTRY_SIZE      1160
  387 #endif
  388 
  389 struct kinfo_vmentry {
  390         int      kve_structsize;                /* Variable size of record. */
  391         int      kve_type;                      /* Type of map entry. */
  392         uint64_t kve_start;                     /* Starting address. */
  393         uint64_t kve_end;                       /* Finishing address. */
  394         uint64_t kve_offset;                    /* Mapping offset in object */
  395         uint64_t kve_fileid;                    /* inode number if vnode */
  396         uint32_t kve_fsid;                      /* dev_t of vnode location */
  397         int      kve_flags;                     /* Flags on map entry. */
  398         int      kve_resident;                  /* Number of resident pages. */
  399         int      kve_private_resident;          /* Number of private pages. */
  400         int      kve_protection;                /* Protection bitmask. */
  401         int      kve_ref_count;                 /* VM obj ref count. */
  402         int      kve_shadow_count;              /* VM obj shadow count. */
  403         int      _kve_pad0;                     /* 64bit align next field */
  404         int      _kve_ispare[16];               /* Space for more stuff. */
  405         /* Truncated before copyout in sysctl */
  406         char     kve_path[PATH_MAX];            /* Path to VM obj, if any. */
  407 };
  408 
  409 /*
  410  * The KERN_PROC_KSTACK sysctl allows a process to dump the kernel stacks of
  411  * another process as a series of entries.  Each stack is represented by a
  412  * series of symbol names and offsets as generated by stack_sbuf_print(9).
  413  */
  414 #define KKST_MAXLEN     1024
  415 
  416 #define KKST_STATE_STACKOK      0               /* Stack is valid. */
  417 #define KKST_STATE_SWAPPED      1               /* Stack swapped out. */
  418 #define KKST_STATE_RUNNING      2               /* Stack ephemeral. */
  419 
  420 #if defined(__amd64__) || defined(__i386__)
  421 #define KINFO_KSTACK_SIZE       1096
  422 #endif
  423 
  424 struct kinfo_kstack {
  425         lwpid_t  kkst_tid;                      /* ID of thread. */
  426         int      kkst_state;                    /* Validity of stack. */
  427         char     kkst_trace[KKST_MAXLEN];       /* String representing stack. */
  428         int      _kkst_ispare[16];              /* Space for more stuff. */
  429 };
  430 
  431 #endif

Cache object: 466be54815075b8996d6fe0e49fcf29d


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