1/* 2 * dlsof.h - Darwin header file for /dev/kmem-based lsof 3 */ 4 5 6/* 7 * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana 8 * 47907. All rights reserved. 9 * 10 * Written by Victor A. Abell 11 * 12 * This software is not subject to any license of the American Telephone 13 * and Telegraph Company or the Regents of the University of California. 14 * 15 * Permission is granted to anyone to use this software for any purpose on 16 * any computer system, and to alter it and redistribute it freely, subject 17 * to the following restrictions: 18 * 19 * 1. Neither the authors nor Purdue University are responsible for any 20 * consequences of the use of this software. 21 * 22 * 2. The origin of this software must not be misrepresented, either by 23 * explicit claim or by omission. Credit to the authors and Purdue 24 * University must appear in documentation and sources. 25 * 26 * 3. Altered versions must be plainly marked as such, and must not be 27 * misrepresented as being the original software. 28 * 29 * 4. This notice may not be removed or altered. 30 */ 31 32 33/* 34 * $Id: dlsof.h,v 1.11 2005/11/01 20:24:51 abe Exp $ 35 */ 36 37 38#if !defined(DARWIN_LSOF_H) 39#define DARWIN_LSOF_H 1 40 41#include <stdlib.h> 42#include <dirent.h> 43#include <nlist.h> 44#include <setjmp.h> 45#include <string.h> 46#include <unistd.h> 47#include <sys/conf.h> 48#include <sys/filedesc.h> 49#include <sys/ucred.h> 50 51#if DARWINV<800 52#include <sys/mount.h> 53#define m_stat mnt_stat 54#else /* DARWINV>=800 */ 55#include <sys/mount_internal.h> 56#define m_stat mnt_vfsstat 57#endif /* DARWINV>=800 */ 58 59#if DARWINV<800 60#include <sys/uio.h> 61#include <sys/vnode.h> 62#else /* DARWINV>=800 */ 63#include <sys/vnode.h> 64#define _SYS_SYSTM_H_ 65struct nameidata { int dummy; }; /* to satisfy function prototypes */ 66#include <sys/vnode_internal.h> 67#endif /* DARWINV>=800 */ 68 69#include <rpc/types.h> 70#define KERNEL_PRIVATE 71#include <sys/socketvar.h> 72#undef KERNEL_PRIVATE 73#include <sys/protosw.h> 74#include <sys/socket.h> 75#include <sys/un.h> 76#include <sys/unpcb.h> 77 78# if defined(AF_NDRV) 79#include <net/if_var.h> 80#define KERNEL 81#include <sys/kern_event.h> 82#undef KERNEL 83#include <net/ndrv.h> 84# if DARWINV>=530 85#define KERNEL 1 86#include <net/ndrv_var.h> 87#undef KERNEL 88# endif /* DARWINV>=530 */ 89# endif /* defined(AF_NDRV) */ 90 91# if defined(AF_SYSTEM) 92#include <sys/queue.h> 93#define KERNEL 94#include <sys/kern_event.h> 95#undef KERNEL 96# endif /* defined(AF_SYSTEM) */ 97 98#include <netinet/in.h> 99#include <netinet/in_systm.h> 100#include <netinet/ip.h> 101#include <net/route.h> 102#include <netinet6/ipsec.h> 103#include <netinet/in_pcb.h> 104#include <netinet/ip_var.h> 105#include <netinet/tcp.h> 106#include <netinet/tcpip.h> 107#include <netinet/tcp_fsm.h> 108#include <netinet/tcp_timer.h> 109#include <netinet/tcp_var.h> 110#include <arpa/inet.h> 111#include <net/raw_cb.h> 112#include <sys/domain.h> 113#define pmap RPC_pmap 114#include <rpc/rpc.h> 115#include <rpc/pmap_prot.h> 116#undef pmap 117 118#include <sys/quota.h> 119#include <sys/event.h> 120 121# if DARWINV<800 122#include <paths.h> 123#undef MAXNAMLEN 124#include <ufs/ufs/quota.h> 125#include <paths.h> 126#include <ufs/ufs/quota.h> 127#include <ufs/ufs/inode.h> 128#include <nfs/rpcv2.h> 129#include <nfs/nfs.h> 130#include <nfs/nfsproto.h> 131#include <nfs/nfsnode.h> 132 133# if DARWINV<600 134#include <hfs/hfs.h> 135#undef offsetof 136# else /* DARWINV>=600 */ 137#define KERNEL 138#include <hfs/hfs_cnode.h> 139#undef KERNEL 140# endif /* DARWINV<600 */ 141# endif /* DARWINV<800 */ 142 143# if DARWINV<800 144#define time t1 /* hack to make dn_times() happy */ 145#include <miscfs/devfs/devfsdefs.h> 146#undef time 147# endif /* DARWINV<800 */ 148 149# if DARWINV<800 150#define KERNEL 151#include <miscfs/fdesc/fdesc.h> 152#undef KERNEL 153# endif /* DARWINV<800 */ 154 155# if DARWINV<800 156#include <sys/proc.h> 157# else /* DARWINV>=800 */ 158#define PROC_DEF_ENABLED 159#define sleep kernel_sleep 160#include <sys/proc_internal.h> 161#undef sleep 162# endif /* DARWINV<800 */ 163 164#include <kvm.h> 165#undef TRUE 166#undef FALSE 167 168# if DARWINV<800 169#include <sys/sysctl.h> 170# else /* DARWINV>=800 */ 171#include "/usr/include/sys/sysctl.h" 172# endif /* DARWINV<800 */ 173 174# if DARWINV<800 175#define KERNEL 176#include <sys/fcntl.h> 177#include <sys/file.h> 178#undef KERNEL 179# else /* DARWINV>=800 */ 180#include <sys/fcntl.h> 181#include <sys/file_internal.h> 182# endif /* DARWINV<800 */ 183 184# if defined(HASKQUEUE) 185#include <sys/eventvar.h> 186# endif /* defined(HASKQUEUE) */ 187 188# if defined(DTYPE_PSXSEM) 189#define HASPSXSEM /* has the POSIX semaphore file 190 * type */ 191# endif /* defined(DTYPE_PSXSEM) */ 192 193# if defined(DTYPE_PSXSHM) 194#define HASPSXSHM /* has the POSIX shared memory 195 * file type */ 196# endif /* defined(DTYPE_PSXSHM) */ 197 198struct vop_advlock_args { int dummy; }; /* to satisfy lf_advlock() prototype */ 199#include <sys/lockf.h> 200#include <sys/lock.h> 201 202/* 203 * Compensate for removal of MAP_ENTRY_IS_A_MAP from <vm/vm_map.h>, 204 * This work-around was supplied by John Polstra <jdp@polstra.com>. 205 */ 206 207# if defined(MAP_ENTRY_IS_SUB_MAP) && !defined(MAP_ENTRY_IS_A_MAP) 208#define MAP_ENTRY_IS_A_MAP 0 209# endif /* defined(MAP_ENTRY_IS_SUB_MAP) && !defined(MAP_ENTRY_IS_A_MAP) */ 210 211#undef B_NEEDCOMMIT 212#include <sys/buf.h> 213#include <sys/signal.h> 214#define user_sigaltstack sigaltstack 215#include <sys/user.h> 216 217#define COMP_P const void 218#define DEVINCR 1024 /* device table malloc() increment */ 219#define DIRTYPE dirent /* directory entry type */ 220 221typedef u_long KA_T; 222 223#define KMEM "/dev/kmem" 224#define LOGINML MAXLOGNAME 225#define MALLOC_P void 226#define FREE_P MALLOC_P 227#define MALLOC_S size_t 228 229#define N_UNIX "/mach_kernel" 230 231#define QSORT_P void 232#define READLEN_T int 233#define STRNCPY_L size_t 234#define SWAP "/dev/drum" 235 236# if DARWINV>=800 237#define SZOFFTYPE unsigned long long 238 /* size and offset internal storage 239 * type */ 240#define SZOFFPSPEC "ll" /* SZOFFTYPE printf specification 241 * modifier */ 242# endif /* DARWINV>=800 */ 243 244 245/* 246 * Global storage definitions (including their structure definitions) 247 */ 248 249struct file * Cfp; 250 251extern int Kd; /* KMEM descriptor */ 252extern KA_T Kpa; 253 254struct l_vfs { 255 KA_T addr; /* kernel address */ 256 fsid_t fsid; /* file system ID */ 257 258# if defined(MOUNT_NONE) 259 short type; /* type of file system */ 260# else /* !defined(MOUNT_NONE) */ 261 char *typnm; /* file system type name */ 262# endif /* defined(MOUNT_NONE) */ 263 264 char *dir; /* mounted directory */ 265 char *fsname; /* file system name */ 266 struct l_vfs *next; /* forward link */ 267}; 268extern struct l_vfs *Lvfs; 269 270struct mounts { 271 char *dir; /* directory (mounted on) */ 272 char *fsname; /* file system 273 * (symbolic links unresolved) */ 274 char *fsnmres; /* file system 275 * (symbolic links resolved) */ 276 dev_t dev; /* directory st_dev */ 277 dev_t rdev; /* directory st_rdev */ 278 INODETYPE inode; /* directory st_ino */ 279 mode_t mode; /* directory st_mode */ 280 mode_t fs_mode; /* file system st_mode */ 281 struct mounts *next; /* forward link */ 282}; 283 284#define X_NCACHE "ncache" 285#define X_NCSIZE "ncsize" 286#define NL_NAME n_name 287 288struct sfile { 289 char *aname; /* argument file name */ 290 char *name; /* file name (after readlink()) */ 291 char *devnm; /* device name (optional) */ 292 dev_t dev; /* device */ 293 dev_t rdev; /* raw device */ 294 u_short mode; /* S_IFMT mode bits from stat() */ 295 int type; /* file type: 0 = file system 296 * 1 = regular file */ 297 INODETYPE i; /* inode number */ 298 int f; /* file found flag */ 299 struct sfile *next; /* forward link */ 300 301}; 302 303#define XDR_VOID (const xdrproc_t)xdr_void 304#define XDR_PMAPLIST (const xdrproc_t)xdr_pmaplist 305 306 307/* 308 * Definitions for rnmh.c 309 */ 310 311# if defined(HASNCACHE) 312#include <sys/uio.h> 313#include <sys/namei.h> 314 315# if !defined(offsetof) 316#define offsetof(type, member) ((size_t)(&((type *)0)->member)) 317# endif /* !defined(offsetof) */ 318 319#define NCACHE namecache /* kernel's structure name */ 320 321#define NCACHE_NM nc_name /* name in NCACHE */ 322 323# if DARWINV<700 324#define NCACHE_NMLEN nc_nlen /* name length in NCACHE */ 325# endif /* DARWINV<700 */ 326 327#define NCACHE_NXT nc_hash.le_next /* link in NCACHE */ 328#define NCACHE_NODEADDR nc_vp /* node address in NCACHE */ 329#define NCACHE_PARADDR nc_dvp /* parent node address in NCACHE */ 330 331# if defined(HASNCVPID) 332#define NCACHE_NODEID nc_vpid /* node ID in NCACHE */ 333#define NCACHE_PARID nc_dvpid /* parent node ID in NCACHE */ 334# endif /* defined(HASNCVPID) */ 335# endif /* defined(HASNCACHE) */ 336 337#endif /* DARWIN_LSOF_H */ 338