xref: /titanic_50/usr/src/uts/common/sys/procfs.h (revision c64027834c5ffc60c557c2b12555e0cd4d30320c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_PROCFS_H
28 #define	_SYS_PROCFS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This definition is temporary.  Structured proc is the preferred API,
38  * and the older ioctl-based interface will be removed in a future version
39  * of Solaris.  Until then, by default, including <sys/procfs.h> will
40  * provide the older ioctl-based /proc definitions.  To get the structured
41  * /proc definitions, either include <procfs.h> or define _STRUCTURED_PROC
42  * to be 1 before including <sys/procfs.h>.
43  */
44 #ifndef	_STRUCTURED_PROC
45 #define	_STRUCTURED_PROC	0
46 #endif
47 
48 #if !defined(_KERNEL) && _STRUCTURED_PROC == 0
49 
50 #include <sys/old_procfs.h>
51 
52 #else	/* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
53 
54 #include <sys/feature_tests.h>
55 #include <sys/types.h>
56 #include <sys/time_impl.h>
57 #include <sys/signal.h>
58 #include <sys/siginfo.h>
59 #include <sys/fault.h>
60 #include <sys/syscall.h>
61 #include <sys/pset.h>
62 #include <sys/procfs_isa.h>
63 #include <sys/priv.h>
64 #include <sys/lgrp.h>
65 
66 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
67 #error	"Cannot use procfs in the large file compilation environment"
68 #endif
69 
70 /*
71  * System call interfaces for /proc.
72  */
73 
74 /*
75  * Control codes (long values) for messages written to ctl and lwpctl files.
76  */
77 #define	PCNULL   0L	/* null request, advance to next message */
78 #define	PCSTOP   1L	/* direct process or lwp to stop and wait for stop */
79 #define	PCDSTOP  2L	/* direct process or lwp to stop */
80 #define	PCWSTOP  3L	/* wait for process or lwp to stop, no timeout */
81 #define	PCTWSTOP 4L	/* wait for stop, with long millisecond timeout arg */
82 #define	PCRUN    5L	/* make process/lwp runnable, w/ long flags argument */
83 #define	PCCSIG   6L	/* clear current signal from lwp */
84 #define	PCCFAULT 7L	/* clear current fault from lwp */
85 #define	PCSSIG   8L	/* set current signal from siginfo_t argument */
86 #define	PCKILL   9L	/* post a signal to process/lwp, long argument */
87 #define	PCUNKILL 10L	/* delete a pending signal from process/lwp, long arg */
88 #define	PCSHOLD  11L	/* set lwp signal mask from sigset_t argument */
89 #define	PCSTRACE 12L	/* set traced signal set from sigset_t argument */
90 #define	PCSFAULT 13L	/* set traced fault set from fltset_t argument */
91 #define	PCSENTRY 14L	/* set traced syscall entry set from sysset_t arg */
92 #define	PCSEXIT  15L	/* set traced syscall exit set from sysset_t arg */
93 #define	PCSET    16L	/* set modes from long argument */
94 #define	PCUNSET  17L	/* unset modes from long argument */
95 #define	PCSREG   18L	/* set lwp general registers from prgregset_t arg */
96 #define	PCSFPREG 19L	/* set lwp floating-point registers from prfpregset_t */
97 #define	PCSXREG  20L	/* set lwp extra registers from prxregset_t arg */
98 #define	PCNICE   21L	/* set nice priority from long argument */
99 #define	PCSVADDR 22L	/* set %pc virtual address from long argument */
100 #define	PCWATCH  23L	/* set/unset watched memory area from prwatch_t arg */
101 #define	PCAGENT  24L	/* create agent lwp with regs from prgregset_t arg */
102 #define	PCREAD   25L	/* read from the address space via priovec_t arg */
103 #define	PCWRITE  26L	/* write to the address space via priovec_t arg */
104 #define	PCSCRED  27L	/* set process credentials from prcred_t argument */
105 #define	PCSASRS  28L	/* set ancillary state registers from asrset_t arg */
106 #define	PCSPRIV  29L	/* set process privileges from prpriv_t argument */
107 #define	PCSZONE  30L	/* set zoneid from zoneid_t argument */
108 #define	PCSCREDX 31L	/* as PCSCRED but with supplemental groups */
109 /*
110  * PCRUN long operand flags.
111  */
112 #define	PRCSIG		0x01	/* clear current signal, if any */
113 #define	PRCFAULT	0x02	/* clear current fault, if any */
114 #define	PRSTEP		0x04	/* direct the lwp to single-step */
115 #define	PRSABORT	0x08	/* abort syscall, if in syscall */
116 #define	PRSTOP		0x10	/* set directed stop request */
117 
118 /*
119  * lwp status file.  /proc/<pid>/lwp/<lwpid>/lwpstatus
120  */
121 #define	PRCLSZ		8	/* maximum size of scheduling class name */
122 #define	PRSYSARGS	8	/* maximum number of syscall arguments */
123 typedef struct lwpstatus {
124 	int	pr_flags;	/* flags (see below) */
125 	id_t	pr_lwpid;	/* specific lwp identifier */
126 	short	pr_why;		/* reason for lwp stop, if stopped */
127 	short	pr_what;	/* more detailed reason */
128 	short	pr_cursig;	/* current signal, if any */
129 	short	pr_pad1;
130 	siginfo_t pr_info;	/* info associated with signal or fault */
131 	sigset_t pr_lwppend;	/* set of signals pending to the lwp */
132 	sigset_t pr_lwphold;	/* set of signals blocked by the lwp */
133 	struct sigaction pr_action;	/* signal action for current signal */
134 	stack_t	pr_altstack;	/* alternate signal stack info */
135 	uintptr_t pr_oldcontext;	/* address of previous ucontext */
136 	short	pr_syscall;	/* system call number (if in syscall) */
137 	short	pr_nsysarg;	/* number of arguments to this syscall */
138 	int	pr_errno;	/* errno for failed syscall, 0 if successful */
139 	long	pr_sysarg[PRSYSARGS];	/* arguments to this syscall */
140 	long	pr_rval1;	/* primary syscall return value */
141 	long	pr_rval2;	/* second syscall return value, if any */
142 	char	pr_clname[PRCLSZ];	/* scheduling class name */
143 	timestruc_t pr_tstamp;	/* real-time time stamp of stop */
144 	timestruc_t pr_utime;	/* lwp user cpu time */
145 	timestruc_t pr_stime;	/* lwp system cpu time */
146 	int	pr_filler[11 - 2 * sizeof (timestruc_t) / sizeof (int)];
147 	int	pr_errpriv;	/* missing privilege */
148 	uintptr_t pr_ustack;	/* address of stack boundary data (stack_t) */
149 	ulong_t	pr_instr;	/* current instruction */
150 	prgregset_t pr_reg;	/* general registers */
151 	prfpregset_t pr_fpreg;	/* floating-point registers */
152 } lwpstatus_t;
153 
154 /*
155  * process status file.  /proc/<pid>/status
156  */
157 typedef struct pstatus {
158 	int	pr_flags;	/* flags (see below) */
159 	int	pr_nlwp;	/* number of active lwps in the process */
160 	pid_t	pr_pid;		/* process id */
161 	pid_t	pr_ppid;	/* parent process id */
162 	pid_t	pr_pgid;	/* process group id */
163 	pid_t	pr_sid;		/* session id */
164 	id_t	pr_aslwpid;	/* historical; now always zero */
165 	id_t	pr_agentid;	/* lwp id of the /proc agent lwp, if any */
166 	sigset_t pr_sigpend;	/* set of process pending signals */
167 	uintptr_t pr_brkbase;	/* address of the process heap */
168 	size_t	pr_brksize;	/* size of the process heap, in bytes */
169 	uintptr_t pr_stkbase;	/* address of the process stack */
170 	size_t	pr_stksize;	/* size of the process stack, in bytes */
171 	timestruc_t pr_utime;	/* process user cpu time */
172 	timestruc_t pr_stime;	/* process system cpu time */
173 	timestruc_t pr_cutime;	/* sum of children's user times */
174 	timestruc_t pr_cstime;	/* sum of children's system times */
175 	sigset_t pr_sigtrace;	/* set of traced signals */
176 	fltset_t pr_flttrace;	/* set of traced faults */
177 	sysset_t pr_sysentry;	/* set of system calls traced on entry */
178 	sysset_t pr_sysexit;	/* set of system calls traced on exit */
179 	char	pr_dmodel;	/* data model of the process (see below) */
180 	char	pr_pad[3];
181 	taskid_t pr_taskid;	/* task id */
182 	projid_t pr_projid;	/* project id */
183 	int	pr_nzomb;	/* number of zombie lwps in the process */
184 	zoneid_t pr_zoneid;	/* zone id */
185 	int	pr_filler[15];	/* reserved for future use */
186 	lwpstatus_t pr_lwp;	/* status of the representative lwp */
187 } pstatus_t;
188 
189 /*
190  * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
191  *
192  * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
193  * (which are both deprecated).
194  */
195 /* The following flags apply to the specific or representative lwp */
196 #define	PR_STOPPED 0x00000001	/* lwp is stopped */
197 #define	PR_ISTOP   0x00000002	/* lwp is stopped on an event of interest */
198 #define	PR_DSTOP   0x00000004	/* lwp has a stop directive in effect */
199 #define	PR_STEP	   0x00000008	/* lwp has a single-step directive in effect */
200 #define	PR_ASLEEP  0x00000010	/* lwp is sleeping in a system call */
201 #define	PR_PCINVAL 0x00000020	/* contents of pr_instr undefined */
202 #define	PR_ASLWP   0x00000040	/* obsolete flag; never set */
203 #define	PR_AGENT   0x00000080	/* this lwp is the /proc agent lwp */
204 #define	PR_DETACH  0x00000100	/* this is a detached lwp */
205 #define	PR_DAEMON  0x00000200	/* this is a daemon lwp */
206 /* The following flags apply to the process, not to an individual lwp */
207 #define	PR_ISSYS   0x00001000	/* this is a system process */
208 #define	PR_VFORKP  0x00002000	/* process is the parent of a vfork()d child */
209 #define	PR_ORPHAN  0x00004000	/* process's process group is orphaned */
210 /* The following process flags are modes settable by PCSET/PCUNSET */
211 #define	PR_FORK	   0x00100000	/* inherit-on-fork is in effect */
212 #define	PR_RLC	   0x00200000	/* run-on-last-close is in effect */
213 #define	PR_KLC	   0x00400000	/* kill-on-last-close is in effect */
214 #define	PR_ASYNC   0x00800000	/* asynchronous-stop is in effect */
215 #define	PR_MSACCT  0x01000000	/* micro-state usage accounting is in effect */
216 #define	PR_BPTADJ  0x02000000	/* breakpoint trap pc adjustment is in effect */
217 #define	PR_PTRACE  0x04000000	/* ptrace-compatibility mode is in effect */
218 #define	PR_MSFORK  0x08000000	/* micro-state accounting inherited on fork */
219 #define	PR_IDLE    0x10000000	/* lwp is a cpu's idle thread */
220 
221 /*
222  * See <sys/procfs_isa.h> for possible values of pr_dmodel.
223  */
224 
225 /*
226  * Reasons for stopping (pr_why).
227  */
228 #define	PR_REQUESTED	1
229 #define	PR_SIGNALLED	2
230 #define	PR_SYSENTRY	3
231 #define	PR_SYSEXIT	4
232 #define	PR_JOBCONTROL	5
233 #define	PR_FAULTED	6
234 #define	PR_SUSPENDED	7
235 #define	PR_CHECKPOINT	8
236 
237 /*
238  * lwp ps(1) information file.  /proc/<pid>/lwp/<lwpid>/lwpsinfo
239  */
240 #define	PRFNSZ		16	/* Maximum size of execed filename */
241 typedef struct lwpsinfo {
242 	int	pr_flag;	/* lwp flags (DEPRECATED; do not use) */
243 	id_t	pr_lwpid;	/* lwp id */
244 	uintptr_t pr_addr;	/* internal address of lwp */
245 	uintptr_t pr_wchan;	/* wait addr for sleeping lwp */
246 	char	pr_stype;	/* synchronization event type */
247 	char	pr_state;	/* numeric lwp state */
248 	char	pr_sname;	/* printable character for pr_state */
249 	char	pr_nice;	/* nice for cpu usage */
250 	short	pr_syscall;	/* system call number (if in syscall) */
251 	char	pr_oldpri;	/* pre-SVR4, low value is high priority */
252 	char	pr_cpu;		/* pre-SVR4, cpu usage for scheduling */
253 	int	pr_pri;		/* priority, high value is high priority */
254 			/* The following percent number is a 16-bit binary */
255 			/* fraction [0 .. 1] with the binary point to the */
256 			/* right of the high-order bit (1.0 == 0x8000) */
257 	ushort_t pr_pctcpu;	/* % of recent cpu time used by this lwp */
258 	ushort_t pr_pad;
259 	timestruc_t pr_start;	/* lwp start time, from the epoch */
260 	timestruc_t pr_time;	/* usr+sys cpu time for this lwp */
261 	char	pr_clname[PRCLSZ];	/* scheduling class name */
262 	char	pr_name[PRFNSZ];	/* name of system lwp */
263 	processorid_t pr_onpro;		/* processor which last ran this lwp */
264 	processorid_t pr_bindpro;	/* processor to which lwp is bound */
265 	psetid_t pr_bindpset;	/* processor set to which lwp is bound */
266 	lgrp_id_t pr_lgrp;	/* lwp home lgroup */
267 	int	pr_filler[4];	/* reserved for future use */
268 } lwpsinfo_t;
269 
270 /*
271  * process ps(1) information file.  /proc/<pid>/psinfo
272  */
273 #define	PRARGSZ		80	/* number of chars of arguments */
274 typedef struct psinfo {
275 	int	pr_flag;	/* process flags (DEPRECATED; do not use) */
276 	int	pr_nlwp;	/* number of active lwps in the process */
277 	pid_t	pr_pid;		/* unique process id */
278 	pid_t	pr_ppid;	/* process id of parent */
279 	pid_t	pr_pgid;	/* pid of process group leader */
280 	pid_t	pr_sid;		/* session id */
281 	uid_t	pr_uid;		/* real user id */
282 	uid_t	pr_euid;	/* effective user id */
283 	gid_t	pr_gid;		/* real group id */
284 	gid_t	pr_egid;	/* effective group id */
285 	uintptr_t pr_addr;	/* address of process */
286 	size_t	pr_size;	/* size of process image in Kbytes */
287 	size_t	pr_rssize;	/* resident set size in Kbytes */
288 	size_t	pr_pad1;
289 	dev_t	pr_ttydev;	/* controlling tty device (or PRNODEV) */
290 			/* The following percent numbers are 16-bit binary */
291 			/* fractions [0 .. 1] with the binary point to the */
292 			/* right of the high-order bit (1.0 == 0x8000) */
293 	ushort_t pr_pctcpu;	/* % of recent cpu time used by all lwps */
294 	ushort_t pr_pctmem;	/* % of system memory used by process */
295 	timestruc_t pr_start;	/* process start time, from the epoch */
296 	timestruc_t pr_time;	/* usr+sys cpu time for this process */
297 	timestruc_t pr_ctime;	/* usr+sys cpu time for reaped children */
298 	char	pr_fname[PRFNSZ];	/* name of execed file */
299 	char	pr_psargs[PRARGSZ];	/* initial characters of arg list */
300 	int	pr_wstat;	/* if zombie, the wait() status */
301 	int	pr_argc;	/* initial argument count */
302 	uintptr_t pr_argv;	/* address of initial argument vector */
303 	uintptr_t pr_envp;	/* address of initial environment vector */
304 	char	pr_dmodel;	/* data model of the process */
305 	char	pr_pad2[3];
306 	taskid_t pr_taskid;	/* task id */
307 	projid_t pr_projid;	/* project id */
308 	int	pr_nzomb;	/* number of zombie lwps in the process */
309 	poolid_t pr_poolid;	/* pool id */
310 	zoneid_t pr_zoneid;	/* zone id */
311 	id_t	pr_contract;	/* process contract */
312 	int	pr_filler[1];	/* reserved for future use */
313 	lwpsinfo_t pr_lwp;	/* information for representative lwp */
314 } psinfo_t;
315 
316 #define	PRNODEV	(dev_t)(-1)	/* non-existent device */
317 
318 /*
319  * Memory-map interface.  /proc/<pid>/map /proc/<pid>/rmap
320  */
321 #define	PRMAPSZ	64
322 typedef struct prmap {
323 	uintptr_t pr_vaddr;	/* virtual address of mapping */
324 	size_t	pr_size;	/* size of mapping in bytes */
325 	char	pr_mapname[PRMAPSZ];	/* name in /proc/<pid>/object */
326 	offset_t pr_offset;	/* offset into mapped object, if any */
327 	int	pr_mflags;	/* protection and attribute flags (see below) */
328 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
329 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
330 	int	pr_filler[1];	/* filler for future expansion */
331 } prmap_t;
332 
333 /*
334  * HAT memory-map interface.  /proc/<pid>/xmap
335  *
336  * The xmap structure is a Sun private interface. The existence, semantics
337  * and contents of the xmap structure are subject to arbitrary change.
338  */
339 typedef struct prxmap {
340 	uintptr_t pr_vaddr;	/* virtual address of mapping */
341 	size_t	pr_size;	/* size of mapping in bytes */
342 	char	pr_mapname[PRMAPSZ];	/* name in /proc/<pid>/object */
343 	offset_t pr_offset;	/* offset into mapped object, if any */
344 	int	pr_mflags;	/* protection and attribute flags (see below) */
345 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
346 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
347 	dev_t	pr_dev;	/* st_dev from stat64() of mapped object, or PRNODEV */
348 	uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */
349 	ulong_t	pr_rss; 	/* pages of resident memory */
350 	ulong_t	pr_anon;	/* pages of resident anonymous memory */
351 	ulong_t	pr_locked;	/* pages of locked memory */
352 	int	pr_hatpagesize;	/* pagesize of the hat mapping */
353 	ulong_t	pr_filler[8];	/* filler for future expansion */
354 } prxmap_t;
355 
356 
357 /* Protection and attribute flags */
358 #define	MA_READ		0x04	/* readable by the traced process */
359 #define	MA_WRITE	0x02	/* writable by the traced process */
360 #define	MA_EXEC		0x01	/* executable by the traced process */
361 #define	MA_SHARED	0x08	/* changes are shared by mapped object */
362 #define	MA_ANON		0x40	/* anonymous memory (e.g. /dev/zero) */
363 #define	MA_ISM		0x80	/* intimate shared mem (shared MMU resources) */
364 #define	MA_NORESERVE	0x100	/* mapped with MAP_NORESERVE */
365 #define	MA_SHM		0x200	/* System V shared memory */
366 #define	MA_RESERVED1	0x400	/* reserved for future use */
367 
368 /*
369  * These are obsolete and unreliable.
370  * They are included here only for historical compatibility.
371  */
372 #define	MA_BREAK	0x10	/* grown by brk(2) */
373 #define	MA_STACK	0x20	/* grown automatically on stack faults */
374 
375 /*
376  * Process credentials.  PCSCRED and /proc/<pid>/cred
377  */
378 typedef struct prcred {
379 	uid_t	pr_euid;	/* effective user id */
380 	uid_t	pr_ruid;	/* real user id */
381 	uid_t	pr_suid;	/* saved user id (from exec) */
382 	gid_t	pr_egid;	/* effective group id */
383 	gid_t	pr_rgid;	/* real group id */
384 	gid_t	pr_sgid;	/* saved group id (from exec) */
385 	int	pr_ngroups;	/* number of supplementary groups */
386 	gid_t	pr_groups[1];	/* array of supplementary groups */
387 } prcred_t;
388 
389 /*
390  * Process privileges.  PCSPRIV and /proc/<pid>/priv
391  */
392 typedef struct prpriv {
393 	uint32_t	pr_nsets;		/* number of privilege set */
394 	uint32_t	pr_setsize;		/* size of privilege set */
395 	uint32_t	pr_infosize;		/* size of supplementary data */
396 	priv_chunk_t	pr_sets[1];		/* array of sets */
397 } prpriv_t;
398 
399 /*
400  * Watchpoint interface.  PCWATCH and /proc/<pid>/watch
401  */
402 typedef struct prwatch {
403 	uintptr_t pr_vaddr;	/* virtual address of watched area */
404 	size_t	pr_size;	/* size of watched area in bytes */
405 	int	pr_wflags;	/* watch type flags */
406 	int	pr_pad;
407 } prwatch_t;
408 
409 /* pr_wflags */
410 #define	WA_READ		0x04	/* trap on read access */
411 #define	WA_WRITE	0x02	/* trap on write access */
412 #define	WA_EXEC		0x01	/* trap on execute access */
413 #define	WA_TRAPAFTER	0x08	/* trap after instruction completes */
414 
415 /*
416  * PCREAD/PCWRITE I/O interface.
417  */
418 typedef struct priovec {
419 	void	*pio_base;	/* buffer in controlling process */
420 	size_t	pio_len;	/* size of read/write request */
421 	off_t	pio_offset;	/* virtual address in target process */
422 } priovec_t;
423 
424 /*
425  * Resource usage.  /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
426  */
427 typedef struct prusage {
428 	id_t		pr_lwpid;	/* lwp id.  0: process or defunct */
429 	int		pr_count;	/* number of contributing lwps */
430 	timestruc_t	pr_tstamp;	/* current time stamp */
431 	timestruc_t	pr_create;	/* process/lwp creation time stamp */
432 	timestruc_t	pr_term;	/* process/lwp termination time stamp */
433 	timestruc_t	pr_rtime;	/* total lwp real (elapsed) time */
434 	timestruc_t	pr_utime;	/* user level cpu time */
435 	timestruc_t	pr_stime;	/* system call cpu time */
436 	timestruc_t	pr_ttime;	/* other system trap cpu time */
437 	timestruc_t	pr_tftime;	/* text page fault sleep time */
438 	timestruc_t	pr_dftime;	/* data page fault sleep time */
439 	timestruc_t	pr_kftime;	/* kernel page fault sleep time */
440 	timestruc_t	pr_ltime;	/* user lock wait sleep time */
441 	timestruc_t	pr_slptime;	/* all other sleep time */
442 	timestruc_t	pr_wtime;	/* wait-cpu (latency) time */
443 	timestruc_t	pr_stoptime;	/* stopped time */
444 	timestruc_t	filltime[6];	/* filler for future expansion */
445 	ulong_t		pr_minf;	/* minor page faults */
446 	ulong_t		pr_majf;	/* major page faults */
447 	ulong_t		pr_nswap;	/* swaps */
448 	ulong_t		pr_inblk;	/* input blocks */
449 	ulong_t		pr_oublk;	/* output blocks */
450 	ulong_t		pr_msnd;	/* messages sent */
451 	ulong_t		pr_mrcv;	/* messages received */
452 	ulong_t		pr_sigs;	/* signals received */
453 	ulong_t		pr_vctx;	/* voluntary context switches */
454 	ulong_t		pr_ictx;	/* involuntary context switches */
455 	ulong_t		pr_sysc;	/* system calls */
456 	ulong_t		pr_ioch;	/* chars read and written */
457 	ulong_t		filler[10];	/* filler for future expansion */
458 } prusage_t;
459 
460 /*
461  * Page data file.  /proc/<pid>/pagedata
462  */
463 
464 /* page data file header */
465 typedef struct prpageheader {
466 	timestruc_t	pr_tstamp;	/* real time stamp */
467 	long		pr_nmap;	/* number of address space mappings */
468 	long		pr_npage;	/* total number of pages */
469 } prpageheader_t;
470 
471 /* page data mapping header */
472 typedef struct prasmap {
473 	uintptr_t pr_vaddr;	/* virtual address of mapping */
474 	size_t	pr_npage;	/* number of pages in mapping */
475 	char	pr_mapname[PRMAPSZ];	/* name in /proc/<pid>/object */
476 	offset_t pr_offset;	/* offset into mapped object, if any */
477 	int	pr_mflags;	/* protection and attribute flags */
478 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
479 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
480 	int	pr_filler[1];	/* filler for future expansion */
481 } prasmap_t;
482 
483 /*
484  * pr_npage bytes (plus 0-7 null bytes to round up to an 8-byte boundary)
485  * follow each mapping header, each containing zero or more of these flags.
486  */
487 #define	PG_REFERENCED	0x02		/* page referenced since last read */
488 #define	PG_MODIFIED	0x01		/* page modified since last read */
489 #define	PG_HWMAPPED	0x04		/* page is present and mapped */
490 
491 /*
492  * Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
493  */
494 typedef struct prheader {
495 	long	pr_nent;	/* number of entries */
496 	long	pr_entsize;	/* size of each entry, in bytes */
497 } prheader_t;
498 
499 /*
500  * Macros for manipulating sets of flags.
501  * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t.
502  * flag must be a member of the enumeration corresponding to *sp.
503  */
504 
505 /* turn on all flags in set */
506 #define	prfillset(sp) \
507 	{ register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
508 		while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0xFFFFFFFF; }
509 
510 /* turn off all flags in set */
511 #define	premptyset(sp) \
512 	{ register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
513 		while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0; }
514 
515 /* turn on specified flag in set */
516 #define	praddset(sp, flag) \
517 	((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
518 	(((uint32_t *)(sp))[((flag)-1)/32] |= (1U<<(((flag)-1)%32))) : 0))
519 
520 /* turn off specified flag in set */
521 #define	prdelset(sp, flag) \
522 	((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
523 	    (((uint32_t *)(sp))[((flag)-1)/32] &= ~(1U<<(((flag)-1)%32))) : 0))
524 
525 /* query: != 0 iff flag is turned on in set */
526 #define	prismember(sp, flag) \
527 	(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) && \
528 	    (((uint32_t *)(sp))[((flag)-1)/32] & (1U<<(((flag)-1)%32))))
529 
530 #if defined(_SYSCALL32)
531 
532 /*
533  * dev32_t version of PRNODEV
534  */
535 #define	PRNODEV32 (dev32_t)(-1)
536 
537 /*
538  * Kernel view of /proc structures for _ILP32 programs.
539  */
540 
541 /*
542  * _ILP32 lwp status file.  /proc/<pid>/lwp/<lwpid>/lwpstatus
543  */
544 typedef struct lwpstatus32 {
545 	int	pr_flags;	/* flags */
546 	id32_t	pr_lwpid;	/* specific lwp identifier */
547 	short	pr_why;		/* reason for lwp stop, if stopped */
548 	short	pr_what;	/* more detailed reason */
549 	short	pr_cursig;	/* current signal, if any */
550 	short	pr_pad1;
551 	siginfo32_t pr_info;	/* info associated with signal or fault */
552 	sigset_t pr_lwppend;	/* set of signals pending to the lwp */
553 	sigset_t pr_lwphold;	/* set of signals blocked by the lwp */
554 	struct sigaction32 pr_action;	/* signal action for current signal */
555 	stack32_t pr_altstack;	/* alternate signal stack info */
556 	caddr32_t pr_oldcontext;	/* address of previous ucontext */
557 	short	pr_syscall;	/* system call number (if in syscall) */
558 	short	pr_nsysarg;	/* number of arguments to this syscall */
559 	int	pr_errno;	/* errno for failed syscall, 0 if successful */
560 	int32_t	pr_sysarg[PRSYSARGS];	/* arguments to this syscall */
561 	int32_t	pr_rval1;	/* primary syscall return value */
562 	int32_t	pr_rval2;	/* second syscall return value, if any */
563 	char	pr_clname[PRCLSZ];	/* scheduling class name */
564 	timestruc32_t pr_tstamp;	/* real-time time stamp of stop */
565 	timestruc32_t pr_utime;	/* lwp user cpu time */
566 	timestruc32_t pr_stime;	/* lwp system cpu time */
567 	int	pr_filler[11 - 2 * sizeof (timestruc32_t) / sizeof (int)];
568 	int	pr_errpriv;	/* missing privilege */
569 	caddr32_t pr_ustack;	/* address of stack boundary data (stack32_t) */
570 	uint32_t pr_instr;	/* current instruction */
571 	prgregset32_t pr_reg;	/* general registers */
572 	prfpregset32_t pr_fpreg; /* floating-point registers */
573 } lwpstatus32_t;
574 
575 /*
576  * _ILP32 process status file.  /proc/<pid>/status
577  */
578 typedef struct pstatus32 {
579 	int	pr_flags;	/* flags */
580 	int	pr_nlwp;	/* number of active lwps in the process */
581 	pid32_t	pr_pid;		/* process id */
582 	pid32_t	pr_ppid;	/* parent process id */
583 	pid32_t	pr_pgid;	/* process group id */
584 	pid32_t	pr_sid;		/* session id */
585 	id32_t	pr_aslwpid;	/* historical; now always zero */
586 	id32_t	pr_agentid;	/* lwp id of the /proc agent lwp, if any */
587 	sigset_t pr_sigpend;	/* set of process pending signals */
588 	caddr32_t pr_brkbase;	/* address of the process heap */
589 	size32_t pr_brksize;	/* size of the process heap, in bytes */
590 	caddr32_t pr_stkbase;	/* address of the process stack */
591 	size32_t pr_stksize;	/* size of the process stack, in bytes */
592 	timestruc32_t pr_utime;	/* process user cpu time */
593 	timestruc32_t pr_stime;	/* process system cpu time */
594 	timestruc32_t pr_cutime;	/* sum of children's user times */
595 	timestruc32_t pr_cstime;	/* sum of children's system times */
596 	sigset_t pr_sigtrace;	/* set of traced signals */
597 	fltset_t pr_flttrace;	/* set of traced faults */
598 	sysset_t pr_sysentry;	/* set of system calls traced on entry */
599 	sysset_t pr_sysexit;	/* set of system calls traced on exit */
600 	char	pr_dmodel;	/* data model of the process */
601 	char	pr_pad[3];
602 	id32_t	pr_taskid;	/* task id */
603 	id32_t	pr_projid;	/* project id */
604 	int	pr_nzomb;	/* number of zombie lwps in the process */
605 	id32_t	pr_zoneid;	/* zone id */
606 	int	pr_filler[15];	/* reserved for future use */
607 	lwpstatus32_t pr_lwp;	/* status of the representative lwp */
608 } pstatus32_t;
609 
610 /*
611  * _ILP32 lwp ps(1) information file.  /proc/<pid>/lwp/<lwpid>/lwpsinfo
612  */
613 typedef struct lwpsinfo32 {
614 	int	pr_flag;	/* lwp flags */
615 	id32_t	pr_lwpid;	/* lwp id */
616 	caddr32_t pr_addr;	/* internal address of lwp */
617 	caddr32_t pr_wchan;	/* wait addr for sleeping lwp */
618 	char	pr_stype;	/* synchronization event type */
619 	char	pr_state;	/* numeric lwp state */
620 	char	pr_sname;	/* printable character for pr_state */
621 	char	pr_nice;	/* nice for cpu usage */
622 	short	pr_syscall;	/* system call number (if in syscall) */
623 	char	pr_oldpri;	/* pre-SVR4, low value is high priority */
624 	char	pr_cpu;		/* pre-SVR4, cpu usage for scheduling */
625 	int	pr_pri;		/* priority, high value is high priority */
626 			/* The following percent number is a 16-bit binary */
627 			/* fraction [0 .. 1] with the binary point to the */
628 			/* right of the high-order bit (1.0 == 0x8000) */
629 	ushort_t pr_pctcpu;	/* % of recent cpu time used by this lwp */
630 	ushort_t pr_pad;
631 	timestruc32_t pr_start;	/* lwp start time, from the epoch */
632 	timestruc32_t pr_time;	/* usr+sys cpu time for this lwp */
633 	char	pr_clname[PRCLSZ];	/* scheduling class name */
634 	char	pr_name[PRFNSZ];	/* name of system lwp */
635 	processorid_t pr_onpro;		/* processor which last ran this lwp */
636 	processorid_t pr_bindpro;	/* processor to which lwp is bound */
637 	psetid_t pr_bindpset;	/* processor set to which lwp is bound */
638 	lgrp_id_t pr_lgrp;	/* lwp home lgroup */
639 	int	pr_filler[4];	/* reserved for future use */
640 } lwpsinfo32_t;
641 
642 /*
643  * _ILP32 process ps(1) information file.  /proc/<pid>/psinfo
644  */
645 typedef struct psinfo32 {
646 	int	pr_flag;	/* process flags */
647 	int	pr_nlwp;	/* number of active lwps in the process */
648 	pid32_t	pr_pid;		/* unique process id */
649 	pid32_t	pr_ppid;	/* process id of parent */
650 	pid32_t	pr_pgid;	/* pid of process group leader */
651 	pid32_t	pr_sid;		/* session id */
652 	uid32_t	pr_uid;		/* real user id */
653 	uid32_t	pr_euid;	/* effective user id */
654 	gid32_t	pr_gid;		/* real group id */
655 	gid32_t	pr_egid;	/* effective group id */
656 	caddr32_t pr_addr;	/* address of process */
657 	size32_t pr_size;	/* size of process image in Kbytes */
658 	size32_t pr_rssize;	/* resident set size in Kbytes */
659 	size32_t pr_pad1;
660 	dev32_t	pr_ttydev;	/* controlling tty device (or PRNODEV) */
661 	ushort_t pr_pctcpu;	/* % of recent cpu time used by all lwps */
662 	ushort_t pr_pctmem;	/* % of system memory used by process */
663 	timestruc32_t pr_start;	/* process start time, from the epoch */
664 	timestruc32_t pr_time;	/* usr+sys cpu time for this process */
665 	timestruc32_t pr_ctime;	/* usr+sys cpu time for reaped children */
666 	char	pr_fname[PRFNSZ];	/* name of execed file */
667 	char	pr_psargs[PRARGSZ];	/* initial characters of arg list */
668 	int	pr_wstat;	/* if zombie, the wait() status */
669 	int	pr_argc;	/* initial argument count */
670 	caddr32_t pr_argv;	/* address of initial argument vector */
671 	caddr32_t pr_envp;	/* address of initial environment vector */
672 	char	pr_dmodel;	/* data model of the process */
673 	char	pr_pad2[3];
674 	id32_t	pr_taskid;	/* task id */
675 	id32_t	pr_projid;	/* project id */
676 	int	pr_nzomb;	/* number of zombie lwps in the process */
677 	id32_t	pr_poolid;	/* pool id */
678 	id32_t	pr_zoneid;	/* zone id */
679 	id32_t	pr_contract;	/* process contract */
680 	int	pr_filler[1];	/* reserved for future use */
681 	lwpsinfo32_t pr_lwp;	/* information for representative lwp */
682 } psinfo32_t;
683 
684 /*
685  * _ILP32 Memory-management interface.  /proc/<pid>/map /proc/<pid>/rmap
686  */
687 typedef struct prmap32 {
688 	caddr32_t pr_vaddr;	/* virtual address of mapping */
689 	size32_t pr_size;	/* size of mapping in bytes */
690 	char	pr_mapname[64];	/* name in /proc/<pid>/object */
691 	offset_t pr_offset;	/* offset into mapped object, if any */
692 	int	pr_mflags;	/* protection and attribute flags */
693 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
694 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
695 	int	pr_filler[1];	/* filler for future expansion */
696 } prmap32_t;
697 
698 /*
699  * _ILP32 HAT memory-map interface.  /proc/<pid>/xmap
700  *
701  * The xmap structure is a Sun private interface. The existence, semantics
702  * and contents of the xmap structure are subject to arbitrary change.
703  */
704 typedef struct prxmap32 {
705 	caddr32_t pr_vaddr;	/* virtual address of mapping */
706 	size32_t pr_size;	/* size of mapping in bytes */
707 	char	pr_mapname[PRMAPSZ];	/* name in /proc/<pid>/object */
708 	offset_t pr_offset;	/* offset into mapped object, if any */
709 	int	pr_mflags;	/* protection and attribute flags (see below) */
710 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
711 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
712 	dev32_t	pr_dev;  /* st_dev from stat64() of mapped object, or PRNODEV */
713 	uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */
714 	uint32_t pr_rss;	/* pages of resident memory */
715 	uint32_t pr_anon;	/* pages of resident anonymous memory */
716 	uint32_t pr_locked;	/* pages of locked memory */
717 	int	pr_hatpagesize;	/* pagesize of the hat mapping */
718 	uint32_t pr_filler[7];	/* filler for future expansion */
719 } prxmap32_t;
720 
721 /*
722  * _ILP32 Process credentials.  PCSCRED and /proc/<pid>/cred
723  */
724 typedef struct prcred32 {
725 	uid32_t	pr_euid;	/* effective user id */
726 	uid32_t	pr_ruid;	/* real user id */
727 	uid32_t	pr_suid;	/* saved user id (from exec) */
728 	gid32_t	pr_egid;	/* effective group id */
729 	gid32_t	pr_rgid;	/* real group id */
730 	gid32_t	pr_sgid;	/* saved group id (from exec) */
731 	int	pr_ngroups;	/* number of supplementary groups */
732 	gid32_t	pr_groups[1];	/* array of supplementary groups */
733 } prcred32_t;
734 
735 /*
736  * _ILP32 Watchpoint interface.  PCWATCH and /proc/<pid>/watch
737  */
738 typedef struct prwatch32 {
739 	caddr32_t pr_vaddr;	/* virtual address of watched area */
740 	size32_t pr_size;	/* size of watched area in bytes */
741 	int	pr_wflags;	/* watch type flags */
742 	int	pr_pad;
743 } prwatch32_t;
744 
745 /*
746  * _ILP32 PCREAD/PCWRITE I/O interface.
747  */
748 typedef struct priovec32 {
749 	caddr32_t pio_base;	/* buffer in controlling process */
750 	size32_t pio_len;	/* size of read/write request */
751 	off32_t	pio_offset;	/* virtual address in target process */
752 } priovec32_t;
753 
754 /*
755  * _ILP32 Resource usage.  /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
756  */
757 typedef struct prusage32 {
758 	id32_t		pr_lwpid;	/* lwp id.  0: process or defunct */
759 	int32_t		pr_count;	/* number of contributing lwps */
760 	timestruc32_t	pr_tstamp;	/* current time stamp */
761 	timestruc32_t	pr_create;	/* process/lwp creation time stamp */
762 	timestruc32_t	pr_term;	/* process/lwp termination time stamp */
763 	timestruc32_t	pr_rtime;	/* total lwp real (elapsed) time */
764 	timestruc32_t	pr_utime;	/* user level cpu time */
765 	timestruc32_t	pr_stime;	/* system call cpu time */
766 	timestruc32_t	pr_ttime;	/* other system trap cpu time */
767 	timestruc32_t	pr_tftime;	/* text page fault sleep time */
768 	timestruc32_t	pr_dftime;	/* data page fault sleep time */
769 	timestruc32_t	pr_kftime;	/* kernel page fault sleep time */
770 	timestruc32_t	pr_ltime;	/* user lock wait sleep time */
771 	timestruc32_t	pr_slptime;	/* all other sleep time */
772 	timestruc32_t	pr_wtime;	/* wait-cpu (latency) time */
773 	timestruc32_t	pr_stoptime;	/* stopped time */
774 	timestruc32_t	filltime[6];	/* filler for future expansion */
775 	uint32_t	pr_minf;	/* minor page faults */
776 	uint32_t	pr_majf;	/* major page faults */
777 	uint32_t	pr_nswap;	/* swaps */
778 	uint32_t	pr_inblk;	/* input blocks */
779 	uint32_t	pr_oublk;	/* output blocks */
780 	uint32_t	pr_msnd;	/* messages sent */
781 	uint32_t	pr_mrcv;	/* messages received */
782 	uint32_t	pr_sigs;	/* signals received */
783 	uint32_t	pr_vctx;	/* voluntary context switches */
784 	uint32_t	pr_ictx;	/* involuntary context switches */
785 	uint32_t	pr_sysc;	/* system calls */
786 	uint32_t	pr_ioch;	/* chars read and written */
787 	uint32_t	filler[10];	/* filler for future expansion */
788 } prusage32_t;
789 
790 /*
791  * _ILP32 Page data file.  /proc/<pid>/pagedata
792  */
793 
794 /* _ILP32 page data file header */
795 typedef struct prpageheader32 {
796 	timestruc32_t	pr_tstamp;	/* real time stamp */
797 	int32_t		pr_nmap;	/* number of address space mappings */
798 	int32_t		pr_npage;	/* total number of pages */
799 } prpageheader32_t;
800 
801 /* _ILP32 page data mapping header */
802 typedef struct prasmap32 {
803 	caddr32_t pr_vaddr;	/* virtual address of mapping */
804 	size32_t pr_npage;	/* number of pages in mapping */
805 	char	pr_mapname[64];	/* name in /proc/<pid>/object */
806 	offset_t pr_offset;	/* offset into mapped object, if any */
807 	int	pr_mflags;	/* protection and attribute flags */
808 	int	pr_pagesize;	/* pagesize (bytes) for this mapping */
809 	int	pr_shmid;	/* SysV shmid, -1 if not SysV shared memory */
810 	int	pr_filler[1];	/* filler for future expansion */
811 } prasmap32_t;
812 
813 /*
814  * _ILP32 Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
815  */
816 typedef struct prheader32 {
817 	int32_t	pr_nent;	/* number of entries */
818 	int32_t	pr_entsize;	/* size of each entry, in bytes */
819 } prheader32_t;
820 
821 #endif	/* _SYSCALL32 */
822 
823 #endif	/* !_KERNEL && _STRUCTURED_PROC == 0 */
824 
825 #ifdef	__cplusplus
826 }
827 #endif
828 
829 #endif	/* _SYS_PROCFS_H */
830