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