user.h revision 130640
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 * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)user.h	8.2 (Berkeley) 9/23/93
3050477Speter * $FreeBSD: head/sys/sys/user.h 130640 2004-06-17 17:16:53Z phk $
311541Srgrimes */
321541Srgrimes
332165Spaul#ifndef _SYS_USER_H_
342165Spaul#define _SYS_USER_H_
352165Spaul
361541Srgrimes#include <machine/pcb.h>
3755205Speter#ifndef _KERNEL
381541Srgrimes/* stuff that *used* to be included by user.h, or is now needed */
3918207Sbde#include <sys/errno.h>
401541Srgrimes#include <sys/time.h>
411541Srgrimes#include <sys/resource.h>
421541Srgrimes#include <sys/ucred.h>
431541Srgrimes#include <sys/uio.h>
4492047Sdd#include <sys/queue.h>
4581202Sjhb#include <sys/_lock.h>
4676166Smarkm#include <sys/_mutex.h>
4711913Sphk#include <sys/proc.h>
4812685Speter#include <vm/vm.h>		/* XXX */
4912685Speter#include <vm/vm_param.h>	/* XXX */
5012685Speter#include <vm/pmap.h>		/* XXX */
5112685Speter#include <vm/vm_map.h>		/* XXX */
5255205Speter#endif /* !_KERNEL */
5334924Sbde#ifndef _SYS_RESOURCEVAR_H_
541541Srgrimes#include <sys/resourcevar.h>
5534924Sbde#endif
5634924Sbde#ifndef _SYS_SIGNALVAR_H_
571541Srgrimes#include <sys/signalvar.h>
5834924Sbde#endif
591541Srgrimes
601541Srgrimes/*
6169896Smckusick * KERN_PROC subtype ops return arrays of selected proc structure entries:
6269896Smckusick *
6369896Smckusick * When adding new fields to this structure, ALWAYS add them at the end
6469896Smckusick * and decrease the size of the spare field by the amount of space that
6569896Smckusick * you are adding.  Byte aligned data should be added to the ki_sparestring
6669896Smckusick * space; other entries should be added to the ki_spare space. Always
6769896Smckusick * verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE when you are
6869896Smckusick * done. If you change the size of this structure, many programs will stop
6969896Smckusick * working! Once you have added the new field, you will need to add code
7069896Smckusick * to initialize it in two places: kern/kern_proc.c in the function
7169896Smckusick * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist.
7211865Sphk */
73114341Speter#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) || \
74114341Speter    defined(__amd64__)
7573994Sgallatin#define	KINFO_PROC_SIZE	912		/* the correct size for kinfo_proc */
7674022Sdfr#endif
77129036Scognet#if	__i386__ || defined __arm__
7873892Sphk#define	KINFO_PROC_SIZE	648		/* the correct size for kinfo_proc */
7971040Smjacob#endif
8077956Sbenno#ifdef  __powerpc__
8177956Sbenno#define	KINFO_PROC_SIZE	656
8277956Sbenno#endif
8374022Sdfr#ifndef	KINFO_PROC_SIZE
8474022Sdfr#error	"Unknown architecture"
8574022Sdfr#endif
8669896Smckusick#define	WMESGLEN	8		/* size of returned wchan message */
87104387Sjhb#define	LOCKNAMELEN	8		/* size of returned lock name */
8881759Speter#define	OCOMMLEN	16		/* size of returned ki_ocomm name */
8981759Speter#define	COMMLEN		19		/* size of returned ki_comm name */
9081759Speter#define	KI_NGROUPS	16		/* number of groups in ki_groups */
9181759Speter#define	LOGNAMELEN	17		/* size of returned ki_login */
9269896Smckusick
9311865Sphkstruct kinfo_proc {
9469896Smckusick	int	ki_structsize;		/* size of this structure */
9572415Sphk	int	ki_layout;		/* reserved: layout identifier */
9669896Smckusick	struct	pargs *ki_args;		/* address of command arguments */
9769896Smckusick	struct	proc *ki_paddr;		/* address of proc */
9869896Smckusick	struct	user *ki_addr;		/* kernel virtual addr of u-area */
9969896Smckusick	struct	vnode *ki_tracep;	/* pointer to trace file */
10069896Smckusick	struct	vnode *ki_textvp;	/* pointer to executable file */
10169896Smckusick	struct	filedesc *ki_fd;	/* pointer to open file info */
10269896Smckusick	struct	vmspace *ki_vmspace;	/* pointer to kernel vmspace struct */
10369896Smckusick	void	*ki_wchan;		/* sleep address */
10469896Smckusick	pid_t	ki_pid;			/* Process identifier */
10569896Smckusick	pid_t	ki_ppid;		/* parent process id */
10669896Smckusick	pid_t	ki_pgid;		/* process group id */
10769896Smckusick	pid_t	ki_tpgid;		/* tty process group id */
10869896Smckusick	pid_t	ki_sid;			/* Process session ID */
10969896Smckusick	pid_t	ki_tsid;		/* Terminal session ID */
11069896Smckusick	short	ki_jobc;		/* job control counter */
111130640Sphk	dev_t	ki_tdev;		/* controlling tty dev */
11269896Smckusick	sigset_t ki_siglist;		/* Signals arrived but not delivered */
11369896Smckusick	sigset_t ki_sigmask;		/* Current signal mask */
11469896Smckusick	sigset_t ki_sigignore;		/* Signals being ignored */
11569896Smckusick	sigset_t ki_sigcatch;		/* Signals being caught by user */
11669896Smckusick	uid_t	ki_uid;			/* effective user id */
11769896Smckusick	uid_t	ki_ruid;		/* Real user id */
11869896Smckusick	uid_t	ki_svuid;		/* Saved effective user id */
11969896Smckusick	gid_t	ki_rgid;		/* Real group id */
12069896Smckusick	gid_t	ki_svgid;		/* Saved effective group id */
12169896Smckusick	short	ki_ngroups;		/* number of groups */
12281759Speter	gid_t	ki_groups[KI_NGROUPS];	/* groups */
12369896Smckusick	vm_size_t ki_size;		/* virtual size */
12469896Smckusick	segsz_t ki_rssize;		/* current resident set size in pages */
12569896Smckusick	segsz_t ki_swrss;		/* resident set size before last swap */
12669896Smckusick	segsz_t ki_tsize;		/* text size (pages) XXX */
12769896Smckusick	segsz_t ki_dsize;		/* data size (pages) XXX */
12869896Smckusick	segsz_t ki_ssize;		/* stack size (pages) */
12969896Smckusick	u_short	ki_xstat;		/* Exit status for wait & stop signal */
13069896Smckusick	u_short	ki_acflag;		/* Accounting flags */
13169896Smckusick	fixpt_t	ki_pctcpu;	 	/* %cpu for process during ki_swtime */
13269896Smckusick	u_int	ki_estcpu;	 	/* Time averaged value of ki_cpticks */
13369896Smckusick	u_int	ki_slptime;	 	/* Time since last blocked */
13469896Smckusick	u_int	ki_swtime;	 	/* Time swapped in or out */
13569896Smckusick	u_int64_t ki_runtime;		/* Real time in microsec */
13669896Smckusick	struct	timeval ki_start;	/* starting time */
13769896Smckusick	struct	timeval ki_childtime;	/* time used by process children */
13869896Smckusick	long	ki_flag;		/* P_* flags */
13969896Smckusick	long	ki_kiflag;		/* KI_* flags (below) */
14069896Smckusick	int	ki_traceflag;		/* Kernel trace points */
14169896Smckusick	char	ki_stat;		/* S* process status */
142124829Sgrehan	signed char ki_nice;		/* Process "nice" value */
14369896Smckusick	char	ki_lock;		/* Process lock (prevent swap) count */
14469896Smckusick	char	ki_rqindex;		/* Run queue index */
14569896Smckusick	u_char	ki_oncpu;		/* Which cpu we are on */
14669896Smckusick	u_char	ki_lastcpu;		/* Last cpu we were on */
14781759Speter	char	ki_ocomm[OCOMMLEN+1];	/* command name */
14869896Smckusick	char	ki_wmesg[WMESGLEN+1];	/* wchan message */
14981759Speter	char	ki_login[LOGNAMELEN+1];	/* setlogin name */
150104387Sjhb	char	ki_lockname[LOCKNAMELEN+1]; /* lock name */
15181759Speter	char	ki_comm[COMMLEN+1];	/* command name */
15281759Speter	char	ki_sparestrings[85];	/* spare string space */
15369896Smckusick	struct	rusage ki_rusage;	/* process rusage statistics */
15471577Sjhb	long	ki_sflag;		/* PS_* flags */
15572376Sjake	struct	priority ki_pri;	/* process priority */
15683366Sjulian	long	ki_tdflags;		/* XXXKSE kthread flag */
15783366Sjulian	struct	pcb *ki_pcb;		/* kernel virtual addr of pcb */
15883366Sjulian	void	*ki_kstack;		/* kernel virtual addr of stack */
15983366Sjulian	long	ki_spare[22];		/* spare constants */
16011865Sphk};
16192719Salfredvoid fill_kinfo_proc(struct proc *, struct kinfo_proc *);
16211865Sphk
16369896Smckusick/* ki_sessflag values */
16469896Smckusick#define	KI_CTTY		0x00000001	/* controlling tty vnode active */
16569896Smckusick#define	KI_SLEADER	0x00000002	/* session leader */
166104387Sjhb#define	KI_LOCKBLOCK	0x00000004	/* proc blocked on lock ki_lockname */
16711865Sphk
16811865Sphk/*
1691541Srgrimes * Per process structure containing data that isn't needed in core
1701541Srgrimes * when the process isn't running (esp. when swapped out).
1711541Srgrimes */
17283421Sobrienstruct user {
17383366Sjulian	struct	pstats u_stats;		/* *p_stats */
1741541Srgrimes	/*
175105138Speter	 * Remaining field for a.out core dumps - not valid at other times!
1761541Srgrimes	 */
17783366Sjulian	struct	kinfo_proc u_kproc;	/* eproc */
1781541Srgrimes};
1791541Srgrimes
18037689Sdfr#endif
181