user.h revision 172207
1139825Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1989, 1991, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)user.h 8.2 (Berkeley) 9/23/93 3050477Speter * $FreeBSD: head/sys/sys/user.h 172207 2007-09-17 05:31:39Z jeff $ 311541Srgrimes */ 321541Srgrimes 332165Spaul#ifndef _SYS_USER_H_ 342165Spaul#define _SYS_USER_H_ 352165Spaul 361541Srgrimes#include <machine/pcb.h> 3755205Speter#ifndef _KERNEL 381541Srgrimes/* stuff that *used* to be included by user.h, or is now needed */ 3918207Sbde#include <sys/errno.h> 401541Srgrimes#include <sys/time.h> 411541Srgrimes#include <sys/resource.h> 421541Srgrimes#include <sys/ucred.h> 431541Srgrimes#include <sys/uio.h> 4492047Sdd#include <sys/queue.h> 4581202Sjhb#include <sys/_lock.h> 4676166Smarkm#include <sys/_mutex.h> 4711913Sphk#include <sys/proc.h> 4812685Speter#include <vm/vm.h> /* XXX */ 4912685Speter#include <vm/vm_param.h> /* XXX */ 5012685Speter#include <vm/pmap.h> /* XXX */ 5112685Speter#include <vm/vm_map.h> /* XXX */ 5255205Speter#endif /* !_KERNEL */ 5334924Sbde#ifndef _SYS_RESOURCEVAR_H_ 541541Srgrimes#include <sys/resourcevar.h> 5534924Sbde#endif 5634924Sbde#ifndef _SYS_SIGNALVAR_H_ 571541Srgrimes#include <sys/signalvar.h> 5834924Sbde#endif 591541Srgrimes 601541Srgrimes/* 6169896Smckusick * KERN_PROC subtype ops return arrays of selected proc structure entries: 6269896Smckusick * 63147188Sgad * This struct includes several arrays of spare space, with different arrays 64147188Sgad * for different standard C-types. When adding new variables to this struct, 65147188Sgad * the space for byte-aligned data should be taken from the ki_sparestring, 66147188Sgad * pointers from ki_spareptrs, word-aligned data from ki_spareints, and 67147188Sgad * doubleword-aligned data from ki_sparelongs. Make sure the space for new 68147188Sgad * variables come from the array which matches the size and alignment of 69147188Sgad * those variables on ALL hardware platforms, and then adjust the appropriate 70147188Sgad * KI_NSPARE_* value(s) to match. 71130825Sgad * 72147188Sgad * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all 73147188Sgad * platforms after you have added new variables. Note that if you change 74147188Sgad * the value of KINFO_PROC_SIZE, then many userland programs will stop 75147188Sgad * working until they are recompiled! 76147188Sgad * 77147188Sgad * Once you have added the new field, you will need to add code to initialize 78147188Sgad * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and 79147188Sgad * function kvm_proclist in lib/libkvm/kvm_proc.c . 8011865Sphk */ 81147188Sgad#define KI_NSPARE_INT 10 82147188Sgad#define KI_NSPARE_LONG 12 83147188Sgad#define KI_NSPARE_PTR 7 84130825Sgad 85130825Sgad#ifdef __amd64__ 86147188Sgad#define KINFO_PROC_SIZE 1088 8771040Smjacob#endif 88130825Sgad#ifdef __arm__ 89158581Scognet#define KINFO_PROC_SIZE 792 9077956Sbenno#endif 91130825Sgad#ifdef __ia64__ 92147188Sgad#define KINFO_PROC_SIZE 1088 9374022Sdfr#endif 94130825Sgad#ifdef __i386__ 95147188Sgad#define KINFO_PROC_SIZE 768 96130825Sgad#endif 97130825Sgad#ifdef __powerpc__ 98147188Sgad#define KINFO_PROC_SIZE 768 99130825Sgad#endif 100130825Sgad#ifdef __sparc64__ 101147188Sgad#define KINFO_PROC_SIZE 1088 102130825Sgad#endif 103130825Sgad#ifndef KINFO_PROC_SIZE 104130825Sgad#error "Unknown architecture" 105130825Sgad#endif 106130825Sgad 10769896Smckusick#define WMESGLEN 8 /* size of returned wchan message */ 108104387Sjhb#define LOCKNAMELEN 8 /* size of returned lock name */ 109154535Sjulian#define OCOMMLEN 16 /* size of returned thread name */ 11081759Speter#define COMMLEN 19 /* size of returned ki_comm name */ 111130726Sgad#define KI_EMULNAMELEN 16 /* size of returned ki_emul */ 11281759Speter#define KI_NGROUPS 16 /* number of groups in ki_groups */ 11381759Speter#define LOGNAMELEN 17 /* size of returned ki_login */ 11469896Smckusick 11511865Sphkstruct kinfo_proc { 11669896Smckusick int ki_structsize; /* size of this structure */ 11772415Sphk int ki_layout; /* reserved: layout identifier */ 11869896Smckusick struct pargs *ki_args; /* address of command arguments */ 11969896Smckusick struct proc *ki_paddr; /* address of proc */ 12069896Smckusick struct user *ki_addr; /* kernel virtual addr of u-area */ 12169896Smckusick struct vnode *ki_tracep; /* pointer to trace file */ 12269896Smckusick struct vnode *ki_textvp; /* pointer to executable file */ 12369896Smckusick struct filedesc *ki_fd; /* pointer to open file info */ 12469896Smckusick struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */ 12569896Smckusick void *ki_wchan; /* sleep address */ 12669896Smckusick pid_t ki_pid; /* Process identifier */ 12769896Smckusick pid_t ki_ppid; /* parent process id */ 12869896Smckusick pid_t ki_pgid; /* process group id */ 12969896Smckusick pid_t ki_tpgid; /* tty process group id */ 13069896Smckusick pid_t ki_sid; /* Process session ID */ 13169896Smckusick pid_t ki_tsid; /* Terminal session ID */ 13269896Smckusick short ki_jobc; /* job control counter */ 133130726Sgad short ki_spare_short1; /* unused (just here for alignment) */ 134130640Sphk dev_t ki_tdev; /* controlling tty dev */ 13569896Smckusick sigset_t ki_siglist; /* Signals arrived but not delivered */ 13669896Smckusick sigset_t ki_sigmask; /* Current signal mask */ 13769896Smckusick sigset_t ki_sigignore; /* Signals being ignored */ 13869896Smckusick sigset_t ki_sigcatch; /* Signals being caught by user */ 13969896Smckusick uid_t ki_uid; /* effective user id */ 14069896Smckusick uid_t ki_ruid; /* Real user id */ 14169896Smckusick uid_t ki_svuid; /* Saved effective user id */ 14269896Smckusick gid_t ki_rgid; /* Real group id */ 14369896Smckusick gid_t ki_svgid; /* Saved effective group id */ 14469896Smckusick short ki_ngroups; /* number of groups */ 145130726Sgad short ki_spare_short2; /* unused (just here for alignment) */ 14681759Speter gid_t ki_groups[KI_NGROUPS]; /* groups */ 14769896Smckusick vm_size_t ki_size; /* virtual size */ 14869896Smckusick segsz_t ki_rssize; /* current resident set size in pages */ 14969896Smckusick segsz_t ki_swrss; /* resident set size before last swap */ 15069896Smckusick segsz_t ki_tsize; /* text size (pages) XXX */ 15169896Smckusick segsz_t ki_dsize; /* data size (pages) XXX */ 15269896Smckusick segsz_t ki_ssize; /* stack size (pages) */ 15369896Smckusick u_short ki_xstat; /* Exit status for wait & stop signal */ 15469896Smckusick u_short ki_acflag; /* Accounting flags */ 15569896Smckusick fixpt_t ki_pctcpu; /* %cpu for process during ki_swtime */ 15669896Smckusick u_int ki_estcpu; /* Time averaged value of ki_cpticks */ 15769896Smckusick u_int ki_slptime; /* Time since last blocked */ 15869896Smckusick u_int ki_swtime; /* Time swapped in or out */ 159147188Sgad int ki_spareint1; /* unused (just here for alignment) */ 16069896Smckusick u_int64_t ki_runtime; /* Real time in microsec */ 16169896Smckusick struct timeval ki_start; /* starting time */ 16269896Smckusick struct timeval ki_childtime; /* time used by process children */ 16369896Smckusick long ki_flag; /* P_* flags */ 16469896Smckusick long ki_kiflag; /* KI_* flags (below) */ 16569896Smckusick int ki_traceflag; /* Kernel trace points */ 16669896Smckusick char ki_stat; /* S* process status */ 167124829Sgrehan signed char ki_nice; /* Process "nice" value */ 16869896Smckusick char ki_lock; /* Process lock (prevent swap) count */ 16969896Smckusick char ki_rqindex; /* Run queue index */ 17069896Smckusick u_char ki_oncpu; /* Which cpu we are on */ 17169896Smckusick u_char ki_lastcpu; /* Last cpu we were on */ 172154535Sjulian char ki_ocomm[OCOMMLEN+1]; /* thread name */ 17369896Smckusick char ki_wmesg[WMESGLEN+1]; /* wchan message */ 17481759Speter char ki_login[LOGNAMELEN+1]; /* setlogin name */ 175104387Sjhb char ki_lockname[LOCKNAMELEN+1]; /* lock name */ 17681759Speter char ki_comm[COMMLEN+1]; /* command name */ 177130726Sgad char ki_emul[KI_EMULNAMELEN+1]; /* emulation name */ 178147188Sgad /* 179147188Sgad * When adding new variables, take space for char-strings from the 180147188Sgad * front of ki_sparestrings, and ints from the end of ki_spareints. 181147188Sgad * That way the spare room from both arrays will remain contiguous. 182147188Sgad */ 183130726Sgad char ki_sparestrings[68]; /* spare string space */ 184147188Sgad int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ 185147188Sgad int ki_jid; /* Process jail ID */ 186147188Sgad int ki_numthreads; /* XXXKSE number of threads in total */ 187147188Sgad lwpid_t ki_tid; /* XXXKSE thread id */ 188147188Sgad struct priority ki_pri; /* process priority */ 18969896Smckusick struct rusage ki_rusage; /* process rusage statistics */ 190147188Sgad /* XXX - most fields in ki_rusage_ch are not (yet) filled in */ 191147188Sgad struct rusage ki_rusage_ch; /* rusage of children processes */ 19283366Sjulian struct pcb *ki_pcb; /* kernel virtual addr of pcb */ 19383366Sjulian void *ki_kstack; /* kernel virtual addr of stack */ 194132014Salfred void *ki_udata; /* User convenience pointer */ 195147188Sgad /* 196147188Sgad * When adding new variables, take space for pointers from the 197147188Sgad * front of ki_spareptrs, and longs from the end of ki_sparelongs. 198147188Sgad * That way the spare room from both arrays will remain contiguous. 199147188Sgad */ 200147188Sgad void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 201147188Sgad long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */ 202147188Sgad long ki_sflag; /* PS_* flags */ 203147188Sgad long ki_tdflags; /* XXXKSE kthread flag */ 20411865Sphk}; 20592719Salfredvoid fill_kinfo_proc(struct proc *, struct kinfo_proc *); 206147188Sgad/* XXX - the following two defines are temporary */ 207147188Sgad#define ki_childstime ki_rusage_ch.ru_stime 208147188Sgad#define ki_childutime ki_rusage_ch.ru_utime 20911865Sphk 210172207Sjeff/* 211172207Sjeff * Legacy PS_ flag. This moved to p_flag but is maintained for 212172207Sjeff * compatibility. 213172207Sjeff */ 214172207Sjeff#define PS_INMEM 0x00001 /* Loaded into memory. */ 215172207Sjeff 21669896Smckusick/* ki_sessflag values */ 21769896Smckusick#define KI_CTTY 0x00000001 /* controlling tty vnode active */ 21869896Smckusick#define KI_SLEADER 0x00000002 /* session leader */ 219104387Sjhb#define KI_LOCKBLOCK 0x00000004 /* proc blocked on lock ki_lockname */ 22011865Sphk 22111865Sphk/* 222137920Sdas * This used to be the per-process structure containing data that 223137920Sdas * isn't needed in core when the process is swapped out, but now it 224137920Sdas * remains only for the benefit of a.out core dumps. 2251541Srgrimes */ 22683421Sobrienstruct user { 22783366Sjulian struct pstats u_stats; /* *p_stats */ 22883366Sjulian struct kinfo_proc u_kproc; /* eproc */ 2291541Srgrimes}; 2301541Srgrimes 23137689Sdfr#endif 232