user.h revision 124829
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 * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)user.h	8.2 (Berkeley) 9/23/93
3450477Speter * $FreeBSD: head/sys/sys/user.h 124829 2004-01-22 06:56:00Z grehan $
351541Srgrimes */
361541Srgrimes
372165Spaul#ifndef _SYS_USER_H_
382165Spaul#define _SYS_USER_H_
392165Spaul
401541Srgrimes#include <machine/pcb.h>
4155205Speter#ifndef _KERNEL
421541Srgrimes/* stuff that *used* to be included by user.h, or is now needed */
4318207Sbde#include <sys/errno.h>
441541Srgrimes#include <sys/time.h>
451541Srgrimes#include <sys/resource.h>
461541Srgrimes#include <sys/ucred.h>
471541Srgrimes#include <sys/uio.h>
4892047Sdd#include <sys/queue.h>
4981202Sjhb#include <sys/_lock.h>
5076166Smarkm#include <sys/_mutex.h>
5111913Sphk#include <sys/proc.h>
5212685Speter#include <vm/vm.h>		/* XXX */
5312685Speter#include <vm/vm_param.h>	/* XXX */
5412685Speter#include <vm/pmap.h>		/* XXX */
5512685Speter#include <vm/vm_map.h>		/* XXX */
5655205Speter#endif /* !_KERNEL */
5734924Sbde#ifndef _SYS_RESOURCEVAR_H_
581541Srgrimes#include <sys/resourcevar.h>
5934924Sbde#endif
6034924Sbde#ifndef _SYS_SIGNALVAR_H_
611541Srgrimes#include <sys/signalvar.h>
6234924Sbde#endif
631541Srgrimes
641541Srgrimes/*
6569896Smckusick * KERN_PROC subtype ops return arrays of selected proc structure entries:
6669896Smckusick *
6769896Smckusick * When adding new fields to this structure, ALWAYS add them at the end
6869896Smckusick * and decrease the size of the spare field by the amount of space that
6969896Smckusick * you are adding.  Byte aligned data should be added to the ki_sparestring
7069896Smckusick * space; other entries should be added to the ki_spare space. Always
7169896Smckusick * verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE when you are
7269896Smckusick * done. If you change the size of this structure, many programs will stop
7369896Smckusick * working! Once you have added the new field, you will need to add code
7469896Smckusick * to initialize it in two places: kern/kern_proc.c in the function
7569896Smckusick * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist.
7611865Sphk */
77114341Speter#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) || \
78114341Speter    defined(__amd64__)
7973994Sgallatin#define	KINFO_PROC_SIZE	912		/* the correct size for kinfo_proc */
8074022Sdfr#endif
8174022Sdfr#ifdef	__i386__
8273892Sphk#define	KINFO_PROC_SIZE	648		/* the correct size for kinfo_proc */
8371040Smjacob#endif
8477956Sbenno#ifdef  __powerpc__
8577956Sbenno#define	KINFO_PROC_SIZE	656
8677956Sbenno#endif
8774022Sdfr#ifndef	KINFO_PROC_SIZE
8874022Sdfr#error	"Unknown architecture"
8974022Sdfr#endif
9069896Smckusick#define	WMESGLEN	8		/* size of returned wchan message */
91104387Sjhb#define	LOCKNAMELEN	8		/* size of returned lock name */
9281759Speter#define	OCOMMLEN	16		/* size of returned ki_ocomm name */
9381759Speter#define	COMMLEN		19		/* size of returned ki_comm name */
9481759Speter#define	KI_NGROUPS	16		/* number of groups in ki_groups */
9581759Speter#define	LOGNAMELEN	17		/* size of returned ki_login */
9669896Smckusick
9711865Sphkstruct kinfo_proc {
9869896Smckusick	int	ki_structsize;		/* size of this structure */
9972415Sphk	int	ki_layout;		/* reserved: layout identifier */
10069896Smckusick	struct	pargs *ki_args;		/* address of command arguments */
10169896Smckusick	struct	proc *ki_paddr;		/* address of proc */
10269896Smckusick	struct	user *ki_addr;		/* kernel virtual addr of u-area */
10369896Smckusick	struct	vnode *ki_tracep;	/* pointer to trace file */
10469896Smckusick	struct	vnode *ki_textvp;	/* pointer to executable file */
10569896Smckusick	struct	filedesc *ki_fd;	/* pointer to open file info */
10669896Smckusick	struct	vmspace *ki_vmspace;	/* pointer to kernel vmspace struct */
10769896Smckusick	void	*ki_wchan;		/* sleep address */
10869896Smckusick	pid_t	ki_pid;			/* Process identifier */
10969896Smckusick	pid_t	ki_ppid;		/* parent process id */
11069896Smckusick	pid_t	ki_pgid;		/* process group id */
11169896Smckusick	pid_t	ki_tpgid;		/* tty process group id */
11269896Smckusick	pid_t	ki_sid;			/* Process session ID */
11369896Smckusick	pid_t	ki_tsid;		/* Terminal session ID */
11469896Smckusick	short	ki_jobc;		/* job control counter */
11569896Smckusick	udev_t	ki_tdev;		/* controlling tty dev */
11669896Smckusick	sigset_t ki_siglist;		/* Signals arrived but not delivered */
11769896Smckusick	sigset_t ki_sigmask;		/* Current signal mask */
11869896Smckusick	sigset_t ki_sigignore;		/* Signals being ignored */
11969896Smckusick	sigset_t ki_sigcatch;		/* Signals being caught by user */
12069896Smckusick	uid_t	ki_uid;			/* effective user id */
12169896Smckusick	uid_t	ki_ruid;		/* Real user id */
12269896Smckusick	uid_t	ki_svuid;		/* Saved effective user id */
12369896Smckusick	gid_t	ki_rgid;		/* Real group id */
12469896Smckusick	gid_t	ki_svgid;		/* Saved effective group id */
12569896Smckusick	short	ki_ngroups;		/* number of groups */
12681759Speter	gid_t	ki_groups[KI_NGROUPS];	/* groups */
12769896Smckusick	vm_size_t ki_size;		/* virtual size */
12869896Smckusick	segsz_t ki_rssize;		/* current resident set size in pages */
12969896Smckusick	segsz_t ki_swrss;		/* resident set size before last swap */
13069896Smckusick	segsz_t ki_tsize;		/* text size (pages) XXX */
13169896Smckusick	segsz_t ki_dsize;		/* data size (pages) XXX */
13269896Smckusick	segsz_t ki_ssize;		/* stack size (pages) */
13369896Smckusick	u_short	ki_xstat;		/* Exit status for wait & stop signal */
13469896Smckusick	u_short	ki_acflag;		/* Accounting flags */
13569896Smckusick	fixpt_t	ki_pctcpu;	 	/* %cpu for process during ki_swtime */
13669896Smckusick	u_int	ki_estcpu;	 	/* Time averaged value of ki_cpticks */
13769896Smckusick	u_int	ki_slptime;	 	/* Time since last blocked */
13869896Smckusick	u_int	ki_swtime;	 	/* Time swapped in or out */
13969896Smckusick	u_int64_t ki_runtime;		/* Real time in microsec */
14069896Smckusick	struct	timeval ki_start;	/* starting time */
14169896Smckusick	struct	timeval ki_childtime;	/* time used by process children */
14269896Smckusick	long	ki_flag;		/* P_* flags */
14369896Smckusick	long	ki_kiflag;		/* KI_* flags (below) */
14469896Smckusick	int	ki_traceflag;		/* Kernel trace points */
14569896Smckusick	char	ki_stat;		/* S* process status */
146124829Sgrehan	signed char ki_nice;		/* Process "nice" value */
14769896Smckusick	char	ki_lock;		/* Process lock (prevent swap) count */
14869896Smckusick	char	ki_rqindex;		/* Run queue index */
14969896Smckusick	u_char	ki_oncpu;		/* Which cpu we are on */
15069896Smckusick	u_char	ki_lastcpu;		/* Last cpu we were on */
15181759Speter	char	ki_ocomm[OCOMMLEN+1];	/* command name */
15269896Smckusick	char	ki_wmesg[WMESGLEN+1];	/* wchan message */
15381759Speter	char	ki_login[LOGNAMELEN+1];	/* setlogin name */
154104387Sjhb	char	ki_lockname[LOCKNAMELEN+1]; /* lock name */
15581759Speter	char	ki_comm[COMMLEN+1];	/* command name */
15681759Speter	char	ki_sparestrings[85];	/* spare string space */
15769896Smckusick	struct	rusage ki_rusage;	/* process rusage statistics */
15871577Sjhb	long	ki_sflag;		/* PS_* flags */
15972376Sjake	struct	priority ki_pri;	/* process priority */
16083366Sjulian	long	ki_tdflags;		/* XXXKSE kthread flag */
16183366Sjulian	struct	pcb *ki_pcb;		/* kernel virtual addr of pcb */
16283366Sjulian	void	*ki_kstack;		/* kernel virtual addr of stack */
16383366Sjulian	long	ki_spare[22];		/* spare constants */
16411865Sphk};
16592719Salfredvoid fill_kinfo_proc(struct proc *, struct kinfo_proc *);
16611865Sphk
16769896Smckusick/* ki_sessflag values */
16869896Smckusick#define	KI_CTTY		0x00000001	/* controlling tty vnode active */
16969896Smckusick#define	KI_SLEADER	0x00000002	/* session leader */
170104387Sjhb#define	KI_LOCKBLOCK	0x00000004	/* proc blocked on lock ki_lockname */
17111865Sphk
17211865Sphk/*
1731541Srgrimes * Per process structure containing data that isn't needed in core
1741541Srgrimes * when the process isn't running (esp. when swapped out).
1751541Srgrimes */
17683421Sobrienstruct user {
17783366Sjulian	struct	pstats u_stats;		/* *p_stats */
1781541Srgrimes	/*
179105138Speter	 * Remaining field for a.out core dumps - not valid at other times!
1801541Srgrimes	 */
18183366Sjulian	struct	kinfo_proc u_kproc;	/* eproc */
1821541Srgrimes};
1831541Srgrimes
18437689Sdfr#endif
185