1 /* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)user.h 8.2 (Berkeley) 9/23/93 30 * $FreeBSD$ 31 */ 32 33 #ifndef _SYS_USER_H_ 34 #define _SYS_USER_H_ 35 36 #include <machine/pcb.h> 37 #ifndef _KERNEL 38 /* stuff that *used* to be included by user.h, or is now needed */ 39 #include <sys/errno.h> 40 #include <sys/time.h> 41 #include <sys/resource.h> 42 #include <sys/ucred.h> 43 #include <sys/uio.h> 44 #include <sys/queue.h> 45 #include <sys/_lock.h> 46 #include <sys/_mutex.h> 47 #include <sys/proc.h> 48 #include <vm/vm.h> /* XXX */ 49 #include <vm/vm_param.h> /* XXX */ 50 #include <vm/pmap.h> /* XXX */ 51 #include <vm/vm_map.h> /* XXX */ 52 #endif /* !_KERNEL */ 53 #ifndef _SYS_RESOURCEVAR_H_ 54 #include <sys/resourcevar.h> 55 #endif 56 #ifndef _SYS_SIGNALVAR_H_ 57 #include <sys/signalvar.h> 58 #endif 59 60 /* 61 * KERN_PROC subtype ops return arrays of selected proc structure entries: 62 * 63 * When adding new fields to this structure, ALWAYS add them at the end 64 * and decrease the size of the spare field by the amount of space that 65 * you are adding. Byte aligned data should be added to the ki_sparestring 66 * space; other entries should be added to the ki_spare space. Always 67 * verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE when you are 68 * done. If you change the size of this structure, many programs will stop 69 * working! Once you have added the new field, you will need to add code 70 * to initialize it in two places: kern/kern_proc.c in the function 71 * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist. 72 * 73 * KI_NSPARE is the number of spare-longs to define in the array at the 74 * end of kinfo_proc. It may need to be overridden on a platform-specific 75 * basis as new fields are added. 76 */ 77 #define KI_NSPARE 16 78 79 #ifdef __alpha__ 80 #define KINFO_PROC_SIZE 912 81 #endif 82 #ifdef __amd64__ 83 #define KINFO_PROC_SIZE 912 84 #endif 85 #ifdef __arm__ 86 #undef KI_NSPARE /* Fewer spare longs on this arch */ 87 #define KI_NSPARE 15 88 #define KINFO_PROC_SIZE 648 89 #endif 90 #ifdef __ia64__ 91 #define KINFO_PROC_SIZE 912 92 #endif 93 #ifdef __i386__ 94 #undef KI_NSPARE /* Fewer spare longs on this arch */ 95 #define KI_NSPARE 15 96 #define KINFO_PROC_SIZE 648 97 #endif 98 #ifdef __powerpc__ 99 #define KINFO_PROC_SIZE 656 100 #endif 101 #ifdef __sparc64__ 102 #define KINFO_PROC_SIZE 912 103 #endif 104 #ifndef KINFO_PROC_SIZE 105 #error "Unknown architecture" 106 #endif 107 108 #define WMESGLEN 8 /* size of returned wchan message */ 109 #define LOCKNAMELEN 8 /* size of returned lock name */ 110 #define OCOMMLEN 16 /* size of returned ki_ocomm name */ 111 #define COMMLEN 19 /* size of returned ki_comm name */ 112 #define KI_EMULNAMELEN 16 /* size of returned ki_emul */ 113 #define KI_NGROUPS 16 /* number of groups in ki_groups */ 114 #define LOGNAMELEN 17 /* size of returned ki_login */ 115 116 struct kinfo_proc { 117 int ki_structsize; /* size of this structure */ 118 int ki_layout; /* reserved: layout identifier */ 119 struct pargs *ki_args; /* address of command arguments */ 120 struct proc *ki_paddr; /* address of proc */ 121 struct user *ki_addr; /* kernel virtual addr of u-area */ 122 struct vnode *ki_tracep; /* pointer to trace file */ 123 struct vnode *ki_textvp; /* pointer to executable file */ 124 struct filedesc *ki_fd; /* pointer to open file info */ 125 struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */ 126 void *ki_wchan; /* sleep address */ 127 pid_t ki_pid; /* Process identifier */ 128 pid_t ki_ppid; /* parent process id */ 129 pid_t ki_pgid; /* process group id */ 130 pid_t ki_tpgid; /* tty process group id */ 131 pid_t ki_sid; /* Process session ID */ 132 pid_t ki_tsid; /* Terminal session ID */ 133 short ki_jobc; /* job control counter */ 134 short ki_spare_short1; /* unused (just here for alignment) */ 135 dev_t ki_tdev; /* controlling tty dev */ 136 sigset_t ki_siglist; /* Signals arrived but not delivered */ 137 sigset_t ki_sigmask; /* Current signal mask */ 138 sigset_t ki_sigignore; /* Signals being ignored */ 139 sigset_t ki_sigcatch; /* Signals being caught by user */ 140 uid_t ki_uid; /* effective user id */ 141 uid_t ki_ruid; /* Real user id */ 142 uid_t ki_svuid; /* Saved effective user id */ 143 gid_t ki_rgid; /* Real group id */ 144 gid_t ki_svgid; /* Saved effective group id */ 145 short ki_ngroups; /* number of groups */ 146 short ki_spare_short2; /* unused (just here for alignment) */ 147 gid_t ki_groups[KI_NGROUPS]; /* groups */ 148 vm_size_t ki_size; /* virtual size */ 149 segsz_t ki_rssize; /* current resident set size in pages */ 150 segsz_t ki_swrss; /* resident set size before last swap */ 151 segsz_t ki_tsize; /* text size (pages) XXX */ 152 segsz_t ki_dsize; /* data size (pages) XXX */ 153 segsz_t ki_ssize; /* stack size (pages) */ 154 u_short ki_xstat; /* Exit status for wait & stop signal */ 155 u_short ki_acflag; /* Accounting flags */ 156 fixpt_t ki_pctcpu; /* %cpu for process during ki_swtime */ 157 u_int ki_estcpu; /* Time averaged value of ki_cpticks */ 158 u_int ki_slptime; /* Time since last blocked */ 159 u_int ki_swtime; /* Time swapped in or out */ 160 u_int64_t ki_runtime; /* Real time in microsec */ 161 struct timeval ki_start; /* starting time */ 162 struct timeval ki_childtime; /* time used by process children */ 163 long ki_flag; /* P_* flags */ 164 long ki_kiflag; /* KI_* flags (below) */ 165 int ki_traceflag; /* Kernel trace points */ 166 char ki_stat; /* S* process status */ 167 signed char ki_nice; /* Process "nice" value */ 168 char ki_lock; /* Process lock (prevent swap) count */ 169 char ki_rqindex; /* Run queue index */ 170 u_char ki_oncpu; /* Which cpu we are on */ 171 u_char ki_lastcpu; /* Last cpu we were on */ 172 char ki_ocomm[OCOMMLEN+1]; /* command name */ 173 char ki_wmesg[WMESGLEN+1]; /* wchan message */ 174 char ki_login[LOGNAMELEN+1]; /* setlogin name */ 175 char ki_lockname[LOCKNAMELEN+1]; /* lock name */ 176 char ki_comm[COMMLEN+1]; /* command name */ 177 char ki_emul[KI_EMULNAMELEN+1]; /* emulation name */ 178 char ki_sparestrings[68]; /* spare string space */ 179 struct rusage ki_rusage; /* process rusage statistics */ 180 long ki_sflag; /* PS_* flags */ 181 struct priority ki_pri; /* process priority */ 182 long ki_tdflags; /* XXXKSE kthread flag */ 183 struct pcb *ki_pcb; /* kernel virtual addr of pcb */ 184 void *ki_kstack; /* kernel virtual addr of stack */ 185 struct timeval ki_childstime; /* system time used by children */ 186 struct timeval ki_childutime; /* user time used by children */ 187 lwpid_t ki_tid; /* XXXKSE thread id */ 188 int ki_numthreads; /* XXXKSE number of threads in total */ 189 void *ki_udata; /* User convenience pointer */ 190 long ki_spare[KI_NSPARE]; /* spare room for later growth */ 191 }; 192 void fill_kinfo_proc(struct proc *, struct kinfo_proc *); 193 194 /* ki_sessflag values */ 195 #define KI_CTTY 0x00000001 /* controlling tty vnode active */ 196 #define KI_SLEADER 0x00000002 /* session leader */ 197 #define KI_LOCKBLOCK 0x00000004 /* proc blocked on lock ki_lockname */ 198 199 /* 200 * Per process structure containing data that isn't needed in core 201 * when the process isn't running (esp. when swapped out). 202 */ 203 struct user { 204 struct pstats u_stats; /* *p_stats */ 205 /* 206 * Remaining field for a.out core dumps - not valid at other times! 207 */ 208 struct kinfo_proc u_kproc; /* eproc */ 209 }; 210 211 #endif 212