1 | /*- |
---|
2 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 |
---|
3 | * The Regents of the University of California. |
---|
4 | * Copyright (c) 2007 Robert N. M. Watson |
---|
5 | * All rights reserved. |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms, with or without |
---|
8 | * modification, are permitted provided that the following conditions |
---|
9 | * are met: |
---|
10 | * 1. Redistributions of source code must retain the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer. |
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer in the |
---|
14 | * documentation and/or other materials provided with the distribution. |
---|
15 | * 4. Neither the name of the University nor the names of its contributors |
---|
16 | * may be used to endorse or promote products derived from this software |
---|
17 | * without specific prior written permission. |
---|
18 | * |
---|
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
---|
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
---|
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
29 | * SUCH DAMAGE. |
---|
30 | * |
---|
31 | * @(#)user.h 8.2 (Berkeley) 9/23/93 |
---|
32 | * $FreeBSD$ |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _SYS_USER_H_ |
---|
36 | #define _SYS_USER_H_ |
---|
37 | |
---|
38 | #include <machine/pcb.h> |
---|
39 | #ifndef _KERNEL |
---|
40 | /* stuff that *used* to be included by user.h, or is now needed */ |
---|
41 | #include <rtems/bsd/sys/errno.h> |
---|
42 | #include <sys/time.h> |
---|
43 | #include <rtems/bsd/sys/resource.h> |
---|
44 | #include <sys/ucred.h> |
---|
45 | #include <sys/uio.h> |
---|
46 | #include <sys/queue.h> |
---|
47 | #include <sys/_lock.h> |
---|
48 | #include <sys/_mutex.h> |
---|
49 | #include <sys/proc.h> |
---|
50 | #include <vm/vm.h> /* XXX */ |
---|
51 | #include <vm/vm_param.h> /* XXX */ |
---|
52 | #include <vm/pmap.h> /* XXX */ |
---|
53 | #include <vm/vm_map.h> /* XXX */ |
---|
54 | #endif /* !_KERNEL */ |
---|
55 | #ifndef _SYS_RESOURCEVAR_H_ |
---|
56 | #include <sys/resourcevar.h> |
---|
57 | #endif |
---|
58 | #ifndef _SYS_SIGNALVAR_H_ |
---|
59 | #include <sys/signalvar.h> |
---|
60 | #endif |
---|
61 | #ifndef _SYS_SOCKET_VAR_H_ |
---|
62 | #include <sys/socket.h> |
---|
63 | #endif |
---|
64 | |
---|
65 | /* |
---|
66 | * KERN_PROC subtype ops return arrays of selected proc structure entries: |
---|
67 | * |
---|
68 | * This struct includes several arrays of spare space, with different arrays |
---|
69 | * for different standard C-types. When adding new variables to this struct, |
---|
70 | * the space for byte-aligned data should be taken from the ki_sparestring, |
---|
71 | * pointers from ki_spareptrs, word-aligned data from ki_spareints, and |
---|
72 | * doubleword-aligned data from ki_sparelongs. Make sure the space for new |
---|
73 | * variables come from the array which matches the size and alignment of |
---|
74 | * those variables on ALL hardware platforms, and then adjust the appropriate |
---|
75 | * KI_NSPARE_* value(s) to match. |
---|
76 | * |
---|
77 | * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all |
---|
78 | * platforms after you have added new variables. Note that if you change |
---|
79 | * the value of KINFO_PROC_SIZE, then many userland programs will stop |
---|
80 | * working until they are recompiled! |
---|
81 | * |
---|
82 | * Once you have added the new field, you will need to add code to initialize |
---|
83 | * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and |
---|
84 | * function kvm_proclist in lib/libkvm/kvm_proc.c . |
---|
85 | */ |
---|
86 | #define KI_NSPARE_INT 7 |
---|
87 | #define KI_NSPARE_LONG 12 |
---|
88 | #define KI_NSPARE_PTR 6 |
---|
89 | |
---|
90 | #ifndef _KERNEL |
---|
91 | #ifndef KINFO_PROC_SIZE |
---|
92 | #error "Unknown architecture" |
---|
93 | #endif |
---|
94 | #endif /* !_KERNEL */ |
---|
95 | |
---|
96 | #define WMESGLEN 8 /* size of returned wchan message */ |
---|
97 | #define LOCKNAMELEN 8 /* size of returned lock name */ |
---|
98 | #define TDNAMLEN 16 /* size of returned thread name */ |
---|
99 | #define COMMLEN 19 /* size of returned ki_comm name */ |
---|
100 | #define KI_EMULNAMELEN 16 /* size of returned ki_emul */ |
---|
101 | #define KI_NGROUPS 16 /* number of groups in ki_groups */ |
---|
102 | #define LOGNAMELEN 17 /* size of returned ki_login */ |
---|
103 | #define LOGINCLASSLEN 17 /* size of returned ki_loginclass */ |
---|
104 | |
---|
105 | #ifndef BURN_BRIDGES |
---|
106 | #define OCOMMLEN TDNAMLEN |
---|
107 | #define ki_ocomm ki_tdname |
---|
108 | #endif |
---|
109 | |
---|
110 | /* Flags for the process credential. */ |
---|
111 | #define KI_CRF_CAPABILITY_MODE 0x00000001 |
---|
112 | /* |
---|
113 | * Steal a bit from ki_cr_flags to indicate that the cred had more than |
---|
114 | * KI_NGROUPS groups. |
---|
115 | */ |
---|
116 | #define KI_CRF_GRP_OVERFLOW 0x80000000 |
---|
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 | u_int ki_cow; /* number of copy-on-write faults */ |
---|
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_tdname[TDNAMLEN+1]; /* thread 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 | char ki_loginclass[LOGINCLASSLEN+1]; /* login class */ |
---|
182 | /* |
---|
183 | * When adding new variables, take space for char-strings from the |
---|
184 | * front of ki_sparestrings, and ints from the end of ki_spareints. |
---|
185 | * That way the spare room from both arrays will remain contiguous. |
---|
186 | */ |
---|
187 | char ki_sparestrings[50]; /* spare string space */ |
---|
188 | int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ |
---|
189 | int ki_flag2; /* P2_* flags */ |
---|
190 | int ki_fibnum; /* Default FIB number */ |
---|
191 | u_int ki_cr_flags; /* Credential flags */ |
---|
192 | int ki_jid; /* Process jail ID */ |
---|
193 | int ki_numthreads; /* XXXKSE number of threads in total */ |
---|
194 | lwpid_t ki_tid; /* XXXKSE thread id */ |
---|
195 | #ifndef __rtems__ |
---|
196 | struct priority ki_pri; /* process priority */ |
---|
197 | #endif /* __rtems__ */ |
---|
198 | struct rusage ki_rusage; /* process rusage statistics */ |
---|
199 | /* XXX - most fields in ki_rusage_ch are not (yet) filled in */ |
---|
200 | struct rusage ki_rusage_ch; /* rusage of children processes */ |
---|
201 | struct pcb *ki_pcb; /* kernel virtual addr of pcb */ |
---|
202 | void *ki_kstack; /* kernel virtual addr of stack */ |
---|
203 | void *ki_udata; /* User convenience pointer */ |
---|
204 | struct thread *ki_tdaddr; /* address of thread */ |
---|
205 | /* |
---|
206 | * When adding new variables, take space for pointers from the |
---|
207 | * front of ki_spareptrs, and longs from the end of ki_sparelongs. |
---|
208 | * That way the spare room from both arrays will remain contiguous. |
---|
209 | */ |
---|
210 | void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ |
---|
211 | long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */ |
---|
212 | long ki_sflag; /* PS_* flags */ |
---|
213 | long ki_tdflags; /* XXXKSE kthread flag */ |
---|
214 | }; |
---|
215 | void fill_kinfo_proc(struct proc *, struct kinfo_proc *); |
---|
216 | /* XXX - the following two defines are temporary */ |
---|
217 | #define ki_childstime ki_rusage_ch.ru_stime |
---|
218 | #define ki_childutime ki_rusage_ch.ru_utime |
---|
219 | |
---|
220 | /* |
---|
221 | * Legacy PS_ flag. This moved to p_flag but is maintained for |
---|
222 | * compatibility. |
---|
223 | */ |
---|
224 | #define PS_INMEM 0x00001 /* Loaded into memory. */ |
---|
225 | |
---|
226 | /* ki_sessflag values */ |
---|
227 | #define KI_CTTY 0x00000001 /* controlling tty vnode active */ |
---|
228 | #define KI_SLEADER 0x00000002 /* session leader */ |
---|
229 | #define KI_LOCKBLOCK 0x00000004 /* proc blocked on lock ki_lockname */ |
---|
230 | |
---|
231 | /* |
---|
232 | * This used to be the per-process structure containing data that |
---|
233 | * isn't needed in core when the process is swapped out, but now it |
---|
234 | * remains only for the benefit of a.out core dumps. |
---|
235 | */ |
---|
236 | struct user { |
---|
237 | struct pstats u_stats; /* *p_stats */ |
---|
238 | struct kinfo_proc u_kproc; /* eproc */ |
---|
239 | }; |
---|
240 | |
---|
241 | /* |
---|
242 | * The KERN_PROC_FILE sysctl allows a process to dump the file descriptor |
---|
243 | * array of another process. |
---|
244 | */ |
---|
245 | #define KF_ATTR_VALID 0x0001 |
---|
246 | |
---|
247 | #define KF_TYPE_NONE 0 |
---|
248 | #define KF_TYPE_VNODE 1 |
---|
249 | #define KF_TYPE_SOCKET 2 |
---|
250 | #define KF_TYPE_PIPE 3 |
---|
251 | #define KF_TYPE_FIFO 4 |
---|
252 | #define KF_TYPE_KQUEUE 5 |
---|
253 | #define KF_TYPE_CRYPTO 6 |
---|
254 | #define KF_TYPE_MQUEUE 7 |
---|
255 | #define KF_TYPE_SHM 8 |
---|
256 | #define KF_TYPE_SEM 9 |
---|
257 | #define KF_TYPE_PTS 10 |
---|
258 | /* no KF_TYPE_CAPABILITY (11), since capabilities wrap other file objects */ |
---|
259 | #define KF_TYPE_PROCDESC 12 |
---|
260 | #define KF_TYPE_UNKNOWN 255 |
---|
261 | |
---|
262 | #define KF_VTYPE_VNON 0 |
---|
263 | #define KF_VTYPE_VREG 1 |
---|
264 | #define KF_VTYPE_VDIR 2 |
---|
265 | #define KF_VTYPE_VBLK 3 |
---|
266 | #define KF_VTYPE_VCHR 4 |
---|
267 | #define KF_VTYPE_VLNK 5 |
---|
268 | #define KF_VTYPE_VSOCK 6 |
---|
269 | #define KF_VTYPE_VFIFO 7 |
---|
270 | #define KF_VTYPE_VBAD 8 |
---|
271 | #define KF_VTYPE_UNKNOWN 255 |
---|
272 | |
---|
273 | #define KF_FD_TYPE_CWD -1 /* Current working directory */ |
---|
274 | #define KF_FD_TYPE_ROOT -2 /* Root directory */ |
---|
275 | #define KF_FD_TYPE_JAIL -3 /* Jail directory */ |
---|
276 | #define KF_FD_TYPE_TRACE -4 /* ptrace vnode */ |
---|
277 | #define KF_FD_TYPE_TEXT -5 /* Text vnode */ |
---|
278 | #define KF_FD_TYPE_CTTY -6 /* Controlling terminal */ |
---|
279 | |
---|
280 | #define KF_FLAG_READ 0x00000001 |
---|
281 | #define KF_FLAG_WRITE 0x00000002 |
---|
282 | #define KF_FLAG_APPEND 0x00000004 |
---|
283 | #define KF_FLAG_ASYNC 0x00000008 |
---|
284 | #define KF_FLAG_FSYNC 0x00000010 |
---|
285 | #define KF_FLAG_NONBLOCK 0x00000020 |
---|
286 | #define KF_FLAG_DIRECT 0x00000040 |
---|
287 | #define KF_FLAG_HASLOCK 0x00000080 |
---|
288 | #define KF_FLAG_SHLOCK 0x00000100 |
---|
289 | #define KF_FLAG_EXLOCK 0x00000200 |
---|
290 | #define KF_FLAG_NOFOLLOW 0x00000400 |
---|
291 | #define KF_FLAG_CREAT 0x00000800 |
---|
292 | #define KF_FLAG_TRUNC 0x00001000 |
---|
293 | #define KF_FLAG_EXCL 0x00002000 |
---|
294 | #define KF_FLAG_EXEC 0x00004000 |
---|
295 | #define KF_FLAG_CAPABILITY 0x00008000 |
---|
296 | |
---|
297 | /* |
---|
298 | * Old format. Has variable hidden padding due to alignment. |
---|
299 | * This is a compatability hack for pre-build 7.1 packages. |
---|
300 | */ |
---|
301 | #if defined(__amd64__) |
---|
302 | #define KINFO_OFILE_SIZE 1328 |
---|
303 | #endif |
---|
304 | #if defined(__i386__) |
---|
305 | #define KINFO_OFILE_SIZE 1324 |
---|
306 | #endif |
---|
307 | |
---|
308 | struct kinfo_ofile { |
---|
309 | int kf_structsize; /* Size of kinfo_file. */ |
---|
310 | int kf_type; /* Descriptor type. */ |
---|
311 | int kf_fd; /* Array index. */ |
---|
312 | int kf_ref_count; /* Reference count. */ |
---|
313 | int kf_flags; /* Flags. */ |
---|
314 | /* XXX Hidden alignment padding here on amd64 */ |
---|
315 | off_t kf_offset; /* Seek location. */ |
---|
316 | int kf_vnode_type; /* Vnode type. */ |
---|
317 | int kf_sock_domain; /* Socket domain. */ |
---|
318 | int kf_sock_type; /* Socket type. */ |
---|
319 | int kf_sock_protocol; /* Socket protocol. */ |
---|
320 | char kf_path[PATH_MAX]; /* Path to file, if any. */ |
---|
321 | struct sockaddr_storage kf_sa_local; /* Socket address. */ |
---|
322 | struct sockaddr_storage kf_sa_peer; /* Peer address. */ |
---|
323 | }; |
---|
324 | |
---|
325 | #if defined(__amd64__) || defined(__i386__) |
---|
326 | #define KINFO_FILE_SIZE 1392 |
---|
327 | #endif |
---|
328 | |
---|
329 | struct kinfo_file { |
---|
330 | #ifndef __rtems__ |
---|
331 | int kf_structsize; /* Variable size of record. */ |
---|
332 | int kf_type; /* Descriptor type. */ |
---|
333 | int kf_fd; /* Array index. */ |
---|
334 | int kf_ref_count; /* Reference count. */ |
---|
335 | int kf_flags; /* Flags. */ |
---|
336 | int kf_pad0; /* Round to 64 bit alignment. */ |
---|
337 | int64_t kf_offset; /* Seek location. */ |
---|
338 | int kf_vnode_type; /* Vnode type. */ |
---|
339 | int kf_sock_domain; /* Socket domain. */ |
---|
340 | int kf_sock_type; /* Socket type. */ |
---|
341 | int kf_sock_protocol; /* Socket protocol. */ |
---|
342 | struct sockaddr_storage kf_sa_local; /* Socket address. */ |
---|
343 | struct sockaddr_storage kf_sa_peer; /* Peer address. */ |
---|
344 | union { |
---|
345 | struct { |
---|
346 | /* Address of so_pcb. */ |
---|
347 | uint64_t kf_sock_pcb; |
---|
348 | /* Address of inp_ppcb. */ |
---|
349 | uint64_t kf_sock_inpcb; |
---|
350 | /* Address of unp_conn. */ |
---|
351 | uint64_t kf_sock_unpconn; |
---|
352 | /* Send buffer state. */ |
---|
353 | uint16_t kf_sock_snd_sb_state; |
---|
354 | /* Receive buffer state. */ |
---|
355 | uint16_t kf_sock_rcv_sb_state; |
---|
356 | /* Round to 64 bit alignment. */ |
---|
357 | uint32_t kf_sock_pad0; |
---|
358 | } kf_sock; |
---|
359 | struct { |
---|
360 | /* Global file id. */ |
---|
361 | uint64_t kf_file_fileid; |
---|
362 | /* File size. */ |
---|
363 | uint64_t kf_file_size; |
---|
364 | /* Vnode filesystem id. */ |
---|
365 | uint32_t kf_file_fsid; |
---|
366 | /* File device. */ |
---|
367 | uint32_t kf_file_rdev; |
---|
368 | /* File mode. */ |
---|
369 | uint16_t kf_file_mode; |
---|
370 | /* Round to 64 bit alignment. */ |
---|
371 | uint16_t kf_file_pad0; |
---|
372 | uint32_t kf_file_pad1; |
---|
373 | } kf_file; |
---|
374 | struct { |
---|
375 | uint32_t kf_sem_value; |
---|
376 | uint16_t kf_sem_mode; |
---|
377 | } kf_sem; |
---|
378 | struct { |
---|
379 | uint64_t kf_pipe_addr; |
---|
380 | uint64_t kf_pipe_peer; |
---|
381 | uint32_t kf_pipe_buffer_cnt; |
---|
382 | /* Round to 64 bit alignment. */ |
---|
383 | uint32_t kf_pipe_pad0[3]; |
---|
384 | } kf_pipe; |
---|
385 | struct { |
---|
386 | uint32_t kf_pts_dev; |
---|
387 | /* Round to 64 bit alignment. */ |
---|
388 | uint32_t kf_pts_pad0[7]; |
---|
389 | } kf_pts; |
---|
390 | struct { |
---|
391 | pid_t kf_pid; |
---|
392 | } kf_proc; |
---|
393 | } kf_un; |
---|
394 | uint16_t kf_status; /* Status flags. */ |
---|
395 | uint16_t kf_pad1; /* Round to 32 bit alignment. */ |
---|
396 | int _kf_ispare0; /* Space for more stuff. */ |
---|
397 | cap_rights_t kf_cap_rights; /* Capability rights. */ |
---|
398 | int _kf_ispare[4]; /* Space for more stuff. */ |
---|
399 | /* Truncated before copyout in sysctl */ |
---|
400 | char kf_path[PATH_MAX]; /* Path to file, if any. */ |
---|
401 | #else /* __rtems__ */ |
---|
402 | int kf_dummy; |
---|
403 | #endif /* __rtems__ */ |
---|
404 | }; |
---|
405 | |
---|
406 | /* |
---|
407 | * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of |
---|
408 | * another process as a series of entries. |
---|
409 | */ |
---|
410 | #define KVME_TYPE_NONE 0 |
---|
411 | #define KVME_TYPE_DEFAULT 1 |
---|
412 | #define KVME_TYPE_VNODE 2 |
---|
413 | #define KVME_TYPE_SWAP 3 |
---|
414 | #define KVME_TYPE_DEVICE 4 |
---|
415 | #define KVME_TYPE_PHYS 5 |
---|
416 | #define KVME_TYPE_DEAD 6 |
---|
417 | #define KVME_TYPE_SG 7 |
---|
418 | #define KVME_TYPE_MGTDEVICE 8 |
---|
419 | #define KVME_TYPE_UNKNOWN 255 |
---|
420 | |
---|
421 | #define KVME_PROT_READ 0x00000001 |
---|
422 | #define KVME_PROT_WRITE 0x00000002 |
---|
423 | #define KVME_PROT_EXEC 0x00000004 |
---|
424 | |
---|
425 | #define KVME_FLAG_COW 0x00000001 |
---|
426 | #define KVME_FLAG_NEEDS_COPY 0x00000002 |
---|
427 | #define KVME_FLAG_NOCOREDUMP 0x00000004 |
---|
428 | #define KVME_FLAG_SUPER 0x00000008 |
---|
429 | #define KVME_FLAG_GROWS_UP 0x00000010 |
---|
430 | #define KVME_FLAG_GROWS_DOWN 0x00000020 |
---|
431 | |
---|
432 | #if defined(__amd64__) |
---|
433 | #define KINFO_OVMENTRY_SIZE 1168 |
---|
434 | #endif |
---|
435 | #if defined(__i386__) |
---|
436 | #define KINFO_OVMENTRY_SIZE 1128 |
---|
437 | #endif |
---|
438 | |
---|
439 | struct kinfo_ovmentry { |
---|
440 | int kve_structsize; /* Size of kinfo_vmmapentry. */ |
---|
441 | int kve_type; /* Type of map entry. */ |
---|
442 | void *kve_start; /* Starting address. */ |
---|
443 | void *kve_end; /* Finishing address. */ |
---|
444 | int kve_flags; /* Flags on map entry. */ |
---|
445 | int kve_resident; /* Number of resident pages. */ |
---|
446 | int kve_private_resident; /* Number of private pages. */ |
---|
447 | int kve_protection; /* Protection bitmask. */ |
---|
448 | int kve_ref_count; /* VM obj ref count. */ |
---|
449 | int kve_shadow_count; /* VM obj shadow count. */ |
---|
450 | char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ |
---|
451 | void *_kve_pspare[8]; /* Space for more stuff. */ |
---|
452 | off_t kve_offset; /* Mapping offset in object */ |
---|
453 | uint64_t kve_fileid; /* inode number if vnode */ |
---|
454 | dev_t kve_fsid; /* dev_t of vnode location */ |
---|
455 | int _kve_ispare[3]; /* Space for more stuff. */ |
---|
456 | }; |
---|
457 | |
---|
458 | #if defined(__amd64__) || defined(__i386__) |
---|
459 | #define KINFO_VMENTRY_SIZE 1160 |
---|
460 | #endif |
---|
461 | |
---|
462 | struct kinfo_vmentry { |
---|
463 | int kve_structsize; /* Variable size of record. */ |
---|
464 | int kve_type; /* Type of map entry. */ |
---|
465 | uint64_t kve_start; /* Starting address. */ |
---|
466 | uint64_t kve_end; /* Finishing address. */ |
---|
467 | uint64_t kve_offset; /* Mapping offset in object */ |
---|
468 | uint64_t kve_vn_fileid; /* inode number if vnode */ |
---|
469 | uint32_t kve_vn_fsid; /* dev_t of vnode location */ |
---|
470 | int kve_flags; /* Flags on map entry. */ |
---|
471 | int kve_resident; /* Number of resident pages. */ |
---|
472 | int kve_private_resident; /* Number of private pages. */ |
---|
473 | int kve_protection; /* Protection bitmask. */ |
---|
474 | int kve_ref_count; /* VM obj ref count. */ |
---|
475 | int kve_shadow_count; /* VM obj shadow count. */ |
---|
476 | int kve_vn_type; /* Vnode type. */ |
---|
477 | uint64_t kve_vn_size; /* File size. */ |
---|
478 | uint32_t kve_vn_rdev; /* Device id if device. */ |
---|
479 | uint16_t kve_vn_mode; /* File mode. */ |
---|
480 | uint16_t kve_status; /* Status flags. */ |
---|
481 | int _kve_ispare[12]; /* Space for more stuff. */ |
---|
482 | /* Truncated before copyout in sysctl */ |
---|
483 | char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ |
---|
484 | }; |
---|
485 | |
---|
486 | /* |
---|
487 | * The KERN_PROC_KSTACK sysctl allows a process to dump the kernel stacks of |
---|
488 | * another process as a series of entries. Each stack is represented by a |
---|
489 | * series of symbol names and offsets as generated by stack_sbuf_print(9). |
---|
490 | */ |
---|
491 | #define KKST_MAXLEN 1024 |
---|
492 | |
---|
493 | #define KKST_STATE_STACKOK 0 /* Stack is valid. */ |
---|
494 | #define KKST_STATE_SWAPPED 1 /* Stack swapped out. */ |
---|
495 | #define KKST_STATE_RUNNING 2 /* Stack ephemeral. */ |
---|
496 | |
---|
497 | #if defined(__amd64__) || defined(__i386__) |
---|
498 | #define KINFO_KSTACK_SIZE 1096 |
---|
499 | #endif |
---|
500 | |
---|
501 | struct kinfo_kstack { |
---|
502 | lwpid_t kkst_tid; /* ID of thread. */ |
---|
503 | int kkst_state; /* Validity of stack. */ |
---|
504 | char kkst_trace[KKST_MAXLEN]; /* String representing stack. */ |
---|
505 | int _kkst_ispare[16]; /* Space for more stuff. */ |
---|
506 | }; |
---|
507 | |
---|
508 | struct kinfo_sigtramp { |
---|
509 | void *ksigtramp_start; |
---|
510 | void *ksigtramp_end; |
---|
511 | void *ksigtramp_spare[4]; |
---|
512 | }; |
---|
513 | |
---|
514 | #ifdef _KERNEL |
---|
515 | /* Flags for kern_proc_out function. */ |
---|
516 | #define KERN_PROC_NOTHREADS 0x1 |
---|
517 | #define KERN_PROC_MASK32 0x2 |
---|
518 | |
---|
519 | struct sbuf; |
---|
520 | |
---|
521 | /* |
---|
522 | * The kern_proc out functions are helper functions to dump process |
---|
523 | * miscellaneous kinfo structures to sbuf. The main consumers are KERN_PROC |
---|
524 | * sysctls but they may also be used by other kernel subsystems. |
---|
525 | * |
---|
526 | * The functions manipulate the process locking state and expect the process |
---|
527 | * to be locked on enter. On return the process is unlocked. |
---|
528 | */ |
---|
529 | |
---|
530 | int kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen); |
---|
531 | int kern_proc_out(struct proc *p, struct sbuf *sb, int flags); |
---|
532 | int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb); |
---|
533 | |
---|
534 | int vntype_to_kinfo(int vtype); |
---|
535 | #endif /* !_KERNEL */ |
---|
536 | |
---|
537 | #endif |
---|