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 /* 356 * Socket 357 */ 358 359 360 /* 361 * IPv4 and IPv6 Sockets 362 */ 363 364 #define INI_IPV4 0x1 365 #define INI_IPV6 0x2 366 367 struct in4in6_addr { 368 u_int32_t i46a_pad32[3]; 369 struct in_addr i46a_addr4; 370 }; 371 372 struct in_sockinfo { 373 int insi_fport; /* foreign port */ 374 int insi_lport; /* local port */ 375 uint64_t insi_gencnt; /* generation count of this instance */ 376 uint32_t insi_flags; /* generic IP/datagram flags */ 377 uint32_t insi_flow; 378 379 uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */ 380 uint8_t insi_ip_ttl; /* time to live proto */ 381 uint32_t rfu_1; /* reserved */ 382 /* protocol dependent part */ 383 union { 384 struct in4in6_addr ina_46; 385 struct in6_addr ina_6; 386 } insi_faddr; /* foreign host table entry */ 387 union { 388 struct in4in6_addr ina_46; 389 struct in6_addr ina_6; 390 } insi_laddr; /* local host table entry */ 391 struct { 392 u_char in4_tos; /* type of service */ 393 } insi_v4; 394 struct { 395 uint8_t in6_hlim; 396 int in6_cksum; 397 u_short in6_ifindex; 398 short in6_hops; 399 } insi_v6; 400 }; 401 402 /* 403 * TCP Sockets 404 */ 405 406 #define TSI_T_REXMT 0 /* retransmit */ 407 #define TSI_T_PERSIST 1 /* retransmit persistence */ 408 #define TSI_T_KEEP 2 /* keep alive */ 409 #define TSI_T_2MSL 3 /* 2*msl quiet time timer */ 410 #define TSI_T_NTIMERS 4 411 412 #define TSI_S_CLOSED 0 /* closed */ 413 #define TSI_S_LISTEN 1 /* listening for connection */ 414 #define TSI_S_SYN_SENT 2 /* active, have sent syn */ 415 #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */ 416 #define TSI_S_ESTABLISHED 4 /* established */ 417 #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 418 #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */ 419 #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 420 #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */ 421 #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */ 422 #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 423 #define TSI_S_RESERVED 11 /* pseudo state: reserved */ 424 425 struct tcp_sockinfo { 426 struct in_sockinfo tcpsi_ini; 427 int tcpsi_state; 428 int tcpsi_timer[TSI_T_NTIMERS]; 429 int tcpsi_mss; 430 uint32_t tcpsi_flags; 431 uint32_t rfu_1; /* reserved */ 432 uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */ 433 }; 434 435 /* 436 * Unix Domain Sockets 437 */ 438 439 440 struct un_sockinfo { 441 uint64_t unsi_conn_so; /* opaque handle of connected socket */ 442 uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */ 443 union { 444 struct sockaddr_un ua_sun; 445 char ua_dummy[SOCK_MAXADDRLEN]; 446 } unsi_addr; /* bound address */ 447 union { 448 struct sockaddr_un ua_sun; 449 char ua_dummy[SOCK_MAXADDRLEN]; 450 } unsi_caddr; /* address of socket connected to */ 451 }; 452 453 /* 454 * PF_NDRV Sockets 455 */ 456 457 struct ndrv_info { 458 uint32_t ndrvsi_if_family; 459 uint32_t ndrvsi_if_unit; 460 char ndrvsi_if_name[IF_NAMESIZE]; 461 }; 462 463 /* 464 * Kernel Event Sockets 465 */ 466 467 struct kern_event_info { 468 uint32_t kesi_vendor_code_filter; 469 uint32_t kesi_class_filter; 470 uint32_t kesi_subclass_filter; 471 }; 472 473 /* 474 * Kernel Control Sockets 475 */ 476 477 struct kern_ctl_info { 478 uint32_t kcsi_id; 479 uint32_t kcsi_reg_unit; 480 uint32_t kcsi_flags; /* support flags */ 481 uint32_t kcsi_recvbufsize; /* request more than the default buffer size */ 482 uint32_t kcsi_sendbufsize; /* request more than the default buffer size */ 483 uint32_t kcsi_unit; 484 char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */ 485 }; 486 487 /* 488 * VSock Sockets 489 */ 490 491 struct vsock_sockinfo { 492 uint32_t local_cid; 493 uint32_t local_port; 494 uint32_t remote_cid; 495 uint32_t remote_port; 496 }; 497 498 /* soi_state */ 499 500 #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */ 501 #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */ 502 #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */ 503 #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */ 504 #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */ 505 #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */ 506 #define SOI_S_RCVATMARK 0x0040 /* at mark on input */ 507 #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */ 508 #define SOI_S_NBIO 0x0100 /* non-blocking ops */ 509 #define SOI_S_ASYNC 0x0200 /* async i/o notify */ 510 #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */ 511 #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */ 512 #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ 513 #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */ 514 515 struct sockbuf_info { 516 uint32_t sbi_cc; 517 uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */ 518 uint32_t sbi_mbcnt; 519 uint32_t sbi_mbmax; 520 uint32_t sbi_lowat; 521 short sbi_flags; 522 short sbi_timeo; 523 }; 524 525 enum { 526 SOCKINFO_GENERIC = 0, 527 SOCKINFO_IN = 1, 528 SOCKINFO_TCP = 2, 529 SOCKINFO_UN = 3, 530 SOCKINFO_NDRV = 4, 531 SOCKINFO_KERN_EVENT = 5, 532 SOCKINFO_KERN_CTL = 6, 533 SOCKINFO_VSOCK = 7, 534 }; 535 536 struct socket_info { 537 struct vinfo_stat soi_stat; 538 uint64_t soi_so; /* opaque handle of socket */ 539 uint64_t soi_pcb; /* opaque handle of protocol control block */ 540 int soi_type; 541 int soi_protocol; 542 int soi_family; 543 short soi_options; 544 short soi_linger; 545 short soi_state; 546 short soi_qlen; 547 short soi_incqlen; 548 short soi_qlimit; 549 short soi_timeo; 550 u_short soi_error; 551 uint32_t soi_oobmark; 552 struct sockbuf_info soi_rcv; 553 struct sockbuf_info soi_snd; 554 int soi_kind; 555 uint32_t rfu_1; /* reserved */ 556 union { 557 struct in_sockinfo pri_in; /* SOCKINFO_IN */ 558 struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */ 559 struct un_sockinfo pri_un; /* SOCKINFO_UN */ 560 struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */ 561 struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */ 562 struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */ 563 struct vsock_sockinfo pri_vsock; /* SOCKINFO_VSOCK */ 564 } soi_proto; 565 }; 566 567 struct socket_fdinfo { 568 struct proc_fileinfo pfi; 569 struct socket_info psi; 570 }; 571 572 573 574 struct psem_info { 575 struct vinfo_stat psem_stat; 576 char psem_name[MAXPATHLEN]; 577 }; 578 579 struct psem_fdinfo { 580 struct proc_fileinfo pfi; 581 struct psem_info pseminfo; 582 }; 583 584 585 586 struct pshm_info { 587 struct vinfo_stat pshm_stat; 588 uint64_t pshm_mappaddr; 589 char pshm_name[MAXPATHLEN]; 590 }; 591 592 struct pshm_fdinfo { 593 struct proc_fileinfo pfi; 594 struct pshm_info pshminfo; 595 }; 596 597 598 struct pipe_info { 599 struct vinfo_stat pipe_stat; 600 uint64_t pipe_handle; 601 uint64_t pipe_peerhandle; 602 int pipe_status; 603 int rfu_1; /* reserved */ 604 }; 605 606 struct pipe_fdinfo { 607 struct proc_fileinfo pfi; 608 struct pipe_info pipeinfo; 609 }; 610 611 612 struct kqueue_info { 613 struct vinfo_stat kq_stat; 614 uint32_t kq_state; 615 uint32_t rfu_1; /* reserved */ 616 }; 617 618 struct kqueue_dyninfo { 619 struct kqueue_info kqdi_info; 620 uint64_t kqdi_servicer; 621 uint64_t kqdi_owner; 622 uint32_t kqdi_sync_waiters; 623 uint8_t kqdi_sync_waiter_qos; 624 uint8_t kqdi_async_qos; 625 uint16_t kqdi_request_state; 626 uint8_t kqdi_events_qos; 627 uint8_t kqdi_pri; 628 uint8_t kqdi_pol; 629 uint8_t kqdi_cpupercent; 630 uint8_t _kqdi_reserved0[4]; 631 uint64_t _kqdi_reserved1[4]; 632 }; 633 634 /* keep in sync with KQ_* in sys/eventvar.h */ 635 #define PROC_KQUEUE_SELECT 0x0001 636 #define PROC_KQUEUE_SLEEP 0x0002 637 #define PROC_KQUEUE_32 0x0008 638 #define PROC_KQUEUE_64 0x0010 639 #define PROC_KQUEUE_QOS 0x0020 640 #ifdef PRIVATE 641 /* Additional PROC_KQUEUE values in proc_info_private.h */ 642 #endif /* PRIVATE */ 643 644 struct kqueue_fdinfo { 645 struct proc_fileinfo pfi; 646 struct kqueue_info kqueueinfo; 647 }; 648 649 struct appletalk_info { 650 struct vinfo_stat atalk_stat; 651 }; 652 653 struct appletalk_fdinfo { 654 struct proc_fileinfo pfi; 655 struct appletalk_info appletalkinfo; 656 }; 657 658 typedef uint64_t proc_info_udata_t; 659 660 /* defns of process file desc type */ 661 #define PROX_FDTYPE_ATALK 0 662 #define PROX_FDTYPE_VNODE 1 663 #define PROX_FDTYPE_SOCKET 2 664 #define PROX_FDTYPE_PSHM 3 665 #define PROX_FDTYPE_PSEM 4 666 #define PROX_FDTYPE_KQUEUE 5 667 #define PROX_FDTYPE_PIPE 6 668 #define PROX_FDTYPE_FSEVENTS 7 669 #define PROX_FDTYPE_NETPOLICY 9 670 #define PROX_FDTYPE_CHANNEL 10 671 #define PROX_FDTYPE_NEXUS 11 672 673 struct proc_fdinfo { 674 int32_t proc_fd; 675 uint32_t proc_fdtype; 676 }; 677 678 struct proc_fileportinfo { 679 uint32_t proc_fileport; 680 uint32_t proc_fdtype; 681 }; 682 683 /* 684 * Channel 685 */ 686 687 /* type */ 688 #define PROC_CHANNEL_TYPE_USER_PIPE 0 689 #define PROC_CHANNEL_TYPE_KERNEL_PIPE 1 690 #define PROC_CHANNEL_TYPE_NET_IF 2 691 #define PROC_CHANNEL_TYPE_FLOW_SWITCH 3 692 693 /* flags */ 694 #define PROC_CHANNEL_FLAGS_MONITOR_TX 0x1 695 #define PROC_CHANNEL_FLAGS_MONITOR_RX 0x2 696 #define PROC_CHANNEL_FLAGS_MONITOR_NO_COPY 0x4 697 #define PROC_CHANNEL_FLAGS_EXCLUSIVE 0x10 698 #define PROC_CHANNEL_FLAGS_USER_PACKET_POOL 0x20 699 #define PROC_CHANNEL_FLAGS_DEFUNCT_OK 0x40 700 #define PROC_CHANNEL_FLAGS_LOW_LATENCY 0x80 701 #define PROC_CHANNEL_FLAGS_MONITOR \ 702 (PROC_CHANNEL_FLAGS_MONITOR_TX | PROC_CHANNEL_FLAGS_MONITOR_RX) 703 704 struct proc_channel_info { 705 uuid_t chi_instance; 706 uint32_t chi_port; 707 uint32_t chi_type; 708 uint32_t chi_flags; 709 uint32_t rfu_1;/* reserved */ 710 }; 711 712 struct channel_fdinfo { 713 struct proc_fileinfo pfi; 714 struct proc_channel_info channelinfo; 715 }; 716 717 /* Flavors for proc_pidinfo() */ 718 #define PROC_PIDLISTFDS 1 719 #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo)) 720 721 #define PROC_PIDTASKALLINFO 2 722 #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo)) 723 724 #define PROC_PIDTBSDINFO 3 725 #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo)) 726 727 #define PROC_PIDTASKINFO 4 728 #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo)) 729 730 #define PROC_PIDTHREADINFO 5 731 #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo)) 732 733 #define PROC_PIDLISTTHREADS 6 734 #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t)) 735 736 #define PROC_PIDREGIONINFO 7 737 #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo)) 738 739 #define PROC_PIDREGIONPATHINFO 8 740 #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo)) 741 742 #define PROC_PIDVNODEPATHINFO 9 743 #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo)) 744 745 #define PROC_PIDTHREADPATHINFO 10 746 #define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo)) 747 748 #define PROC_PIDPATHINFO 11 749 #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN) 750 #define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN) 751 752 #define PROC_PIDWORKQUEUEINFO 12 753 #define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo)) 754 755 #define PROC_PIDT_SHORTBSDINFO 13 756 #define PROC_PIDT_SHORTBSDINFO_SIZE (sizeof(struct proc_bsdshortinfo)) 757 758 #define PROC_PIDLISTFILEPORTS 14 759 #define PROC_PIDLISTFILEPORTS_SIZE (sizeof(struct proc_fileportinfo)) 760 761 #define PROC_PIDTHREADID64INFO 15 762 #define PROC_PIDTHREADID64INFO_SIZE (sizeof(struct proc_threadinfo)) 763 764 #define PROC_PID_RUSAGE 16 765 #define PROC_PID_RUSAGE_SIZE 0 766 767 #ifdef PRIVATE 768 /* Additional PROC_PID values in proc_info_private.h */ 769 #endif /* PRIVATE */ 770 /* Flavors for proc_pidfdinfo */ 771 772 #define PROC_PIDFDVNODEINFO 1 773 #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo)) 774 775 #define PROC_PIDFDVNODEPATHINFO 2 776 #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath)) 777 778 #define PROC_PIDFDSOCKETINFO 3 779 #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo)) 780 781 #define PROC_PIDFDPSEMINFO 4 782 #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo)) 783 784 #define PROC_PIDFDPSHMINFO 5 785 #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo)) 786 787 #define PROC_PIDFDPIPEINFO 6 788 #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo)) 789 790 #define PROC_PIDFDKQUEUEINFO 7 791 #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo)) 792 793 #define PROC_PIDFDATALKINFO 8 794 #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo)) 795 796 #ifdef PRIVATE 797 /* Additional PROC_PIDFD values in proc_info_private.h */ 798 #endif /* PRIVATE */ 799 800 #define PROC_PIDFDCHANNELINFO 10 801 #define PROC_PIDFDCHANNELINFO_SIZE (sizeof(struct channel_fdinfo)) 802 803 /* Flavors for proc_pidfileportinfo */ 804 805 #define PROC_PIDFILEPORTVNODEPATHINFO 2 /* out: vnode_fdinfowithpath */ 806 #define PROC_PIDFILEPORTVNODEPATHINFO_SIZE \ 807 PROC_PIDFDVNODEPATHINFO_SIZE 808 809 #define PROC_PIDFILEPORTSOCKETINFO 3 /* out: socket_fdinfo */ 810 #define PROC_PIDFILEPORTSOCKETINFO_SIZE PROC_PIDFDSOCKETINFO_SIZE 811 812 #define PROC_PIDFILEPORTPSHMINFO 5 /* out: pshm_fdinfo */ 813 #define PROC_PIDFILEPORTPSHMINFO_SIZE PROC_PIDFDPSHMINFO_SIZE 814 815 #define PROC_PIDFILEPORTPIPEINFO 6 /* out: pipe_fdinfo */ 816 #define PROC_PIDFILEPORTPIPEINFO_SIZE PROC_PIDFDPIPEINFO_SIZE 817 818 /* used for proc_setcontrol */ 819 #define PROC_SELFSET_PCONTROL 1 820 821 #define PROC_SELFSET_THREADNAME 2 822 #define PROC_SELFSET_THREADNAME_SIZE (MAXTHREADNAMESIZE -1) 823 824 #define PROC_SELFSET_VMRSRCOWNER 3 825 826 #define PROC_SELFSET_DELAYIDLESLEEP 4 827 828 /* used for proc_dirtycontrol */ 829 #define PROC_DIRTYCONTROL_TRACK 1 830 #define PROC_DIRTYCONTROL_SET 2 831 #define PROC_DIRTYCONTROL_GET 3 832 #define PROC_DIRTYCONTROL_CLEAR 4 833 834 /* proc_track_dirty() flags */ 835 #define PROC_DIRTY_TRACK 0x1 836 #define PROC_DIRTY_ALLOW_IDLE_EXIT 0x2 837 #define PROC_DIRTY_DEFER 0x4 838 #define PROC_DIRTY_LAUNCH_IN_PROGRESS 0x8 839 #define PROC_DIRTY_DEFER_ALWAYS 0x10 840 #define PROC_DIRTY_SHUTDOWN_ON_CLEAN 0x20 841 842 /* proc_get_dirty() flags */ 843 #define PROC_DIRTY_TRACKED 0x1 844 #define PROC_DIRTY_ALLOWS_IDLE_EXIT 0x2 845 #define PROC_DIRTY_IS_DIRTY 0x4 846 #define PROC_DIRTY_LAUNCH_IS_IN_PROGRESS 0x8 847 848 /* Flavors for proc_udata_info */ 849 #define PROC_UDATA_INFO_GET 1 850 #define PROC_UDATA_INFO_SET 2 851 852 __END_DECLS 853 854 #ifdef PRIVATE 855 #include <sys/proc_info_private.h> 856 #endif 857 858 #endif /*_SYS_PROC_INFO_H */ 859