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