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