2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _SYS_PROC_INFO_H
30 #define _SYS_PROC_INFO_H
32 #include <sys/cdefs.h>
33 #include <sys/param.h>
34 #include <sys/types.h>
36 #include <sys/mount.h>
37 #include <sys/socket.h>
39 #include <sys/kern_control.h>
41 #include <net/route.h>
42 #include <netinet/in.h>
43 #include <netinet/tcp.h>
48 #define PROC_ALL_PIDS 1
49 #define PROC_PGRP_ONLY 2
50 #define PROC_TTY_ONLY 3
51 #define PROC_UID_ONLY 4
52 #define PROC_RUID_ONLY 5
55 uint32_t pbi_flags
; /* 64bit; emulated etc */
66 uint32_t rfu_1
; /* reserved */
67 char pbi_comm
[MAXCOMLEN
];
68 char pbi_name
[2*MAXCOMLEN
]; /* empty if no name is registered */
72 uint32_t e_tdev
; /* controlling tty dev */
73 uint32_t e_tpgid
; /* tty process group id */
75 uint64_t pbi_start_tvsec
;
76 uint64_t pbi_start_tvusec
;
81 /* pbi_flags values */
82 #define PROC_FLAG_SYSTEM 1
83 #define PROC_FLAG_TRACED 2
84 #define PROC_FLAG_INEXIT 4
85 #define PROC_FLAG_PPWAIT 8
86 #define PROC_FLAG_LP64 0x10
87 #define PROC_FLAG_SLEADER 0x20
88 #define PROC_FLAG_CTTY 0x40
89 #define PROC_FLAG_CONTROLT 0x80
90 #define PROC_FLAG_THCWD 0x100
91 /* process control bits for resource starvation */
92 #define PROC_FLAG_PC_THROTTLE 0x200
93 #define PROC_FLAG_PC_SUSP 0x400
94 #define PROC_FLAG_PC_KILL 0x600
95 #define PROC_FLAG_PC_MASK 0x600
96 /* process action bits for resource starvation */
97 #define PROC_FLAG_PA_THROTTLE 0x800
98 #define PROC_FLAG_PA_SUSP 0x1000
101 struct proc_taskinfo
{
102 uint64_t pti_virtual_size
; /* virtual memory size (bytes) */
103 uint64_t pti_resident_size
; /* resident memory size (bytes) */
104 uint64_t pti_total_user
; /* total time */
105 uint64_t pti_total_system
;
106 uint64_t pti_threads_user
; /* existing threads only */
107 uint64_t pti_threads_system
;
108 int32_t pti_policy
; /* default policy for new threads */
109 int32_t pti_faults
; /* number of page faults */
110 int32_t pti_pageins
; /* number of actual pageins */
111 int32_t pti_cow_faults
; /* number of copy-on-write faults */
112 int32_t pti_messages_sent
; /* number of messages sent */
113 int32_t pti_messages_received
; /* number of messages received */
114 int32_t pti_syscalls_mach
; /* number of mach system calls */
115 int32_t pti_syscalls_unix
; /* number of unix system calls */
116 int32_t pti_csw
; /* number of context switches */
117 int32_t pti_threadnum
; /* number of threads in the task */
118 int32_t pti_numrunning
; /* number of running threads */
119 int32_t pti_priority
; /* task priority*/
122 struct proc_taskallinfo
{
123 struct proc_bsdinfo pbsd
;
124 struct proc_taskinfo ptinfo
;
127 #define MAXTHREADNAMESIZE 64
129 struct proc_threadinfo
{
130 uint64_t pth_user_time
; /* user run time */
131 uint64_t pth_system_time
; /* system run time */
132 int32_t pth_cpu_usage
; /* scaled cpu usage percentage */
133 int32_t pth_policy
; /* scheduling policy in effect */
134 int32_t pth_run_state
; /* run state (see below) */
135 int32_t pth_flags
; /* various flags (see below) */
136 int32_t pth_sleep_time
; /* number of seconds that thread */
137 int32_t pth_curpri
; /* cur priority*/
138 int32_t pth_priority
; /* priority*/
139 int32_t pth_maxpriority
; /* max priority*/
140 char pth_name
[MAXTHREADNAMESIZE
]; /* thread name, if any */
143 struct proc_regioninfo
{
144 uint32_t pri_protection
;
145 uint32_t pri_max_protection
;
146 uint32_t pri_inheritance
;
147 uint32_t pri_flags
; /* shared, external pager, is submap */
149 uint32_t pri_behavior
;
150 uint32_t pri_user_wired_count
;
151 uint32_t pri_user_tag
;
152 uint32_t pri_pages_resident
;
153 uint32_t pri_pages_shared_now_private
;
154 uint32_t pri_pages_swapped_out
;
155 uint32_t pri_pages_dirtied
;
156 uint32_t pri_ref_count
;
157 uint32_t pri_shadow_depth
;
158 uint32_t pri_share_mode
;
159 uint32_t pri_private_pages_resident
;
160 uint32_t pri_shared_pages_resident
;
163 uint64_t pri_address
;
167 #define PROC_REGION_SUBMAP 1
168 #define PROC_REGION_SHARED 2
174 #define SM_TRUESHARED 5
175 #define SM_PRIVATE_ALIASED 6
176 #define SM_SHARED_ALIASED 7
180 * Thread run states (state field).
183 #define TH_STATE_RUNNING 1 /* thread is running normally */
184 #define TH_STATE_STOPPED 2 /* thread is stopped */
185 #define TH_STATE_WAITING 3 /* thread is waiting normally */
186 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
188 #define TH_STATE_HALTED 5 /* thread is halted at a
192 * Thread flags (flags field).
194 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
195 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
198 struct proc_workqueueinfo
{
199 uint32_t pwq_nthreads
; /* total number of workqueue threads */
200 uint32_t pwq_runthreads
; /* total number of running workqueue threads */
201 uint32_t pwq_blockedthreads
; /* total number of blocked workqueue threads */
202 uint32_t reserved
[1]; /* reserved for future use */
205 struct proc_fileinfo
{
206 uint32_t fi_openflags
;
210 int32_t rfu_1
; /* reserved */
213 /* stats flags in proc_fileinfo */
214 #define PROC_FP_SHARED 1 /* shared by more than one fd */
215 #define PROC_FP_CLEXEC 2 /* close on exec */
218 * A copy of stat64 with static sized fields.
221 uint32_t vst_dev
; /* [XSI] ID of device containing file */
222 uint16_t vst_mode
; /* [XSI] Mode of file (see below) */
223 uint16_t vst_nlink
; /* [XSI] Number of hard links */
224 uint64_t vst_ino
; /* [XSI] File serial number */
225 uid_t vst_uid
; /* [XSI] User ID of the file */
226 gid_t vst_gid
; /* [XSI] Group ID of the file */
227 int64_t vst_atime
; /* [XSI] Time of last access */
228 int64_t vst_atimensec
; /* nsec of last access */
229 int64_t vst_mtime
; /* [XSI] Last data modification time */
230 int64_t vst_mtimensec
; /* last data modification nsec */
231 int64_t vst_ctime
; /* [XSI] Time of last status change */
232 int64_t vst_ctimensec
; /* nsec of last status change */
233 int64_t vst_birthtime
; /* File creation time(birth) */
234 int64_t vst_birthtimensec
; /* nsec of File creation time */
235 off_t vst_size
; /* [XSI] file size, in bytes */
236 int64_t vst_blocks
; /* [XSI] blocks allocated for file */
237 int32_t vst_blksize
; /* [XSI] optimal blocksize for I/O */
238 uint32_t vst_flags
; /* user defined flags for file */
239 uint32_t vst_gen
; /* file generation number */
240 uint32_t vst_rdev
; /* [XSI] Device ID */
241 int64_t vst_qspare
[2]; /* RESERVED: DO NOT USE! */
245 struct vinfo_stat vi_stat
;
251 struct vnode_info_path
{
252 struct vnode_info vip_vi
;
253 char vip_path
[MAXPATHLEN
]; /* tail end of it */
256 struct vnode_fdinfo
{
257 struct proc_fileinfo pfi
;
258 struct vnode_info pvi
;
261 struct vnode_fdinfowithpath
{
262 struct proc_fileinfo pfi
;
263 struct vnode_info_path pvip
;
266 struct proc_regionwithpathinfo
{
267 struct proc_regioninfo prp_prinfo
;
268 struct vnode_info_path prp_vip
;
271 struct proc_vnodepathinfo
{
272 struct vnode_info_path pvi_cdir
;
273 struct vnode_info_path pvi_rdir
;
276 struct proc_threadwithpathinfo
{
277 struct proc_threadinfo pt
;
278 struct vnode_info_path pvip
;
287 * IPv4 and IPv6 Sockets
294 u_int32_t i46a_pad32
[3];
295 struct in_addr i46a_addr4
;
299 int insi_fport
; /* foreign port */
300 int insi_lport
; /* local port */
301 uint64_t insi_gencnt
; /* generation count of this instance */
302 uint32_t insi_flags
; /* generic IP/datagram flags */
305 uint8_t insi_vflag
; /* ini_IPV4 or ini_IPV6 */
306 uint8_t insi_ip_ttl
; /* time to live proto */
307 uint32_t rfu_1
; /* reserved */
308 /* protocol dependent part */
310 struct in4in6_addr ina_46
;
311 struct in6_addr ina_6
;
312 } insi_faddr
; /* foreign host table entry */
314 struct in4in6_addr ina_46
;
315 struct in6_addr ina_6
;
316 } insi_laddr
; /* local host table entry */
318 u_char in4_tos
; /* type of service */
332 #define TSI_T_REXMT 0 /* retransmit */
333 #define TSI_T_PERSIST 1 /* retransmit persistence */
334 #define TSI_T_KEEP 2 /* keep alive */
335 #define TSI_T_2MSL 3 /* 2*msl quiet time timer */
336 #define TSI_T_NTIMERS 4
338 #define TSI_S_CLOSED 0 /* closed */
339 #define TSI_S_LISTEN 1 /* listening for connection */
340 #define TSI_S_SYN_SENT 2 /* active, have sent syn */
341 #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */
342 #define TSI_S_ESTABLISHED 4 /* established */
343 #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */
344 #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */
345 #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */
346 #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */
347 #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */
348 #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */
349 #define TSI_S_RESERVED 11 /* pseudo state: reserved */
351 struct tcp_sockinfo
{
352 struct in_sockinfo tcpsi_ini
;
354 int tcpsi_timer
[TSI_T_NTIMERS
];
356 uint32_t tcpsi_flags
;
357 uint32_t rfu_1
; /* reserved */
358 uint64_t tcpsi_tp
; /* opaque handle of TCP protocol control block */
362 * Unix Domain Sockets
367 uint64_t unsi_conn_so
; /* opaque handle of connected socket */
368 uint64_t unsi_conn_pcb
; /* opaque handle of connected protocol control block */
370 struct sockaddr_un ua_sun
;
371 char ua_dummy
[SOCK_MAXADDRLEN
];
372 } unsi_addr
; /* bound address */
374 struct sockaddr_un ua_sun
;
375 char ua_dummy
[SOCK_MAXADDRLEN
];
376 } unsi_caddr
; /* address of socket connected to */
384 uint32_t ndrvsi_if_family
;
385 uint32_t ndrvsi_if_unit
;
386 char ndrvsi_if_name
[IF_NAMESIZE
];
390 * Kernel Event Sockets
393 struct kern_event_info
{
394 uint32_t kesi_vendor_code_filter
;
395 uint32_t kesi_class_filter
;
396 uint32_t kesi_subclass_filter
;
400 * Kernel Control Sockets
403 struct kern_ctl_info
{
405 uint32_t kcsi_reg_unit
;
406 uint32_t kcsi_flags
; /* support flags */
407 uint32_t kcsi_recvbufsize
; /* request more than the default buffer size */
408 uint32_t kcsi_sendbufsize
; /* request more than the default buffer size */
410 char kcsi_name
[MAX_KCTL_NAME
]; /* unique nke identifier, provided by DTS */
415 #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */
416 #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */
417 #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */
418 #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */
419 #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */
420 #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */
421 #define SOI_S_RCVATMARK 0x0040 /* at mark on input */
422 #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */
423 #define SOI_S_NBIO 0x0100 /* non-blocking ops */
424 #define SOI_S_ASYNC 0x0200 /* async i/o notify */
425 #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */
426 #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */
427 #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
428 #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */
430 struct sockbuf_info
{
432 uint32_t sbi_hiwat
; /* SO_RCVBUF, SO_SNDBUF */
441 SOCKINFO_GENERIC
= 0,
446 SOCKINFO_KERN_EVENT
= 5,
447 SOCKINFO_KERN_CTL
= 6
451 struct vinfo_stat soi_stat
;
452 uint64_t soi_so
; /* opaque handle of socket */
453 uint64_t soi_pcb
; /* opaque handle of protocol control block */
465 uint32_t soi_oobmark
;
466 struct sockbuf_info soi_rcv
;
467 struct sockbuf_info soi_snd
;
469 uint32_t rfu_1
; /* reserved */
471 struct in_sockinfo pri_in
; /* SOCKINFO_IN */
472 struct tcp_sockinfo pri_tcp
; /* SOCKINFO_TCP */
473 struct un_sockinfo pri_un
; /* SOCKINFO_UN */
474 struct ndrv_info pri_ndrv
; /* SOCKINFO_NDRV */
475 struct kern_event_info pri_kern_event
; /* SOCKINFO_KERN_EVENT */
476 struct kern_ctl_info pri_kern_ctl
; /* SOCKINFO_KERN_CTL */
480 struct socket_fdinfo
{
481 struct proc_fileinfo pfi
;
482 struct socket_info psi
;
488 struct vinfo_stat psem_stat
;
489 char psem_name
[MAXPATHLEN
];
493 struct proc_fileinfo pfi
;
494 struct psem_info pseminfo
;
500 struct vinfo_stat pshm_stat
;
501 uint64_t pshm_mappaddr
;
502 char pshm_name
[MAXPATHLEN
];
506 struct proc_fileinfo pfi
;
507 struct pshm_info pshminfo
;
512 struct vinfo_stat pipe_stat
;
513 uint64_t pipe_handle
;
514 uint64_t pipe_peerhandle
;
516 int rfu_1
; /* reserved */
520 struct proc_fileinfo pfi
;
521 struct pipe_info pipeinfo
;
526 struct vinfo_stat kq_stat
;
528 uint32_t rfu_1
; /* reserved */
530 #define PROC_KQUEUE_SELECT 1
531 #define PROC_KQUEUE_SLEEP 2
533 struct kqueue_fdinfo
{
534 struct proc_fileinfo pfi
;
535 struct kqueue_info kqueueinfo
;
538 struct appletalk_info
{
539 struct vinfo_stat atalk_stat
;
542 struct appletalk_fdinfo
{
543 struct proc_fileinfo pfi
;
544 struct appletalk_info appletalkinfo
;
549 /* defns of process file desc type */
550 #define PROX_FDTYPE_ATALK 0
551 #define PROX_FDTYPE_VNODE 1
552 #define PROX_FDTYPE_SOCKET 2
553 #define PROX_FDTYPE_PSHM 3
554 #define PROX_FDTYPE_PSEM 4
555 #define PROX_FDTYPE_KQUEUE 5
556 #define PROX_FDTYPE_PIPE 6
557 #define PROX_FDTYPE_FSEVENTS 7
561 uint32_t proc_fdtype
;
564 /* Flavors for proc_pidinfo() */
565 #define PROC_PIDLISTFDS 1
566 #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
568 #define PROC_PIDTASKALLINFO 2
569 #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo))
571 #define PROC_PIDTBSDINFO 3
572 #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo))
574 #define PROC_PIDTASKINFO 4
575 #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo))
577 #define PROC_PIDTHREADINFO 5
578 #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo))
580 #define PROC_PIDLISTTHREADS 6
581 #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t))
584 #define PROC_PIDREGIONINFO 7
585 #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo))
587 #define PROC_PIDREGIONPATHINFO 8
588 #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo))
590 #define PROC_PIDVNODEPATHINFO 9
591 #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo))
593 #define PROC_PIDTHREADPATHINFO 10
594 #define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo))
596 #define PROC_PIDPATHINFO 11
597 #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN)
598 #define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN)
600 #define PROC_PIDWORKQUEUEINFO 12
601 #define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo))
603 /* Flavors for proc_pidfdinfo */
605 #define PROC_PIDFDVNODEINFO 1
606 #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo))
608 #define PROC_PIDFDVNODEPATHINFO 2
609 #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath))
611 #define PROC_PIDFDSOCKETINFO 3
612 #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo))
614 #define PROC_PIDFDPSEMINFO 4
615 #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo))
617 #define PROC_PIDFDPSHMINFO 5
618 #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo))
620 #define PROC_PIDFDPIPEINFO 6
621 #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo))
623 #define PROC_PIDFDKQUEUEINFO 7
624 #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo))
626 #define PROC_PIDFDATALKINFO 8
627 #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo))
629 /* used for proc_setcontrol */
630 #define PROC_SELFSET_PCONTROL 1
632 #ifdef XNU_KERNEL_PRIVATE
645 extern int fill_socketinfo(socket_t so
, struct socket_info
*si
);
646 extern int fill_pshminfo(struct pshmnode
* pshm
, struct pshm_info
* pinfo
);
647 extern int fill_pseminfo(struct psemnode
* psem
, struct psem_info
* pinfo
);
648 extern int fill_pipeinfo(struct pipe
* cpipe
, struct pipe_info
* pinfo
);
649 extern int fill_kqueueinfo(struct kqueue
* kq
, struct kqueue_info
* kinfo
);
650 extern int fill_procworkqueue(proc_t
, struct proc_workqueueinfo
*);
651 #endif /* XNU_KERNEL_PRIVATE */
655 #endif /*_SYS_PROC_INFO_H */