#if !defined(LSOF_H)
#define LSOF_H 1
#include "machine.h"
# if !defined(FSV_DEFAULT)
#define FSV_DEFAULT 0
# endif
#include "lsof_fields.h"
#include <ctype.h>
#include <errno.h>
# if defined(HASSETLOCALE)
#include <locale.h>
# endif
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/wait.h>
# if !defined(INODETYPE)
#define INODETYPE unsigned long
#define INODEPSPEC "l"
# endif
struct l_dev {
dev_t rdev;
INODETYPE inode;
char *name;
int v;
};
#define FF_AIO "AIO"
#define FF_APPEND "AP"
#define FF_ASYNC "ASYN"
#define FF_BLKANDSET "BAS"
#define FF_BLKINUSE "BKIU"
#define FF_BLKSEEK "BSK"
#define FF_CIO "CIO"
#define FF_CLONE "CLON"
#define FF_CLREAD "CLRD"
#define FF_COPYAVOID "CA"
#define FF_CREAT "CR"
#define FF_DATAFLUSH "DFLU"
#define FF_DEFER "DF"
#define FF_DEFERIND "DFI"
#define FF_DELAY "DLY"
#define FF_DIRECT "DIR"
#define FF_DOCLONE "DOCL"
#define FF_DSYNC "DSYN"
#define FF_EVTONLY "EVO"
#define FF_EXCL "EXCL"
#define FF_EXEC "EX"
#define FF_EXLOCK "XL"
#define FF_FILE_MBLK "MBLK"
#define FF_FSYNC "FSYN"
#define FF_GCFDEFER "GCDF"
#define FF_GCFMARK "GCMK"
#define FF_GENTTY "GTTY"
#define FF_HASLOCK "LCK"
#define FF_HUP "HUP"
#define FF_KERNEL "KERN"
#define FF_KIOCTL "KIOC"
#define FF_LARGEFILE "LG"
#define FF_MARK "MK"
#define FF_MOUNT "MNT"
#define FF_MSYNC "MSYN"
#define FF_NBDRM "NBDR"
#define FF_NBIO "NBIO"
#define FF_NBLOCK "NB"
#define FF_NBUF "NBF"
#define FF_NMFS "NMFS"
#define FF_NDELAY "ND"
#define FF_NET "NET"
#define FF_NOCACHE "NC"
#define FF_NOCTTY "NTTY"
#define FF_NODSYNC "NDSY"
#define FF_NOTOSTOP "NOTO"
#define FF_NSHARE "NSH"
#define FF_OLRMIRROR "OLRM"
#define FF_POSIX_AIO "PAIO"
#define FF_POSIX_PIPE "PP"
#define FF_RAIOSIG "RAIO"
#define FF_RCACH "RC"
#define FF_READ "R"
#define FF_REVOKED "REV"
#define FF_RSHARE "RSH"
#define FF_RSYNC "RSYN"
#define FF_SETBLK "BL"
#define FF_SHLOCK "SL"
#define FF_SNAP "SNAP"
#define FF_SOCKET "SOCK"
#define FF_SQTSH1 "SQS1"
#define FF_SQTSH2 "SQS2"
#define FF_SQTREPAIR "SQR"
#define FF_SQTSH "SQSH"
#define FF_SQTSVM "SQSV"
#define FF_STOPIO "STPI"
#define FF_SYNC "SYN"
#define FF_SYNCRON "SWR"
#define FF_TCP_MDEVONLY "TCPM"
#define FF_TERMIO "TIO"
#define FF_TRUNC "TR"
#define FF_VHANGUP "VH"
#define FF_VTEXT "VTXT"
#define FF_WAKEUP "WKUP"
#define FF_WAITING "WTG"
#define FF_WRITE "W"
#define POF_ALLOCATED "ALLC"
#define POF_BNRD "BR"
#define POF_BNWR "BW"
#define POF_BNHUP "BHUP"
#define POF_CLOEXEC "CX"
#define POF_CLOSING "CLSG"
#define POF_FDLOCK "LCK"
#define POF_INUSE "USE"
#define POF_MAPPED "MP"
#define POF_FSHMAT "SHMT"
#define POF_RESERVED "OPIP"
#define POF_RSVWT "RSVW"
#define XO_FILESYS 0x1
#define XO_SYMLINK 0x2
#define XO_ALL (XO_FILESYS | XO_SYMLINK)
#include "dlsof.h"
#include <sys/types.h>
#include "./regex.h"
# if defined(EMPTY)
#undef EMPTY
# endif
# if defined(HASUTMPX)
#include <utmpx.h>
# else
#include <utmp.h>
# endif
extern int errno;
extern char *optarg;
extern int optind;
#define ACCESSERRFMT "%s: WARNING: access %s: %s\n"
# if defined(HASDCACHE)
#define CRC_POLY 0120001
#define CRC_TBLL 256
#define CRC_BITS 8
# endif
#define CMDL 9
#define CWD " cwd"
#define FDLEN 8
#define FSV_FA 0x1
#define FSV_CT 0x2
#define FSV_FG 0x4
#define FSV_NI 0x8
# if !defined(GET_MAJ_DEV)
#define GET_MAJ_DEV major
# endif
# if !defined(GET_MIN_DEV)
#define GET_MIN_DEV minor
# endif
# if defined(HASSELINUX)
#define HASHCNTX 128
# endif
# if defined(HASZONES)
#define HASHZONE 128
# endif
#define IDINCR 10
# if !defined(INADDR_LOOPBACK)
#define INADDR_LOOPBACK (u_long)0x7f000001
# endif
#define IPROTOL 8
# if !defined(KA_T_FMT_X)
#define KA_T_FMT_X "0x%08lx"
# endif
# if !defined(LOGINML)
# if defined(HASUTMPX)
static struct utmpx dummy_utmp;
# else
static struct utmp dummy_utmp;
# endif
#define LOGINML sizeof(dummy_utmp.ut_name)
# endif
#define LPROCINCR 128
#define LSOF_URL "ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/"
#define MIN_AF_ADDR sizeof(struct in_addr)
# if defined(HASIPv6)
#define MAX_AF_ADDR sizeof(struct in6_addr)
# else
#define MAX_AF_ADDR MIN_AF_ADDR
# endif
#define MAXDCPATH 4
#define MAXNWAD 100
# if !defined(MEMMOVE)
#define MEMMOVE memmove
# endif
#define N_REGLR 0
#define N_AFS 1
#define N_AFPFS 2
#define N_AUSX 3
#define N_AUTO 4
#define N_BLK 5
#define N_CACHE 6
#define N_CDFS 7
#define N_CFS 8
#define N_CHR 9
#define N_COM 10
#define N_CTFSADIR 11
#define N_CTFSBUND 12
#define N_CTFSCDIR 13
#define N_CTFSCTL 14
#define N_CTFSEVT 15
#define N_CTFSLATE 16
#define N_CTFSROOT 17
#define N_CTFSSTAT 18
#define N_CTFSSYM 19
#define N_CTFSTDIR 20
#define N_CTFSTMPL 21
#define N_DEV 22
#define N_DOOR 23
#define N_FD 24
#define N_FIFO 25
#define N_HSFS 26
#define N_KERN 27
#define N_LOFS 28
#define N_MNT 29
#define N_MPC 30
#define N_MVFS 31
#define N_NFS 32
#define N_NFS4 33
#define N_NM 34
#define N_OBJF 35
#define N_PCFS 36
#define N_PIPE 37
#define N_PORT 38
#define N_PROC 39
#define N_PSEU 49
#define N_SAMFS 41
#define N_SANFS 42
#define N_SOCK 43
#define N_SPEC 44
#define N_STREAM 45
#define N_TMP 46
#define N_UFS 47
#define N_VXFS 48
#define N_XFS 49
#define N_ZFS 50
# if !defined(OFFDECDIG)
#define OFFDECDIG 8
# endif
# if !defined(USELOCALREADDIR)
#define CloseDir closedir
#define OpenDir opendir
#define ReadDir readdir
# endif
#define RPTTM 15
#define RTD " rtd"
#define TCPTPI_FLAGS 0x0001
#define TCPTPI_QUEUES 0x0002
#define TCPTPI_STATE 0x0004
#define TCPTPI_WINDOWS 0x0008
#define TCPTPI_ALL (TCPTPI_QUEUES | TCPTPI_STATE | TCPTPI_WINDOWS)
#define TMLIMIT 15
#define TMLIMMIN 2
#define TYPEL 8
#define UIDCACHEL 1024
#define UIDINCR 10
#define USERPRTL 8
# if !defined(SZOFFTYPE)
#define SZOFFTYPE unsigned long
#undef SZOFFPSPEC
#define SZOFFPSPEC "l"
# endif
# if !defined(TIMEVAL_LSOF)
#define TIMEVAL_LSOF timeval
# endif
# if !defined(XDR_PMAPLIST)
#define XDR_PMAPLIST xdr_pmaplist
# endif
# if !defined(XDR_VOID)
#define XDR_VOID xdr_void
# endif
#define CMDTTL "COMMAND"
extern int CmdColW;
#define CNTXTTL "SECURITY-CONTEXT"
extern int CntxColW;
#define DEVTTL "DEVICE"
extern int DevColW;
#define FCTTL "FCT"
extern int FcColW;
#define FDTTL "FD"
extern int FdColW;
#define FGTTL "FILE-FLAG"
extern int FgColW;
#define FSTTL "FILE-ADDR"
extern int FsColW;
#define NITTL "NODE-ID"
extern int NiColW;
extern char *NiTtl;
#define NLTTL "NLINK"
extern int NlColW;
#define NMTTL "NAME"
extern int NmColW;
#define NODETTL "NODE"
extern int NodeColW;
#define OFFTTL "OFFSET"
#define PGIDTTL "PGID"
extern int PgidColW;
#define PIDTTL "PID"
extern int PidColW;
#define PPIDTTL "PPID"
extern int PpidColW;
#define SZTTL "SIZE"
#define SZOFFTTL "SIZE/OFF"
extern int SzOffColW;
#define TYPETTL "TYPE"
extern int TypeColW;
#define USERTTL "USER"
extern int UserColW;
#define ZONETTL "ZONE"
extern int ZoneColW;
#define PS_PRI 1
#define PS_SEC 2
#define SELCMD 0x0001
#define SELCNTX 0x0002
#define SELFD 0x0004
#define SELNA 0x0008
#define SELNET 0x0010
#define SELNFS 0x0020
#define SELNLINK 0x0040
#define SELNM 0x0080
#define SELPGID 0x0100
#define SELPID 0x0200
#define SELUID 0x0400
#define SELUNX 0x0800
#define SELZONE 0x1000
#define SELALL (SELCMD|SELCNTX|SELFD|SELNA|SELNET|SELNM|SELNFS|SELPID|SELUID|SELUNX|SELZONE)
#define SELPROC (SELCMD|SELCNTX|SELPGID|SELPID|SELUID|SELZONE)
#define SELFILE (SELFD|SELNFS|SELNLINK|SELNM)
#define SELNW (SELNA|SELNET|SELUNX)
# if defined(HAS_AFS)
struct afsnode {
dev_t dev;
unsigned char ino_st;
unsigned char nlink_st;
INODETYPE inode;
unsigned long size;
long nlink;
};
# endif
# if defined(HAS_STD_CLONE)
struct clone {
int dx;
struct clone *next;
};
extern struct clone *Clone;
# endif
# if defined(HASNLIST)
struct drive_Nl {
char *nn;
char *knm;
};
extern struct drive_Nl Drive_Nl[];
# endif
struct int_lst {
int i;
int f;
int x;
};
typedef struct lsof_rx {
char *exp;
regex_t cx;
int mc;
} lsof_rx_t;
extern lsof_rx_t *CmdRx;
extern int NCmdRxU;
# if defined(HASFSTRUCT)
struct pff_tab {
long val;
char *nm;
};
# endif
struct seluid {
uid_t uid;
char *lnm;
unsigned char excl;
unsigned char f;
};
# if defined(HASBLKDEV)
extern struct l_dev *BDevtp, **BSdev;
extern int BNdev;
# endif
extern int CkPasswd;
struct str_lst {
char *str;
int len;
int f;
struct str_lst *next;
};
extern struct str_lst *Cmdl;
extern int CmdLim;
# if defined(HASSELINUX)
typedef struct cntxlist {
char *cntx;
int f;
struct cntxlist *next;
} cntxlist_t;
extern cntxlist_t *CntxArg;
# endif
# if defined(HASDCACHE)
extern unsigned DCcksum;
extern int DCfd;
extern FILE *DCfs;
extern char *DCpathArg;
extern char *DCpath[];
extern int DCpathX;
extern int DCrebuilt;
extern int DCstate;
extern int DCunsafe;
# endif
extern int DChelp;
extern dev_t DevDev;
extern struct l_dev *Devtp;
extern char **Dstk;
extern int Dstkn;
extern int Dstkx;
extern int ErrStat;
extern uid_t Euid;
extern int Fand;
extern int Fblock;
extern int Fcntx;
extern int Ffield;
extern int Ffilesys;
extern int Fhelp;
extern int Fhost;
# if defined(HASNCACHE)
extern int Fncache;
extern int NcacheReload;
# endif
extern int Fnet;
extern int FnetTy;
extern int Fnfs;
extern int Fnlink;
extern int Foffset;
extern int Fovhd;
extern int Fport;
extern int FportMap;
extern int Fpgid;
extern int Fppid;
extern int Fsize;
extern int Fsv;
extern int FsvFlagX;
extern int Ftcptpi;
extern int Fterse;
extern int Funix;
extern int Futol;
extern int Fverbose;
extern int Fwarn;
# if defined(HASXOPT_VALUE)
extern int Fxopt;
# endif
extern int Fxover;
extern int Fzone;
struct fd_lst {
char *nm;
int lo;
int hi;
struct fd_lst *next;
};
extern struct fd_lst *Fdl;
extern int FdlTy;
struct fieldsel {
char id;
unsigned char st;
char *nm;
int *opt;
int ov;
};
extern struct fieldsel FieldSel[];
extern int Hdr;
enum IDType {PGID, PID};
extern char *InodeFmt_d;
extern char *InodeFmt_x;
struct lfile {
char access;
char lock;
unsigned char dev_def;
unsigned char inp_ty;
unsigned char is_com;
unsigned char is_nfs;
unsigned char is_stream;
# if defined(HASVXFS) && defined(HASVXFSDNLC)
unsigned char is_vxfs;
# endif
unsigned char lmi_srch;
# if defined(HASMNTSTAT)
unsigned char mnt_stat;
# endif
unsigned char nlink_def;
unsigned char off_def;
unsigned char rdev_def;
unsigned char sz_def;
# if defined(HASFSTRUCT)
unsigned char fsv;
# endif
char fd[FDLEN];
char iproto[IPROTOL];
char type[TYPEL];
short sf;
int ch;
int ntype;
SZOFFTYPE off;
SZOFFTYPE sz;
dev_t dev;
dev_t rdev;
INODETYPE inode;
long nlink;
char *dev_ch;
char *fsdir;
char *fsdev;
# if defined(HASFSINO)
INODETYPE fs_ino;
# endif
struct linaddr {
int af;
int p;
union {
struct in_addr a4;
# if defined(HASIPv6)
struct in6_addr a6;
# endif
} ia;
} li[2];
struct ltstate {
int type;
union {
int i;
unsigned int ui;
} state;
# if defined(HASSOOPT)
unsigned char pqlens;
unsigned char qlens;
unsigned char qlims;
unsigned char rbszs;
unsigned char sbszs;
int kai;
int ltm;
unsigned int opt;
unsigned int pqlen;
unsigned int qlen;
unsigned int qlim;
unsigned long rbsz;
unsigned long sbsz;
# endif
# if defined(HASSOSTATE)
unsigned int ss;
# if defined(HASSBSTATE)
unsigned int sbs_rcv;
unsigned int sbs_snd;
# endif
# endif
# if defined(HASTCPOPT)
unsigned int topt;
unsigned char msss;
unsigned long mss;
# endif
# if defined(HASTCPTPIQ)
unsigned long rq;
unsigned long sq;
unsigned char rqs;
unsigned char sqs;
# endif
# if defined(HASTCPTPIW)
unsigned char rws;
unsigned char wws;
unsigned long rw;
unsigned long ww;
# endif
} lts;
char *nm;
char *nma;
# if defined(HASNCACHE) && HASNCACHE<2
KA_T na;
# endif
# if defined(HASNCACHE) && defined(HASNCVPID)
unsigned long id;
# endif
# if defined(HASLFILEADD)
HASLFILEADD
# endif
# if defined(HASFSTRUCT)
KA_T fsa;
long fct;
long ffg;
long pof;
KA_T fna;
# endif
struct lfile *next;
};
extern struct lfile *Lf, *Plf;
struct lproc {
char *cmd;
# if defined(HASSELINUX)
char *cntx;
# endif
short sf;
short pss;
int pid;
int pgid;
int ppid;
uid_t uid;
# if defined(HASZONES)
char *zn;
# endif
struct lfile *file;
};
extern struct lproc *Lp, *Lproc;
extern char *Memory;
extern int MntSup;
extern char *MntSupP;
# if defined(HASPROCFS)
extern struct mounts *Mtprocfs;
# endif
extern int Mxpgid;
extern int Mxpid;
extern int Mxuid;
extern gid_t Mygid;
extern int Mypid;
extern uid_t Myuid;
extern char *Namech;
extern size_t Namechl;
extern int Ndev;
# if defined(HASNLIST)
# if !defined(NLIST_TYPE)
#define NLIST_TYPE nlist
# endif
extern struct NLIST_TYPE *Nl;
extern int Nll;
# endif
extern long Nlink;
extern int Nlproc;
extern char *Nmlst;
extern int Npgid;
extern int Npgidi;
extern int Npgidx;
extern int Npid;
extern int Npidi;
extern int Npidx;
extern int Npuns;
extern int Ntype;
extern int Nuid;
extern int Nuidexcl;
extern int Nuidincl;
struct nwad {
char *arg;
char *proto;
int af;
unsigned char a[MAX_AF_ADDR];
int sport;
int eport;
int f;
struct nwad *next;
};
extern struct nwad *Nwad;
extern int OffDecDig;
extern char *Pn;
# if defined(HASFSTRUCT)
extern struct pff_tab Pff_tab[];
extern struct pff_tab Pof_tab[];
# endif
# if defined(HASPROCFS)
struct procfsid {
pid_t pid;
char *nm;
unsigned char f;
# if defined(HASPINODEN)
INODETYPE inode;
# endif
struct procfsid *next;
};
extern int Procfind;
extern struct procfsid *Procfsid;
extern int Procsrch;
# endif
extern int PrPass;
extern int RptTm;
extern struct l_dev **Sdev;
extern int Selall;
extern int Selflags;
extern int Setgid;
extern int Selinet;
extern int Setuidroot;
extern struct sfile *Sfile;
extern struct int_lst *Spgid;
extern struct int_lst *Spid;
extern struct seluid *Suid;
extern char *SzOffFmt_0t;
extern char *SzOffFmt_d;
extern char *SzOffFmt_dv;
extern char *SzOffFmt_x;
extern char Terminator;
extern int TmLimit;
#if defined(HASZONES)
typedef struct znhash {
char *zn;
int f;
struct znhash *next;
} znhash_t;
extern znhash_t **ZoneArg;
#endif
#include "proto.h"
#include "dproto.h"
#endif