user.h revision 137920
11541Srgrimes/* 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 137920 2004-11-20 02:31:46Z das $ 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 * 6369896Smckusick * When adding new fields to this structure, ALWAYS add them at the end 6469896Smckusick * and decrease the size of the spare field by the amount of space that 6569896Smckusick * you are adding. Byte aligned data should be added to the ki_sparestring 6669896Smckusick * space; other entries should be added to the ki_spare space. Always 6769896Smckusick * verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE when you are 6869896Smckusick * done. If you change the size of this structure, many programs will stop 6969896Smckusick * working! Once you have added the new field, you will need to add code 7069896Smckusick * to initialize it in two places: kern/kern_proc.c in the function 7169896Smckusick * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist. 72130825Sgad * 73130825Sgad * KI_NSPARE is the number of spare-longs to define in the array at the 74130825Sgad * end of kinfo_proc. It may need to be overridden on a platform-specific 75130825Sgad * basis as new fields are added. 7611865Sphk */ 77132014Salfred#define KI_NSPARE 16 78130825Sgad 79130825Sgad#ifdef __alpha__ 80130825Sgad#define KINFO_PROC_SIZE 912 8174022Sdfr#endif 82130825Sgad#ifdef __amd64__ 83130825Sgad#define KINFO_PROC_SIZE 912 8471040Smjacob#endif 85130825Sgad#ifdef __arm__ 86130825Sgad#undef KI_NSPARE /* Fewer spare longs on this arch */ 87132014Salfred#define KI_NSPARE 15 88130825Sgad#define KINFO_PROC_SIZE 648 8977956Sbenno#endif 90130825Sgad#ifdef __ia64__ 91130825Sgad#define KINFO_PROC_SIZE 912 9274022Sdfr#endif 93130825Sgad#ifdef __i386__ 94130825Sgad#undef KI_NSPARE /* Fewer spare longs on this arch */ 95132014Salfred#define KI_NSPARE 15 96130825Sgad#define KINFO_PROC_SIZE 648 97130825Sgad#endif 98130825Sgad#ifdef __powerpc__ 99130825Sgad#define KINFO_PROC_SIZE 656 100130825Sgad#endif 101130825Sgad#ifdef __sparc64__ 102130825Sgad#define KINFO_PROC_SIZE 912 103130825Sgad#endif 104130825Sgad#ifndef KINFO_PROC_SIZE 105130825Sgad#error "Unknown architecture" 106130825Sgad#endif 107130825Sgad 10869896Smckusick#define WMESGLEN 8 /* size of returned wchan message */ 109104387Sjhb#define LOCKNAMELEN 8 /* size of returned lock name */ 11081759Speter#define OCOMMLEN 16 /* size of returned ki_ocomm name */ 11181759Speter#define COMMLEN 19 /* size of returned ki_comm name */ 112130726Sgad#define KI_EMULNAMELEN 16 /* size of returned ki_emul */ 11381759Speter#define KI_NGROUPS 16 /* number of groups in ki_groups */ 11481759Speter#define LOGNAMELEN 17 /* size of returned ki_login */ 11569896Smckusick 11611865Sphkstruct kinfo_proc { 11769896Smckusick int ki_structsize; /* size of this structure */ 11872415Sphk int ki_layout; /* reserved: layout identifier */ 11969896Smckusick struct pargs *ki_args; /* address of command arguments */ 12069896Smckusick struct proc *ki_paddr; /* address of proc */ 12169896Smckusick struct user *ki_addr; /* kernel virtual addr of u-area */ 12269896Smckusick struct vnode *ki_tracep; /* pointer to trace file */ 12369896Smckusick struct vnode *ki_textvp; /* pointer to executable file */ 12469896Smckusick struct filedesc *ki_fd; /* pointer to open file info */ 12569896Smckusick struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */ 12669896Smckusick void *ki_wchan; /* sleep address */ 12769896Smckusick pid_t ki_pid; /* Process identifier */ 12869896Smckusick pid_t ki_ppid; /* parent process id */ 12969896Smckusick pid_t ki_pgid; /* process group id */ 13069896Smckusick pid_t ki_tpgid; /* tty process group id */ 13169896Smckusick pid_t ki_sid; /* Process session ID */ 13269896Smckusick pid_t ki_tsid; /* Terminal session ID */ 13369896Smckusick short ki_jobc; /* job control counter */ 134130726Sgad short ki_spare_short1; /* unused (just here for alignment) */ 135130640Sphk dev_t ki_tdev; /* controlling tty dev */ 13669896Smckusick sigset_t ki_siglist; /* Signals arrived but not delivered */ 13769896Smckusick sigset_t ki_sigmask; /* Current signal mask */ 13869896Smckusick sigset_t ki_sigignore; /* Signals being ignored */ 13969896Smckusick sigset_t ki_sigcatch; /* Signals being caught by user */ 14069896Smckusick uid_t ki_uid; /* effective user id */ 14169896Smckusick uid_t ki_ruid; /* Real user id */ 14269896Smckusick uid_t ki_svuid; /* Saved effective user id */ 14369896Smckusick gid_t ki_rgid; /* Real group id */ 14469896Smckusick gid_t ki_svgid; /* Saved effective group id */ 14569896Smckusick short ki_ngroups; /* number of groups */ 146130726Sgad short ki_spare_short2; /* unused (just here for alignment) */ 14781759Speter gid_t ki_groups[KI_NGROUPS]; /* groups */ 14869896Smckusick vm_size_t ki_size; /* virtual size */ 14969896Smckusick segsz_t ki_rssize; /* current resident set size in pages */ 15069896Smckusick segsz_t ki_swrss; /* resident set size before last swap */ 15169896Smckusick segsz_t ki_tsize; /* text size (pages) XXX */ 15269896Smckusick segsz_t ki_dsize; /* data size (pages) XXX */ 15369896Smckusick segsz_t ki_ssize; /* stack size (pages) */ 15469896Smckusick u_short ki_xstat; /* Exit status for wait & stop signal */ 15569896Smckusick u_short ki_acflag; /* Accounting flags */ 15669896Smckusick fixpt_t ki_pctcpu; /* %cpu for process during ki_swtime */ 15769896Smckusick u_int ki_estcpu; /* Time averaged value of ki_cpticks */ 15869896Smckusick u_int ki_slptime; /* Time since last blocked */ 15969896Smckusick u_int ki_swtime; /* Time swapped in or out */ 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 */ 17281759Speter char ki_ocomm[OCOMMLEN+1]; /* command 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 */ 178130726Sgad char ki_sparestrings[68]; /* spare string space */ 17969896Smckusick struct rusage ki_rusage; /* process rusage statistics */ 18071577Sjhb long ki_sflag; /* PS_* flags */ 18172376Sjake struct priority ki_pri; /* process priority */ 18283366Sjulian long ki_tdflags; /* XXXKSE kthread flag */ 18383366Sjulian struct pcb *ki_pcb; /* kernel virtual addr of pcb */ 18483366Sjulian void *ki_kstack; /* kernel virtual addr of stack */ 185130726Sgad struct timeval ki_childstime; /* system time used by children */ 186130726Sgad struct timeval ki_childutime; /* user time used by children */ 187130855Sgad lwpid_t ki_tid; /* XXXKSE thread id */ 188130825Sgad int ki_numthreads; /* XXXKSE number of threads in total */ 189132014Salfred void *ki_udata; /* User convenience pointer */ 190130726Sgad long ki_spare[KI_NSPARE]; /* spare room for later growth */ 19111865Sphk}; 19292719Salfredvoid fill_kinfo_proc(struct proc *, struct kinfo_proc *); 19311865Sphk 19469896Smckusick/* ki_sessflag values */ 19569896Smckusick#define KI_CTTY 0x00000001 /* controlling tty vnode active */ 19669896Smckusick#define KI_SLEADER 0x00000002 /* session leader */ 197104387Sjhb#define KI_LOCKBLOCK 0x00000004 /* proc blocked on lock ki_lockname */ 19811865Sphk 19911865Sphk/* 200137920Sdas * This used to be the per-process structure containing data that 201137920Sdas * isn't needed in core when the process is swapped out, but now it 202137920Sdas * remains only for the benefit of a.out core dumps. 2031541Srgrimes */ 20483421Sobrienstruct user { 20583366Sjulian struct pstats u_stats; /* *p_stats */ 20683366Sjulian struct kinfo_proc u_kproc; /* eproc */ 2071541Srgrimes}; 2081541Srgrimes 209137920Sdasvoid fill_user(struct proc *, struct user *); 210137920Sdas 21137689Sdfr#endif 212