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.
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.
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]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
28 * Copyright 2018 Joyent, Inc.
29 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
30 * Copyright 2024 Oxide Computer Company
41 * This definition is temporary. Structured proc is the preferred API,
42 * and the older ioctl-based interface will be removed in a future version
43 * of Solaris. Until then, by default, including <sys/procfs.h> will
44 * provide the older ioctl-based /proc definitions. To get the structured
45 * /proc definitions, either include <procfs.h> or define _STRUCTURED_PROC
46 * to be 1 before including <sys/procfs.h>.
48 #ifndef _STRUCTURED_PROC
49 #define _STRUCTURED_PROC 0
52 #if !defined(_KERNEL) && _STRUCTURED_PROC == 0
54 #include <sys/old_procfs.h>
56 #else /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
58 #include <sys/feature_tests.h>
59 #include <sys/types.h>
60 #include <sys/time_impl.h>
61 #include <sys/signal.h>
62 #include <sys/siginfo.h>
63 #include <sys/fault.h>
64 #include <sys/syscall.h>
66 #include <sys/procfs_isa.h>
69 #include <sys/param.h>
70 #include <sys/secflags.h>
71 #include <sys/thread.h>
74 * System call interfaces for /proc.
78 * Control codes (long values) for messages written to ctl and lwpctl files.
80 #define PCNULL 0L /* null request, advance to next message */
81 #define PCSTOP 1L /* direct process or lwp to stop and wait for stop */
82 #define PCDSTOP 2L /* direct process or lwp to stop */
83 #define PCWSTOP 3L /* wait for process or lwp to stop, no timeout */
84 #define PCTWSTOP 4L /* wait for stop, with long millisecond timeout arg */
85 #define PCRUN 5L /* make process/lwp runnable, w/ long flags argument */
86 #define PCCSIG 6L /* clear current signal from lwp */
87 #define PCCFAULT 7L /* clear current fault from lwp */
88 #define PCSSIG 8L /* set current signal from siginfo_t argument */
89 #define PCKILL 9L /* post a signal to process/lwp, long argument */
90 #define PCUNKILL 10L /* delete a pending signal from process/lwp, long arg */
91 #define PCSHOLD 11L /* set lwp signal mask from sigset_t argument */
92 #define PCSTRACE 12L /* set traced signal set from sigset_t argument */
93 #define PCSFAULT 13L /* set traced fault set from fltset_t argument */
94 #define PCSENTRY 14L /* set traced syscall entry set from sysset_t arg */
95 #define PCSEXIT 15L /* set traced syscall exit set from sysset_t arg */
96 #define PCSET 16L /* set modes from long argument */
97 #define PCUNSET 17L /* unset modes from long argument */
98 #define PCSREG 18L /* set lwp general registers from prgregset_t arg */
99 #define PCSFPREG 19L /* set lwp floating-point registers from prfpregset_t */
100 #define PCSXREG 20L /* set lwp extra registers from prxregset_t arg */
101 #define PCNICE 21L /* set nice priority from long argument */
102 #define PCSVADDR 22L /* set %pc virtual address from long argument */
103 #define PCWATCH 23L /* set/unset watched memory area from prwatch_t arg */
104 #define PCAGENT 24L /* create agent lwp with regs from prgregset_t arg */
105 #define PCREAD 25L /* read from the address space via priovec_t arg */
106 #define PCWRITE 26L /* write to the address space via priovec_t arg */
107 #define PCSCRED 27L /* set process credentials from prcred_t argument */
108 #define PCSASRS 28L /* set ancillary state registers from asrset_t arg */
109 #define PCSPRIV 29L /* set process privileges from prpriv_t argument */
110 #define PCSZONE 30L /* set zoneid from zoneid_t argument */
111 #define PCSCREDX 31L /* as PCSCRED but with supplemental groups */
113 * PCRUN long operand flags.
115 #define PRCSIG 0x01 /* clear current signal, if any */
116 #define PRCFAULT 0x02 /* clear current fault, if any */
117 #define PRSTEP 0x04 /* direct the lwp to single-step */
118 #define PRSABORT 0x08 /* abort syscall, if in syscall */
119 #define PRSTOP 0x10 /* set directed stop request */
122 * lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
124 #define PRCLSZ 8 /* maximum size of scheduling class name */
125 #define PRSYSARGS 8 /* maximum number of syscall arguments */
126 typedef struct lwpstatus
{
127 int pr_flags
; /* flags (see below) */
128 id_t pr_lwpid
; /* specific lwp identifier */
129 short pr_why
; /* reason for lwp stop, if stopped */
130 short pr_what
; /* more detailed reason */
131 short pr_cursig
; /* current signal, if any */
133 siginfo_t pr_info
; /* info associated with signal or fault */
134 sigset_t pr_lwppend
; /* set of signals pending to the lwp */
135 sigset_t pr_lwphold
; /* set of signals blocked by the lwp */
136 struct sigaction pr_action
; /* signal action for current signal */
137 stack_t pr_altstack
; /* alternate signal stack info */
138 uintptr_t pr_oldcontext
; /* address of previous ucontext */
139 short pr_syscall
; /* system call number (if in syscall) */
140 short pr_nsysarg
; /* number of arguments to this syscall */
141 int pr_errno
; /* errno for failed syscall, 0 if successful */
142 long pr_sysarg
[PRSYSARGS
]; /* arguments to this syscall */
143 long pr_rval1
; /* primary syscall return value */
144 long pr_rval2
; /* second syscall return value, if any */
145 char pr_clname
[PRCLSZ
]; /* scheduling class name */
146 timestruc_t pr_tstamp
; /* real-time time stamp of stop */
147 timestruc_t pr_utime
; /* lwp user cpu time */
148 timestruc_t pr_stime
; /* lwp system cpu time */
149 int pr_filler
[11 - 2 * sizeof (timestruc_t
) / sizeof (int)];
150 int pr_errpriv
; /* missing privilege */
151 uintptr_t pr_ustack
; /* address of stack boundary data (stack_t) */
152 ulong_t pr_instr
; /* current instruction */
153 prgregset_t pr_reg
; /* general registers */
154 prfpregset_t pr_fpreg
; /* floating-point registers */
158 * process status file. /proc/<pid>/status
160 typedef struct pstatus
{
161 int pr_flags
; /* flags (see below) */
162 int pr_nlwp
; /* number of active lwps in the process */
163 pid_t pr_pid
; /* process id */
164 pid_t pr_ppid
; /* parent process id */
165 pid_t pr_pgid
; /* process group id */
166 pid_t pr_sid
; /* session id */
167 id_t pr_aslwpid
; /* historical; now always zero */
168 id_t pr_agentid
; /* lwp id of the /proc agent lwp, if any */
169 sigset_t pr_sigpend
; /* set of process pending signals */
170 uintptr_t pr_brkbase
; /* address of the process heap */
171 size_t pr_brksize
; /* size of the process heap, in bytes */
172 uintptr_t pr_stkbase
; /* address of the process stack */
173 size_t pr_stksize
; /* size of the process stack, in bytes */
174 timestruc_t pr_utime
; /* process user cpu time */
175 timestruc_t pr_stime
; /* process system cpu time */
176 timestruc_t pr_cutime
; /* sum of children's user times */
177 timestruc_t pr_cstime
; /* sum of children's system times */
178 sigset_t pr_sigtrace
; /* set of traced signals */
179 fltset_t pr_flttrace
; /* set of traced faults */
180 sysset_t pr_sysentry
; /* set of system calls traced on entry */
181 sysset_t pr_sysexit
; /* set of system calls traced on exit */
182 char pr_dmodel
; /* data model of the process (see below) */
184 taskid_t pr_taskid
; /* task id */
185 projid_t pr_projid
; /* project id */
186 int pr_nzomb
; /* number of zombie lwps in the process */
187 zoneid_t pr_zoneid
; /* zone id */
188 int pr_filler
[15]; /* reserved for future use */
189 lwpstatus_t pr_lwp
; /* status of the representative lwp */
193 * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
195 * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
196 * (which are both deprecated).
198 /* The following flags apply to the specific or representative lwp */
199 #define PR_STOPPED 0x00000001 /* lwp is stopped */
200 #define PR_ISTOP 0x00000002 /* lwp is stopped on an event of interest */
201 #define PR_DSTOP 0x00000004 /* lwp has a stop directive in effect */
202 #define PR_STEP 0x00000008 /* lwp has a single-step directive in effect */
203 #define PR_ASLEEP 0x00000010 /* lwp is sleeping in a system call */
204 #define PR_PCINVAL 0x00000020 /* contents of pr_instr undefined */
205 #define PR_ASLWP 0x00000040 /* obsolete flag; never set */
206 #define PR_AGENT 0x00000080 /* this lwp is the /proc agent lwp */
207 #define PR_DETACH 0x00000100 /* this is a detached lwp */
208 #define PR_DAEMON 0x00000200 /* this is a daemon lwp */
209 #define PR_IDLE 0x00000400 /* lwp is a cpu's idle thread */
210 /* The following flags apply to the process, not to an individual lwp */
211 #define PR_ISSYS 0x00001000 /* this is a system process */
212 #define PR_VFORKP 0x00002000 /* process is the parent of a vfork()d child */
213 #define PR_ORPHAN 0x00004000 /* process's process group is orphaned */
214 #define PR_NOSIGCHLD 0x00008000 /* process will not generate SIGCHLD on exit */
215 #define PR_WAITPID 0x00010000 /* only waitid(P_PID, pid) can reap the child */
216 /* The following process flags are modes settable by PCSET/PCUNSET */
217 #define PR_FORK 0x00100000 /* inherit-on-fork is in effect */
218 #define PR_RLC 0x00200000 /* run-on-last-close is in effect */
219 #define PR_KLC 0x00400000 /* kill-on-last-close is in effect */
220 #define PR_ASYNC 0x00800000 /* asynchronous-stop is in effect */
221 #define PR_MSACCT 0x01000000 /* micro-state usage accounting is in effect */
222 #define PR_BPTADJ 0x02000000 /* breakpoint trap pc adjustment is in effect */
223 #define PR_PTRACE 0x04000000 /* ptrace-compatibility mode is in effect */
224 #define PR_MSFORK 0x08000000 /* micro-state accounting inherited on fork */
227 * See <sys/procfs_isa.h> for possible values of pr_dmodel.
231 * Reasons for stopping (pr_why).
233 #define PR_REQUESTED 1
234 #define PR_SIGNALLED 2
235 #define PR_SYSENTRY 3
237 #define PR_JOBCONTROL 5
239 #define PR_SUSPENDED 7
240 #define PR_CHECKPOINT 8
243 * lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
245 #define PRFNSZ 16 /* Maximum size of execed filename */
246 typedef struct lwpsinfo
{
247 int pr_flag
; /* lwp flags (DEPRECATED; do not use) */
248 id_t pr_lwpid
; /* lwp id */
249 uintptr_t pr_addr
; /* internal address of lwp */
250 uintptr_t pr_wchan
; /* wait addr for sleeping lwp */
251 char pr_stype
; /* synchronization event type */
252 char pr_state
; /* numeric lwp state */
253 char pr_sname
; /* printable character for pr_state */
254 char pr_nice
; /* nice for cpu usage */
255 short pr_syscall
; /* system call number (if in syscall) */
256 char pr_oldpri
; /* pre-SVR4, low value is high priority */
257 char pr_cpu
; /* pre-SVR4, cpu usage for scheduling */
258 int pr_pri
; /* priority, high value is high priority */
259 /* The following percent number is a 16-bit binary */
260 /* fraction [0 .. 1] with the binary point to the */
261 /* right of the high-order bit (1.0 == 0x8000) */
262 ushort_t pr_pctcpu
; /* % of recent cpu time used by this lwp */
264 timestruc_t pr_start
; /* lwp start time, from the epoch */
265 timestruc_t pr_time
; /* usr+sys cpu time for this lwp */
266 char pr_clname
[PRCLSZ
]; /* scheduling class name */
267 char pr_name
[PRFNSZ
]; /* name of system lwp */
268 processorid_t pr_onpro
; /* processor which last ran this lwp */
269 processorid_t pr_bindpro
; /* processor to which lwp is bound */
270 psetid_t pr_bindpset
; /* processor set to which lwp is bound */
271 int pr_lgrp
; /* lwp home lgroup */
272 int pr_filler
[4]; /* reserved for future use */
276 * process ps(1) information file. /proc/<pid>/psinfo
278 #define PRARGSZ 80 /* number of chars of arguments */
279 typedef struct psinfo
{
280 int pr_flag
; /* process flags (DEPRECATED; do not use) */
281 int pr_nlwp
; /* number of active lwps in the process */
282 pid_t pr_pid
; /* unique process id */
283 pid_t pr_ppid
; /* process id of parent */
284 pid_t pr_pgid
; /* pid of process group leader */
285 pid_t pr_sid
; /* session id */
286 uid_t pr_uid
; /* real user id */
287 uid_t pr_euid
; /* effective user id */
288 gid_t pr_gid
; /* real group id */
289 gid_t pr_egid
; /* effective group id */
290 uintptr_t pr_addr
; /* address of process */
291 size_t pr_size
; /* size of process image in Kbytes */
292 size_t pr_rssize
; /* resident set size in Kbytes */
294 dev_t pr_ttydev
; /* controlling tty device (or PRNODEV) */
295 /* The following percent numbers are 16-bit binary */
296 /* fractions [0 .. 1] with the binary point to the */
297 /* right of the high-order bit (1.0 == 0x8000) */
298 ushort_t pr_pctcpu
; /* % of recent cpu time used by all lwps */
299 ushort_t pr_pctmem
; /* % of system memory used by process */
300 timestruc_t pr_start
; /* process start time, from the epoch */
301 timestruc_t pr_time
; /* usr+sys cpu time for this process */
302 timestruc_t pr_ctime
; /* usr+sys cpu time for reaped children */
303 char pr_fname
[PRFNSZ
]; /* name of execed file */
304 char pr_psargs
[PRARGSZ
]; /* initial characters of arg list */
305 int pr_wstat
; /* if zombie, the wait() status */
306 int pr_argc
; /* initial argument count */
307 uintptr_t pr_argv
; /* address of initial argument vector */
308 uintptr_t pr_envp
; /* address of initial environment vector */
309 char pr_dmodel
; /* data model of the process */
311 taskid_t pr_taskid
; /* task id */
312 projid_t pr_projid
; /* project id */
313 int pr_nzomb
; /* number of zombie lwps in the process */
314 poolid_t pr_poolid
; /* pool id */
315 zoneid_t pr_zoneid
; /* zone id */
316 id_t pr_contract
; /* process contract */
317 int pr_filler
[1]; /* reserved for future use */
318 lwpsinfo_t pr_lwp
; /* information for representative lwp */
321 #define PRNODEV (dev_t)(-1) /* non-existent device */
324 * Memory-map interface. /proc/<pid>/map /proc/<pid>/rmap
327 typedef struct prmap
{
328 uintptr_t pr_vaddr
; /* virtual address of mapping */
329 size_t pr_size
; /* size of mapping in bytes */
330 char pr_mapname
[PRMAPSZ
]; /* name in /proc/<pid>/object */
331 offset_t pr_offset
; /* offset into mapped object, if any */
332 int pr_mflags
; /* protection and attribute flags (see below) */
333 int pr_pagesize
; /* pagesize (bytes) for this mapping */
334 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
335 int pr_filler
[1]; /* filler for future expansion */
339 * HAT memory-map interface. /proc/<pid>/xmap
341 typedef struct prxmap
{
342 uintptr_t pr_vaddr
; /* virtual address of mapping */
343 size_t pr_size
; /* size of mapping in bytes */
344 char pr_mapname
[PRMAPSZ
]; /* name in /proc/<pid>/object */
345 offset_t pr_offset
; /* offset into mapped object, if any */
346 int pr_mflags
; /* protection and attribute flags (see below) */
347 int pr_pagesize
; /* pagesize (bytes) for this mapping */
348 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
349 dev_t pr_dev
; /* st_dev from stat64() of mapped object, or PRNODEV */
350 uint64_t pr_ino
; /* st_ino from stat64() of mapped object, if any */
351 size_t pr_rss
; /* pages of resident memory */
352 size_t pr_anon
; /* pages of resident anonymous memory */
353 size_t pr_locked
; /* pages of locked memory */
354 size_t pr_pad
; /* currently unused */
355 uint64_t pr_hatpagesize
; /* pagesize of the hat mapping */
357 ulong_t pr_filler
[6]; /* filler for future expansion */
359 ulong_t pr_filler
[7]; /* filler for future expansion */
364 /* Protection and attribute flags */
365 #define MA_READ 0x04 /* readable by the traced process */
366 #define MA_WRITE 0x02 /* writable by the traced process */
367 #define MA_EXEC 0x01 /* executable by the traced process */
368 #define MA_SHARED 0x08 /* changes are shared by mapped object */
369 #define MA_ANON 0x40 /* anonymous memory (e.g. /dev/zero) */
370 #define MA_ISM 0x80 /* intimate shared mem (shared MMU resources) */
371 #define MA_NORESERVE 0x100 /* mapped with MAP_NORESERVE */
372 #define MA_SHM 0x200 /* System V shared memory */
373 #define MA_RESERVED1 0x400 /* reserved for future use */
376 * These are obsolete and unreliable.
377 * They are included here only for historical compatibility.
379 #define MA_BREAK 0x10 /* grown by brk(2) */
380 #define MA_STACK 0x20 /* grown automatically on stack faults */
383 * Process credentials. PCSCRED and /proc/<pid>/cred
385 typedef struct prcred
{
386 uid_t pr_euid
; /* effective user id */
387 uid_t pr_ruid
; /* real user id */
388 uid_t pr_suid
; /* saved user id (from exec) */
389 gid_t pr_egid
; /* effective group id */
390 gid_t pr_rgid
; /* real group id */
391 gid_t pr_sgid
; /* saved group id (from exec) */
392 int pr_ngroups
; /* number of supplementary groups */
393 gid_t pr_groups
[1]; /* array of supplementary groups */
397 * Process privileges. PCSPRIV and /proc/<pid>/priv
399 typedef struct prpriv
{
400 uint32_t pr_nsets
; /* number of privilege set */
401 uint32_t pr_setsize
; /* size of privilege set */
402 uint32_t pr_infosize
; /* size of supplementary data */
403 priv_chunk_t pr_sets
[1]; /* array of sets */
406 #define PRSECFLAGS_VERSION_1 1
407 #define PRSECFLAGS_VERSION_CURRENT PRSECFLAGS_VERSION_1
408 typedef struct prsecflags
{
411 secflagset_t pr_effective
;
412 secflagset_t pr_inherit
;
413 secflagset_t pr_lower
;
414 secflagset_t pr_upper
;
418 * Watchpoint interface. PCWATCH and /proc/<pid>/watch
420 typedef struct prwatch
{
421 uintptr_t pr_vaddr
; /* virtual address of watched area */
422 size_t pr_size
; /* size of watched area in bytes */
423 int pr_wflags
; /* watch type flags */
428 #define WA_READ 0x04 /* trap on read access */
429 #define WA_WRITE 0x02 /* trap on write access */
430 #define WA_EXEC 0x01 /* trap on execute access */
431 #define WA_TRAPAFTER 0x08 /* trap after instruction completes */
434 * PCREAD/PCWRITE I/O interface.
436 typedef struct priovec
{
437 void *pio_base
; /* buffer in controlling process */
438 size_t pio_len
; /* size of read/write request */
439 off_t pio_offset
; /* virtual address in target process */
443 * Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
445 typedef struct prusage
{
446 id_t pr_lwpid
; /* lwp id. 0: process or defunct */
447 int pr_count
; /* number of contributing lwps */
448 timestruc_t pr_tstamp
; /* current time stamp */
449 timestruc_t pr_create
; /* process/lwp creation time stamp */
450 timestruc_t pr_term
; /* process/lwp termination time stamp */
451 timestruc_t pr_rtime
; /* total lwp real (elapsed) time */
452 timestruc_t pr_utime
; /* user level cpu time */
453 timestruc_t pr_stime
; /* system call cpu time */
454 timestruc_t pr_ttime
; /* other system trap cpu time */
455 timestruc_t pr_tftime
; /* text page fault sleep time */
456 timestruc_t pr_dftime
; /* data page fault sleep time */
457 timestruc_t pr_kftime
; /* kernel page fault sleep time */
458 timestruc_t pr_ltime
; /* user lock wait sleep time */
459 timestruc_t pr_slptime
; /* all other sleep time */
460 timestruc_t pr_wtime
; /* wait-cpu (latency) time */
461 timestruc_t pr_stoptime
; /* stopped time */
462 timestruc_t filltime
[6]; /* filler for future expansion */
463 ulong_t pr_minf
; /* minor page faults */
464 ulong_t pr_majf
; /* major page faults */
465 ulong_t pr_nswap
; /* swaps */
466 ulong_t pr_inblk
; /* input blocks */
467 ulong_t pr_oublk
; /* output blocks */
468 ulong_t pr_msnd
; /* messages sent */
469 ulong_t pr_mrcv
; /* messages received */
470 ulong_t pr_sigs
; /* signals received */
471 ulong_t pr_vctx
; /* voluntary context switches */
472 ulong_t pr_ictx
; /* involuntary context switches */
473 ulong_t pr_sysc
; /* system calls */
474 ulong_t pr_ioch
; /* chars read and written */
475 ulong_t filler
[10]; /* filler for future expansion */
479 * Page data file. /proc/<pid>/pagedata
482 /* page data file header */
483 typedef struct prpageheader
{
484 timestruc_t pr_tstamp
; /* real time stamp */
485 long pr_nmap
; /* number of address space mappings */
486 long pr_npage
; /* total number of pages */
489 /* page data mapping header */
490 typedef struct prasmap
{
491 uintptr_t pr_vaddr
; /* virtual address of mapping */
492 size_t pr_npage
; /* number of pages in mapping */
493 char pr_mapname
[PRMAPSZ
]; /* name in /proc/<pid>/object */
494 offset_t pr_offset
; /* offset into mapped object, if any */
495 int pr_mflags
; /* protection and attribute flags */
496 int pr_pagesize
; /* pagesize (bytes) for this mapping */
497 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
498 int pr_filler
[1]; /* filler for future expansion */
502 * pr_npage bytes (plus 0-7 null bytes to round up to an 8-byte boundary)
503 * follow each mapping header, each containing zero or more of these flags.
505 #define PG_REFERENCED 0x02 /* page referenced since last read */
506 #define PG_MODIFIED 0x01 /* page modified since last read */
507 #define PG_HWMAPPED 0x04 /* page is present and mapped */
510 * Open file information; used in core files. Note that we'd like to use
511 * the stat or stat64 structure, but both of these structures are unfortunately
512 * not consistent between 32 and 64 bit modes. To keep our lives simpler, we
513 * just define our own structure with types that are not sensitive to this
514 * difference. Also, it turns out that pfiles omits a lot of info from the
515 * struct stat (e.g. times, device sizes, etc.) so we don't bother adding those
518 typedef struct prfdinfo_core
{
525 major_t pr_major
; /* think stat.st_dev */
528 major_t pr_rmajor
; /* think stat.st_rdev */
535 int pr_fileflags
; /* fcntl(F_GETXFL), etc */
536 int pr_fdflags
; /* fcntl(F_GETFD), etc. */
538 char pr_path
[MAXPATHLEN
];
542 * Open file information; used in /proc/<pid>/fdinfo/nn files.
543 * This differs from prfdinfo_core_t above as it exposes more information
544 * and is variable length, with the last element, pr_misc, pointing to an
545 * array of miscellaneous data items.
548 typedef struct prfdinfo
{
549 int pr_fd
; /* file descriptor number */
550 mode_t pr_mode
; /* (see st_mode in stat(2)) */
551 ino64_t pr_ino
; /* inode number */
552 off64_t pr_size
; /* file size */
553 off64_t pr_offset
; /* current offset of file descriptor */
554 uid_t pr_uid
; /* owner's user id */
555 gid_t pr_gid
; /* owner's group id */
556 major_t pr_major
; /* major number of device */
557 minor_t pr_minor
; /* minor number of device */
558 major_t pr_rmajor
; /* major number (if special file) */
559 minor_t pr_rminor
; /* minor number (if special file) */
560 int pr_fileflags
; /* (see F_GETXFL in fcntl(2)) */
561 int pr_fdflags
; /* (see F_GETFD in fcntl(2)) */
562 short pr_locktype
; /* (see F_GETLK in fcntl(2)) */
563 pid_t pr_lockpid
; /* process holding file lock */
565 int pr_locksysid
; /* sysid of locking process */
567 pid_t pr_peerpid
; /* peer process (socket, door) */
568 int pr_filler
[25]; /* reserved for future use */
569 char pr_peername
[PRFNSZ
]; /* peer process name */
570 #if __STDC_VERSION__ >= 199901L
571 uint8_t pr_misc
[]; /* self describing structures */
573 uint8_t pr_misc
[1]; /* self describing structures */
577 /* pr_misc item size is rounded up to maintain alignment */
578 #define PRFDINFO_ROUNDUP(num) P2ROUNDUP((num), 4)
580 typedef struct pr_misc_header
{
586 * The gaps in this enumeration are present to maintain compatibility with
587 * the values used in Solaris. Any future illumos-specific additions to this
588 * list should use the PR_ILLUMOS_ prefix, be placed after PR_MISC_TYPES_MAX
589 * and start from a number sufficiently large enough to leave space for any
590 * future additions in Solaris.
597 PR_SOCKOPTS_BOOL_OPTS
,
601 PR_SOCKOPT_IP_NEXTHOP
,
602 PR_SOCKOPT_IPV6_NEXTHOP
,
604 PR_SOCKOPT_TCP_CONGESTION
= 11,
605 PR_SOCKFILTERS_PRIV
= 14,
609 typedef struct prsockopts_bool_opts
{
610 unsigned int prsock_bool_opts
;
611 } prsockopts_bool_opts_t
;
613 #define PR_SO_DEBUG (1 << 0)
614 #define PR_SO_REUSEADDR (1 << 1)
615 #define PR_SO_REUSEPORT (1 << 2)
616 #define PR_SO_KEEPALIVE (1 << 3)
617 #define PR_SO_DONTROUTE (1 << 4)
618 #define PR_SO_BROADCAST (1 << 5)
619 #define PR_SO_OOBINLINE (1 << 7)
620 #define PR_SO_DGRAM_ERRIND (1 << 8)
621 #define PR_SO_ALLZONES (1 << 9)
622 #define PR_SO_MAC_EXEMPT (1 << 10)
623 #define PR_SO_EXCLBIND (1 << 11)
624 #define PR_SO_PASSIVE_CONNECT (1 << 12)
625 #define PR_SO_ACCEPTCONN (1 << 13)
626 #define PR_UDP_NAT_T_ENDPOINT (1 << 14)
627 #define PR_SO_VRRP (1 << 15)
628 #define PR_SO_MAC_IMPLICIT (1 << 16)
631 * Representation of LWP name in core files. In /proc, we use a simple char
632 * array, but in core files we need to make it easy to correlate the note back
633 * to the right LWP. For simplicity, we'll use 32/64 consistent types.
635 typedef struct prlwpname
{
637 char pr_lwpname
[THREAD_NAME_MAX
];
641 * Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
643 typedef struct prheader
{
644 long pr_nent
; /* number of entries */
645 long pr_entsize
; /* size of each entry, in bytes */
649 * Macros for manipulating sets of flags.
650 * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t.
651 * flag must be a member of the enumeration corresponding to *sp.
654 /* turn on all flags in set */
655 #define prfillset(sp) \
656 { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
657 while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0xFFFFFFFF; }
659 /* turn off all flags in set */
660 #define premptyset(sp) \
661 { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
662 while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0; }
664 /* turn on specified flag in set */
665 #define praddset(sp, flag) \
666 ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
667 (((uint32_t *)(sp))[((flag)-1)/32] |= (1U<<(((flag)-1)%32))) : 0))
669 /* turn off specified flag in set */
670 #define prdelset(sp, flag) \
671 ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
672 (((uint32_t *)(sp))[((flag)-1)/32] &= ~(1U<<(((flag)-1)%32))) : 0))
674 /* query: != 0 iff flag is turned on in set */
675 #define prismember(sp, flag) \
676 (((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) && \
677 (((uint32_t *)(sp))[((flag)-1)/32] & (1U<<(((flag)-1)%32))))
680 * Core file upanic NT_UPANIC structure.
682 #define PRUPANIC_VERSION_1 1
683 #define PRUPANIC_VERSION_CURRENT PRUPANIC_VERSION_1
684 #define PRUPANIC_FLAG_MSG_VALID 0x01
685 #define PRUPANIC_FLAG_MSG_ERROR 0x02
686 #define PRUPANIC_FLAG_MSG_TRUNC 0x04
687 #define PRUPANIC_BUFLEN 1024
688 typedef struct prupanic
{
689 uint32_t pru_version
;
691 uint8_t pru_data
[PRUPANIC_BUFLEN
];
695 * Core file NT_CWD structure.
699 char prcwd_fsname
[_ST_FSTYPSZ
];
700 char prcwd_mntpt
[MAXPATHLEN
];
701 char prcwd_mntspec
[MAXPATHLEN
];
702 char prcwd_cwd
[MAXPATHLEN
];
705 #if defined(_SYSCALL32)
708 * dev32_t version of PRNODEV
710 #define PRNODEV32 (dev32_t)(-1)
713 * Kernel view of /proc structures for _ILP32 programs.
717 * _ILP32 lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
719 typedef struct lwpstatus32
{
720 int pr_flags
; /* flags */
721 id32_t pr_lwpid
; /* specific lwp identifier */
722 short pr_why
; /* reason for lwp stop, if stopped */
723 short pr_what
; /* more detailed reason */
724 short pr_cursig
; /* current signal, if any */
726 siginfo32_t pr_info
; /* info associated with signal or fault */
727 sigset_t pr_lwppend
; /* set of signals pending to the lwp */
728 sigset_t pr_lwphold
; /* set of signals blocked by the lwp */
729 struct sigaction32 pr_action
; /* signal action for current signal */
730 stack32_t pr_altstack
; /* alternate signal stack info */
731 caddr32_t pr_oldcontext
; /* address of previous ucontext */
732 short pr_syscall
; /* system call number (if in syscall) */
733 short pr_nsysarg
; /* number of arguments to this syscall */
734 int pr_errno
; /* errno for failed syscall, 0 if successful */
735 int32_t pr_sysarg
[PRSYSARGS
]; /* arguments to this syscall */
736 int32_t pr_rval1
; /* primary syscall return value */
737 int32_t pr_rval2
; /* second syscall return value, if any */
738 char pr_clname
[PRCLSZ
]; /* scheduling class name */
739 timestruc32_t pr_tstamp
; /* real-time time stamp of stop */
740 timestruc32_t pr_utime
; /* lwp user cpu time */
741 timestruc32_t pr_stime
; /* lwp system cpu time */
742 int pr_filler
[11 - 2 * sizeof (timestruc32_t
) / sizeof (int)];
743 int pr_errpriv
; /* missing privilege */
744 caddr32_t pr_ustack
; /* address of stack boundary data (stack32_t) */
745 uint32_t pr_instr
; /* current instruction */
746 prgregset32_t pr_reg
; /* general registers */
747 prfpregset32_t pr_fpreg
; /* floating-point registers */
751 * _ILP32 process status file. /proc/<pid>/status
753 typedef struct pstatus32
{
754 int pr_flags
; /* flags */
755 int pr_nlwp
; /* number of active lwps in the process */
756 pid32_t pr_pid
; /* process id */
757 pid32_t pr_ppid
; /* parent process id */
758 pid32_t pr_pgid
; /* process group id */
759 pid32_t pr_sid
; /* session id */
760 id32_t pr_aslwpid
; /* historical; now always zero */
761 id32_t pr_agentid
; /* lwp id of the /proc agent lwp, if any */
762 sigset_t pr_sigpend
; /* set of process pending signals */
763 caddr32_t pr_brkbase
; /* address of the process heap */
764 size32_t pr_brksize
; /* size of the process heap, in bytes */
765 caddr32_t pr_stkbase
; /* address of the process stack */
766 size32_t pr_stksize
; /* size of the process stack, in bytes */
767 timestruc32_t pr_utime
; /* process user cpu time */
768 timestruc32_t pr_stime
; /* process system cpu time */
769 timestruc32_t pr_cutime
; /* sum of children's user times */
770 timestruc32_t pr_cstime
; /* sum of children's system times */
771 sigset_t pr_sigtrace
; /* set of traced signals */
772 fltset_t pr_flttrace
; /* set of traced faults */
773 sysset_t pr_sysentry
; /* set of system calls traced on entry */
774 sysset_t pr_sysexit
; /* set of system calls traced on exit */
775 char pr_dmodel
; /* data model of the process */
777 id32_t pr_taskid
; /* task id */
778 id32_t pr_projid
; /* project id */
779 int pr_nzomb
; /* number of zombie lwps in the process */
780 id32_t pr_zoneid
; /* zone id */
781 int pr_filler
[15]; /* reserved for future use */
782 lwpstatus32_t pr_lwp
; /* status of the representative lwp */
786 * _ILP32 lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
788 typedef struct lwpsinfo32
{
789 int pr_flag
; /* lwp flags */
790 id32_t pr_lwpid
; /* lwp id */
791 caddr32_t pr_addr
; /* internal address of lwp */
792 caddr32_t pr_wchan
; /* wait addr for sleeping lwp */
793 char pr_stype
; /* synchronization event type */
794 char pr_state
; /* numeric lwp state */
795 char pr_sname
; /* printable character for pr_state */
796 char pr_nice
; /* nice for cpu usage */
797 short pr_syscall
; /* system call number (if in syscall) */
798 char pr_oldpri
; /* pre-SVR4, low value is high priority */
799 char pr_cpu
; /* pre-SVR4, cpu usage for scheduling */
800 int pr_pri
; /* priority, high value is high priority */
801 /* The following percent number is a 16-bit binary */
802 /* fraction [0 .. 1] with the binary point to the */
803 /* right of the high-order bit (1.0 == 0x8000) */
804 ushort_t pr_pctcpu
; /* % of recent cpu time used by this lwp */
806 timestruc32_t pr_start
; /* lwp start time, from the epoch */
807 timestruc32_t pr_time
; /* usr+sys cpu time for this lwp */
808 char pr_clname
[PRCLSZ
]; /* scheduling class name */
809 char pr_name
[PRFNSZ
]; /* name of system lwp */
810 processorid_t pr_onpro
; /* processor which last ran this lwp */
811 processorid_t pr_bindpro
; /* processor to which lwp is bound */
812 psetid_t pr_bindpset
; /* processor set to which lwp is bound */
813 int pr_lgrp
; /* lwp home lgroup */
814 int pr_filler
[4]; /* reserved for future use */
818 * _ILP32 process ps(1) information file. /proc/<pid>/psinfo
820 typedef struct psinfo32
{
821 int pr_flag
; /* process flags */
822 int pr_nlwp
; /* number of active lwps in the process */
823 pid32_t pr_pid
; /* unique process id */
824 pid32_t pr_ppid
; /* process id of parent */
825 pid32_t pr_pgid
; /* pid of process group leader */
826 pid32_t pr_sid
; /* session id */
827 uid32_t pr_uid
; /* real user id */
828 uid32_t pr_euid
; /* effective user id */
829 gid32_t pr_gid
; /* real group id */
830 gid32_t pr_egid
; /* effective group id */
831 caddr32_t pr_addr
; /* address of process */
832 size32_t pr_size
; /* size of process image in Kbytes */
833 size32_t pr_rssize
; /* resident set size in Kbytes */
835 dev32_t pr_ttydev
; /* controlling tty device (or PRNODEV) */
836 ushort_t pr_pctcpu
; /* % of recent cpu time used by all lwps */
837 ushort_t pr_pctmem
; /* % of system memory used by process */
838 timestruc32_t pr_start
; /* process start time, from the epoch */
839 timestruc32_t pr_time
; /* usr+sys cpu time for this process */
840 timestruc32_t pr_ctime
; /* usr+sys cpu time for reaped children */
841 char pr_fname
[PRFNSZ
]; /* name of execed file */
842 char pr_psargs
[PRARGSZ
]; /* initial characters of arg list */
843 int pr_wstat
; /* if zombie, the wait() status */
844 int pr_argc
; /* initial argument count */
845 caddr32_t pr_argv
; /* address of initial argument vector */
846 caddr32_t pr_envp
; /* address of initial environment vector */
847 char pr_dmodel
; /* data model of the process */
849 id32_t pr_taskid
; /* task id */
850 id32_t pr_projid
; /* project id */
851 int pr_nzomb
; /* number of zombie lwps in the process */
852 id32_t pr_poolid
; /* pool id */
853 id32_t pr_zoneid
; /* zone id */
854 id32_t pr_contract
; /* process contract */
855 int pr_filler
[1]; /* reserved for future use */
856 lwpsinfo32_t pr_lwp
; /* information for representative lwp */
860 * _ILP32 Memory-management interface. /proc/<pid>/map /proc/<pid>/rmap
862 typedef struct prmap32
{
863 caddr32_t pr_vaddr
; /* virtual address of mapping */
864 size32_t pr_size
; /* size of mapping in bytes */
865 char pr_mapname
[64]; /* name in /proc/<pid>/object */
866 offset_t pr_offset
; /* offset into mapped object, if any */
867 int pr_mflags
; /* protection and attribute flags */
868 int pr_pagesize
; /* pagesize (bytes) for this mapping */
869 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
870 int pr_filler
[1]; /* filler for future expansion */
874 * _ILP32 HAT memory-map interface. /proc/<pid>/xmap
876 typedef struct prxmap32
{
877 caddr32_t pr_vaddr
; /* virtual address of mapping */
878 size32_t pr_size
; /* size of mapping in bytes */
879 char pr_mapname
[PRMAPSZ
]; /* name in /proc/<pid>/object */
880 offset_t pr_offset
; /* offset into mapped object, if any */
881 int pr_mflags
; /* protection and attribute flags (see below) */
882 int pr_pagesize
; /* pagesize (bytes) for this mapping */
883 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
884 dev32_t pr_dev
; /* st_dev from stat64() of mapped object, or PRNODEV */
885 uint64_t pr_ino
; /* st_ino from stat64() of mapped object, if any */
886 uint32_t pr_rss
; /* pages of resident memory */
887 uint32_t pr_anon
; /* pages of resident anonymous memory */
888 uint32_t pr_locked
; /* pages of locked memory */
889 uint32_t pr_pad
; /* currently unused */
890 uint64_t pr_hatpagesize
; /* pagesize of the hat mapping */
891 uint32_t pr_filler
[6]; /* filler for future expansion */
895 * _ILP32 Process credentials. PCSCRED and /proc/<pid>/cred
897 typedef struct prcred32
{
898 uid32_t pr_euid
; /* effective user id */
899 uid32_t pr_ruid
; /* real user id */
900 uid32_t pr_suid
; /* saved user id (from exec) */
901 gid32_t pr_egid
; /* effective group id */
902 gid32_t pr_rgid
; /* real group id */
903 gid32_t pr_sgid
; /* saved group id (from exec) */
904 int pr_ngroups
; /* number of supplementary groups */
905 gid32_t pr_groups
[1]; /* array of supplementary groups */
909 * _ILP32 Watchpoint interface. PCWATCH and /proc/<pid>/watch
911 typedef struct prwatch32
{
912 caddr32_t pr_vaddr
; /* virtual address of watched area */
913 size32_t pr_size
; /* size of watched area in bytes */
914 int pr_wflags
; /* watch type flags */
919 * _ILP32 PCREAD/PCWRITE I/O interface.
921 typedef struct priovec32
{
922 caddr32_t pio_base
; /* buffer in controlling process */
923 size32_t pio_len
; /* size of read/write request */
924 off32_t pio_offset
; /* virtual address in target process */
928 * _ILP32 Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
930 typedef struct prusage32
{
931 id32_t pr_lwpid
; /* lwp id. 0: process or defunct */
932 int32_t pr_count
; /* number of contributing lwps */
933 timestruc32_t pr_tstamp
; /* current time stamp */
934 timestruc32_t pr_create
; /* process/lwp creation time stamp */
935 timestruc32_t pr_term
; /* process/lwp termination time stamp */
936 timestruc32_t pr_rtime
; /* total lwp real (elapsed) time */
937 timestruc32_t pr_utime
; /* user level cpu time */
938 timestruc32_t pr_stime
; /* system call cpu time */
939 timestruc32_t pr_ttime
; /* other system trap cpu time */
940 timestruc32_t pr_tftime
; /* text page fault sleep time */
941 timestruc32_t pr_dftime
; /* data page fault sleep time */
942 timestruc32_t pr_kftime
; /* kernel page fault sleep time */
943 timestruc32_t pr_ltime
; /* user lock wait sleep time */
944 timestruc32_t pr_slptime
; /* all other sleep time */
945 timestruc32_t pr_wtime
; /* wait-cpu (latency) time */
946 timestruc32_t pr_stoptime
; /* stopped time */
947 timestruc32_t filltime
[6]; /* filler for future expansion */
948 uint32_t pr_minf
; /* minor page faults */
949 uint32_t pr_majf
; /* major page faults */
950 uint32_t pr_nswap
; /* swaps */
951 uint32_t pr_inblk
; /* input blocks */
952 uint32_t pr_oublk
; /* output blocks */
953 uint32_t pr_msnd
; /* messages sent */
954 uint32_t pr_mrcv
; /* messages received */
955 uint32_t pr_sigs
; /* signals received */
956 uint32_t pr_vctx
; /* voluntary context switches */
957 uint32_t pr_ictx
; /* involuntary context switches */
958 uint32_t pr_sysc
; /* system calls */
959 uint32_t pr_ioch
; /* chars read and written */
960 uint32_t filler
[10]; /* filler for future expansion */
964 * _ILP32 Page data file. /proc/<pid>/pagedata
967 /* _ILP32 page data file header */
968 typedef struct prpageheader32
{
969 timestruc32_t pr_tstamp
; /* real time stamp */
970 int32_t pr_nmap
; /* number of address space mappings */
971 int32_t pr_npage
; /* total number of pages */
974 /* _ILP32 page data mapping header */
975 typedef struct prasmap32
{
976 caddr32_t pr_vaddr
; /* virtual address of mapping */
977 size32_t pr_npage
; /* number of pages in mapping */
978 char pr_mapname
[64]; /* name in /proc/<pid>/object */
979 offset_t pr_offset
; /* offset into mapped object, if any */
980 int pr_mflags
; /* protection and attribute flags */
981 int pr_pagesize
; /* pagesize (bytes) for this mapping */
982 int pr_shmid
; /* SysV shmid, -1 if not SysV shared memory */
983 int pr_filler
[1]; /* filler for future expansion */
987 * _ILP32 Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
989 typedef struct prheader32
{
990 int32_t pr_nent
; /* number of entries */
991 int32_t pr_entsize
; /* size of each entry, in bytes */
994 #endif /* _SYSCALL32 */
996 #endif /* !_KERNEL && _STRUCTURED_PROC == 0 */
1002 #endif /* _SYS_PROCFS_H */