FreeBSD/Linux Kernel Cross Reference
sys/sys/user.h
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: releng/6.4/sys/sys/user.h 159908 2006-06-23 23:41:05Z cognet $
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 * This struct includes several arrays of spare space, with different arrays
64 * for different standard C-types. When adding new variables to this struct,
65 * the space for byte-aligned data should be taken from the ki_sparestring,
66 * pointers from ki_spareptrs, word-aligned data from ki_spareints, and
67 * doubleword-aligned data from ki_sparelongs. Make sure the space for new
68 * variables come from the array which matches the size and alignment of
69 * those variables on ALL hardware platforms, and then adjust the appropriate
70 * KI_NSPARE_* value(s) to match.
71 *
72 * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all
73 * platforms after you have added new variables. Note that if you change
74 * the value of KINFO_PROC_SIZE, then many userland programs will stop
75 * working until they are recompiled!
76 *
77 * Once you have added the new field, you will need to add code to initialize
78 * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
79 * function kvm_proclist in lib/libkvm/kvm_proc.c .
80 */
81 #define KI_NSPARE_INT 10
82 #define KI_NSPARE_LONG 12
83 #define KI_NSPARE_PTR 7
84
85 #ifdef __alpha__
86 #define KINFO_PROC_SIZE 1088
87 #endif
88 #ifdef __amd64__
89 #define KINFO_PROC_SIZE 1088
90 #endif
91 #ifdef __arm__
92 #define KINFO_PROC_SIZE 792
93 #endif
94 #ifdef __ia64__
95 #define KINFO_PROC_SIZE 1088
96 #endif
97 #ifdef __i386__
98 #define KINFO_PROC_SIZE 768
99 #endif
100 #ifdef __powerpc__
101 #define KINFO_PROC_SIZE 768
102 #endif
103 #ifdef __sparc64__
104 #define KINFO_PROC_SIZE 1088
105 #endif
106 #ifndef KINFO_PROC_SIZE
107 #error "Unknown architecture"
108 #endif
109
110 #define WMESGLEN 8 /* size of returned wchan message */
111 #define LOCKNAMELEN 8 /* size of returned lock name */
112 #define OCOMMLEN 16 /* size of returned ki_ocomm name */
113 #define COMMLEN 19 /* size of returned ki_comm name */
114 #define KI_EMULNAMELEN 16 /* size of returned ki_emul */
115 #define KI_NGROUPS 16 /* number of groups in ki_groups */
116 #define LOGNAMELEN 17 /* size of returned ki_login */
117
118 struct kinfo_proc {
119 int ki_structsize; /* size of this structure */
120 int ki_layout; /* reserved: layout identifier */
121 struct pargs *ki_args; /* address of command arguments */
122 struct proc *ki_paddr; /* address of proc */
123 struct user *ki_addr; /* kernel virtual addr of u-area */
124 struct vnode *ki_tracep; /* pointer to trace file */
125 struct vnode *ki_textvp; /* pointer to executable file */
126 struct filedesc *ki_fd; /* pointer to open file info */
127 struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */
128 void *ki_wchan; /* sleep address */
129 pid_t ki_pid; /* Process identifier */
130 pid_t ki_ppid; /* parent process id */
131 pid_t ki_pgid; /* process group id */
132 pid_t ki_tpgid; /* tty process group id */
133 pid_t ki_sid; /* Process session ID */
134 pid_t ki_tsid; /* Terminal session ID */
135 short ki_jobc; /* job control counter */
136 short ki_spare_short1; /* unused (just here for alignment) */
137 dev_t ki_tdev; /* controlling tty dev */
138 sigset_t ki_siglist; /* Signals arrived but not delivered */
139 sigset_t ki_sigmask; /* Current signal mask */
140 sigset_t ki_sigignore; /* Signals being ignored */
141 sigset_t ki_sigcatch; /* Signals being caught by user */
142 uid_t ki_uid; /* effective user id */
143 uid_t ki_ruid; /* Real user id */
144 uid_t ki_svuid; /* Saved effective user id */
145 gid_t ki_rgid; /* Real group id */
146 gid_t ki_svgid; /* Saved effective group id */
147 short ki_ngroups; /* number of groups */
148 short ki_spare_short2; /* unused (just here for alignment) */
149 gid_t ki_groups[KI_NGROUPS]; /* groups */
150 vm_size_t ki_size; /* virtual size */
151 segsz_t ki_rssize; /* current resident set size in pages */
152 segsz_t ki_swrss; /* resident set size before last swap */
153 segsz_t ki_tsize; /* text size (pages) XXX */
154 segsz_t ki_dsize; /* data size (pages) XXX */
155 segsz_t ki_ssize; /* stack size (pages) */
156 u_short ki_xstat; /* Exit status for wait & stop signal */
157 u_short ki_acflag; /* Accounting flags */
158 fixpt_t ki_pctcpu; /* %cpu for process during ki_swtime */
159 u_int ki_estcpu; /* Time averaged value of ki_cpticks */
160 u_int ki_slptime; /* Time since last blocked */
161 u_int ki_swtime; /* Time swapped in or out */
162 int ki_spareint1; /* unused (just here for alignment) */
163 u_int64_t ki_runtime; /* Real time in microsec */
164 struct timeval ki_start; /* starting time */
165 struct timeval ki_childtime; /* time used by process children */
166 long ki_flag; /* P_* flags */
167 long ki_kiflag; /* KI_* flags (below) */
168 int ki_traceflag; /* Kernel trace points */
169 char ki_stat; /* S* process status */
170 signed char ki_nice; /* Process "nice" value */
171 char ki_lock; /* Process lock (prevent swap) count */
172 char ki_rqindex; /* Run queue index */
173 u_char ki_oncpu; /* Which cpu we are on */
174 u_char ki_lastcpu; /* Last cpu we were on */
175 char ki_ocomm[OCOMMLEN+1]; /* command name */
176 char ki_wmesg[WMESGLEN+1]; /* wchan message */
177 char ki_login[LOGNAMELEN+1]; /* setlogin name */
178 char ki_lockname[LOCKNAMELEN+1]; /* lock name */
179 char ki_comm[COMMLEN+1]; /* command name */
180 char ki_emul[KI_EMULNAMELEN+1]; /* emulation name */
181 /*
182 * When adding new variables, take space for char-strings from the
183 * front of ki_sparestrings, and ints from the end of ki_spareints.
184 * That way the spare room from both arrays will remain contiguous.
185 */
186 char ki_sparestrings[68]; /* spare string space */
187 int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */
188 int ki_jid; /* Process jail ID */
189 int ki_numthreads; /* XXXKSE number of threads in total */
190 lwpid_t ki_tid; /* XXXKSE thread id */
191 struct priority ki_pri; /* process priority */
192 struct rusage ki_rusage; /* process rusage statistics */
193 /* XXX - most fields in ki_rusage_ch are not (yet) filled in */
194 struct rusage ki_rusage_ch; /* rusage of children processes */
195 struct pcb *ki_pcb; /* kernel virtual addr of pcb */
196 void *ki_kstack; /* kernel virtual addr of stack */
197 void *ki_udata; /* User convenience pointer */
198 /*
199 * When adding new variables, take space for pointers from the
200 * front of ki_spareptrs, and longs from the end of ki_sparelongs.
201 * That way the spare room from both arrays will remain contiguous.
202 */
203 void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */
204 long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */
205 long ki_sflag; /* PS_* flags */
206 long ki_tdflags; /* XXXKSE kthread flag */
207 };
208 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
209 /* XXX - the following two defines are temporary */
210 #define ki_childstime ki_rusage_ch.ru_stime
211 #define ki_childutime ki_rusage_ch.ru_utime
212
213 /* ki_sessflag values */
214 #define KI_CTTY 0x00000001 /* controlling tty vnode active */
215 #define KI_SLEADER 0x00000002 /* session leader */
216 #define KI_LOCKBLOCK 0x00000004 /* proc blocked on lock ki_lockname */
217
218 /*
219 * This used to be the per-process structure containing data that
220 * isn't needed in core when the process is swapped out, but now it
221 * remains only for the benefit of a.out core dumps.
222 */
223 struct user {
224 struct pstats u_stats; /* *p_stats */
225 struct kinfo_proc u_kproc; /* eproc */
226 };
227
228 #endif
Cache object: c82ceec291f32039aac523b2fc067144
|