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 char pbi_comm
[MAXCOMLEN
+ 1];
67 char pbi_name
[2*MAXCOMLEN
+ 1]; /* empty if no name is registered */
71 uint32_t e_tdev
; /* controlling tty dev */
72 uint32_t e_tpgid
; /* tty process group id */
73 struct timeval pbi_start
;
79 /* pbi_flags values */
80 #define PROC_FLAG_SYSTEM 1
81 #define PROC_FLAG_TRACED 2
82 #define PROC_FLAG_INEXIT 4
83 #define PROC_FLAG_PPWAIT 8
84 #define PROC_FLAG_LP64 0x10
85 #define PROC_FLAG_SLEADER 0x20
86 #define PROC_FLAG_CTTY 0x40
87 #define PROC_FLAG_CONTROLT 0x80
90 struct proc_taskinfo
{
91 uint64_t pti_virtual_size
; /* virtual memory size (bytes) */
92 uint64_t pti_resident_size
; /* resident memory size (bytes) */
93 uint64_t pti_total_user
; /* total time */
94 uint64_t pti_total_system
;
95 uint64_t pti_threads_user
; /* existing threads only */
96 uint64_t pti_threads_system
;
97 int32_t pti_policy
; /* default policy for new threads */
98 int32_t pti_faults
; /* number of page faults */
99 int32_t pti_pageins
; /* number of actual pageins */
100 int32_t pti_cow_faults
; /* number of copy-on-write faults */
101 int32_t pti_messages_sent
; /* number of messages sent */
102 int32_t pti_messages_received
; /* number of messages received */
103 int32_t pti_syscalls_mach
; /* number of mach system calls */
104 int32_t pti_syscalls_unix
; /* number of unix system calls */
105 int32_t pti_csw
; /* number of context switches */
106 int32_t pti_threadnum
; /* number of threads in the task */
107 int32_t pti_numrunning
; /* number of running threads */
108 int32_t pti_priority
; /* task priority*/
111 struct proc_taskallinfo
{
112 struct proc_bsdinfo pbsd
;
113 struct proc_taskinfo ptinfo
;
117 struct proc_threadinfo
{
118 uint64_t pth_user_time
; /* user run time */
119 uint64_t pth_system_time
; /* system run time */
120 int32_t pth_cpu_usage
; /* scaled cpu usage percentage */
121 int32_t pth_policy
; /* scheduling policy in effect */
122 int32_t pth_run_state
; /* run state (see below) */
123 int32_t pth_flags
; /* various flags (see below) */
124 int32_t pth_sleep_time
; /* number of seconds that thread */
125 int32_t pth_curpri
; /* cur priority*/
126 int32_t pth_priority
; /* priority*/
127 int32_t pth_maxpriority
; /* max priority*/
130 struct proc_regioninfo
{
131 uint32_t pri_protection
;
132 uint32_t pri_max_protection
;
133 uint32_t pri_inheritance
;
134 uint32_t pri_flags
; /* shared, external pager, is submap */
136 uint32_t pri_behavior
;
137 uint32_t pri_user_wired_count
;
138 uint32_t pri_user_tag
;
139 uint32_t pri_pages_resident
;
140 uint32_t pri_pages_shared_now_private
;
141 uint32_t pri_pages_swapped_out
;
142 uint32_t pri_pages_dirtied
;
143 uint32_t pri_ref_count
;
144 uint32_t pri_shadow_depth
;
145 uint32_t pri_share_mode
;
146 uint32_t pri_private_pages_resident
;
147 uint32_t pri_shared_pages_resident
;
149 uint64_t pri_address
;
154 #define PROC_REGION_SUBMAP 1
155 #define PROC_REGION_SHARED 2
161 #define SM_TRUESHARED 5
162 #define SM_PRIVATE_ALIASED 6
163 #define SM_SHARED_ALIASED 7
167 * Thread run states (state field).
170 #define TH_STATE_RUNNING 1 /* thread is running normally */
171 #define TH_STATE_STOPPED 2 /* thread is stopped */
172 #define TH_STATE_WAITING 3 /* thread is waiting normally */
173 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
175 #define TH_STATE_HALTED 5 /* thread is halted at a
179 * Thread flags (flags field).
181 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
182 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
186 struct proc_fileinfo
{
187 uint32_t fi_openflags
;
200 struct vnode_info_path
{
201 struct vnode_info vip_vi
;
202 char vip_path
[MAXPATHLEN
]; /* tail end of it */
205 struct vnode_fdinfo
{
206 struct proc_fileinfo pfi
;
207 struct vnode_info pvi
;
210 struct vnode_fdinfowithpath
{
211 struct proc_fileinfo pfi
;
212 struct vnode_info_path pvip
;
217 struct proc_regionwithpathinfo
{
218 struct proc_regioninfo prp_prinfo
;
219 struct vnode_info_path prp_vip
;
222 struct proc_vnodepathinfo
{
223 struct vnode_info_path pvi_cdir
;
224 struct vnode_info_path pvi_rdir
;
234 * IPv4 and IPv6 Sockets
241 u_int32_t i46a_pad32
[3];
242 struct in_addr i46a_addr4
;
246 int insi_fport
; /* foreign port */
247 int insi_lport
; /* local port */
248 uint64_t insi_gencnt
; /* generation count of this instance */
249 uint32_t insi_flags
; /* generic IP/datagram flags */
252 uint8_t insi_vflag
; /* ini_IPV4 or ini_IPV6 */
253 uint8_t insi_ip_ttl
; /* time to live proto */
254 /* protocol dependent part */
256 struct in4in6_addr ina_46
;
257 struct in6_addr ina_6
;
258 } insi_faddr
; /* foreign host table entry */
260 struct in4in6_addr ina_46
;
261 struct in6_addr ina_6
;
262 } insi_laddr
; /* local host table entry */
264 u_char in4_tos
; /* type of service */
278 #define TSI_T_REXMT 0 /* retransmit */
279 #define TSI_T_PERSIST 1 /* retransmit persistence */
280 #define TSI_T_KEEP 2 /* keep alive */
281 #define TSI_T_2MSL 3 /* 2*msl quiet time timer */
282 #define TSI_T_NTIMERS 4
284 #define TSI_S_CLOSED 0 /* closed */
285 #define TSI_S_LISTEN 1 /* listening for connection */
286 #define TSI_S_SYN_SENT 2 /* active, have sent syn */
287 #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */
288 #define TSI_S_ESTABLISHED 4 /* established */
289 #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */
290 #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */
291 #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */
292 #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */
293 #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */
294 #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */
295 #define TSI_S_RESERVED 11 /* pseudo state: reserved */
297 struct tcp_sockinfo
{
298 struct in_sockinfo tcpsi_ini
;
300 int tcpsi_timer
[TSI_T_NTIMERS
];
302 uint32_t tcpsi_flags
;
303 uint64_t tcpsi_tp
; /* opaque handle of TCP protocol control block */
307 * Unix Domain Sockets
312 uint64_t unsi_conn_so
; /* opaque handle of connected socket */
313 uint64_t unsi_conn_pcb
; /* opaque handle of connected protocol control block */
315 struct sockaddr_un ua_sun
;
316 char ua_dummy
[SOCK_MAXADDRLEN
];
317 } unsi_addr
; /* bound address */
319 struct sockaddr_un ua_sun
;
320 char ua_dummy
[SOCK_MAXADDRLEN
];
321 } unsi_caddr
; /* address of socket connected to */
329 uint32_t ndrvsi_if_family
;
330 uint32_t ndrvsi_if_unit
;
331 char ndrvsi_if_name
[IF_NAMESIZE
];
335 * Kernel Event Sockets
338 struct kern_event_info
{
339 uint32_t kesi_vendor_code_filter
;
340 uint32_t kesi_class_filter
;
341 uint32_t kesi_subclass_filter
;
345 * Kernel Control Sockets
348 struct kern_ctl_info
{
350 uint32_t kcsi_reg_unit
;
351 uint32_t kcsi_flags
; /* support flags */
352 uint32_t kcsi_recvbufsize
; /* request more than the default buffer size */
353 uint32_t kcsi_sendbufsize
; /* request more than the default buffer size */
355 char kcsi_name
[MAX_KCTL_NAME
]; /* unique nke identifier, provided by DTS */
360 #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */
361 #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */
362 #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */
363 #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */
364 #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */
365 #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */
366 #define SOI_S_RCVATMARK 0x0040 /* at mark on input */
367 #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */
368 #define SOI_S_NBIO 0x0100 /* non-blocking ops */
369 #define SOI_S_ASYNC 0x0200 /* async i/o notify */
370 #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */
371 #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */
372 #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
373 #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */
375 struct sockbuf_info
{
377 uint32_t sbi_hiwat
; /* SO_RCVBUF, SO_SNDBUF */
386 SOCKINFO_GENERIC
= 0,
391 SOCKINFO_KERN_EVENT
= 5,
392 SOCKINFO_KERN_CTL
= 6
396 struct stat soi_stat
;
397 uint64_t soi_so
; /* opaque handle of socket */
398 uint64_t soi_pcb
; /* opaque handle of protocol control block */
410 uint32_t soi_oobmark
;
411 struct sockbuf_info soi_rcv
;
412 struct sockbuf_info soi_snd
;
415 struct in_sockinfo pri_in
; /* SOCKINFO_IN */
416 struct tcp_sockinfo pri_tcp
; /* SOCKINFO_TCP */
417 struct un_sockinfo pri_un
; /* SOCKINFO_UN */
418 struct ndrv_info pri_ndrv
; /* SOCKINFO_NDRV */
419 struct kern_event_info pri_kern_event
; /* SOCKINFO_KERN_EVENT */
420 struct kern_ctl_info pri_kern_ctl
; /* SOCKINFO_KERN_CTL */
424 struct socket_fdinfo
{
425 struct proc_fileinfo pfi
;
426 struct socket_info psi
;
432 struct stat psem_stat
;
433 char psem_name
[MAXPATHLEN
];
437 struct proc_fileinfo pfi
;
438 struct psem_info pseminfo
;
444 struct stat pshm_stat
;
445 uint64_t pshm_mappaddr
;
446 char pshm_name
[MAXPATHLEN
];
450 struct proc_fileinfo pfi
;
451 struct pshm_info pshminfo
;
456 struct stat pipe_stat
;
457 uint64_t pipe_handle
;
458 uint64_t pipe_peerhandle
;
463 struct proc_fileinfo pfi
;
464 struct pipe_info pipeinfo
;
472 #define PROC_KQUEUE_SELECT 1
473 #define PROC_KQUEUE_SLEEP 2
475 struct kqueue_fdinfo
{
476 struct proc_fileinfo pfi
;
477 struct kqueue_info kqueueinfo
;
480 struct appletalk_info
{
481 struct stat atalk_stat
;
484 struct appletalk_fdinfo
{
485 struct proc_fileinfo pfi
;
486 struct appletalk_info appletalkinfo
;
491 /* defns of process file desc type */
492 #define PROX_FDTYPE_ATALK 0
493 #define PROX_FDTYPE_VNODE 1
494 #define PROX_FDTYPE_SOCKET 2
495 #define PROX_FDTYPE_PSHM 3
496 #define PROX_FDTYPE_PSEM 4
497 #define PROX_FDTYPE_KQUEUE 5
498 #define PROX_FDTYPE_PIPE 6
499 #define PROX_FDTYPE_FSEVENTS 7
503 uint32_t proc_fdtype
;
506 /* Falvors for proc_pidinfo() */
507 #define PROC_PIDLISTFDS 1
508 #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
510 #define PROC_PIDTASKALLINFO 2
511 #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo))
513 #define PROC_PIDTBSDINFO 3
514 #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo))
516 #define PROC_PIDTASKINFO 4
517 #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo))
519 #define PROC_PIDTHREADINFO 5
520 #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo))
522 #define PROC_PIDLISTTHREADS 6
523 #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t))
526 #define PROC_PIDREGIONINFO 7
527 #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo))
529 #define PROC_PIDREGIONPATHINFO 8
530 #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo))
532 #define PROC_PIDVNODEPATHINFO 9
533 #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo))
535 /* Flavors for proc_pidfdinfo */
537 #define PROC_PIDFDVNODEINFO 1
538 #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo))
540 #define PROC_PIDFDVNODEPATHINFO 2
541 #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath))
543 #define PROC_PIDFDSOCKETINFO 3
544 #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo))
546 #define PROC_PIDFDPSEMINFO 4
547 #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo))
549 #define PROC_PIDFDPSHMINFO 5
550 #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo))
552 #define PROC_PIDFDPIPEINFO 6
553 #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo))
555 #define PROC_PIDFDKQUEUEINFO 7
556 #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo))
558 #define PROC_PIDFDATALKINFO 8
559 #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo))
563 #ifdef XNU_KERNEL_PRIVATE
564 extern int fill_socketinfo(socket_t so
, struct socket_info
*si
);
565 extern int fill_pshminfo(struct pshmnode
* pshm
, struct pshm_info
* pinfo
);
566 extern int fill_pseminfo(struct psemnode
* psem
, struct psem_info
* pinfo
);
567 extern int fill_pipeinfo(struct pipe
* cpipe
, struct pipe_info
* pinfo
);
568 extern int fill_kqueueinfo(struct kqueue
* kq
, struct kqueue_info
* kinfo
);
569 #endif /* XNU_KERNEL_PRIVATE */
574 #endif /*_SYS_PROC_INFO_H */