1/* 2 * dlsof.h -- Darwin header file for libproc-based lsof 3 */ 4 5 6/* 7 * Portions Copyright 2005-2007 Apple Inc. All rights reserved. 8 * 9 * Copyright 2005 Purdue Research Foundation, West Lafayette, Indiana 10 * 47907. All rights reserved. 11 * 12 * Written by Allan Nathanson, Apple Inc., and Victor A. Abell, Purdue 13 * University. 14 * 15 * This software is not subject to any license of the American Telephone 16 * and Telegraph Company or the Regents of the University of California. 17 * 18 * Permission is granted to anyone to use this software for any purpose on 19 * any computer system, and to alter it and redistribute it freely, subject 20 * to the following restrictions: 21 * 22 * 1. Neither the authors, nor Apple Inc. nor Purdue University are 23 * responsible for any consequences of the use of this software. 24 * 25 * 2. The origin of this software must not be misrepresented, either 26 * by explicit claim or by omission. Credit to the authors, Apple 27 * Inc. and Purdue University must appear in documentation and sources. 28 * 29 * 3. Altered versions must be plainly marked as such, and must not be 30 * misrepresented as being the original software. 31 * 32 * 4. This notice may not be removed or altered. 33 */ 34 35 36/* 37 * $Id: dlsof.h,v 1.8 2012/04/10 16:41:04 abe Exp $ 38 */ 39 40 41#if !defined(DARWIN_LSOF_H) 42#define DARWIN_LSOF_H 1 43 44#include <stdlib.h> 45#include <dirent.h> 46#include <setjmp.h> 47#include <signal.h> 48#include <string.h> 49#include <unistd.h> 50#include <wctype.h> 51#include <arpa/inet.h> 52#include <sys/attr.h> 53#include <sys/fcntl.h> 54#include <sys/socket.h> 55#include <netinet/in.h> 56#include <netinet/tcp_fsm.h> 57#include <netinet/tcp_timer.h> 58#include <rpc/rpc.h> 59#include <rpc/pmap_prot.h> 60#include <libproc.h> 61 62# if DARWINV<900 63#define vst_blksize st_blksize 64#define vst_dev st_dev 65#define vst_ino st_ino 66#define vst_mode st_mode 67#define vst_nlink st_nlink 68#define vst_rdev st_rdev 69#define vst_size st_size 70# endif /* DARWINV<=900 */ 71 72#define COMP_P const void 73#define DEVINCR 1024 /* device table malloc() increment */ 74#define DIRTYPE dirent /* directory entry type */ 75typedef uintptr_t KA_T; 76#define KA_T_FMT_X "0x%08lx" 77#define LOGINML MAXLOGNAME 78#define MALLOC_P void 79#define FREE_P MALLOC_P 80#define MALLOC_S size_t 81#define MAXSYSCMDL (MAXCOMLEN - 1) /* max system command name length */ 82#define MOUNTED MNT_MNTTAB 83#define QSORT_P void 84#define READLEN_T int 85#define STRNCPY_L size_t 86#define SZOFFTYPE unsigned long long 87 /* size and offset internal storage 88 * type */ 89#define SZOFFPSPEC "ll" /* SZOFFTYPE printf specification 90 * modifier */ 91 92 93/* 94 * Global storage definitions (including their structure definitions) 95 */ 96 97struct file *Cfp; 98 99struct mounts { 100 char *dir; /* directory (mounted on) */ 101 char *fsname; /* file system 102 * (symbolic links unresolved) */ 103 char *fsnmres; /* file system 104 * (symbolic links resolved) */ 105 dev_t dev; /* directory st_dev */ 106 dev_t rdev; /* directory st_rdev */ 107 INODETYPE inode; /* directory st_ino */ 108 mode_t mode; /* directory st_mode */ 109 mode_t fs_mode; /* file system st_mode */ 110 int is_nfs; /* 1 if NFS file system, 0 if not */ 111 struct mounts *next; /* forward link */ 112}; 113 114struct sfile { 115 char *aname; /* argument file name */ 116 char *name; /* file name (after readlink()) */ 117 char *devnm; /* device name (optional) */ 118 dev_t dev; /* device */ 119 dev_t rdev; /* raw device */ 120 u_short mode; /* S_IFMT mode bits from stat() */ 121 int type; /* file type: 0 = file system 122 * 1 = regular file */ 123 INODETYPE i; /* inode number */ 124 int f; /* file found flag */ 125 struct sfile *next; /* forward link */ 126 127}; 128 129#define XDR_VOID (const xdrproc_t)xdr_void 130#define XDR_PMAPLIST (const xdrproc_t)xdr_pmaplist 131 132# if !defined(offsetof) 133#define offsetof(type, member) ((size_t)(&((type *)0)->member)) 134# endif /* !defined(offsetof) */ 135 136#endif /* DARWIN_LSOF_H */ 137