]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/proc_info.h
xnu-792.10.96.tar.gz
[apple/xnu.git] / bsd / sys / proc_info.h
CommitLineData
c0fea474
A
1/*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _SYS_PROC_INFO_H
24#define _SYS_PROC_INFO_H
25
26#include <sys/cdefs.h>
27#include <sys/param.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <sys/mount.h>
31#include <sys/socket.h>
32#include <sys/un.h>
33#include <sys/kern_control.h>
34#include <net/if.h>
35#include <net/route.h>
36#include <netinet/in.h>
37#include <netinet/tcp.h>
38
39__BEGIN_DECLS
40
41
42#define PROC_ALL_PIDS 1
43#define PROC_PGRP_ONLY 2
44#define PROC_TTY_ONLY 3
45#define PROC_UID_ONLY 4
46#define PROC_RUID_ONLY 5
47
48struct proc_bsdinfo {
49 uint32_t pbi_flags; /* 64bit; emulated etc */
50 uint32_t pbi_status;
51 uint32_t pbi_xstatus;
52 uint32_t pbi_pid;
53 uint32_t pbi_ppid;
54 uid_t pbi_uid;
55 gid_t pbi_gid;
56 uid_t pbi_ruid;
57 gid_t pbi_rgid;
58 uid_t pbi_svuid;
59 gid_t pbi_svgid;
60 char pbi_comm[MAXCOMLEN + 1];
61 char pbi_name[2*MAXCOMLEN + 1]; /* empty if no name is registered */
62 uint32_t pbi_nfiles;
63 uint32_t pbi_pgid;
64 uint32_t pbi_pjobc;
65 uint32_t e_tdev; /* controlling tty dev */
66 uint32_t e_tpgid; /* tty process group id */
67 struct timeval pbi_start;
68 int32_t pbi_nice;
69};
70
71
72
73/* pbi_flags values */
74#define PROC_FLAG_SYSTEM 1
75#define PROC_FLAG_TRACED 2
76#define PROC_FLAG_INEXIT 4
77#define PROC_FLAG_PPWAIT 8
78#define PROC_FLAG_LP64 0x10
79#define PROC_FLAG_SLEADER 0x20
80#define PROC_FLAG_CTTY 0x40
81#define PROC_FLAG_CONTROLT 0x80
82
83
84struct proc_taskinfo {
85 uint64_t pti_virtual_size; /* virtual memory size (bytes) */
86 uint64_t pti_resident_size; /* resident memory size (bytes) */
87 uint64_t pti_total_user; /* total time */
88 uint64_t pti_total_system;
89 uint64_t pti_threads_user; /* existing threads only */
90 uint64_t pti_threads_system;
91 int32_t pti_policy; /* default policy for new threads */
92 int32_t pti_faults; /* number of page faults */
93 int32_t pti_pageins; /* number of actual pageins */
94 int32_t pti_cow_faults; /* number of copy-on-write faults */
95 int32_t pti_messages_sent; /* number of messages sent */
96 int32_t pti_messages_received; /* number of messages received */
97 int32_t pti_syscalls_mach; /* number of mach system calls */
98 int32_t pti_syscalls_unix; /* number of unix system calls */
99 int32_t pti_csw; /* number of context switches */
100 int32_t pti_threadnum; /* number of threads in the task */
101 int32_t pti_numrunning; /* number of running threads */
102 int32_t pti_priority; /* task priority*/
103};
104
105struct proc_taskallinfo {
106 struct proc_bsdinfo pbsd;
107 struct proc_taskinfo ptinfo;
108};
109
110
111struct proc_threadinfo {
112 uint64_t pth_user_time; /* user run time */
113 uint64_t pth_system_time; /* system run time */
114 int32_t pth_cpu_usage; /* scaled cpu usage percentage */
115 int32_t pth_policy; /* scheduling policy in effect */
116 int32_t pth_run_state; /* run state (see below) */
117 int32_t pth_flags; /* various flags (see below) */
118 int32_t pth_sleep_time; /* number of seconds that thread */
119 int32_t pth_curpri; /* cur priority*/
120 int32_t pth_priority; /* priority*/
121 int32_t pth_maxpriority; /* max priority*/
122};
123
124struct proc_regioninfo {
125 uint32_t pri_protection;
126 uint32_t pri_max_protection;
127 uint32_t pri_inheritance;
128 uint32_t pri_flags; /* shared, external pager, is submap */
129 uint64_t pri_offset;
130 uint32_t pri_behavior;
131 uint32_t pri_user_wired_count;
132 uint32_t pri_user_tag;
133 uint32_t pri_pages_resident;
134 uint32_t pri_pages_shared_now_private;
135 uint32_t pri_pages_swapped_out;
136 uint32_t pri_pages_dirtied;
137 uint32_t pri_ref_count;
138 uint32_t pri_shadow_depth;
139 uint32_t pri_share_mode;
140 uint32_t pri_private_pages_resident;
141 uint32_t pri_shared_pages_resident;
142 uint32_t pri_obj_id;
143 uint64_t pri_address;
144 uint64_t pri_size;
145 uint32_t pri_depth;
146};
147
148#define PROC_REGION_SUBMAP 1
149#define PROC_REGION_SHARED 2
150
151#define SM_COW 1
152#define SM_PRIVATE 2
153#define SM_EMPTY 3
154#define SM_SHARED 4
155#define SM_TRUESHARED 5
156#define SM_PRIVATE_ALIASED 6
157#define SM_SHARED_ALIASED 7
158
159
160/*
161 * Thread run states (state field).
162 */
163
164#define TH_STATE_RUNNING 1 /* thread is running normally */
165#define TH_STATE_STOPPED 2 /* thread is stopped */
166#define TH_STATE_WAITING 3 /* thread is waiting normally */
167#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
168 wait */
169#define TH_STATE_HALTED 5 /* thread is halted at a
170 clean point */
171
172/*
173 * Thread flags (flags field).
174 */
175#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
176#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
177
178
179
180struct proc_fileinfo {
181 uint32_t fi_openflags;
182 uint32_t fi_status;
183 off_t fi_offset;
184 int32_t fi_type;
185};
186
187
188struct vnode_info {
189 struct stat vi_stat;
190 int vi_type;
191 fsid_t vi_fsid;
192};
193
194struct vnode_info_path {
195 struct vnode_info vip_vi;
196 char vip_path[MAXPATHLEN]; /* tail end of it */
197};
198
199struct vnode_fdinfo {
200 struct proc_fileinfo pfi;
201 struct vnode_info pvi;
202};
203
204struct vnode_fdinfowithpath {
205 struct proc_fileinfo pfi;
206 struct vnode_info_path pvip;
207
208};
209
210
211struct proc_regionwithpathinfo {
212 struct proc_regioninfo prp_prinfo;
213 struct vnode_info_path prp_vip;
214};
215
216struct proc_vnodepathinfo {
217 struct vnode_info_path pvi_cdir;
218 struct vnode_info_path pvi_rdir;
219};
220
221
222/*
223 * Socket
224 */
225
226
227/*
228 * IPv4 and IPv6 Sockets
229 */
230
231#define INI_IPV4 0x1
232#define INI_IPV6 0x2
233
234struct in4in6_addr {
235 u_int32_t i46a_pad32[3];
236 struct in_addr i46a_addr4;
237};
238
239struct in_sockinfo {
240 int insi_fport; /* foreign port */
241 int insi_lport; /* local port */
242 uint64_t insi_gencnt; /* generation count of this instance */
243 uint32_t insi_flags; /* generic IP/datagram flags */
244 uint32_t insi_flow;
245
246 uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */
247 uint8_t insi_ip_ttl; /* time to live proto */
248 /* protocol dependent part */
249 union {
250 struct in4in6_addr ina_46;
251 struct in6_addr ina_6;
252 } insi_faddr; /* foreign host table entry */
253 union {
254 struct in4in6_addr ina_46;
255 struct in6_addr ina_6;
256 } insi_laddr; /* local host table entry */
257 struct {
258 u_char in4_tos; /* type of service */
259 } insi_v4;
260 struct {
261 uint8_t in6_hlim;
262 int in6_cksum;
263 u_short in6_ifindex;
264 short in6_hops;
265 } insi_v6;
266};
267
268/*
269 * TCP Sockets
270 */
271
272#define TSI_T_REXMT 0 /* retransmit */
273#define TSI_T_PERSIST 1 /* retransmit persistence */
274#define TSI_T_KEEP 2 /* keep alive */
275#define TSI_T_2MSL 3 /* 2*msl quiet time timer */
276#define TSI_T_NTIMERS 4
277
278#define TSI_S_CLOSED 0 /* closed */
279#define TSI_S_LISTEN 1 /* listening for connection */
280#define TSI_S_SYN_SENT 2 /* active, have sent syn */
281#define TSI_S_SYN_RECEIVED 3 /* have send and received syn */
282#define TSI_S_ESTABLISHED 4 /* established */
283#define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */
284#define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */
285#define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */
286#define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */
287#define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */
288#define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */
289#define TSI_S_RESERVED 11 /* pseudo state: reserved */
290
291struct tcp_sockinfo {
292 struct in_sockinfo tcpsi_ini;
293 int tcpsi_state;
294 int tcpsi_timer[TSI_T_NTIMERS];
295 int tcpsi_mss;
296 uint32_t tcpsi_flags;
297 uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */
298};
299
300/*
301 * Unix Domain Sockets
302 */
303
304
305struct un_sockinfo {
306 uint64_t unsi_conn_so; /* opaque handle of connected socket */
307 uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */
308 union {
309 struct sockaddr_un ua_sun;
310 char ua_dummy[SOCK_MAXADDRLEN];
311 } unsi_addr; /* bound address */
312 union {
313 struct sockaddr_un ua_sun;
314 char ua_dummy[SOCK_MAXADDRLEN];
315 } unsi_caddr; /* address of socket connected to */
316};
317
318/*
319 * PF_NDRV Sockets
320 */
321
322struct ndrv_info {
323 uint32_t ndrvsi_if_family;
324 uint32_t ndrvsi_if_unit;
325 char ndrvsi_if_name[IF_NAMESIZE];
326};
327
328/*
329 * Kernel Event Sockets
330 */
331
332struct kern_event_info {
333 uint32_t kesi_vendor_code_filter;
334 uint32_t kesi_class_filter;
335 uint32_t kesi_subclass_filter;
336};
337
338/*
339 * Kernel Control Sockets
340 */
341
342struct kern_ctl_info {
343 uint32_t kcsi_id;
344 uint32_t kcsi_reg_unit;
345 uint32_t kcsi_flags; /* support flags */
346 uint32_t kcsi_recvbufsize; /* request more than the default buffer size */
347 uint32_t kcsi_sendbufsize; /* request more than the default buffer size */
348 uint32_t kcsi_unit;
349 char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */
350};
351
352/* soi_state */
353
354#define SOI_S_NOFDREF 0x0001 /* no file table ref any more */
355#define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */
356#define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */
357#define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */
358#define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */
359#define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */
360#define SOI_S_RCVATMARK 0x0040 /* at mark on input */
361#define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */
362#define SOI_S_NBIO 0x0100 /* non-blocking ops */
363#define SOI_S_ASYNC 0x0200 /* async i/o notify */
364#define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */
365#define SOI_S_COMP 0x1000 /* unaccepted, complete connection */
366#define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
367#define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */
368
369struct sockbuf_info {
370 uint32_t sbi_cc;
371 uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */
372 uint32_t sbi_mbcnt;
373 uint32_t sbi_mbmax;
374 uint32_t sbi_lowat;
375 short sbi_flags;
376 short sbi_timeo;
377};
378
379enum {
380 SOCKINFO_GENERIC = 0,
381 SOCKINFO_IN = 1,
382 SOCKINFO_TCP = 2,
383 SOCKINFO_UN = 3,
384 SOCKINFO_NDRV = 4,
385 SOCKINFO_KERN_EVENT = 5,
386 SOCKINFO_KERN_CTL = 6
387};
388
389struct socket_info {
390 struct stat soi_stat;
391 uint64_t soi_so; /* opaque handle of socket */
392 uint64_t soi_pcb; /* opaque handle of protocol control block */
393 int soi_type;
394 int soi_protocol;
395 int soi_family;
396 short soi_options;
397 short soi_linger;
398 short soi_state;
399 short soi_qlen;
400 short soi_incqlen;
401 short soi_qlimit;
402 short soi_timeo;
403 u_short soi_error;
404 uint32_t soi_oobmark;
405 struct sockbuf_info soi_rcv;
406 struct sockbuf_info soi_snd;
407 int soi_kind;
408 union {
409 struct in_sockinfo pri_in; /* SOCKINFO_IN */
410 struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */
411 struct un_sockinfo pri_un; /* SOCKINFO_UN */
412 struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */
413 struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */
414 struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */
415 } soi_proto;
416};
417
418struct socket_fdinfo {
419 struct proc_fileinfo pfi;
420 struct socket_info psi;
421};
422
423
424
425struct psem_info {
426 struct stat psem_stat;
427 char psem_name[MAXPATHLEN];
428};
429
430struct psem_fdinfo {
431 struct proc_fileinfo pfi;
432 struct psem_info pseminfo;
433};
434
435
436
437struct pshm_info {
438 struct stat pshm_stat;
439 uint64_t pshm_mappaddr;
440 char pshm_name[MAXPATHLEN];
441};
442
443struct pshm_fdinfo {
444 struct proc_fileinfo pfi;
445 struct pshm_info pshminfo;
446};
447
448
449struct pipe_info {
450 struct stat pipe_stat;
451 uint64_t pipe_handle;
452 uint64_t pipe_peerhandle;
453 int pipe_status;
454};
455
456struct pipe_fdinfo {
457 struct proc_fileinfo pfi;
458 struct pipe_info pipeinfo;
459};
460
461
462struct kqueue_info {
463 struct stat kq_stat;
464 uint32_t kq_state;
465};
466#define PROC_KQUEUE_SELECT 1
467#define PROC_KQUEUE_SLEEP 2
468
469struct kqueue_fdinfo {
470 struct proc_fileinfo pfi;
471 struct kqueue_info kqueueinfo;
472};
473
474struct appletalk_info {
475 struct stat atalk_stat;
476};
477
478struct appletalk_fdinfo {
479 struct proc_fileinfo pfi;
480 struct appletalk_info appletalkinfo;
481};
482
483
484
485/* defns of process file desc type */
486#define PROX_FDTYPE_ATALK 0
487#define PROX_FDTYPE_VNODE 1
488#define PROX_FDTYPE_SOCKET 2
489#define PROX_FDTYPE_PSHM 3
490#define PROX_FDTYPE_PSEM 4
491#define PROX_FDTYPE_KQUEUE 5
492#define PROX_FDTYPE_PIPE 6
493#define PROX_FDTYPE_FSEVENTS 7
494
495struct proc_fdinfo {
496 int32_t proc_fd;
497 uint32_t proc_fdtype;
498};
499
500/* Falvors for proc_pidinfo() */
501#define PROC_PIDLISTFDS 1
502#define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
503
504#define PROC_PIDTASKALLINFO 2
505#define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo))
506
507#define PROC_PIDTBSDINFO 3
508#define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo))
509
510#define PROC_PIDTASKINFO 4
511#define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo))
512
513#define PROC_PIDTHREADINFO 5
514#define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo))
515
516#define PROC_PIDLISTTHREADS 6
517#define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t))
518
519
520#define PROC_PIDREGIONINFO 7
521#define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo))
522
523#define PROC_PIDREGIONPATHINFO 8
524#define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo))
525
526#define PROC_PIDVNODEPATHINFO 9
527#define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo))
528
529/* Flavors for proc_pidfdinfo */
530
531#define PROC_PIDFDVNODEINFO 1
532#define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo))
533
534#define PROC_PIDFDVNODEPATHINFO 2
535#define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath))
536
537#define PROC_PIDFDSOCKETINFO 3
538#define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo))
539
540#define PROC_PIDFDPSEMINFO 4
541#define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo))
542
543#define PROC_PIDFDPSHMINFO 5
544#define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo))
545
546#define PROC_PIDFDPIPEINFO 6
547#define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo))
548
549#define PROC_PIDFDKQUEUEINFO 7
550#define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo))
551
552#define PROC_PIDFDATALKINFO 8
553#define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo))
554
555
556
557#ifdef XNU_KERNEL_PRIVATE
558extern int fill_socketinfo(socket_t so, struct socket_info *si);
559extern int fill_pshminfo(struct pshmnode * pshm, struct pshm_info * pinfo);
560extern int fill_pseminfo(struct psemnode * psem, struct psem_info * pinfo);
561extern int fill_pipeinfo(struct pipe * cpipe, struct pipe_info * pinfo);
562extern int fill_kqueueinfo(struct kqueue * kq, struct kqueue_info * kinfo);
563#endif /* XNU_KERNEL_PRIVATE */
564
565
566__END_DECLS
567
568#endif /*_SYS_PROC_INFO_H */