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