user.h revision 221807
1102644Snectar/*-
255682Smarkm * Copyright (c) 1982, 1986, 1989, 1991, 1993
3142403Snectar *	The Regents of the University of California.
4233294Sstas * Copyright (c) 2007 Robert N. M. Watson
5142403Snectar * All rights reserved.
6127808Snectar *
7127808Snectar * Redistribution and use in source and binary forms, with or without
8127808Snectar * modification, are permitted provided that the following conditions
9102644Snectar * are met:
10127808Snectar * 1. Redistributions of source code must retain the above copyright
11102644Snectar *    notice, this list of conditions and the following disclaimer.
12127808Snectar * 2. Redistributions in binary form must reproduce the above copyright
13127808Snectar *    notice, this list of conditions and the following disclaimer in the
14127808Snectar *    documentation and/or other materials provided with the distribution.
15127808Snectar * 4. Neither the name of the University nor the names of its contributors
16127808Snectar *    may be used to endorse or promote products derived from this software
17127808Snectar *    without specific prior written permission.
18127808Snectar *
19127808Snectar * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20127808Snectar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21127808Snectar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22127808Snectar * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23127808Snectar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24127808Snectar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25127808Snectar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26127808Snectar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27127808Snectar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28127808Snectar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29127808Snectar * SUCH DAMAGE.
30127808Snectar *
31127808Snectar *	@(#)user.h	8.2 (Berkeley) 9/23/93
32127808Snectar * $FreeBSD: head/sys/sys/user.h 221807 2011-05-12 10:11:39Z stas $
33127808Snectar */
34127808Snectar
35127808Snectar#ifndef _SYS_USER_H_
36127808Snectar#define _SYS_USER_H_
3755682Smarkm
3855682Smarkm#include <machine/pcb.h>
3955682Smarkm#ifndef _KERNEL
4055682Smarkm/* stuff that *used* to be included by user.h, or is now needed */
4155682Smarkm#include <sys/errno.h>
42178825Sdfr#include <sys/time.h>
4355682Smarkm#include <sys/resource.h>
44178825Sdfr#include <sys/ucred.h>
45178825Sdfr#include <sys/uio.h>
46178825Sdfr#include <sys/queue.h>
47178825Sdfr#include <sys/_lock.h>
4855682Smarkm#include <sys/_mutex.h>
4955682Smarkm#include <sys/proc.h>
5055682Smarkm#include <vm/vm.h>		/* XXX */
51233294Sstas#include <vm/vm_param.h>	/* XXX */
52178825Sdfr#include <vm/pmap.h>		/* XXX */
53178825Sdfr#include <vm/vm_map.h>		/* XXX */
54178825Sdfr#endif /* !_KERNEL */
55178825Sdfr#ifndef _SYS_RESOURCEVAR_H_
56178825Sdfr#include <sys/resourcevar.h>
5755682Smarkm#endif
58178825Sdfr#ifndef _SYS_SIGNALVAR_H_
59178825Sdfr#include <sys/signalvar.h>
6055682Smarkm#endif
61233294Sstas#ifndef _SYS_SOCKET_VAR_H_
62233294Sstas#include <sys/socket.h>
63233294Sstas#endif
64233294Sstas
65233294Sstas/*
66233294Sstas * KERN_PROC subtype ops return arrays of selected proc structure entries:
67233294Sstas *
68233294Sstas * This struct includes several arrays of spare space, with different arrays
69233294Sstas * for different standard C-types.  When adding new variables to this struct,
7055682Smarkm * the space for byte-aligned data should be taken from the ki_sparestring,
71233294Sstas * pointers from ki_spareptrs, word-aligned data from ki_spareints, and
72233294Sstas * doubleword-aligned data from ki_sparelongs.  Make sure the space for new
73233294Sstas * variables come from the array which matches the size and alignment of
74233294Sstas * those variables on ALL hardware platforms, and then adjust the appropriate
75233294Sstas * KI_NSPARE_* value(s) to match.
76233294Sstas *
77233294Sstas * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all
78233294Sstas * platforms after you have added new variables.  Note that if you change
79233294Sstas * the value of KINFO_PROC_SIZE, then many userland programs will stop
80233294Sstas * working until they are recompiled!
81233294Sstas *
82178825Sdfr * Once you have added the new field, you will need to add code to initialize
83178825Sdfr * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
84178825Sdfr * function kvm_proclist in lib/libkvm/kvm_proc.c .
85178825Sdfr */
86178825Sdfr#define	KI_NSPARE_INT	9
87233294Sstas#define	KI_NSPARE_LONG	12
88178825Sdfr#define	KI_NSPARE_PTR	6
89142403Snectar
90233294Sstas#ifndef _KERNEL
91233294Sstas#ifndef KINFO_PROC_SIZE
92142403Snectar#error "Unknown architecture"
93233294Sstas#endif
94142403Snectar#endif /* !_KERNEL */
95142403Snectar
96142403Snectar#define	WMESGLEN	8		/* size of returned wchan message */
97233294Sstas#define	LOCKNAMELEN	8		/* size of returned lock name */
98233294Sstas#define	OCOMMLEN	16		/* size of returned thread name */
99233294Sstas#define	COMMLEN		19		/* size of returned ki_comm name */
100178825Sdfr#define	KI_EMULNAMELEN	16		/* size of returned ki_emul */
10155682Smarkm#define KI_NGROUPS	16		/* number of groups in ki_groups */
102233294Sstas#define	LOGNAMELEN	17		/* size of returned ki_login */
103233294Sstas#define	LOGINCLASSLEN	17		/* size of returned ki_loginclass */
104142403Snectar
105178825Sdfr/* Flags for the process credential. */
106178825Sdfr#define	KI_CRF_CAPABILITY_MODE	0x00000001
10755682Smarkm/*
108178825Sdfr * Steal a bit from ki_cr_flags to indicate that the cred had more than
109178825Sdfr * KI_NGROUPS groups.
110178825Sdfr */
11155682Smarkm#define KI_CRF_GRP_OVERFLOW	0x80000000
112142403Snectar
113233294Sstasstruct kinfo_proc {
114233294Sstas	int	ki_structsize;		/* size of this structure */
11555682Smarkm	int	ki_layout;		/* reserved: layout identifier */
116233294Sstas	struct	pargs *ki_args;		/* address of command arguments */
117233294Sstas	struct	proc *ki_paddr;		/* address of proc */
118233294Sstas	struct	user *ki_addr;		/* kernel virtual addr of u-area */
119233294Sstas	struct	vnode *ki_tracep;	/* pointer to trace file */
120233294Sstas	struct	vnode *ki_textvp;	/* pointer to executable file */
121233294Sstas	struct	filedesc *ki_fd;	/* pointer to open file info */
122233294Sstas	struct	vmspace *ki_vmspace;	/* pointer to kernel vmspace struct */
123233294Sstas	void	*ki_wchan;		/* sleep address */
124233294Sstas	pid_t	ki_pid;			/* Process identifier */
125233294Sstas	pid_t	ki_ppid;		/* parent process id */
126142403Snectar	pid_t	ki_pgid;		/* process group id */
127233294Sstas	pid_t	ki_tpgid;		/* tty process group id */
128233294Sstas	pid_t	ki_sid;			/* Process session ID */
129142403Snectar	pid_t	ki_tsid;		/* Terminal session ID */
13055682Smarkm	short	ki_jobc;		/* job control counter */
131178825Sdfr	short	ki_spare_short1;	/* unused (just here for alignment) */
132142403Snectar	dev_t	ki_tdev;		/* controlling tty dev */
133233294Sstas	sigset_t ki_siglist;		/* Signals arrived but not delivered */
13455682Smarkm	sigset_t ki_sigmask;		/* Current signal mask */
135233294Sstas	sigset_t ki_sigignore;		/* Signals being ignored */
13655682Smarkm	sigset_t ki_sigcatch;		/* Signals being caught by user */
137233294Sstas	uid_t	ki_uid;			/* effective user id */
138233294Sstas	uid_t	ki_ruid;		/* Real user id */
139142403Snectar	uid_t	ki_svuid;		/* Saved effective user id */
140233294Sstas	gid_t	ki_rgid;		/* Real group id */
14155682Smarkm	gid_t	ki_svgid;		/* Saved effective group id */
142178825Sdfr	short	ki_ngroups;		/* number of groups */
14355682Smarkm	short	ki_spare_short2;	/* unused (just here for alignment) */
144178825Sdfr	gid_t 	ki_groups[KI_NGROUPS];	/* groups */
145178825Sdfr	vm_size_t ki_size;		/* virtual size */
146178825Sdfr	segsz_t ki_rssize;		/* current resident set size in pages */
147178825Sdfr	segsz_t ki_swrss;		/* resident set size before last swap */
148178825Sdfr	segsz_t ki_tsize;		/* text size (pages) XXX */
149178825Sdfr	segsz_t ki_dsize;		/* data size (pages) XXX */
150178825Sdfr	segsz_t ki_ssize;		/* stack size (pages) */
151233294Sstas	u_short	ki_xstat;		/* Exit status for wait & stop signal */
15255682Smarkm	u_short	ki_acflag;		/* Accounting flags */
153142403Snectar	fixpt_t	ki_pctcpu;	 	/* %cpu for process during ki_swtime */
154233294Sstas	u_int	ki_estcpu;	 	/* Time averaged value of ki_cpticks */
155127808Snectar	u_int	ki_slptime;	 	/* Time since last blocked */
156233294Sstas	u_int	ki_swtime;	 	/* Time swapped in or out */
15755682Smarkm	int	ki_spareint1;	 	/* unused (just here for alignment) */
158233294Sstas	u_int64_t ki_runtime;		/* Real time in microsec */
159233294Sstas	struct	timeval ki_start;	/* starting time */
16055682Smarkm	struct	timeval ki_childtime;	/* time used by process children */
161233294Sstas	long	ki_flag;		/* P_* flags */
162127808Snectar	long	ki_kiflag;		/* KI_* flags (below) */
163178825Sdfr	int	ki_traceflag;		/* Kernel trace points */
164178825Sdfr	char	ki_stat;		/* S* process status */
165178825Sdfr	signed char ki_nice;		/* Process "nice" value */
166142403Snectar	char	ki_lock;		/* Process lock (prevent swap) count */
167178825Sdfr	char	ki_rqindex;		/* Run queue index */
168178825Sdfr	u_char	ki_oncpu;		/* Which cpu we are on */
169178825Sdfr	u_char	ki_lastcpu;		/* Last cpu we were on */
170178825Sdfr	char	ki_ocomm[OCOMMLEN+1];	/* thread name */
171178825Sdfr	char	ki_wmesg[WMESGLEN+1];	/* wchan message */
172142403Snectar	char	ki_login[LOGNAMELEN+1];	/* setlogin name */
173233294Sstas	char	ki_lockname[LOCKNAMELEN+1]; /* lock name */
174142403Snectar	char	ki_comm[COMMLEN+1];	/* command name */
17555682Smarkm	char	ki_emul[KI_EMULNAMELEN+1];  /* emulation name */
176233294Sstas	char	ki_loginclass[LOGINCLASSLEN+1]; /* login class */
177178825Sdfr	/*
178178825Sdfr	 * When adding new variables, take space for char-strings from the
179178825Sdfr	 * front of ki_sparestrings, and ints from the end of ki_spareints.
180178825Sdfr	 * That way the spare room from both arrays will remain contiguous.
181178825Sdfr	 */
182233294Sstas	char	ki_sparestrings[50];	/* spare string space */
183178825Sdfr	int	ki_spareints[KI_NSPARE_INT];	/* spare room for growth */
184233294Sstas	u_int	ki_cr_flags;		/* Credential flags */
185178825Sdfr	int	ki_jid;			/* Process jail ID */
186178825Sdfr	int	ki_numthreads;		/* XXXKSE number of threads in total */
187178825Sdfr	lwpid_t	ki_tid;			/* XXXKSE thread id */
188233294Sstas	struct	priority ki_pri;	/* process priority */
189178825Sdfr	struct	rusage ki_rusage;	/* process rusage statistics */
190178825Sdfr	/* XXX - most fields in ki_rusage_ch are not (yet) filled in */
191178825Sdfr	struct	rusage ki_rusage_ch;	/* rusage of children processes */
192178825Sdfr	struct	pcb *ki_pcb;		/* kernel virtual addr of pcb */
193142403Snectar	void	*ki_kstack;		/* kernel virtual addr of stack */
194142403Snectar	void	*ki_udata;		/* User convenience pointer */
195142403Snectar	struct	thread *ki_tdaddr;	/* address of thread */
196142403Snectar	/*
197142403Snectar	 * When adding new variables, take space for pointers from the
198142403Snectar	 * front of ki_spareptrs, and longs from the end of ki_sparelongs.
199142403Snectar	 * That way the spare room from both arrays will remain contiguous.
20055682Smarkm	 */
20155682Smarkm	void	*ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
202178825Sdfr	long	ki_sparelongs[KI_NSPARE_LONG];	/* spare room for growth */
203178825Sdfr	long	ki_sflag;		/* PS_* flags */
204178825Sdfr	long	ki_tdflags;		/* XXXKSE kthread flag */
205178825Sdfr};
206178825Sdfrvoid fill_kinfo_proc(struct proc *, struct kinfo_proc *);
207178825Sdfr/* XXX - the following two defines are temporary */
208178825Sdfr#define	ki_childstime	ki_rusage_ch.ru_stime
209178825Sdfr#define	ki_childutime	ki_rusage_ch.ru_utime
210178825Sdfr
211178825Sdfr/*
212178825Sdfr *  Legacy PS_ flag.  This moved to p_flag but is maintained for
213178825Sdfr *  compatibility.
214178825Sdfr */
215178825Sdfr#define	PS_INMEM	0x00001		/* Loaded into memory. */
216178825Sdfr
217178825Sdfr/* ki_sessflag values */
218178825Sdfr#define	KI_CTTY		0x00000001	/* controlling tty vnode active */
219178825Sdfr#define	KI_SLEADER	0x00000002	/* session leader */
220178825Sdfr#define	KI_LOCKBLOCK	0x00000004	/* proc blocked on lock ki_lockname */
221178825Sdfr
222178825Sdfr/*
223178825Sdfr * This used to be the per-process structure containing data that
224178825Sdfr * isn't needed in core when the process is swapped out, but now it
225178825Sdfr * remains only for the benefit of a.out core dumps.
226178825Sdfr */
227178825Sdfrstruct user {
228178825Sdfr	struct	pstats u_stats;		/* *p_stats */
229142403Snectar	struct	kinfo_proc u_kproc;	/* eproc */
230142403Snectar};
231142403Snectar
232142403Snectar/*
233233294Sstas * The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
234142403Snectar * array of another process.
23555682Smarkm */
236142403Snectar#define	KF_ATTR_VALID	0x0001
237142403Snectar
238178825Sdfr#define	KF_TYPE_NONE	0
239178825Sdfr#define	KF_TYPE_VNODE	1
240178825Sdfr#define	KF_TYPE_SOCKET	2
241178825Sdfr#define	KF_TYPE_PIPE	3
24255682Smarkm#define	KF_TYPE_FIFO	4
243178825Sdfr#define	KF_TYPE_KQUEUE	5
244142403Snectar#define	KF_TYPE_CRYPTO	6
245142403Snectar#define	KF_TYPE_MQUEUE	7
246142403Snectar#define	KF_TYPE_SHM	8
247142403Snectar#define	KF_TYPE_SEM	9
248142403Snectar#define	KF_TYPE_PTS	10
249142403Snectar#define	KF_TYPE_UNKNOWN	255
25055682Smarkm
251233294Sstas#define	KF_VTYPE_VNON	0
252142403Snectar#define	KF_VTYPE_VREG	1
253142403Snectar#define	KF_VTYPE_VDIR	2
254142403Snectar#define	KF_VTYPE_VBLK	3
25555682Smarkm#define	KF_VTYPE_VCHR	4
256233294Sstas#define	KF_VTYPE_VLNK	5
257142403Snectar#define	KF_VTYPE_VSOCK	6
258142403Snectar#define	KF_VTYPE_VFIFO	7
259233294Sstas#define	KF_VTYPE_VBAD	8
260142403Snectar#define	KF_VTYPE_UNKNOWN	255
26155682Smarkm
262142403Snectar#define	KF_FD_TYPE_CWD	-1	/* Current working directory */
263142403Snectar#define	KF_FD_TYPE_ROOT	-2	/* Root directory */
264142403Snectar#define	KF_FD_TYPE_JAIL	-3	/* Jail directory */
265178825Sdfr#define	KF_FD_TYPE_TRACE	-4	/* ptrace vnode */
266233294Sstas#define	KF_FD_TYPE_TEXT	-5	/* Text vnode */
267178825Sdfr#define	KF_FD_TYPE_CTTY	-6	/* Controlling terminal */
268178825Sdfr
269178825Sdfr#define	KF_FLAG_READ		0x00000001
270178825Sdfr#define	KF_FLAG_WRITE		0x00000002
271178825Sdfr#define	KF_FLAG_APPEND		0x00000004
272178825Sdfr#define	KF_FLAG_ASYNC		0x00000008
273178825Sdfr#define	KF_FLAG_FSYNC		0x00000010
274178825Sdfr#define	KF_FLAG_NONBLOCK	0x00000020
275178825Sdfr#define	KF_FLAG_DIRECT		0x00000040
276178825Sdfr#define	KF_FLAG_HASLOCK		0x00000080
277178825Sdfr#define	KF_FLAG_SHLOCK		0x00000100
278178825Sdfr#define	KF_FLAG_EXLOCK		0x00000200
279178825Sdfr#define	KF_FLAG_NOFOLLOW	0x00000400
280178825Sdfr#define	KF_FLAG_CREAT		0x00000800
281178825Sdfr#define	KF_FLAG_TRUNC		0x00001000
282178825Sdfr#define	KF_FLAG_EXCL		0x00002000
283178825Sdfr#define	KF_FLAG_EXEC		0x00004000
284178825Sdfr
285178825Sdfr/*
286178825Sdfr * Old format.  Has variable hidden padding due to alignment.
287178825Sdfr * This is a compatability hack for pre-build 7.1 packages.
288178825Sdfr */
289178825Sdfr#if defined(__amd64__)
290178825Sdfr#define	KINFO_OFILE_SIZE	1328
291178825Sdfr#endif
292178825Sdfr#if defined(__i386__)
293178825Sdfr#define	KINFO_OFILE_SIZE	1324
294178825Sdfr#endif
295178825Sdfr
296178825Sdfrstruct kinfo_ofile {
297178825Sdfr	int	kf_structsize;			/* Size of kinfo_file. */
298178825Sdfr	int	kf_type;			/* Descriptor type. */
299178825Sdfr	int	kf_fd;				/* Array index. */
300178825Sdfr	int	kf_ref_count;			/* Reference count. */
301178825Sdfr	int	kf_flags;			/* Flags. */
302142403Snectar	/* XXX Hidden alignment padding here on amd64 */
303142403Snectar	off_t	kf_offset;			/* Seek location. */
30455682Smarkm	int	kf_vnode_type;			/* Vnode type. */
305178825Sdfr	int	kf_sock_domain;			/* Socket domain. */
30655682Smarkm	int	kf_sock_type;			/* Socket type. */
307178825Sdfr	int	kf_sock_protocol;		/* Socket protocol. */
308178825Sdfr	char	kf_path[PATH_MAX];	/* Path to file, if any. */
309178825Sdfr	struct sockaddr_storage kf_sa_local;	/* Socket address. */
310178825Sdfr	struct sockaddr_storage	kf_sa_peer;	/* Peer address. */
311178825Sdfr};
312178825Sdfr
313178825Sdfr#if defined(__amd64__) || defined(__i386__)
314178825Sdfr#define	KINFO_FILE_SIZE	1392
315178825Sdfr#endif
316178825Sdfr
31755682Smarkmstruct kinfo_file {
318178825Sdfr	int		kf_structsize;		/* Variable size of record. */
319178825Sdfr	int		kf_type;		/* Descriptor type. */
320178825Sdfr	int		kf_fd;			/* Array index. */
321178825Sdfr	int		kf_ref_count;		/* Reference count. */
322178825Sdfr	int		kf_flags;		/* Flags. */
323178825Sdfr	int		kf_pad0;		/* Round to 64 bit alignment. */
324178825Sdfr	int64_t		kf_offset;		/* Seek location. */
32555682Smarkm	int		kf_vnode_type;		/* Vnode type. */
326178825Sdfr	int		kf_sock_domain;		/* Socket domain. */
327178825Sdfr	int		kf_sock_type;		/* Socket type. */
328178825Sdfr	int		kf_sock_protocol;	/* Socket protocol. */
329178825Sdfr	struct sockaddr_storage kf_sa_local;	/* Socket address. */
330178825Sdfr	struct sockaddr_storage	kf_sa_peer;	/* Peer address. */
331178825Sdfr	union {
332178825Sdfr		struct {
33355682Smarkm			/* Address of so_pcb. */
334178825Sdfr			uint64_t	kf_sock_pcb;
335178825Sdfr			/* Address of inp_ppcb. */
336178825Sdfr			uint64_t	kf_sock_inpcb;
337178825Sdfr			/* Address of unp_conn. */
338178825Sdfr			uint64_t	kf_sock_unpconn;
339178825Sdfr			/* Send buffer state. */
340178825Sdfr			uint16_t	kf_sock_snd_sb_state;
341178825Sdfr			/* Receive buffer state. */
342178825Sdfr			uint16_t	kf_sock_rcv_sb_state;
34355682Smarkm			/* Round to 64 bit alignment. */
344178825Sdfr			uint32_t	kf_sock_pad0;
345178825Sdfr		} kf_sock;
346178825Sdfr		struct {
347178825Sdfr			/* Global file id. */
348178825Sdfr			uint64_t	kf_file_fileid;
349178825Sdfr			/* File size. */
350178825Sdfr			uint64_t	kf_file_size;
351178825Sdfr			/* Vnode filesystem id. */
352178825Sdfr			uint32_t	kf_file_fsid;
353178825Sdfr			/* File device. */
354178825Sdfr			uint32_t	kf_file_rdev;
355178825Sdfr			/* File mode. */
356178825Sdfr			uint16_t	kf_file_mode;
357178825Sdfr			/* Round to 64 bit alignment. */
358178825Sdfr			uint16_t	kf_file_pad0;
359178825Sdfr			uint32_t	kf_file_pad1;
360178825Sdfr		} kf_file;
361178825Sdfr		struct {
362178825Sdfr			uint64_t	kf_pipe_addr;
363178825Sdfr			uint64_t	kf_pipe_peer;
364178825Sdfr			uint32_t	kf_pipe_buffer_cnt;
365178825Sdfr			/* Round to 64 bit alignment. */
366178825Sdfr			uint32_t	kf_pipe_pad0[3];
367178825Sdfr		} kf_pipe;
368178825Sdfr		struct {
369178825Sdfr			uint32_t	kf_pts_dev;
370178825Sdfr			/* Round to 64 bit alignment. */
371178825Sdfr			uint32_t	kf_pts_pad0[7];
372178825Sdfr		} kf_pts;
373178825Sdfr	} kf_un;
374178825Sdfr	uint16_t	kf_status;		/* Status flags. */
375178825Sdfr	uint16_t	kf_pad1;		/* Round to 32 bit alignment. */
376178825Sdfr	int		_kf_ispare[7];		/* Space for more stuff. */
377178825Sdfr	/* Truncated before copyout in sysctl */
378178825Sdfr	char		kf_path[PATH_MAX];	/* Path to file, if any. */
379178825Sdfr};
380178825Sdfr
381178825Sdfr/*
382178825Sdfr * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of
383178825Sdfr * another process as a series of entries.
384178825Sdfr */
385178825Sdfr#define	KVME_TYPE_NONE		0
386178825Sdfr#define	KVME_TYPE_DEFAULT	1
387233294Sstas#define	KVME_TYPE_VNODE		2
388233294Sstas#define	KVME_TYPE_SWAP		3
389233294Sstas#define	KVME_TYPE_DEVICE	4
390178825Sdfr#define	KVME_TYPE_PHYS		5
391178825Sdfr#define	KVME_TYPE_DEAD		6
392233294Sstas#define	KVME_TYPE_SG		7
393178825Sdfr#define	KVME_TYPE_UNKNOWN	255
394178825Sdfr
395178825Sdfr#define	KVME_PROT_READ		0x00000001
396233294Sstas#define	KVME_PROT_WRITE		0x00000002
397178825Sdfr#define	KVME_PROT_EXEC		0x00000004
398142403Snectar
399233294Sstas#define	KVME_FLAG_COW		0x00000001
400178825Sdfr#define	KVME_FLAG_NEEDS_COPY	0x00000002
401178825Sdfr#define	KVME_FLAG_NOCOREDUMP	0x00000004
402178825Sdfr
403178825Sdfr#if defined(__amd64__)
404178825Sdfr#define	KINFO_OVMENTRY_SIZE	1168
405178825Sdfr#endif
406178825Sdfr#if defined(__i386__)
407178825Sdfr#define	KINFO_OVMENTRY_SIZE	1128
408178825Sdfr#endif
409178825Sdfr
410178825Sdfrstruct kinfo_ovmentry {
411178825Sdfr	int	 kve_structsize;		/* Size of kinfo_vmmapentry. */
412178825Sdfr	int	 kve_type;			/* Type of map entry. */
413178825Sdfr	void	*kve_start;			/* Starting address. */
414178825Sdfr	void	*kve_end;			/* Finishing address. */
415178825Sdfr	int	 kve_flags;			/* Flags on map entry. */
416178825Sdfr	int	 kve_resident;			/* Number of resident pages. */
417178825Sdfr	int	 kve_private_resident;		/* Number of private pages. */
418178825Sdfr	int	 kve_protection;		/* Protection bitmask. */
419178825Sdfr	int	 kve_ref_count;			/* VM obj ref count. */
420178825Sdfr	int	 kve_shadow_count;		/* VM obj shadow count. */
421178825Sdfr	char	 kve_path[PATH_MAX];		/* Path to VM obj, if any. */
422178825Sdfr	void	*_kve_pspare[8];		/* Space for more stuff. */
423178825Sdfr	off_t	 kve_offset;			/* Mapping offset in object */
424178825Sdfr	uint64_t kve_fileid;			/* inode number if vnode */
425178825Sdfr	dev_t	 kve_fsid;			/* dev_t of vnode location */
426178825Sdfr	int	 _kve_ispare[3];		/* Space for more stuff. */
427178825Sdfr};
428178825Sdfr
429178825Sdfr#if defined(__amd64__) || defined(__i386__)
430178825Sdfr#define	KINFO_VMENTRY_SIZE	1160
431178825Sdfr#endif
432178825Sdfr
433178825Sdfrstruct kinfo_vmentry {
434142403Snectar	int	 kve_structsize;		/* Variable size of record. */
435178825Sdfr	int	 kve_type;			/* Type of map entry. */
436142403Snectar	uint64_t kve_start;			/* Starting address. */
43755682Smarkm	uint64_t kve_end;			/* Finishing address. */
438142403Snectar	uint64_t kve_offset;			/* Mapping offset in object */
439178825Sdfr	uint64_t kve_vn_fileid;			/* inode number if vnode */
440178825Sdfr	uint32_t kve_vn_fsid;			/* dev_t of vnode location */
441178825Sdfr	int	 kve_flags;			/* Flags on map entry. */
442178825Sdfr	int	 kve_resident;			/* Number of resident pages. */
443142403Snectar	int	 kve_private_resident;		/* Number of private pages. */
44455682Smarkm	int	 kve_protection;		/* Protection bitmask. */
445142403Snectar	int	 kve_ref_count;			/* VM obj ref count. */
446142403Snectar	int	 kve_shadow_count;		/* VM obj shadow count. */
447142403Snectar	int	 kve_vn_type;			/* Vnode type. */
44855682Smarkm	uint64_t kve_vn_size;			/* File size. */
449142403Snectar	uint32_t kve_vn_rdev;			/* Device id if device. */
450178825Sdfr	uint16_t kve_vn_mode;			/* File mode. */
451127808Snectar	uint16_t kve_status;			/* Status flags. */
452178825Sdfr	int	 _kve_ispare[12];		/* Space for more stuff. */
453178825Sdfr	/* Truncated before copyout in sysctl */
454127808Snectar	char	 kve_path[PATH_MAX];		/* Path to VM obj, if any. */
455142403Snectar};
456142403Snectar
457142403Snectar/*
458142403Snectar * The KERN_PROC_KSTACK sysctl allows a process to dump the kernel stacks of
459178825Sdfr * another process as a series of entries.  Each stack is represented by a
460142403Snectar * series of symbol names and offsets as generated by stack_sbuf_print(9).
461233294Sstas */
462233294Sstas#define	KKST_MAXLEN	1024
463233294Sstas
464233294Sstas#define	KKST_STATE_STACKOK	0		/* Stack is valid. */
46555682Smarkm#define	KKST_STATE_SWAPPED	1		/* Stack swapped out. */
466233294Sstas#define	KKST_STATE_RUNNING	2		/* Stack ephemeral. */
467233294Sstas
468233294Sstas#if defined(__amd64__) || defined(__i386__)
469233294Sstas#define	KINFO_KSTACK_SIZE	1096
47055682Smarkm#endif
471233294Sstas
472233294Sstasstruct kinfo_kstack {
473233294Sstas	lwpid_t	 kkst_tid;			/* ID of thread. */
474233294Sstas	int	 kkst_state;			/* Validity of stack. */
475233294Sstas	char	 kkst_trace[KKST_MAXLEN];	/* String representing stack. */
476178825Sdfr	int	 _kkst_ispare[16];		/* Space for more stuff. */
477233294Sstas};
478233294Sstas
479233294Sstas#ifdef _KERNEL
480233294Sstasint	vntype_to_kinfo(int vtype);
481233294Sstas#endif /* !_KERNEL */
482233294Sstas
483233294Sstas#endif
484178825Sdfr