user.h revision 83421
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 * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 331541Srgrimes * @(#)user.h 8.2 (Berkeley) 9/23/93 3450477Speter * $FreeBSD: head/sys/sys/user.h 83421 2001-09-13 22:52:42Z obrien $ 351541Srgrimes */ 361541Srgrimes 372165Spaul#ifndef _SYS_USER_H_ 382165Spaul#define _SYS_USER_H_ 392165Spaul 401541Srgrimes#include <machine/pcb.h> 4155205Speter#ifndef _KERNEL 421541Srgrimes/* stuff that *used* to be included by user.h, or is now needed */ 4318207Sbde#include <sys/errno.h> 441541Srgrimes#include <sys/time.h> 451541Srgrimes#include <sys/resource.h> 461541Srgrimes#include <sys/ucred.h> 471541Srgrimes#include <sys/uio.h> 4881202Sjhb#include <sys/_lock.h> 4976166Smarkm#include <sys/_mutex.h> 5011913Sphk#include <sys/proc.h> 5112685Speter#include <vm/vm.h> /* XXX */ 5212685Speter#include <vm/vm_param.h> /* XXX */ 5312685Speter#include <vm/pmap.h> /* XXX */ 5412685Speter#include <vm/vm_map.h> /* XXX */ 5555205Speter#endif /* !_KERNEL */ 5634924Sbde#ifndef _SYS_RESOURCEVAR_H_ 571541Srgrimes#include <sys/resourcevar.h> 5834924Sbde#endif 5934924Sbde#ifndef _SYS_SIGNALVAR_H_ 601541Srgrimes#include <sys/signalvar.h> 6134924Sbde#endif 621541Srgrimes 631541Srgrimes/* 6469896Smckusick * KERN_PROC subtype ops return arrays of selected proc structure entries: 6569896Smckusick * 6669896Smckusick * When adding new fields to this structure, ALWAYS add them at the end 6769896Smckusick * and decrease the size of the spare field by the amount of space that 6869896Smckusick * you are adding. Byte aligned data should be added to the ki_sparestring 6969896Smckusick * space; other entries should be added to the ki_spare space. Always 7069896Smckusick * verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE when you are 7169896Smckusick * done. If you change the size of this structure, many programs will stop 7269896Smckusick * working! Once you have added the new field, you will need to add code 7369896Smckusick * to initialize it in two places: kern/kern_proc.c in the function 7469896Smckusick * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist. 7511865Sphk */ 7671040Smjacob#ifdef __alpha__ 7773994Sgallatin#define KINFO_PROC_SIZE 912 /* the correct size for kinfo_proc */ 7874022Sdfr#endif 7974022Sdfr#ifdef __ia64__ 8074022Sdfr#define KINFO_PROC_SIZE 888 8174022Sdfr#endif 8274022Sdfr#ifdef __i386__ 8373892Sphk#define KINFO_PROC_SIZE 648 /* the correct size for kinfo_proc */ 8471040Smjacob#endif 8577956Sbenno#ifdef __powerpc__ 8677956Sbenno#define KINFO_PROC_SIZE 656 8777956Sbenno#endif 8880706Sjake#ifdef __sparc64__ 8980706Sjake#define KINFO_PROC_SIZE 888 9080706Sjake#endif 9174022Sdfr#ifndef KINFO_PROC_SIZE 9274022Sdfr#error "Unknown architecture" 9374022Sdfr#endif 9469896Smckusick#define WMESGLEN 8 /* size of returned wchan message */ 9569896Smckusick#define MTXNAMELEN 8 /* size of returned mutex name */ 9681759Speter#define OCOMMLEN 16 /* size of returned ki_ocomm name */ 9781759Speter#define COMMLEN 19 /* size of returned ki_comm name */ 9881759Speter#define KI_NGROUPS 16 /* number of groups in ki_groups */ 9981759Speter#define LOGNAMELEN 17 /* size of returned ki_login */ 10069896Smckusick 10111865Sphkstruct kinfo_proc { 10269896Smckusick int ki_structsize; /* size of this structure */ 10372415Sphk int ki_layout; /* reserved: layout identifier */ 10469896Smckusick struct pargs *ki_args; /* address of command arguments */ 10569896Smckusick struct proc *ki_paddr; /* address of proc */ 10669896Smckusick struct user *ki_addr; /* kernel virtual addr of u-area */ 10769896Smckusick struct vnode *ki_tracep; /* pointer to trace file */ 10869896Smckusick struct vnode *ki_textvp; /* pointer to executable file */ 10969896Smckusick struct filedesc *ki_fd; /* pointer to open file info */ 11069896Smckusick struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */ 11169896Smckusick void *ki_wchan; /* sleep address */ 11269896Smckusick pid_t ki_pid; /* Process identifier */ 11369896Smckusick pid_t ki_ppid; /* parent process id */ 11469896Smckusick pid_t ki_pgid; /* process group id */ 11569896Smckusick pid_t ki_tpgid; /* tty process group id */ 11669896Smckusick pid_t ki_sid; /* Process session ID */ 11769896Smckusick pid_t ki_tsid; /* Terminal session ID */ 11869896Smckusick short ki_jobc; /* job control counter */ 11969896Smckusick udev_t ki_tdev; /* controlling tty dev */ 12069896Smckusick sigset_t ki_siglist; /* Signals arrived but not delivered */ 12169896Smckusick sigset_t ki_sigmask; /* Current signal mask */ 12269896Smckusick sigset_t ki_sigignore; /* Signals being ignored */ 12369896Smckusick sigset_t ki_sigcatch; /* Signals being caught by user */ 12469896Smckusick uid_t ki_uid; /* effective user id */ 12569896Smckusick uid_t ki_ruid; /* Real user id */ 12669896Smckusick uid_t ki_svuid; /* Saved effective user id */ 12769896Smckusick gid_t ki_rgid; /* Real group id */ 12869896Smckusick gid_t ki_svgid; /* Saved effective group id */ 12969896Smckusick short ki_ngroups; /* number of groups */ 13081759Speter gid_t ki_groups[KI_NGROUPS]; /* groups */ 13169896Smckusick vm_size_t ki_size; /* virtual size */ 13269896Smckusick segsz_t ki_rssize; /* current resident set size in pages */ 13369896Smckusick segsz_t ki_swrss; /* resident set size before last swap */ 13469896Smckusick segsz_t ki_tsize; /* text size (pages) XXX */ 13569896Smckusick segsz_t ki_dsize; /* data size (pages) XXX */ 13669896Smckusick segsz_t ki_ssize; /* stack size (pages) */ 13769896Smckusick u_short ki_xstat; /* Exit status for wait & stop signal */ 13869896Smckusick u_short ki_acflag; /* Accounting flags */ 13969896Smckusick fixpt_t ki_pctcpu; /* %cpu for process during ki_swtime */ 14069896Smckusick u_int ki_estcpu; /* Time averaged value of ki_cpticks */ 14169896Smckusick u_int ki_slptime; /* Time since last blocked */ 14269896Smckusick u_int ki_swtime; /* Time swapped in or out */ 14369896Smckusick u_int64_t ki_runtime; /* Real time in microsec */ 14469896Smckusick struct timeval ki_start; /* starting time */ 14569896Smckusick struct timeval ki_childtime; /* time used by process children */ 14669896Smckusick long ki_flag; /* P_* flags */ 14769896Smckusick long ki_kiflag; /* KI_* flags (below) */ 14869896Smckusick int ki_traceflag; /* Kernel trace points */ 14969896Smckusick char ki_stat; /* S* process status */ 15069896Smckusick char ki_nice; /* Process "nice" value */ 15169896Smckusick char ki_lock; /* Process lock (prevent swap) count */ 15269896Smckusick char ki_rqindex; /* Run queue index */ 15369896Smckusick u_char ki_oncpu; /* Which cpu we are on */ 15469896Smckusick u_char ki_lastcpu; /* Last cpu we were on */ 15581759Speter char ki_ocomm[OCOMMLEN+1]; /* command name */ 15669896Smckusick char ki_wmesg[WMESGLEN+1]; /* wchan message */ 15781759Speter char ki_login[LOGNAMELEN+1]; /* setlogin name */ 15869896Smckusick char ki_mtxname[MTXNAMELEN+1]; /* mutex name */ 15981759Speter char ki_comm[COMMLEN+1]; /* command name */ 16081759Speter char ki_sparestrings[85]; /* spare string space */ 16169896Smckusick struct rusage ki_rusage; /* process rusage statistics */ 16271577Sjhb long ki_sflag; /* PS_* flags */ 16372376Sjake struct priority ki_pri; /* process priority */ 16483366Sjulian long ki_tdflags; /* XXXKSE kthread flag */ 16583366Sjulian struct pcb *ki_pcb; /* kernel virtual addr of pcb */ 16683366Sjulian void *ki_kstack; /* kernel virtual addr of stack */ 16783366Sjulian long ki_spare[22]; /* spare constants */ 16811865Sphk}; 16969896Smckusickvoid fill_kinfo_proc __P((struct proc *, struct kinfo_proc *)); 17011865Sphk 17169896Smckusick/* ki_sessflag values */ 17269896Smckusick#define KI_CTTY 0x00000001 /* controlling tty vnode active */ 17369896Smckusick#define KI_SLEADER 0x00000002 /* session leader */ 17469896Smckusick#define KI_MTXBLOCK 0x00000004 /* proc blocked on mutex ki_mtxname */ 17511865Sphk 17611865Sphk/* 1771541Srgrimes * Per process structure containing data that isn't needed in core 1781541Srgrimes * when the process isn't running (esp. when swapped out). 1791541Srgrimes * This structure may or may not be at the same kernel address 1801541Srgrimes * in all processes. 1811541Srgrimes */ 1828876Srgrimes 18383421Sobrienstruct user { 18483366Sjulian struct sigacts u_sigacts; /* *p_sigacts */ 18583366Sjulian struct pstats u_stats; /* *p_stats */ 1861541Srgrimes /* 18783366Sjulian * Remaining fields only for 18883366Sjulian * core dump and/or ptrace-- 1891541Srgrimes * not valid at other times! 1901541Srgrimes */ 19183366Sjulian struct kinfo_proc u_kproc; /* eproc */ 19283366Sjulian struct md_coredump u_md; /* glop */ 1931541Srgrimes}; 1941541Srgrimes 19537689Sdfr#endif 196