1 /* 2 * Copyright (c) 2005-2021 Apple 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 #include <uuid/uuid.h> 47 48 __BEGIN_DECLS 49 50 51 #define PROC_ALL_PIDS 1 52 #define PROC_PGRP_ONLY 2 53 #define PROC_TTY_ONLY 3 54 #define PROC_UID_ONLY 4 55 #define PROC_RUID_ONLY 5 56 #define PROC_PPID_ONLY 6 57 #define PROC_KDBG_ONLY 7 58 59 struct proc_bsdinfo { 60 uint32_t pbi_flags; /* 64bit; emulated etc */ 61 uint32_t pbi_status; 62 uint32_t pbi_xstatus; 63 uint32_t pbi_pid; 64 uint32_t pbi_ppid; 65 uid_t pbi_uid; 66 gid_t pbi_gid; 67 uid_t pbi_ruid; 68 gid_t pbi_rgid; 69 uid_t pbi_svuid; 70 gid_t pbi_svgid; 71 uint32_t rfu_1; /* reserved */ 72 char pbi_comm[MAXCOMLEN]; 73 char pbi_name[2 * MAXCOMLEN]; /* empty if no name is registered */ 74 uint32_t pbi_nfiles; 75 uint32_t pbi_pgid; 76 uint32_t pbi_pjobc; 77 uint32_t e_tdev; /* controlling tty dev */ 78 uint32_t e_tpgid; /* tty process group id */ 79 int32_t pbi_nice; 80 uint64_t pbi_start_tvsec; 81 uint64_t pbi_start_tvusec; 82 }; 83 84 85 struct proc_bsdshortinfo { 86 uint32_t pbsi_pid; /* process id */ 87 uint32_t pbsi_ppid; /* process parent id */ 88 uint32_t pbsi_pgid; /* process perp id */ 89 uint32_t pbsi_status; /* p_stat value, SZOMB, SRUN, etc */ 90 char pbsi_comm[MAXCOMLEN]; /* upto 16 characters of process name */ 91 uint32_t pbsi_flags; /* 64bit; emulated etc */ 92 uid_t pbsi_uid; /* current uid on process */ 93 gid_t pbsi_gid; /* current gid on process */ 94 uid_t pbsi_ruid; /* current ruid on process */ 95 gid_t pbsi_rgid; /* current tgid on process */ 96 uid_t pbsi_svuid; /* current svuid on process */ 97 gid_t pbsi_svgid; /* current svgid on process */ 98 uint32_t pbsi_rfu; /* reserved for future use*/ 99 }; 100 101 102 /* pbi_flags values */ 103 #define PROC_FLAG_SYSTEM 1 /* System process */ 104 #define PROC_FLAG_TRACED 2 /* process currently being traced, possibly by gdb */ 105 #define PROC_FLAG_INEXIT 4 /* process is working its way in exit() */ 106 #define PROC_FLAG_PPWAIT 8 107 #define PROC_FLAG_LP64 0x10 /* 64bit process */ 108 #define PROC_FLAG_SLEADER 0x20 /* The process is the session leader */ 109 #define PROC_FLAG_CTTY 0x40 /* process has a control tty */ 110 #define PROC_FLAG_CONTROLT 0x80 /* Has a controlling terminal */ 111 #define PROC_FLAG_THCWD 0x100 /* process has a thread with cwd */ 112 /* process control bits for resource starvation */ 113 #define PROC_FLAG_PC_THROTTLE 0x200 /* In resource starvation situations, this process is to be throttled */ 114 #define PROC_FLAG_PC_SUSP 0x400 /* In resource starvation situations, this process is to be suspended */ 115 #define PROC_FLAG_PC_KILL 0x600 /* In resource starvation situations, this process is to be terminated */ 116 #define PROC_FLAG_PC_MASK 0x600 117 /* process action bits for resource starvation */ 118 #define PROC_FLAG_PA_THROTTLE 0x800 /* The process is currently throttled due to resource starvation */ 119 #define PROC_FLAG_PA_SUSP 0x1000 /* The process is currently suspended due to resource starvation */ 120 #define PROC_FLAG_PSUGID 0x2000 /* process has set privileges since last exec */ 121 #define PROC_FLAG_EXEC 0x4000 /* process has called exec */ 122 #ifdef PRIVATE 123 /* Additional PROC_FLAG values in proc_info_private.h */ 124 #endif 125 126 127 struct proc_taskinfo { 128 uint64_t pti_virtual_size; /* virtual memory size (bytes) */ 129 uint64_t pti_resident_size; /* resident memory size (bytes) */ 130 uint64_t pti_total_user; /* total time */ 131 uint64_t pti_total_system; 132 uint64_t pti_threads_user; /* existing threads only */ 133 uint64_t pti_threads_system; 134 int32_t pti_policy; /* default policy for new threads */ 135 int32_t pti_faults; /* number of page faults */ 136 int32_t pti_pageins; /* number of actual pageins */ 137 int32_t pti_cow_faults; /* number of copy-on-write faults */ 138 int32_t pti_messages_sent; /* number of messages sent */ 139 int32_t pti_messages_received; /* number of messages received */ 140 int32_t pti_syscalls_mach; /* number of mach system calls */ 141 int32_t pti_syscalls_unix; /* number of unix system calls */ 142 int32_t pti_csw; /* number of context switches */ 143 int32_t pti_threadnum; /* number of threads in the task */ 144 int32_t pti_numrunning; /* number of running threads */ 145 int32_t pti_priority; /* task priority*/ 146 }; 147 148 struct proc_taskallinfo { 149 struct proc_bsdinfo pbsd; 150 struct proc_taskinfo ptinfo; 151 }; 152 153 #define MAXTHREADNAMESIZE 64 154 155 struct proc_threadinfo { 156 uint64_t pth_user_time; /* user run time */ 157 uint64_t pth_system_time; /* system run time */ 158 int32_t pth_cpu_usage; /* scaled cpu usage percentage */ 159 int32_t pth_policy; /* scheduling policy in effect */ 160 int32_t pth_run_state; /* run state (see below) */ 161 int32_t pth_flags; /* various flags (see below) */ 162 int32_t pth_sleep_time; /* number of seconds that thread */ 163 int32_t pth_curpri; /* cur priority*/ 164 int32_t pth_priority; /* priority*/ 165 int32_t pth_maxpriority; /* max priority*/ 166 char pth_name[MAXTHREADNAMESIZE]; /* thread name, if any */ 167 }; 168 169 struct proc_regioninfo { 170 uint32_t pri_protection; 171 uint32_t pri_max_protection; 172 uint32_t pri_inheritance; 173 uint32_t pri_flags; /* shared, external pager, is submap */ 174 uint64_t pri_offset; 175 uint32_t pri_behavior; 176 uint32_t pri_user_wired_count; 177 uint32_t pri_user_tag; 178 uint32_t pri_pages_resident; 179 uint32_t pri_pages_shared_now_private; 180 uint32_t pri_pages_swapped_out; 181 uint32_t pri_pages_dirtied; 182 uint32_t pri_ref_count; 183 uint32_t pri_shadow_depth; 184 uint32_t pri_share_mode; 185 uint32_t pri_private_pages_resident; 186 uint32_t pri_shared_pages_resident; 187 uint32_t pri_obj_id; 188 uint32_t pri_depth; 189 uint64_t pri_address; 190 uint64_t pri_size; 191 }; 192 193 #define PROC_REGION_SUBMAP 1 194 #define PROC_REGION_SHARED 2 195 196 #define SM_COW 1 197 #define SM_PRIVATE 2 198 #define SM_EMPTY 3 199 #define SM_SHARED 4 200 #define SM_TRUESHARED 5 201 #define SM_PRIVATE_ALIASED 6 202 #define SM_SHARED_ALIASED 7 203 #define SM_LARGE_PAGE 8 204 205 206 /* 207 * Thread run states (state field). 208 */ 209 210 #define TH_STATE_RUNNING 1 /* thread is running normally */ 211 #define TH_STATE_STOPPED 2 /* thread is stopped */ 212 #define TH_STATE_WAITING 3 /* thread is waiting normally */ 213 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible 214 * wait */ 215 #define TH_STATE_HALTED 5 /* thread is halted at a 216 * clean point */ 217 218 /* 219 * Thread flags (flags field). 220 */ 221 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */ 222 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */ 223 224 225 struct proc_workqueueinfo { 226 uint32_t pwq_nthreads; /* total number of workqueue threads */ 227 uint32_t pwq_runthreads; /* total number of running workqueue threads */ 228 uint32_t pwq_blockedthreads; /* total number of blocked workqueue threads */ 229 uint32_t pwq_state; 230 }; 231 232 /* 233 * workqueue state (pwq_state field) 234 */ 235 #define WQ_EXCEEDED_CONSTRAINED_THREAD_LIMIT 0x1 236 #define WQ_EXCEEDED_TOTAL_THREAD_LIMIT 0x2 237 #define WQ_FLAGS_AVAILABLE 0x4 238 /* 239 * WQ_EXCEEDED_COOPERATIVE_THREAD_LIMIT is set if wq has scheduled cooperative 240 * threads upto the cooperative thread pool limit and there is still more work 241 * pending in the cooperative pool that require a thread. 242 */ 243 #define WQ_EXCEEDED_COOPERATIVE_THREAD_LIMIT 0x8 244 /* 245 * WQ_EXCEEDED_ACTIVE_CONSTRAINED_THREAD_LIMIT is set when wq has pending thread 246 * requests for the constrained thread pool; but, has failed the allowance check 247 * because of active thread limit. 248 */ 249 #define WQ_EXCEEDED_ACTIVE_CONSTRAINED_THREAD_LIMIT 0x10 250 251 struct proc_fileinfo { 252 uint32_t fi_openflags; 253 uint32_t fi_status; 254 off_t fi_offset; 255 int32_t fi_type; 256 uint32_t fi_guardflags; 257 }; 258 259 /* stats flags in proc_fileinfo */ 260 #define PROC_FP_SHARED 1 /* shared by more than one fd */ 261 #define PROC_FP_CLEXEC 2 /* close on exec */ 262 #define PROC_FP_GUARDED 4 /* guarded fd */ 263 #define PROC_FP_CLFORK 8 /* close on fork */ 264 265 #define PROC_FI_GUARD_CLOSE (1u << 0) 266 #define PROC_FI_GUARD_DUP (1u << 1) 267 #define PROC_FI_GUARD_SOCKET_IPC (1u << 2) 268 #define PROC_FI_GUARD_FILEPORT (1u << 3) 269 270 struct proc_exitreasonbasicinfo { 271 uint32_t beri_namespace; 272 uint64_t beri_code; 273 uint64_t beri_flags; 274 uint32_t beri_reason_buf_size; 275 } __attribute__((packed)); 276 277 struct proc_exitreasoninfo { 278 uint32_t eri_namespace; 279 uint64_t eri_code; 280 uint64_t eri_flags; 281 uint32_t eri_reason_buf_size; 282 uint64_t eri_kcd_buf; 283 } __attribute__((packed)); 284 285 /* 286 * A copy of stat64 with static sized fields. 287 */ 288 struct vinfo_stat { 289 uint32_t vst_dev; /* [XSI] ID of device containing file */ 290 uint16_t vst_mode; /* [XSI] Mode of file (see below) */ 291 uint16_t vst_nlink; /* [XSI] Number of hard links */ 292 uint64_t vst_ino; /* [XSI] File serial number */ 293 uid_t vst_uid; /* [XSI] User ID of the file */ 294 gid_t vst_gid; /* [XSI] Group ID of the file */ 295 int64_t vst_atime; /* [XSI] Time of last access */ 296 int64_t vst_atimensec; /* nsec of last access */ 297 int64_t vst_mtime; /* [XSI] Last data modification time */ 298 int64_t vst_mtimensec; /* last data modification nsec */ 299 int64_t vst_ctime; /* [XSI] Time of last status change */ 300 int64_t vst_ctimensec; /* nsec of last status change */ 301 int64_t vst_birthtime; /* File creation time(birth) */ 302 int64_t vst_birthtimensec; /* nsec of File creation time */ 303 off_t vst_size; /* [XSI] file size, in bytes */ 304 int64_t vst_blocks; /* [XSI] blocks allocated for file */ 305 int32_t vst_blksize; /* [XSI] optimal blocksize for I/O */ 306 uint32_t vst_flags; /* user defined flags for file */ 307 uint32_t vst_gen; /* file generation number */ 308 uint32_t vst_rdev; /* [XSI] Device ID */ 309 int64_t vst_qspare[2]; /* RESERVED: DO NOT USE! */ 310 }; 311 312 struct vnode_info { 313 struct vinfo_stat vi_stat; 314 int vi_type; 315 int vi_pad; 316 fsid_t vi_fsid; 317 }; 318 319 struct vnode_info_path { 320 struct vnode_info vip_vi; 321 char vip_path[MAXPATHLEN]; /* tail end of it */ 322 }; 323 324 struct vnode_fdinfo { 325 struct proc_fileinfo pfi; 326 struct vnode_info pvi; 327 }; 328 329 struct vnode_fdinfowithpath { 330 struct proc_fileinfo pfi; 331 struct vnode_info_path pvip; 332 }; 333 334 struct proc_regionwithpathinfo { 335 struct proc_regioninfo prp_prinfo; 336 struct vnode_info_path prp_vip; 337 }; 338 339 struct proc_regionpath { 340 uint64_t prpo_addr; 341 uint64_t prpo_regionlength; 342 char prpo_path[MAXPATHLEN]; 343 }; 344 345 struct proc_vnodepathinfo { 346 struct vnode_info_path pvi_cdir; 347 struct vnode_info_path pvi_rdir; 348 }; 349 350 struct proc_threadwithpathinfo { 351 struct proc_threadinfo pt; 352 struct vnode_info_path pvip; 353 }; 354 355 struct proc_archinfo { 356 cpu_type_t p_cputype; 357 cpu_subtype_t p_cpusubtype; 358 }; 359 360 /* 361 * Socket 362 */ 363 364 365 /* 366 * IPv4 and IPv6 Sockets 367 */ 368 369 #define INI_IPV4 0x1 370 #define INI_IPV6 0x2 371 372 struct in4in6_addr { 373 u_int32_t i46a_pad32[3]; 374 struct in_addr i46a_addr4; 375 }; 376 377 struct in_sockinfo { 378 int insi_fport; /* foreign port */ 379 int insi_lport; /* local port */ 380 uint64_t insi_gencnt; /* generation count of this instance */ 381 uint32_t insi_flags; /* generic IP/datagram flags */ 382 uint32_t insi_flow; 383 384 uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */ 385 uint8_t insi_ip_ttl; /* time to live proto */ 386 uint32_t rfu_1; /* reserved */ 387 /* protocol dependent part */ 388 union { 389 struct in4in6_addr ina_46; 390 struct in6_addr ina_6; 391 } insi_faddr; /* foreign host table entry */ 392 union { 393 struct in4in6_addr ina_46; 394 struct in6_addr ina_6; 395 } insi_laddr; /* local host table entry */ 396 struct { 397 u_char in4_tos; /* type of service */ 398 } insi_v4; 399 struct { 400 uint8_t in6_hlim; 401 int in6_cksum; 402 u_short in6_ifindex; 403 short in6_hops; 404 } insi_v6; 405 }; 406 407 /* 408 * TCP Sockets 409 */ 410 411 #define TSI_T_REXMT 0 /* retransmit */ 412 #define TSI_T_PERSIST 1 /* retransmit persistence */ 413 #define TSI_T_KEEP 2 /* keep alive */ 414 #define TSI_T_2MSL 3 /* 2*msl quiet time timer */ 415 #define TSI_T_NTIMERS 4 416 417 #define TSI_S_CLOSED 0 /* closed */ 418 #define TSI_S_LISTEN 1 /* listening for connection */ 419 #define TSI_S_SYN_SENT 2 /* active, have sent syn */ 420 #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */ 421 #define TSI_S_ESTABLISHED 4 /* established */ 422 #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 423 #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */ 424 #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 425 #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */ 426 #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */ 427 #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 428 #define TSI_S_RESERVED 11 /* pseudo state: reserved */ 429 430 struct tcp_sockinfo { 431 struct in_sockinfo tcpsi_ini; 432 int tcpsi_state; 433 int tcpsi_timer[TSI_T_NTIMERS]; 434 int tcpsi_mss; 435 uint32_t tcpsi_flags; 436 uint32_t rfu_1; /* reserved */ 437 uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */ 438 }; 439 440 /* 441 * Unix Domain Sockets 442 */ 443 444 445 struct un_sockinfo { 446 uint64_t unsi_conn_so; /* opaque handle of connected socket */ 447 uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */ 448 union { 449 struct sockaddr_un ua_sun; 450 char ua_dummy[SOCK_MAXADDRLEN]; 451 } unsi_addr; /* bound address */ 452 union { 453 struct sockaddr_un ua_sun; 454 char ua_dummy[SOCK_MAXADDRLEN]; 455 } unsi_caddr; /* address of socket connected to */ 456 }; 457 458 /* 459 * PF_NDRV Sockets 460 */ 461 462 struct ndrv_info { 463 uint32_t ndrvsi_if_family; 464 uint32_t ndrvsi_if_unit; 465 char ndrvsi_if_name[IF_NAMESIZE]; 466 }; 467 468 /* 469 * Kernel Event Sockets 470 */ 471 472 struct kern_event_info { 473 uint32_t kesi_vendor_code_filter; 474 uint32_t kesi_class_filter; 475 uint32_t kesi_subclass_filter; 476 }; 477 478 /* 479 * Kernel Control Sockets 480 */ 481 482 struct kern_ctl_info { 483 uint32_t kcsi_id; 484 uint32_t kcsi_reg_unit; 485 uint32_t kcsi_flags; /* support flags */ 486 uint32_t kcsi_recvbufsize; /* request more than the default buffer size */ 487 uint32_t kcsi_sendbufsize; /* request more than the default buffer size */ 488 uint32_t kcsi_unit; 489 char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */ 490 }; 491 492 /* 493 * VSock Sockets 494 */ 495 496 struct vsock_sockinfo { 497 uint32_t local_cid; 498 uint32_t local_port; 499 uint32_t remote_cid; 500 uint32_t remote_port; 501 }; 502 503 /* soi_state */ 504 505 #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */ 506 #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */ 507 #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */ 508 #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */ 509 #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */ 510 #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */ 511 #define SOI_S_RCVATMARK 0x0040 /* at mark on input */ 512 #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */ 513 #define SOI_S_NBIO 0x0100 /* non-blocking ops */ 514 #define SOI_S_ASYNC 0x0200 /* async i/o notify */ 515 #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */ 516 #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */ 517 #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ 518 #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */ 519 520 struct sockbuf_info { 521 uint32_t sbi_cc; 522 uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */ 523 uint32_t sbi_mbcnt; 524 uint32_t sbi_mbmax; 525 uint32_t sbi_lowat; 526 short sbi_flags; 527 short sbi_timeo; 528 }; 529 530 enum { 531 SOCKINFO_GENERIC = 0, 532 SOCKINFO_IN = 1, 533 SOCKINFO_TCP = 2, 534 SOCKINFO_UN = 3, 535 SOCKINFO_NDRV = 4, 536 SOCKINFO_KERN_EVENT = 5, 537 SOCKINFO_KERN_CTL = 6, 538 SOCKINFO_VSOCK = 7, 539 }; 540 541 struct socket_info { 542 struct vinfo_stat soi_stat; 543 uint64_t soi_so; /* opaque handle of socket */ 544 uint64_t soi_pcb; /* opaque handle of protocol control block */ 545 int soi_type; 546 int soi_protocol; 547 int soi_family; 548 short soi_options; 549 short soi_linger; 550 short soi_state; 551 short soi_qlen; 552 short soi_incqlen; 553 short soi_qlimit; 554 short soi_timeo; 555 u_short soi_error; 556 uint32_t soi_oobmark; 557 struct sockbuf_info soi_rcv; 558 struct sockbuf_info soi_snd; 559 int soi_kind; 560 uint32_t rfu_1; /* reserved */ 561 union { 562 struct in_sockinfo pri_in; /* SOCKINFO_IN */ 563 struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */ 564 struct un_sockinfo pri_un; /* SOCKINFO_UN */ 565 struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */ 566 struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */ 567 struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */ 568 struct vsock_sockinfo pri_vsock; /* SOCKINFO_VSOCK */ 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 struct kqueue_dyninfo { 624 struct kqueue_info kqdi_info; 625 uint64_t kqdi_servicer; 626 uint64_t kqdi_owner; 627 uint32_t kqdi_sync_waiters; 628 uint8_t kqdi_sync_waiter_qos; 629 uint8_t kqdi_async_qos; 630 uint16_t kqdi_request_state; 631 uint8_t kqdi_events_qos; 632 uint8_t kqdi_pri; 633 uint8_t kqdi_pol; 634 uint8_t kqdi_cpupercent; 635 uint8_t _kqdi_reserved0[4]; 636 uint64_t _kqdi_reserved1[4]; 637 }; 638 639 /* keep in sync with KQ_* in sys/eventvar.h */ 640 #define PROC_KQUEUE_SELECT 0x0001 641 #define PROC_KQUEUE_SLEEP 0x0002 642 #define PROC_KQUEUE_32 0x0008 643 #define PROC_KQUEUE_64 0x0010 644 #define PROC_KQUEUE_QOS 0x0020 645 #ifdef PRIVATE 646 /* Additional PROC_KQUEUE values in proc_info_private.h */ 647 #endif /* PRIVATE */ 648 649 struct kqueue_fdinfo { 650 struct proc_fileinfo pfi; 651 struct kqueue_info kqueueinfo; 652 }; 653 654 struct appletalk_info { 655 struct vinfo_stat atalk_stat; 656 }; 657 658 struct appletalk_fdinfo { 659 struct proc_fileinfo pfi; 660 struct appletalk_info appletalkinfo; 661 }; 662 663 typedef uint64_t proc_info_udata_t; 664 665 /* defns of process file desc type */ 666 #define PROX_FDTYPE_ATALK 0 667 #define PROX_FDTYPE_VNODE 1 668 #define PROX_FDTYPE_SOCKET 2 669 #define PROX_FDTYPE_PSHM 3 670 #define PROX_FDTYPE_PSEM 4 671 #define PROX_FDTYPE_KQUEUE 5 672 #define PROX_FDTYPE_PIPE 6 673 #define PROX_FDTYPE_FSEVENTS 7 674 #define PROX_FDTYPE_NETPOLICY 9 675 #define PROX_FDTYPE_CHANNEL 10 676 #define PROX_FDTYPE_NEXUS 11 677 678 struct proc_fdinfo { 679 int32_t proc_fd; 680 uint32_t proc_fdtype; 681 }; 682 683 struct proc_fileportinfo { 684 uint32_t proc_fileport; 685 uint32_t proc_fdtype; 686 }; 687 688 /* 689 * Channel 690 */ 691 692 /* type */ 693 #define PROC_CHANNEL_TYPE_USER_PIPE 0 694 #define PROC_CHANNEL_TYPE_KERNEL_PIPE 1 695 #define PROC_CHANNEL_TYPE_NET_IF 2 696 #define PROC_CHANNEL_TYPE_FLOW_SWITCH 3 697 698 /* flags */ 699 #define PROC_CHANNEL_FLAGS_MONITOR_TX 0x1 700 #define PROC_CHANNEL_FLAGS_MONITOR_RX 0x2 701 #define PROC_CHANNEL_FLAGS_MONITOR_NO_COPY 0x4 702 #define PROC_CHANNEL_FLAGS_EXCLUSIVE 0x10 703 #define PROC_CHANNEL_FLAGS_USER_PACKET_POOL 0x20 704 #define PROC_CHANNEL_FLAGS_DEFUNCT_OK 0x40 705 #define PROC_CHANNEL_FLAGS_LOW_LATENCY 0x80 706 #define PROC_CHANNEL_FLAGS_MONITOR \ 707 (PROC_CHANNEL_FLAGS_MONITOR_TX | PROC_CHANNEL_FLAGS_MONITOR_RX) 708 709 struct proc_channel_info { 710 uuid_t chi_instance; 711 uint32_t chi_port; 712 uint32_t chi_type; 713 uint32_t chi_flags; 714 uint32_t rfu_1;/* reserved */ 715 }; 716 717 struct channel_fdinfo { 718 struct proc_fileinfo pfi; 719 struct proc_channel_info channelinfo; 720 }; 721 722 /* Flavors for proc_pidinfo() */ 723 #define PROC_PIDLISTFDS 1 724 #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo)) 725 726 #define PROC_PIDTASKALLINFO 2 727 #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo)) 728 729 #define PROC_PIDTBSDINFO 3 730 #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo)) 731 732 #define PROC_PIDTASKINFO 4 733 #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo)) 734 735 #define PROC_PIDTHREADINFO 5 736 #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo)) 737 738 #define PROC_PIDLISTTHREADS 6 739 #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t)) 740 741 #define PROC_PIDREGIONINFO 7 742 #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo)) 743 744 #define PROC_PIDREGIONPATHINFO 8 745 #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo)) 746 747 #define PROC_PIDVNODEPATHINFO 9 748 #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo)) 749 750 #define PROC_PIDTHREADPATHINFO 10 751 #define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo)) 752 753 #define PROC_PIDPATHINFO 11 754 #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN) 755 #define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN) 756 757 #define PROC_PIDWORKQUEUEINFO 12 758 #define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo)) 759 760 #define PROC_PIDT_SHORTBSDINFO 13 761 #define PROC_PIDT_SHORTBSDINFO_SIZE (sizeof(struct proc_bsdshortinfo)) 762 763 #define PROC_PIDLISTFILEPORTS 14 764 #define PROC_PIDLISTFILEPORTS_SIZE (sizeof(struct proc_fileportinfo)) 765 766 #define PROC_PIDTHREADID64INFO 15 767 #define PROC_PIDTHREADID64INFO_SIZE (sizeof(struct proc_threadinfo)) 768 769 #define PROC_PID_RUSAGE 16 770 #define PROC_PID_RUSAGE_SIZE 0 771 772 #define PROC_PIDARCHINFO 19 773 #define PROC_PIDARCHINFO_SIZE (sizeof(struct proc_archinfo)) 774 775 #ifdef PRIVATE 776 /* Additional PROC_PID values in proc_info_private.h */ 777 #endif /* PRIVATE */ 778 /* Flavors for proc_pidfdinfo */ 779 780 #define PROC_PIDFDVNODEINFO 1 781 #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo)) 782 783 #define PROC_PIDFDVNODEPATHINFO 2 784 #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath)) 785 786 #define PROC_PIDFDSOCKETINFO 3 787 #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo)) 788 789 #define PROC_PIDFDPSEMINFO 4 790 #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo)) 791 792 #define PROC_PIDFDPSHMINFO 5 793 #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo)) 794 795 #define PROC_PIDFDPIPEINFO 6 796 #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo)) 797 798 #define PROC_PIDFDKQUEUEINFO 7 799 #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo)) 800 801 #define PROC_PIDFDATALKINFO 8 802 #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo)) 803 804 #ifdef PRIVATE 805 /* Additional PROC_PIDFD values in proc_info_private.h */ 806 #endif /* PRIVATE */ 807 808 #define PROC_PIDFDCHANNELINFO 10 809 #define PROC_PIDFDCHANNELINFO_SIZE (sizeof(struct channel_fdinfo)) 810 811 /* Flavors for proc_pidfileportinfo */ 812 813 #define PROC_PIDFILEPORTVNODEPATHINFO 2 /* out: vnode_fdinfowithpath */ 814 #define PROC_PIDFILEPORTVNODEPATHINFO_SIZE \ 815 PROC_PIDFDVNODEPATHINFO_SIZE 816 817 #define PROC_PIDFILEPORTSOCKETINFO 3 /* out: socket_fdinfo */ 818 #define PROC_PIDFILEPORTSOCKETINFO_SIZE PROC_PIDFDSOCKETINFO_SIZE 819 820 #define PROC_PIDFILEPORTPSHMINFO 5 /* out: pshm_fdinfo */ 821 #define PROC_PIDFILEPORTPSHMINFO_SIZE PROC_PIDFDPSHMINFO_SIZE 822 823 #define PROC_PIDFILEPORTPIPEINFO 6 /* out: pipe_fdinfo */ 824 #define PROC_PIDFILEPORTPIPEINFO_SIZE PROC_PIDFDPIPEINFO_SIZE 825 826 /* used for proc_setcontrol */ 827 #define PROC_SELFSET_PCONTROL 1 828 829 #define PROC_SELFSET_THREADNAME 2 830 #define PROC_SELFSET_THREADNAME_SIZE (MAXTHREADNAMESIZE -1) 831 832 #define PROC_SELFSET_VMRSRCOWNER 3 833 834 #define PROC_SELFSET_DELAYIDLESLEEP 4 835 836 /* used for proc_dirtycontrol */ 837 #define PROC_DIRTYCONTROL_TRACK 1 838 #define PROC_DIRTYCONTROL_SET 2 839 #define PROC_DIRTYCONTROL_GET 3 840 #define PROC_DIRTYCONTROL_CLEAR 4 841 842 /* proc_track_dirty() flags */ 843 #define PROC_DIRTY_TRACK 0x1 844 #define PROC_DIRTY_ALLOW_IDLE_EXIT 0x2 845 #define PROC_DIRTY_DEFER 0x4 846 #define PROC_DIRTY_LAUNCH_IN_PROGRESS 0x8 847 #define PROC_DIRTY_DEFER_ALWAYS 0x10 848 #define PROC_DIRTY_SHUTDOWN_ON_CLEAN 0x20 849 850 /* proc_get_dirty() flags */ 851 #define PROC_DIRTY_TRACKED 0x1 852 #define PROC_DIRTY_ALLOWS_IDLE_EXIT 0x2 853 #define PROC_DIRTY_IS_DIRTY 0x4 854 #define PROC_DIRTY_LAUNCH_IS_IN_PROGRESS 0x8 855 856 /* Flavors for proc_udata_info */ 857 #define PROC_UDATA_INFO_GET 1 858 #define PROC_UDATA_INFO_SET 2 859 860 __END_DECLS 861 862 #ifdef PRIVATE 863 #include <sys/proc_info_private.h> 864 #endif 865 866 #endif /*_SYS_PROC_INFO_H */ 867