]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/proc_info.h
xnu-3248.30.4.tar.gz
[apple/xnu.git] / bsd / sys / proc_info.h
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_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 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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef _SYS_PROC_INFO_H
30 #define _SYS_PROC_INFO_H
31
32 #include <sys/cdefs.h>
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <sys/mount.h>
37 #include <sys/socket.h>
38 #include <sys/un.h>
39 #include <sys/kern_control.h>
40 #include <sys/event.h>
41 #include <net/if.h>
42 #include <net/route.h>
43 #include <netinet/in.h>
44 #include <netinet/tcp.h>
45 #include <mach/machine.h>
46
47 #ifdef PRIVATE
48 #include <mach/coalition.h> /* COALITION_NUM_TYPES */
49 #endif
50
51 __BEGIN_DECLS
52
53
54 #define PROC_ALL_PIDS 1
55 #define PROC_PGRP_ONLY 2
56 #define PROC_TTY_ONLY 3
57 #define PROC_UID_ONLY 4
58 #define PROC_RUID_ONLY 5
59 #define PROC_PPID_ONLY 6
60
61 struct proc_bsdinfo {
62 uint32_t pbi_flags; /* 64bit; emulated etc */
63 uint32_t pbi_status;
64 uint32_t pbi_xstatus;
65 uint32_t pbi_pid;
66 uint32_t pbi_ppid;
67 uid_t pbi_uid;
68 gid_t pbi_gid;
69 uid_t pbi_ruid;
70 gid_t pbi_rgid;
71 uid_t pbi_svuid;
72 gid_t pbi_svgid;
73 uint32_t rfu_1; /* reserved */
74 char pbi_comm[MAXCOMLEN];
75 char pbi_name[2*MAXCOMLEN]; /* empty if no name is registered */
76 uint32_t pbi_nfiles;
77 uint32_t pbi_pgid;
78 uint32_t pbi_pjobc;
79 uint32_t e_tdev; /* controlling tty dev */
80 uint32_t e_tpgid; /* tty process group id */
81 int32_t pbi_nice;
82 uint64_t pbi_start_tvsec;
83 uint64_t pbi_start_tvusec;
84 };
85
86
87 struct proc_bsdshortinfo {
88 uint32_t pbsi_pid; /* process id */
89 uint32_t pbsi_ppid; /* process parent id */
90 uint32_t pbsi_pgid; /* process perp id */
91 uint32_t pbsi_status; /* p_stat value, SZOMB, SRUN, etc */
92 char pbsi_comm[MAXCOMLEN]; /* upto 16 characters of process name */
93 uint32_t pbsi_flags; /* 64bit; emulated etc */
94 uid_t pbsi_uid; /* current uid on process */
95 gid_t pbsi_gid; /* current gid on process */
96 uid_t pbsi_ruid; /* current ruid on process */
97 gid_t pbsi_rgid; /* current tgid on process */
98 uid_t pbsi_svuid; /* current svuid on process */
99 gid_t pbsi_svgid; /* current svgid on process */
100 uint32_t pbsi_rfu; /* reserved for future use*/
101 };
102
103
104 #ifdef PRIVATE
105 struct proc_uniqidentifierinfo {
106 uint8_t p_uuid[16]; /* UUID of the main executable */
107 uint64_t p_uniqueid; /* 64 bit unique identifier for process */
108 uint64_t p_puniqueid; /* unique identifier for process's parent */
109 uint64_t p_reserve2; /* reserved for future use */
110 uint64_t p_reserve3; /* reserved for future use */
111 uint64_t p_reserve4; /* reserved for future use */
112 };
113
114
115 struct proc_bsdinfowithuniqid {
116 struct proc_bsdinfo pbsd;
117 struct proc_uniqidentifierinfo p_uniqidentifier;
118 };
119
120 struct proc_archinfo {
121 cpu_type_t p_cputype;
122 cpu_subtype_t p_cpusubtype;
123 };
124
125 struct proc_pidcoalitioninfo {
126 uint64_t coalition_id[COALITION_NUM_TYPES];
127 uint64_t reserved1;
128 uint64_t reserved2;
129 uint64_t reserved3;
130 };
131
132 struct proc_originatorinfo {
133 uuid_t originator_uuid; /* UUID of the originator process */
134 pid_t originator_pid; /* pid of the originator process */
135 uint64_t p_reserve2;
136 uint64_t p_reserve3;
137 uint64_t p_reserve4;
138 };
139
140 #endif
141
142
143 /* pbi_flags values */
144 #define PROC_FLAG_SYSTEM 1 /* System process */
145 #define PROC_FLAG_TRACED 2 /* process currently being traced, possibly by gdb */
146 #define PROC_FLAG_INEXIT 4 /* process is working its way in exit() */
147 #define PROC_FLAG_PPWAIT 8
148 #define PROC_FLAG_LP64 0x10 /* 64bit process */
149 #define PROC_FLAG_SLEADER 0x20 /* The process is the session leader */
150 #define PROC_FLAG_CTTY 0x40 /* process has a control tty */
151 #define PROC_FLAG_CONTROLT 0x80 /* Has a controlling terminal */
152 #define PROC_FLAG_THCWD 0x100 /* process has a thread with cwd */
153 /* process control bits for resource starvation */
154 #define PROC_FLAG_PC_THROTTLE 0x200 /* In resource starvation situations, this process is to be throttled */
155 #define PROC_FLAG_PC_SUSP 0x400 /* In resource starvation situations, this process is to be suspended */
156 #define PROC_FLAG_PC_KILL 0x600 /* In resource starvation situations, this process is to be terminated */
157 #define PROC_FLAG_PC_MASK 0x600
158 /* process action bits for resource starvation */
159 #define PROC_FLAG_PA_THROTTLE 0x800 /* The process is currently throttled due to resource starvation */
160 #define PROC_FLAG_PA_SUSP 0x1000 /* The process is currently suspended due to resource starvation */
161 #define PROC_FLAG_PSUGID 0x2000 /* process has set privileges since last exec */
162 #define PROC_FLAG_EXEC 0x4000 /* process has called exec */
163 #ifdef PRIVATE
164 #define PROC_FLAG_DARWINBG 0x8000 /* process in darwin background */
165 #define PROC_FLAG_EXT_DARWINBG 0x10000 /* process in darwin background - external enforcement */
166 #define PROC_FLAG_IOS_APPLEDAEMON 0x20000 /* Process is apple daemon */
167 #define PROC_FLAG_DELAYIDLESLEEP 0x40000 /* Process is marked to delay idle sleep on disk IO */
168 #define PROC_FLAG_IOS_IMPPROMOTION 0x80000 /* Process is daemon which receives importane donation */
169 #define PROC_FLAG_ADAPTIVE 0x100000 /* Process is adaptive */
170 #define PROC_FLAG_ADAPTIVE_IMPORTANT 0x200000 /* Process is adaptive, and is currently important */
171 #define PROC_FLAG_IMPORTANCE_DONOR 0x400000 /* Process is marked as an importance donor */
172 #define PROC_FLAG_SUPPRESSED 0x800000 /* Process is suppressed */
173 #define PROC_FLAG_APPLICATION 0x1000000 /* Process is an application */
174 #define PROC_FLAG_IOS_APPLICATION PROC_FLAG_APPLICATION /* Process is an application */
175 #endif
176
177
178 struct proc_taskinfo {
179 uint64_t pti_virtual_size; /* virtual memory size (bytes) */
180 uint64_t pti_resident_size; /* resident memory size (bytes) */
181 uint64_t pti_total_user; /* total time */
182 uint64_t pti_total_system;
183 uint64_t pti_threads_user; /* existing threads only */
184 uint64_t pti_threads_system;
185 int32_t pti_policy; /* default policy for new threads */
186 int32_t pti_faults; /* number of page faults */
187 int32_t pti_pageins; /* number of actual pageins */
188 int32_t pti_cow_faults; /* number of copy-on-write faults */
189 int32_t pti_messages_sent; /* number of messages sent */
190 int32_t pti_messages_received; /* number of messages received */
191 int32_t pti_syscalls_mach; /* number of mach system calls */
192 int32_t pti_syscalls_unix; /* number of unix system calls */
193 int32_t pti_csw; /* number of context switches */
194 int32_t pti_threadnum; /* number of threads in the task */
195 int32_t pti_numrunning; /* number of running threads */
196 int32_t pti_priority; /* task priority*/
197 };
198
199 struct proc_taskallinfo {
200 struct proc_bsdinfo pbsd;
201 struct proc_taskinfo ptinfo;
202 };
203
204 #define MAXTHREADNAMESIZE 64
205
206 struct proc_threadinfo {
207 uint64_t pth_user_time; /* user run time */
208 uint64_t pth_system_time; /* system run time */
209 int32_t pth_cpu_usage; /* scaled cpu usage percentage */
210 int32_t pth_policy; /* scheduling policy in effect */
211 int32_t pth_run_state; /* run state (see below) */
212 int32_t pth_flags; /* various flags (see below) */
213 int32_t pth_sleep_time; /* number of seconds that thread */
214 int32_t pth_curpri; /* cur priority*/
215 int32_t pth_priority; /* priority*/
216 int32_t pth_maxpriority; /* max priority*/
217 char pth_name[MAXTHREADNAMESIZE]; /* thread name, if any */
218 };
219
220 struct proc_regioninfo {
221 uint32_t pri_protection;
222 uint32_t pri_max_protection;
223 uint32_t pri_inheritance;
224 uint32_t pri_flags; /* shared, external pager, is submap */
225 uint64_t pri_offset;
226 uint32_t pri_behavior;
227 uint32_t pri_user_wired_count;
228 uint32_t pri_user_tag;
229 uint32_t pri_pages_resident;
230 uint32_t pri_pages_shared_now_private;
231 uint32_t pri_pages_swapped_out;
232 uint32_t pri_pages_dirtied;
233 uint32_t pri_ref_count;
234 uint32_t pri_shadow_depth;
235 uint32_t pri_share_mode;
236 uint32_t pri_private_pages_resident;
237 uint32_t pri_shared_pages_resident;
238 uint32_t pri_obj_id;
239 uint32_t pri_depth;
240 uint64_t pri_address;
241 uint64_t pri_size;
242 };
243
244 #define PROC_REGION_SUBMAP 1
245 #define PROC_REGION_SHARED 2
246
247 #define SM_COW 1
248 #define SM_PRIVATE 2
249 #define SM_EMPTY 3
250 #define SM_SHARED 4
251 #define SM_TRUESHARED 5
252 #define SM_PRIVATE_ALIASED 6
253 #define SM_SHARED_ALIASED 7
254 #define SM_LARGE_PAGE 8
255
256
257 /*
258 * Thread run states (state field).
259 */
260
261 #define TH_STATE_RUNNING 1 /* thread is running normally */
262 #define TH_STATE_STOPPED 2 /* thread is stopped */
263 #define TH_STATE_WAITING 3 /* thread is waiting normally */
264 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
265 wait */
266 #define TH_STATE_HALTED 5 /* thread is halted at a
267 clean point */
268
269 /*
270 * Thread flags (flags field).
271 */
272 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
273 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
274
275
276 struct proc_workqueueinfo {
277 uint32_t pwq_nthreads; /* total number of workqueue threads */
278 uint32_t pwq_runthreads; /* total number of running workqueue threads */
279 uint32_t pwq_blockedthreads; /* total number of blocked workqueue threads */
280 uint32_t pwq_state;
281 };
282
283 /*
284 * workqueue state (pwq_state field)
285 */
286 #define WQ_EXCEEDED_CONSTRAINED_THREAD_LIMIT 0x1
287 #define WQ_EXCEEDED_TOTAL_THREAD_LIMIT 0x2
288
289
290 struct proc_fileinfo {
291 uint32_t fi_openflags;
292 uint32_t fi_status;
293 off_t fi_offset;
294 int32_t fi_type;
295 uint32_t fi_guardflags;
296 };
297
298 /* stats flags in proc_fileinfo */
299 #define PROC_FP_SHARED 1 /* shared by more than one fd */
300 #define PROC_FP_CLEXEC 2 /* close on exec */
301 #define PROC_FP_GUARDED 4 /* guarded fd */
302 #define PROC_FP_CLFORK 8 /* close on fork */
303
304 #define PROC_FI_GUARD_CLOSE (1u << 0)
305 #define PROC_FI_GUARD_DUP (1u << 1)
306 #define PROC_FI_GUARD_SOCKET_IPC (1u << 2)
307 #define PROC_FI_GUARD_FILEPORT (1u << 3)
308
309 /*
310 * A copy of stat64 with static sized fields.
311 */
312 struct vinfo_stat {
313 uint32_t vst_dev; /* [XSI] ID of device containing file */
314 uint16_t vst_mode; /* [XSI] Mode of file (see below) */
315 uint16_t vst_nlink; /* [XSI] Number of hard links */
316 uint64_t vst_ino; /* [XSI] File serial number */
317 uid_t vst_uid; /* [XSI] User ID of the file */
318 gid_t vst_gid; /* [XSI] Group ID of the file */
319 int64_t vst_atime; /* [XSI] Time of last access */
320 int64_t vst_atimensec; /* nsec of last access */
321 int64_t vst_mtime; /* [XSI] Last data modification time */
322 int64_t vst_mtimensec; /* last data modification nsec */
323 int64_t vst_ctime; /* [XSI] Time of last status change */
324 int64_t vst_ctimensec; /* nsec of last status change */
325 int64_t vst_birthtime; /* File creation time(birth) */
326 int64_t vst_birthtimensec; /* nsec of File creation time */
327 off_t vst_size; /* [XSI] file size, in bytes */
328 int64_t vst_blocks; /* [XSI] blocks allocated for file */
329 int32_t vst_blksize; /* [XSI] optimal blocksize for I/O */
330 uint32_t vst_flags; /* user defined flags for file */
331 uint32_t vst_gen; /* file generation number */
332 uint32_t vst_rdev; /* [XSI] Device ID */
333 int64_t vst_qspare[2]; /* RESERVED: DO NOT USE! */
334 };
335
336 struct vnode_info {
337 struct vinfo_stat vi_stat;
338 int vi_type;
339 int vi_pad;
340 fsid_t vi_fsid;
341 };
342
343 struct vnode_info_path {
344 struct vnode_info vip_vi;
345 char vip_path[MAXPATHLEN]; /* tail end of it */
346 };
347
348 struct vnode_fdinfo {
349 struct proc_fileinfo pfi;
350 struct vnode_info pvi;
351 };
352
353 struct vnode_fdinfowithpath {
354 struct proc_fileinfo pfi;
355 struct vnode_info_path pvip;
356 };
357
358 struct proc_regionwithpathinfo {
359 struct proc_regioninfo prp_prinfo;
360 struct vnode_info_path prp_vip;
361 };
362
363 struct proc_vnodepathinfo {
364 struct vnode_info_path pvi_cdir;
365 struct vnode_info_path pvi_rdir;
366 };
367
368 struct proc_threadwithpathinfo {
369 struct proc_threadinfo pt;
370 struct vnode_info_path pvip;
371 };
372
373 /*
374 * Socket
375 */
376
377
378 /*
379 * IPv4 and IPv6 Sockets
380 */
381
382 #define INI_IPV4 0x1
383 #define INI_IPV6 0x2
384
385 struct in4in6_addr {
386 u_int32_t i46a_pad32[3];
387 struct in_addr i46a_addr4;
388 };
389
390 struct in_sockinfo {
391 int insi_fport; /* foreign port */
392 int insi_lport; /* local port */
393 uint64_t insi_gencnt; /* generation count of this instance */
394 uint32_t insi_flags; /* generic IP/datagram flags */
395 uint32_t insi_flow;
396
397 uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */
398 uint8_t insi_ip_ttl; /* time to live proto */
399 uint32_t rfu_1; /* reserved */
400 /* protocol dependent part */
401 union {
402 struct in4in6_addr ina_46;
403 struct in6_addr ina_6;
404 } insi_faddr; /* foreign host table entry */
405 union {
406 struct in4in6_addr ina_46;
407 struct in6_addr ina_6;
408 } insi_laddr; /* local host table entry */
409 struct {
410 u_char in4_tos; /* type of service */
411 } insi_v4;
412 struct {
413 uint8_t in6_hlim;
414 int in6_cksum;
415 u_short in6_ifindex;
416 short in6_hops;
417 } insi_v6;
418 };
419
420 /*
421 * TCP Sockets
422 */
423
424 #define TSI_T_REXMT 0 /* retransmit */
425 #define TSI_T_PERSIST 1 /* retransmit persistence */
426 #define TSI_T_KEEP 2 /* keep alive */
427 #define TSI_T_2MSL 3 /* 2*msl quiet time timer */
428 #define TSI_T_NTIMERS 4
429
430 #define TSI_S_CLOSED 0 /* closed */
431 #define TSI_S_LISTEN 1 /* listening for connection */
432 #define TSI_S_SYN_SENT 2 /* active, have sent syn */
433 #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */
434 #define TSI_S_ESTABLISHED 4 /* established */
435 #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */
436 #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */
437 #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */
438 #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */
439 #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */
440 #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */
441 #define TSI_S_RESERVED 11 /* pseudo state: reserved */
442
443 struct tcp_sockinfo {
444 struct in_sockinfo tcpsi_ini;
445 int tcpsi_state;
446 int tcpsi_timer[TSI_T_NTIMERS];
447 int tcpsi_mss;
448 uint32_t tcpsi_flags;
449 uint32_t rfu_1; /* reserved */
450 uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */
451 };
452
453 /*
454 * Unix Domain Sockets
455 */
456
457
458 struct un_sockinfo {
459 uint64_t unsi_conn_so; /* opaque handle of connected socket */
460 uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */
461 union {
462 struct sockaddr_un ua_sun;
463 char ua_dummy[SOCK_MAXADDRLEN];
464 } unsi_addr; /* bound address */
465 union {
466 struct sockaddr_un ua_sun;
467 char ua_dummy[SOCK_MAXADDRLEN];
468 } unsi_caddr; /* address of socket connected to */
469 };
470
471 /*
472 * PF_NDRV Sockets
473 */
474
475 struct ndrv_info {
476 uint32_t ndrvsi_if_family;
477 uint32_t ndrvsi_if_unit;
478 char ndrvsi_if_name[IF_NAMESIZE];
479 };
480
481 /*
482 * Kernel Event Sockets
483 */
484
485 struct kern_event_info {
486 uint32_t kesi_vendor_code_filter;
487 uint32_t kesi_class_filter;
488 uint32_t kesi_subclass_filter;
489 };
490
491 /*
492 * Kernel Control Sockets
493 */
494
495 struct kern_ctl_info {
496 uint32_t kcsi_id;
497 uint32_t kcsi_reg_unit;
498 uint32_t kcsi_flags; /* support flags */
499 uint32_t kcsi_recvbufsize; /* request more than the default buffer size */
500 uint32_t kcsi_sendbufsize; /* request more than the default buffer size */
501 uint32_t kcsi_unit;
502 char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */
503 };
504
505 /* soi_state */
506
507 #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */
508 #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */
509 #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */
510 #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */
511 #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */
512 #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */
513 #define SOI_S_RCVATMARK 0x0040 /* at mark on input */
514 #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */
515 #define SOI_S_NBIO 0x0100 /* non-blocking ops */
516 #define SOI_S_ASYNC 0x0200 /* async i/o notify */
517 #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */
518 #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */
519 #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
520 #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */
521
522 struct sockbuf_info {
523 uint32_t sbi_cc;
524 uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */
525 uint32_t sbi_mbcnt;
526 uint32_t sbi_mbmax;
527 uint32_t sbi_lowat;
528 short sbi_flags;
529 short sbi_timeo;
530 };
531
532 enum {
533 SOCKINFO_GENERIC = 0,
534 SOCKINFO_IN = 1,
535 SOCKINFO_TCP = 2,
536 SOCKINFO_UN = 3,
537 SOCKINFO_NDRV = 4,
538 SOCKINFO_KERN_EVENT = 5,
539 SOCKINFO_KERN_CTL = 6
540 };
541
542 struct socket_info {
543 struct vinfo_stat soi_stat;
544 uint64_t soi_so; /* opaque handle of socket */
545 uint64_t soi_pcb; /* opaque handle of protocol control block */
546 int soi_type;
547 int soi_protocol;
548 int soi_family;
549 short soi_options;
550 short soi_linger;
551 short soi_state;
552 short soi_qlen;
553 short soi_incqlen;
554 short soi_qlimit;
555 short soi_timeo;
556 u_short soi_error;
557 uint32_t soi_oobmark;
558 struct sockbuf_info soi_rcv;
559 struct sockbuf_info soi_snd;
560 int soi_kind;
561 uint32_t rfu_1; /* reserved */
562 union {
563 struct in_sockinfo pri_in; /* SOCKINFO_IN */
564 struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */
565 struct un_sockinfo pri_un; /* SOCKINFO_UN */
566 struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */
567 struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */
568 struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */
569 } soi_proto;
570 };
571
572 struct socket_fdinfo {
573 struct proc_fileinfo pfi;
574 struct socket_info psi;
575 };
576
577
578
579 struct psem_info {
580 struct vinfo_stat psem_stat;
581 char psem_name[MAXPATHLEN];
582 };
583
584 struct psem_fdinfo {
585 struct proc_fileinfo pfi;
586 struct psem_info pseminfo;
587 };
588
589
590
591 struct pshm_info {
592 struct vinfo_stat pshm_stat;
593 uint64_t pshm_mappaddr;
594 char pshm_name[MAXPATHLEN];
595 };
596
597 struct pshm_fdinfo {
598 struct proc_fileinfo pfi;
599 struct pshm_info pshminfo;
600 };
601
602
603 struct pipe_info {
604 struct vinfo_stat pipe_stat;
605 uint64_t pipe_handle;
606 uint64_t pipe_peerhandle;
607 int pipe_status;
608 int rfu_1; /* reserved */
609 };
610
611 struct pipe_fdinfo {
612 struct proc_fileinfo pfi;
613 struct pipe_info pipeinfo;
614 };
615
616
617 struct kqueue_info {
618 struct vinfo_stat kq_stat;
619 uint32_t kq_state;
620 uint32_t rfu_1; /* reserved */
621 };
622
623 /* keep in sync with KQ_* in sys/eventvar.h */
624 #define PROC_KQUEUE_SELECT 0x01
625 #define PROC_KQUEUE_SLEEP 0x02
626 #define PROC_KQUEUE_32 0x08
627 #define PROC_KQUEUE_64 0x10
628 #define PROC_KQUEUE_QOS 0x20
629
630 #ifdef PRIVATE
631 struct kevent_extinfo {
632 struct kevent_qos_s kqext_kev;
633 uint64_t kqext_sdata;
634 int kqext_status;
635 int kqext_sfflags;
636 uint64_t kqext_reserved[2];
637 };
638 #endif /* PRIVATE */
639
640 struct kqueue_fdinfo {
641 struct proc_fileinfo pfi;
642 struct kqueue_info kqueueinfo;
643 };
644
645 struct appletalk_info {
646 struct vinfo_stat atalk_stat;
647 };
648
649 struct appletalk_fdinfo {
650 struct proc_fileinfo pfi;
651 struct appletalk_info appletalkinfo;
652 };
653
654
655
656 /* defns of process file desc type */
657 #define PROX_FDTYPE_ATALK 0
658 #define PROX_FDTYPE_VNODE 1
659 #define PROX_FDTYPE_SOCKET 2
660 #define PROX_FDTYPE_PSHM 3
661 #define PROX_FDTYPE_PSEM 4
662 #define PROX_FDTYPE_KQUEUE 5
663 #define PROX_FDTYPE_PIPE 6
664 #define PROX_FDTYPE_FSEVENTS 7
665
666 struct proc_fdinfo {
667 int32_t proc_fd;
668 uint32_t proc_fdtype;
669 };
670
671 struct proc_fileportinfo {
672 uint32_t proc_fileport;
673 uint32_t proc_fdtype;
674 };
675
676 /* Flavors for proc_pidinfo() */
677 #define PROC_PIDLISTFDS 1
678 #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
679
680 #define PROC_PIDTASKALLINFO 2
681 #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo))
682
683 #define PROC_PIDTBSDINFO 3
684 #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo))
685
686 #define PROC_PIDTASKINFO 4
687 #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo))
688
689 #define PROC_PIDTHREADINFO 5
690 #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo))
691
692 #define PROC_PIDLISTTHREADS 6
693 #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t))
694
695
696 #define PROC_PIDREGIONINFO 7
697 #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo))
698
699 #define PROC_PIDREGIONPATHINFO 8
700 #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo))
701
702 #define PROC_PIDVNODEPATHINFO 9
703 #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo))
704
705 #define PROC_PIDTHREADPATHINFO 10
706 #define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo))
707
708 #define PROC_PIDPATHINFO 11
709 #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN)
710 #define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN)
711
712 #define PROC_PIDWORKQUEUEINFO 12
713 #define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo))
714
715 #define PROC_PIDT_SHORTBSDINFO 13
716 #define PROC_PIDT_SHORTBSDINFO_SIZE (sizeof(struct proc_bsdshortinfo))
717
718 #define PROC_PIDLISTFILEPORTS 14
719 #define PROC_PIDLISTFILEPORTS_SIZE (sizeof(struct proc_fileportinfo))
720
721 #define PROC_PIDTHREADID64INFO 15
722 #define PROC_PIDTHREADID64INFO_SIZE (sizeof(struct proc_threadinfo))
723
724 #define PROC_PID_RUSAGE 16
725 #define PROC_PID_RUSAGE_SIZE 0
726
727 #ifdef PRIVATE
728 #define PROC_PIDUNIQIDENTIFIERINFO 17
729 #define PROC_PIDUNIQIDENTIFIERINFO_SIZE \
730 (sizeof(struct proc_uniqidentifierinfo))
731
732 #define PROC_PIDT_BSDINFOWITHUNIQID 18
733 #define PROC_PIDT_BSDINFOWITHUNIQID_SIZE \
734 (sizeof(struct proc_bsdinfowithuniqid))
735
736 #define PROC_PIDARCHINFO 19
737 #define PROC_PIDARCHINFO_SIZE \
738 (sizeof(struct proc_archinfo))
739
740 #define PROC_PIDCOALITIONINFO 20
741 #define PROC_PIDCOALITIONINFO_SIZE (sizeof(struct proc_pidcoalitioninfo))
742
743 #define PROC_PIDNOTEEXIT 21
744 #define PROC_PIDNOTEEXIT_SIZE (sizeof(uint32_t))
745
746 #define PROC_PIDREGIONPATHINFO2 22
747 #define PROC_PIDREGIONPATHINFO2_SIZE (sizeof(struct proc_regionwithpathinfo))
748
749 #define PROC_PIDREGIONPATHINFO3 23
750 #define PROC_PIDREGIONPATHINFO3_SIZE (sizeof(struct proc_regionwithpathinfo))
751
752 #endif
753
754 /* Flavors for proc_pidfdinfo */
755
756 #define PROC_PIDFDVNODEINFO 1
757 #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo))
758
759 #define PROC_PIDFDVNODEPATHINFO 2
760 #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath))
761
762 #define PROC_PIDFDSOCKETINFO 3
763 #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo))
764
765 #define PROC_PIDFDPSEMINFO 4
766 #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo))
767
768 #define PROC_PIDFDPSHMINFO 5
769 #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo))
770
771 #define PROC_PIDFDPIPEINFO 6
772 #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo))
773
774 #define PROC_PIDFDKQUEUEINFO 7
775 #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo))
776
777 #define PROC_PIDFDATALKINFO 8
778 #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo))
779
780 #ifdef PRIVATE
781 #define PROC_PIDFDKQUEUE_EXTINFO 9
782 #define PROC_PIDFDKQUEUE_EXTINFO_SIZE (sizeof(struct kevent_extinfo))
783 #endif /* PRIVATE */
784
785 /* Flavors for proc_pidfileportinfo */
786
787 #define PROC_PIDFILEPORTVNODEPATHINFO 2 /* out: vnode_fdinfowithpath */
788 #define PROC_PIDFILEPORTVNODEPATHINFO_SIZE \
789 PROC_PIDFDVNODEPATHINFO_SIZE
790
791 #define PROC_PIDFILEPORTSOCKETINFO 3 /* out: socket_fdinfo */
792 #define PROC_PIDFILEPORTSOCKETINFO_SIZE PROC_PIDFDSOCKETINFO_SIZE
793
794 #define PROC_PIDFILEPORTPSHMINFO 5 /* out: pshm_fdinfo */
795 #define PROC_PIDFILEPORTPSHMINFO_SIZE PROC_PIDFDPSHMINFO_SIZE
796
797 #define PROC_PIDFILEPORTPIPEINFO 6 /* out: pipe_fdinfo */
798 #define PROC_PIDFILEPORTPIPEINFO_SIZE PROC_PIDFDPIPEINFO_SIZE
799
800 /* used for proc_setcontrol */
801 #define PROC_SELFSET_PCONTROL 1
802
803 #define PROC_SELFSET_THREADNAME 2
804 #define PROC_SELFSET_THREADNAME_SIZE (MAXTHREADNAMESIZE -1)
805
806 #define PROC_SELFSET_VMRSRCOWNER 3
807
808 #define PROC_SELFSET_DELAYIDLESLEEP 4
809
810 /* used for proc_dirtycontrol */
811 #define PROC_DIRTYCONTROL_TRACK 1
812 #define PROC_DIRTYCONTROL_SET 2
813 #define PROC_DIRTYCONTROL_GET 3
814 #define PROC_DIRTYCONTROL_CLEAR 4
815
816 /* proc_track_dirty() flags */
817 #define PROC_DIRTY_TRACK 0x1
818 #define PROC_DIRTY_ALLOW_IDLE_EXIT 0x2
819 #define PROC_DIRTY_DEFER 0x4
820 #define PROC_DIRTY_LAUNCH_IN_PROGRESS 0x8
821
822 /* proc_get_dirty() flags */
823 #define PROC_DIRTY_TRACKED 0x1
824 #define PROC_DIRTY_ALLOWS_IDLE_EXIT 0x2
825 #define PROC_DIRTY_IS_DIRTY 0x4
826 #define PROC_DIRTY_LAUNCH_IS_IN_PROGRESS 0x8
827
828 #ifdef PRIVATE
829
830 /* Flavors for proc_pidoriginatorinfo */
831 #define PROC_PIDORIGINATOR_UUID 0x1
832 #define PROC_PIDORIGINATOR_UUID_SIZE (sizeof(uuid_t))
833
834 #define PROC_PIDORIGINATOR_BGSTATE 0x2
835 #define PROC_PIDORIGINATOR_BGSTATE_SIZE (sizeof(uint32_t))
836
837 #define PROC_PIDORIGINATOR_PID_UUID 0x3
838 #define PROC_PIDORIGINATOR_PID_UUID_SIZE (sizeof(struct proc_originatorinfo))
839
840 /* Flavors for proc_listcoalitions */
841 #define LISTCOALITIONS_ALL_COALS 1
842 #define LISTCOALITIONS_ALL_COALS_SIZE (sizeof(struct procinfo_coalinfo))
843
844 #define LISTCOALITIONS_SINGLE_TYPE 2
845 #define LISTCOALITIONS_SINGLE_TYPE_SIZE (sizeof(struct procinfo_coalinfo))
846
847 /* reasons for proc_can_use_foreground_hw */
848 #define PROC_FGHW_OK 0 /* pid may use foreground HW */
849 #define PROC_FGHW_DAEMON_OK 1
850 #define PROC_FGHW_DAEMON_LEADER 10 /* pid is in a daemon coalition */
851 #define PROC_FGHW_LEADER_NONUI 11 /* coalition leader is in a non-focal state */
852 #define PROC_FGHW_LEADER_BACKGROUND 12 /* coalition leader is in a background state */
853 #define PROC_FGHW_DAEMON_NO_VOUCHER 13 /* pid is a daemon with no adopted voucher */
854 #define PROC_FGHW_NO_VOUCHER_ATTR 14 /* pid has adopted a voucher with no bank/originator attribute */
855 #define PROC_FGHW_NO_ORIGINATOR 15 /* pid has adopted a voucher for a process that's gone away */
856 #define PROC_FGHW_ORIGINATOR_BACKGROUND 16 /* pid has adopted a voucher for an app that's in the background */
857 #define PROC_FGHW_VOUCHER_ERROR 98 /* error in voucher / originator callout */
858 #define PROC_FGHW_ERROR 99 /* syscall parameter/permissions error */
859
860 /* __proc_info() call numbers */
861 #define PROC_INFO_CALL_LISTPIDS 0x1
862 #define PROC_INFO_CALL_PIDINFO 0x2
863 #define PROC_INFO_CALL_PIDFDINFO 0x3
864 #define PROC_INFO_CALL_KERNMSGBUF 0x4
865 #define PROC_INFO_CALL_SETCONTROL 0x5
866 #define PROC_INFO_CALL_PIDFILEPORTINFO 0x6
867 #define PROC_INFO_CALL_TERMINATE 0x7
868 #define PROC_INFO_CALL_DIRTYCONTROL 0x8
869 #define PROC_INFO_CALL_PIDRUSAGE 0x9
870 #define PROC_INFO_CALL_PIDORIGINATORINFO 0xa
871 #define PROC_INFO_CALL_LISTCOALITIONS 0xb
872 #define PROC_INFO_CALL_CANUSEFGHW 0xc
873
874 #endif /* PRIVATE */
875
876 #ifdef XNU_KERNEL_PRIVATE
877 #ifndef pshmnode
878 struct pshmnode;
879 #endif
880
881 #ifndef psemnode
882 struct psemnode ;
883 #endif
884
885 #ifndef pipe
886 struct pipe;
887 #endif
888
889 extern int fill_socketinfo(socket_t so, struct socket_info *si);
890 extern int fill_pshminfo(struct pshmnode * pshm, struct pshm_info * pinfo);
891 extern int fill_pseminfo(struct psemnode * psem, struct psem_info * pinfo);
892 extern int fill_pipeinfo(struct pipe * cpipe, struct pipe_info * pinfo);
893 extern int fill_kqueueinfo(struct kqueue * kq, struct kqueue_info * kinfo);
894 extern int pid_kqueue_extinfo(proc_t, struct kqueue * kq, user_addr_t buffer, uint32_t buffersize, int32_t * retval);
895 extern int fill_procworkqueue(proc_t, struct proc_workqueueinfo *);
896 #endif /* XNU_KERNEL_PRIVATE */
897
898 __END_DECLS
899
900 #endif /*_SYS_PROC_INFO_H */