Imported Upstream version 4.88
[platform/upstream/lsof.git] / lsof.h
1 /*
2  * lsof.h - common header file for 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: lsof.h,v 1.67 2014/10/13 22:36:20 abe Exp $
35  */
36
37
38 #if     !defined(LSOF_H)
39 #define LSOF_H  1
40
41 #include "machine.h"
42
43 # if    !defined(FSV_DEFAULT)
44 #define FSV_DEFAULT     0
45 # endif /* !defined(FSV_DEFAULT) */
46
47 #include "lsof_fields.h"
48
49 #include <ctype.h>
50 #include <errno.h>
51
52 # if    defined(HASSETLOCALE)
53 #include <locale.h>
54 # endif /* defined(HASSETLOCALE) */
55
56 #include <netdb.h>
57 #include <pwd.h>
58 #include <stdio.h>
59
60 #include <sys/stat.h>
61 #include <sys/wait.h>
62
63
64 /*
65  * Definitions and structures that may be needed by dlsof.h
66  */
67
68 # if    !defined(INODETYPE)
69 #define INODETYPE       unsigned long   /* node number storage type */
70 #define INODEPSPEC      "l"             /* node number printf specification
71                                          * modifier */
72 # endif /* !defined(INODETYPE) */
73
74 struct l_dev {
75         dev_t rdev;                     /* device */
76         INODETYPE inode;                /* inode number */
77         char *name;                     /* name */
78         int v;                          /* has been verified
79                                          * (when DCUnsafe == 1) */
80 };
81
82
83 /*
84  * FILE_FLAG column names
85  */
86
87 #define FF_AIO          "AIO"
88 #define FF_APPEND       "AP"
89 #define FF_ASYNC        "ASYN"
90 #define FF_BLKANDSET    "BAS"
91 #define FF_BLKINUSE     "BKIU"
92 #define FF_BLKSEEK      "BSK"
93 #define FF_CIO          "CIO"
94 #define FF_CLONE        "CLON"
95 #define FF_CLREAD       "CLRD"
96 #define FF_COPYAVOID    "CA"
97 #define FF_CREAT        "CR"
98 #define FF_DATAFLUSH    "DFLU"
99 #define FF_DEFER        "DF"
100 #define FF_DEFERIND     "DFI"
101 #define FF_DELAY        "DLY"
102 #define FF_DIRECT       "DIR"
103 #define FF_DIRECTORY    "DTY"
104 #define FF_DOCLONE      "DOCL"
105 #define FF_DSYNC        "DSYN"
106 #define FF_EVTONLY      "EVO"
107 #define FF_EXCL         "EXCL"
108 #define FF_EXEC         "EX"
109 #define FF_EXLOCK       "XL"
110 #define FF_FILE_MBLK    "MBLK"
111 #define FF_FSYNC        "FSYN"
112 #define FF_GCFDEFER     "GCDF"
113 #define FF_GCFMARK      "GCMK"
114 #define FF_GENTTY       "GTTY"
115 #define FF_HASLOCK      "LCK"
116 #define FF_HUP          "HUP"
117 #define FF_KERNEL       "KERN"
118 #define FF_KIOCTL       "KIOC"
119 #define FF_LARGEFILE    "LG"
120 #define FF_MARK         "MK"
121 #define FF_MOUNT        "MNT"
122 #define FF_MSYNC        "MSYN"
123 #define FF_NBDRM        "NBDR"
124 #define FF_NBIO         "NBIO"
125 #define FF_NBLOCK       "NB"
126 #define FF_NBUF         "NBF"
127 #define FF_NMFS         "NMFS"
128 #define FF_NDELAY       "ND"
129 #define FF_NET          "NET"
130 #define FF_NOATM        "NATM"
131 #define FF_NOCACHE      "NC"
132 #define FF_NOCTTY       "NTTY"
133 #define FF_NODSYNC      "NDSY"
134 #define FF_NOFOLNK      "NFLK"
135 #define FF_NOTOSTOP     "NOTO"
136 #define FF_NSHARE       "NSH"
137 #define FF_OLRMIRROR    "OLRM"
138 #define FF_POSIX_AIO    "PAIO"
139 #define FF_POSIX_PIPE   "PP"
140 #define FF_RAIOSIG      "RAIO"
141 #define FF_RCACH        "RC"
142 #define FF_RDWR         "RW"
143 #define FF_READ         "R"
144 #define FF_REVOKED      "REV"
145 #define FF_RSHARE       "RSH"
146 #define FF_RSYNC        "RSYN"
147 #define FF_SETBLK       "BL"
148 #define FF_SHLOCK       "SL"
149 #define FF_SNAP         "SNAP"
150 #define FF_SOCKET       "SOCK"
151 #define FF_SQTSH1       "SQS1"
152 #define FF_SQTSH2       "SQS2"
153 #define FF_SQTREPAIR    "SQR"
154 #define FF_SQTSH        "SQSH"
155 #define FF_SQTSVM       "SQSV"
156 #define FF_STOPIO       "STPI"
157 #define FF_SYNC         "SYN"
158 #define FF_SYNCRON      "SWR"
159 #define FF_TCP_MDEVONLY "TCPM"
160 #define FF_TERMIO       "TIO"
161 #define FF_TRUNC        "TR"
162 #define FF_VHANGUP      "VH"
163 #define FF_VTEXT        "VTXT"
164 #define FF_WAKEUP       "WKUP"
165 #define FF_WAITING      "WTG"
166 #define FF_WRITE        "W"
167
168
169 /*
170  * Process open file flag names
171  */
172
173 #define POF_ALLOCATED   "ALLC"
174 #define POF_BNRD        "BR"
175 #define POF_BNWR        "BW"
176 #define POF_BNHUP       "BHUP"
177 #define POF_CLOEXEC     "CX"
178 #define POF_CLOSING     "CLSG"
179 #define POF_FDLOCK      "LCK"
180 #define POF_INUSE       "USE"
181 #define POF_MAPPED      "MP"
182 #define POF_FSHMAT      "SHMT"
183 #define POF_RESERVED    "OPIP"
184 #define POF_RSVWT       "RSVW"
185
186
187 /*
188  * Cross-over (-x) option values
189  */
190
191 #define XO_FILESYS      0x1             /* file system mount points */
192 #define XO_SYMLINK      0x2             /* symbolic links */
193 #define XO_ALL          (XO_FILESYS | XO_SYMLINK)
194
195 #include "dlsof.h"
196
197 #include <sys/types.h>                  /* just in case -- because utmp.h
198                                          * may need it */
199 #include "./regex.h"
200
201 # if    defined(EMPTY)
202 #undef  EMPTY
203 # endif /* defined(EMPTY) */
204
205 # if    defined(HASUTMPX)
206 #include <utmpx.h>
207 # else  /* !defined(HASUTMPX) */
208 #include <utmp.h>
209 # endif /* defined(HASUTMPX) */
210
211 extern int errno;
212 extern char *optarg;
213 extern int optind;
214
215 #define ACCESSERRFMT    "%s: WARNING: access %s: %s\n"
216
217 # if    defined(HASDCACHE)
218 #define CRC_POLY        0120001         /* CRC-16 polynomial */
219 #define CRC_TBLL        256             /* crc table length for software */
220 #define CRC_BITS        8               /* number of bits contributing */
221 # endif /* defined(HASDCACHE) */
222 #define CMDL            9               /* maximum number of characters from
223                                          * command name to print in COMMAND
224                                          * column */
225 #define CWD             " cwd"          /* current working directory fd name */
226 #define FDLEN           8               /* fd printing array length */
227 #define FSV_FA          0x1             /* file struct addr status */
228 #define FSV_CT          0x2             /* file struct count status */
229 #define FSV_FG          0x4             /* file struct flags */
230 #define FSV_NI          0x8             /* file struct node ID status */
231
232 # if    !defined(GET_MAJ_DEV)
233 #define GET_MAJ_DEV     major           /* if no dialect specific macro has
234                                          * been defined, use standard major()
235                                          * macro */
236 # endif /* !defined(GET_MAJ_DEV) */
237
238 # if    !defined(GET_MIN_DEV)
239 #define GET_MIN_DEV     minor           /* if no dialect specific macro has
240                                          * been defined, use standard minor()
241                                          * macro */
242 # endif /* !defined(GET_MIN_DEV) */
243
244 # if    defined(HASSELINUX)
245 #define HASHCNTX        128             /* security context hash bucket count
246                                          * -- MUST BE A POWER OF 2!!! */
247 # endif /* defined(HASSELINUX) */
248
249 # if    defined(HASZONES)
250 #define HASHZONE        128             /* zone hash bucket count -- MUST BE
251                                          * A POWER OF 2!!! */
252 # endif /* defined(HASZONES) */
253
254 #define IDINCR          10              /* PID/PGID table malloc() increment */
255
256 # if    !defined(INADDR_LOOPBACK)
257 #define INADDR_LOOPBACK (u_long)0x7f000001
258 # endif /* !defined(INADDR_LOOPBACK) */
259
260 #define IPROTOL         8               /* Internet protocol length */
261
262 # if    !defined(KA_T_FMT_X)
263 #define KA_T_FMT_X      "0x%08lx"       /* format for printing kernel
264                                          * addresses in 0x... format */
265 # endif /* !defined(KA_T_FMT_X) */
266
267 # if    !defined(LOGINML)
268 #  if   defined(HASUTMPX)
269 static struct utmpx dummy_utmp;         /* to get login name length */
270 #define LOGINML         sizeof(dummy_utmp.ut_user)
271                                         /* login name length */
272 #  else /* !defined(HASUTMPX) */
273 static struct utmp dummy_utmp;          /* to get login name length */
274 #define LOGINML         sizeof(dummy_utmp.ut_name)
275                                         /* login name length */
276 #  endif        /* defined(HASUTMPX) */
277 # endif /* !defined(LOGINML) */
278
279 #define LPROCINCR       128             /* Lproc[] allocation increment */
280 #define LSOF_URL        "ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/"
281 #define MIN_AF_ADDR     sizeof(struct in_addr)
282                                         /* minimum AF_* address length */
283
284 # if    defined(HASIPv6)
285 #define MAX_AF_ADDR     sizeof(struct in6_addr)
286                                         /* maximum AF_* address length */
287 # else  /* !defined(HASIPv6) */
288 #define MAX_AF_ADDR     MIN_AF_ADDR     /* maximum AF_* address length */
289 # endif /* defined(HASIPv6) */
290
291 #define MAXDCPATH       4               /* paths in DCpath[] */
292 #define MAXNWAD         100             /* maximum network addresses */
293
294 # if    !defined(MEMMOVE)
295 #define MEMMOVE         memmove
296 # endif /* !defined*MEMMOVE) */
297
298 #define N_REGLR         0               /* regular file system node */
299 #define N_AFS           1               /* AFS node */
300 #define N_AFPFS         2               /* Apple Darwin AppleShare */
301 #define N_ANON_INODE    3               /* Linux anon_inodefs node */
302 #define N_AUSX          4               /* Auspex LFS node */
303 #define N_AUTO          5               /* automount node */
304 #define N_BLK           6               /* block device node */
305 #define N_CACHE         7               /* cached file system node */
306 #define N_CDFS          8               /* CD-ROM node */
307 #define N_CFS           9               /* CFS node */
308 #define N_CHR           10              /* character device node */
309 #define N_COM           11              /* streams common device node */
310 #define N_CTFSADIR      12              /* Solaris CTFS adir node */
311 #define N_CTFSBUND      13              /* Solaris CTFS bundle node */
312 #define N_CTFSCDIR      14              /* Solaris CTFS cdir node */
313 #define N_CTFSCTL       15              /* Solaris CTFS ctl node */
314 #define N_CTFSEVT       16              /* Solaris CTFS events node */
315 #define N_CTFSLATE      17              /* Solaris CTFS latest node */
316 #define N_CTFSROOT      18              /* Solaris CTFS root node */
317 #define N_CTFSSTAT      19              /* Solaris CTFS status node */
318 #define N_CTFSSYM       20              /* Solaris CTFS symbolic node */
319 #define N_CTFSTDIR      21              /* Solaris CTFS type node */
320 #define N_CTFSTMPL      22              /* Solaris CTFS template node */
321 #define N_DEV           23              /* DEV FS node */
322 #define N_DOOR          24              /* DOOR node */
323 #define N_FD            25              /* FD node */
324 #define N_FIFO          26              /* FIFO node */
325 #define N_HSFS          27              /* High Sierra node */
326 #define N_KERN          28              /* BSD /kern node */
327 #define N_LOFS          29              /* loopback node */
328 #define N_MNT           30              /* mount file system device node */
329 #define N_MPC           31              /* multiplexed device node */
330 #define N_MVFS          32              /* multi-volume file system node (?) */
331 #define N_NFS           33              /* NFS node */
332 #define N_NFS4          34              /* NFS version 4 node */
333 #define N_NM            35              /* named file system node */
334 #define N_OBJF          36              /* objfs file system node */
335 #define N_PCFS          37              /* PC file system node */
336 #define N_PIPE          38              /* pipe device node */
337 #define N_PORT          39              /* port node */
338 #define N_PROC          40              /* /proc node */
339 #define N_PSEU          41              /* pseudofs node */
340 #define N_SAMFS         42              /* Solaris SAM-FS */
341 #define N_SANFS         43              /* AIX SANFS */
342 #define N_SDEV          44              /* Solaris sdev file system node */
343 #define N_SHARED        45              /* Solaris sharedfs */
344 #define N_SOCK          46              /* sock_vnodeops node */
345 #define N_SPEC          47              /* spec_vnodeops node */
346 #define N_STREAM        48              /* stream node */
347 #define N_TMP           49              /* tmpfs node */
348 #define N_UFS           50              /* UNIX file system node */
349 #define N_UNKN          51              /* unknown node type */
350 #define N_VXFS          52              /* Veritas file system node */
351 #define N_XFS           53              /* XFS node */
352 #define N_ZFS           54              /* ZFS node */
353
354 # if    !defined(OFFDECDIG)
355 #define OFFDECDIG       8               /* maximum number of digits in the
356                                          * offset decimal form (0t...) */
357 # endif /* !defined(OFFDECDIG) */
358
359 # if    !defined(USELOCALREADDIR)
360 #define CloseDir        closedir        /* use standard closedir() */
361 #define OpenDir         opendir         /* use standard opendir() */
362 #define ReadDir         readdir         /* use standard readdir() */
363 # endif /* !defined(USELOCALREADDIR) */
364
365 #define RPTTM           15              /* default repeat seconds */
366 #define RTD             " rtd"          /* root directory fd name */
367 #define TCPTPI_FLAGS    0x0001          /* report TCP/TPI socket options and
368                                          * state, and TCP_NODELAY state */
369 #define TCPTPI_QUEUES   0x0002          /* report TCP/TPI queue lengths */
370 #define TCPTPI_STATE    0x0004          /* report TCP/TPI state */
371 #define TCPTPI_WINDOWS  0x0008          /* report TCP/TPI window sizes */
372 #define TCPTPI_ALL      (TCPTPI_QUEUES | TCPTPI_STATE | TCPTPI_WINDOWS)
373                                         /* report all TCP/TPI info */
374 #define TCPUDPALLOC     32              /* allocation amount for TCP and UDP
375                                          * state tables */
376 #define TMLIMIT         15              /* readlink() & stat() timeout sec */
377 #define TMLIMMIN        2               /* minimum timeout */
378 #define TYPEL           8               /* type character length */
379 #define UIDCACHEL       1024            /* UID cache length */
380 #define UIDINCR         10              /* UID table malloc() increment */
381 #define USERPRTL        8               /* UID/login print length limit */
382
383 # if    !defined(SZOFFTYPE)
384 #define SZOFFTYPE       unsigned long   /* type for size and offset */
385 #undef  SZOFFPSPEC
386 #define SZOFFPSPEC      "l"             /* SZOFFTYPE printf specification
387                                          * modifier */
388 # endif /* !defined(SZOFFTYPE) */
389
390 # if    !defined(TIMEVAL_LSOF)
391 #define TIMEVAL_LSOF    timeval
392 # endif /* !defined(TIMEVAL_LSOF) */
393
394 # if    !defined(XDR_PMAPLIST)
395 #define XDR_PMAPLIST    xdr_pmaplist
396 # endif /* !defined(XDR_PMAPLIST) */
397
398 # if    !defined(XDR_VOID)
399 #define XDR_VOID        xdr_void
400 # endif /* !defined(XDR_VOID) */
401
402
403 /*
404  * Output title definitions
405  */
406
407 #define CMDTTL          "COMMAND"
408 extern int CmdColW;
409 #define CNTXTTL         "SECURITY-CONTEXT"
410 extern int CntxColW;
411 #define DEVTTL          "DEVICE"
412 extern int DevColW;
413 #define FCTTL           "FCT"
414 extern int FcColW;
415 #define FDTTL           "FD"
416 extern int FdColW;
417 #define FGTTL           "FILE-FLAG"
418 extern int FgColW;
419 #define FSTTL           "FILE-ADDR"
420 extern int FsColW;
421 #define NITTL           "NODE-ID"
422 extern int NiColW;
423 extern char *NiTtl;
424 #define NLTTL           "NLINK"
425 extern int NlColW;
426 #define NMTTL           "NAME"
427 extern int NmColW;
428 #define NODETTL         "NODE"
429 extern int NodeColW;
430 #define OFFTTL          "OFFSET"
431 #define PGIDTTL         "PGID"
432 extern int PgidColW;
433 #define PIDTTL          "PID"
434 extern int PidColW;
435 #define PPIDTTL         "PPID"
436 extern int PpidColW;
437 #define SZTTL           "SIZE"
438 #define SZOFFTTL        "SIZE/OFF"
439 extern int SzOffColW;
440 #define TIDTTL          "TID"
441 extern  int TidColW;
442 #define TYPETTL         "TYPE"
443 extern int TypeColW;
444 #define USERTTL         "USER"
445 extern int UserColW;
446 #define ZONETTL         "ZONE"
447 extern int ZoneColW;
448
449
450 /*
451  * Selection flags
452  */
453
454 #define PS_PRI          1               /* primary process selection -- e.g.,
455                                          * by PID or UID */
456 #define PS_SEC          2               /* secondary process selection -- e.g.,
457                                          * by directory or file */
458
459 # if    defined(HASEPTOPTS)
460 #define PS_PIPE         1               /* process has a pipe file */
461 #define PS_PIPE_END     2               /* process has a pipe end point file */
462 # endif /* defined(HASEPTOPTS) */
463
464 #define SELCMD          0x0001          /* select process by command name */
465 #define SELCNTX         0x0002          /* select security context (-Z) */
466 #define SELFD           0x0004          /* select file by descriptor name */
467 #define SELNA           0x0008          /* select socket by address (-i@...) */
468 #define SELNET          0x0010          /* select Internet socket files (-i) */
469 #define SELNFS          0x0020          /* select NFS files (-N) */
470 #define SELNLINK        0x0040          /* select based on link count */
471 #define SELNM           0x0080          /* select by name */
472 #define SELPGID         0x0100          /* select process group IDs (-g) */
473 #define SELPID          0x0200          /* select PIDs (-p) */
474 #define SELUID          0x0400          /* select UIDs (-u) */
475 #define SELUNX          0x0800          /* select UNIX socket (-U) */
476 #define SELZONE         0x1000          /* select zone (-z) */
477 #define SELEXCLF        0x2000          /* file selection excluded */
478 #define SELTASK         0x4000          /* select tasks (-K) */
479 #define SELPINFO        0x8000          /* selected for pipe info (cleared in
480                                          * link_lfile() */
481 #define SELALL          (SELCMD|SELCNTX|SELFD|SELNA|SELNET|SELNM|SELNFS|SELPID|SELUID|SELUNX|SELZONE|SELTASK)
482 #define SELPROC         (SELCMD|SELCNTX|SELPGID|SELPID|SELUID|SELZONE|SELTASK)
483                                         /* process selecters */
484 #define SELFILE         (SELFD|SELNFS|SELNLINK|SELNM)   /* file selecters */
485 #define SELNW           (SELNA|SELNET|SELUNX)           /* network selecters */
486
487 /*
488  * Structure definitions
489  */
490
491 # if    defined(HAS_AFS)
492 struct afsnode {                        /* AFS pseudo-node structure */
493         dev_t dev;
494         unsigned char ino_st;           /* 1 if inode has a value */
495         unsigned char nlink_st;         /* 1 if nlink has a value */
496         INODETYPE inode;
497         unsigned long size;
498         long nlink;
499 };
500 # endif /* defined(HAS_AFS) */
501
502 # if    defined(HAS_STD_CLONE)
503 struct clone {
504         int dx;                 /* index of device entry in Devtp[] */
505         struct clone *next;     /* forward link */
506 };
507 extern struct clone *Clone;
508 # endif /* defined(HAS_STD_CLONE) */
509
510 # if    defined(HASNLIST)
511 struct drive_Nl {                       /* data to drive build_Nl() */
512         char *nn;                       /* nickname for lookups */
513         char *knm;                      /* kernel variable for name list */
514 };
515 extern struct drive_Nl Drive_Nl[];      /* defined in dstore.c */
516 # endif /* defined(HASNLIST) */
517
518
519 /*
520  * Global storage definitions (including their structure definitions)
521  */
522
523 typedef struct efsys_list {
524         char *path;                     /* path to file system for which kernel
525                                          * blocks are to be eliminated */
526         int pathl;                      /* path length */
527         int rdlnk;                      /* avoid readlink(2) if non-zero */
528         struct mounts *mp;              /* local mount table entry pointer */
529         struct efsys_list *next;        /* next efsys_list entry pointer */
530 } efsys_list_t;
531 extern efsys_list_t *Efsysl;            /* file systems for which kernel blocks
532                                          * are to be eliminated */
533
534 struct int_lst {
535         int i;                          /* integer argument */
536         int f;                          /* find state -- meaningful only if
537                                          * x == 0 */
538         int x;                          /* excluded state */
539 };
540
541 typedef struct lsof_rx {                /* regular expression table entry */
542         char *exp;                      /* original regular expression */
543         regex_t cx;                     /* compiled expression */
544         int mc;                         /* match count */ 
545 } lsof_rx_t;
546 extern lsof_rx_t *CmdRx;
547 extern int NCmdRxU;
548
549 # if    defined(HASFSTRUCT)
550 struct pff_tab {                        /* print file flags table structure */
551         long val;                       /* flag value */
552         char *nm;                       /* name to print for flag */
553 };
554 # endif /* defined(HASFSTRUCT) */
555
556 # if    defined(HASEPTOPTS)
557 typedef struct pinfo {                  /* hashed pipe inode numbers */
558         INODETYPE ino;                  /* pipe's inode */
559         struct lfile *lf;               /* connected pipe file */
560         int lpx;                        /* connected process index */
561         struct pinfo *next;             /* next entry for hashed inode */
562 } pinfo_t;
563 # endif /* defined(HASEPTOPTS) */
564
565
566 struct seluid {
567         uid_t uid;                      /* User ID */
568         char *lnm;                      /* specified login name (NULL = none) */
569         unsigned char excl;             /* excluded state */
570         unsigned char f;                /* selected User ID find state
571                                          * (meaningful only if excl == 0) */
572 };
573
574 # if    defined(HASBLKDEV)
575 extern struct l_dev *BDevtp, **BSdev;
576 extern int BNdev;
577 # endif /* defined(HASBLKDEV) */
578
579 extern int CkPasswd;
580
581 struct str_lst {
582         char *str;                      /* string */
583         int len;                        /* string length */
584         short f;                        /* selected string find state */
585         short x;                        /* exclusion (if non-zero) */
586         struct str_lst *next;           /* next list entry */
587 };
588 extern struct str_lst *Cmdl;
589 extern int CmdLim;
590 extern int Cmdni;
591 extern int Cmdnx;
592  
593 # if    defined(HASSELINUX)
594 typedef struct cntxlist {
595         char *cntx;                     /* zone name */
596         int f;                          /* "find" flag (used only in CntxArg) */
597         struct cntxlist *next;          /* next zone hash entry */
598 } cntxlist_t;
599 extern cntxlist_t *CntxArg;
600 extern int CntxStatus;
601 # endif /* defined(HASSELINUX) */
602
603 # if    defined(HASDCACHE)
604 extern unsigned DCcksum;
605 extern int DCfd;
606 extern FILE *DCfs;
607 extern char *DCpathArg;
608 extern char *DCpath[];
609 extern int DCpathX;
610 extern int DCrebuilt;
611 extern int DCstate;
612 extern int DCunsafe;
613 # endif /* defined(HASDCACHE) */
614
615 extern int DChelp;
616 extern dev_t DevDev;
617 extern struct l_dev *Devtp;
618 extern char **Dstk;
619 extern int Dstkn;
620 extern int Dstkx;
621 extern int ErrStat;
622 extern uid_t Euid;
623 extern int Fand;
624 extern int Fblock;
625 extern int Fcntx;
626 extern int Ffield;
627 extern int Ffilesys;
628 extern int Fhelp;
629 extern int Fhost;
630
631 # if    defined(HASNCACHE)
632 extern int Fncache;
633 extern int NcacheReload;
634 # endif /* defined(HASNCACHE) */
635
636 extern int Fnet;
637 extern int FnetTy;
638 extern int Fnfs;
639 extern int Fnlink;
640 extern int Foffset;
641 extern int Fovhd;
642 extern int FpipeE;
643
644 extern int Fport;
645
646 # if    !defined(HASNORPC_H)
647 extern int FportMap;
648 # endif /* !defined(HASNORPC_H) */
649
650 extern int Fpgid;
651 extern int Fppid;
652 extern int Fsize;
653 extern int Fsv;
654 extern int FsvByf;
655 extern int FsvFlagX;
656 extern int Ftask;
657 extern int Ftcptpi;
658 extern int Fterse;
659 extern int Funix;
660 extern int Futol;
661 extern int Fverbose;
662 extern int Fwarn;
663
664 # if    defined(HASXOPT_VALUE)
665 extern int Fxopt;
666 # endif /* defined(HASXOPT_VALUE) */
667
668 extern int Fxover;
669 extern int Fzone;
670
671 struct fd_lst {
672         char *nm;                       /* file descriptor name -- range if
673                                          * NULL */
674         int lo;                         /* range start (if nm NULL) */
675         int hi;                         /* range end (if nm NULL) */
676         struct fd_lst *next;
677 };
678 extern struct fd_lst *Fdl;
679 extern int FdlTy;                       /* Fdl[] type: -1 == none
680                                          *              0 == include
681                                          *              1 == exclude */
682
683 struct fieldsel {
684         char id;                        /* field ID character */
685         unsigned char st;               /* field status */
686         char *nm;                       /* field name */
687         int *opt;                       /* option variable address */
688         int ov;                         /* value to OR with option variable */
689 };
690 extern struct fieldsel FieldSel[];
691
692 extern int Hdr;
693
694 enum IDType {PGID, PID};
695 extern char *InodeFmt_d;
696 extern char *InodeFmt_x;
697 extern int LastPid;
698
699 struct lfile {
700         char access;
701         char lock;
702         unsigned char dev_def;          /* device number definition status */
703         unsigned char inp_ty;           /* inode/iproto type
704                                          *      0: neither inode nor iproto
705                                          *      1: print inode in decimal
706                                          *      2: iproto contains string
707                                          *      3: print inode in hex
708                                          */
709         unsigned char is_com;           /* common stream status */
710         unsigned char is_nfs;           /* NFS file status */
711         unsigned char is_stream;        /* stream device status */
712
713 # if    defined(HASVXFS) && defined(HASVXFSDNLC)
714         unsigned char is_vxfs;          /* VxFS file status */
715 # endif /* defined(HASVXFS) && defined(HASVXFSDNLC) */
716
717         unsigned char lmi_srch;         /* local mount info search status:
718                                          * 1 = printname() search required */
719
720 # if    defined(HASMNTSTAT)
721         unsigned char mnt_stat;         /* mount point stat(2) status */
722 # endif /* defined(HASMNTSTAT) */
723
724         unsigned char nlink_def;        /* link count definition status */
725         unsigned char off_def;          /* offset definition status */
726
727 # if    defined(HASEPTOPTS)
728         unsigned char pipend;           /* pipe endpoint file */
729 # endif /* defined(HASEPTOPTS) */
730
731         unsigned char rdev_def;         /* rdev definition status */
732         unsigned char sz_def;           /* size definition status */
733
734 # if    defined(HASFSTRUCT)
735         unsigned char fsv;              /* file struct value status */
736 # endif /* defined(HASFSTRUCT) */
737
738         char fd[FDLEN];
739         char iproto[IPROTOL];
740         char type[TYPEL];
741         short sf;                       /* select flags -- SEL* symbols */
742         int ch;                         /* VMPC channel: -1 = none */
743         int ntype;                      /* node type -- N_* value */
744         SZOFFTYPE off;
745         SZOFFTYPE sz;
746         dev_t dev;
747         dev_t rdev;
748         INODETYPE inode;
749         long nlink;                     /* link count */
750         char *dev_ch;
751         char *fsdir;                    /* file system directory */
752         char *fsdev;                    /* file system device */
753
754 # if    defined(HASFSINO)
755         INODETYPE fs_ino;               /* file system inode number */
756 # endif /* defined HASFSINO) */
757
758         struct linaddr {                /* local Internet address information */
759             int af;                     /* address family: 0 for none; AF_INET;
760                                          * or AF_INET6 */
761             int p;                      /* port */
762             union {
763                 struct in_addr a4;      /* AF_INET Internet address */
764
765 # if    defined(HASIPv6)
766                 struct in6_addr a6;     /* AF_INET6 Internet address */
767 # endif /* defined(HASIPv6) */
768
769             } ia;
770         } li[2];                        /* li[0]: local
771                                          * li[1]: foreign */
772         struct ltstate {                /* local TCP/TPI state */
773             int type;                   /* state type:
774                                          *   -1 == none
775                                          *    0 == TCP
776                                          *    1 == TPI or socket (SS_*) */
777             union {
778                 int i;                  /* integer state */
779                 unsigned int ui;        /* unsigned integer state */
780             } state;
781
782 # if    defined(HASSOOPT)
783             unsigned char pqlens;       /* pqlen status: 0 = none */
784             unsigned char qlens;        /* qlen status:  0 = none */
785             unsigned char qlims;        /* qlim status:  0 = none */
786             unsigned char rbszs;        /* rbsz status:  0 = none */
787             unsigned char sbszs;        /* sbsz status:  0 = none */
788             int kai;                    /* TCP keep-alive interval */
789             int ltm;                    /* TCP linger time */
790             unsigned int opt;           /* socket options */
791             unsigned int pqlen;         /* partial connection queue length */
792             unsigned int qlen;          /* connection queue length */
793             unsigned int qlim;          /* connection queue limit */
794             unsigned long rbsz;         /* receive buffer size */
795             unsigned long sbsz;         /* send buffer size */
796 # endif /* defined(HASSOOPT) */
797
798 # if    defined(HASSOSTATE)
799             unsigned int ss;            /* socket state */
800 #  if   defined(HASSBSTATE)
801             unsigned int sbs_rcv;       /* receive socket buffer state */
802             unsigned int sbs_snd;       /* send socket buffer state */
803 #  endif        /* defined(HASSBSTATE) */
804 # endif /* defined(HASSOSTATE) */
805
806 # if    defined(HASTCPOPT)
807             unsigned int topt;          /* TCP options */
808             unsigned char msss;         /* mss status: 0 = none */
809             unsigned long mss;          /* TCP maximum segment size */
810 # endif /* defined(HASTCPOPT) */
811
812 # if    defined(HASTCPTPIQ)
813             unsigned long rq;           /* receive queue length */
814             unsigned long sq;           /* send queue length */
815             unsigned char rqs;          /* rq status: 0 = none */
816             unsigned char sqs;          /* sq status: 0 = none */
817 # endif /* defined(HASTCPTPIQ) */
818
819 # if    defined(HASTCPTPIW)
820             unsigned char rws;          /* rw status: 0 = none */
821             unsigned char wws;          /* ww status: 0 = none */
822             unsigned long rw;           /* read window size */
823             unsigned long ww;           /* write window size */
824 # endif /* defined(HASTCPTPIW) */
825
826         } lts;
827         char *nm;
828         char *nma;                      /* NAME column addition */
829
830 # if    defined(HASNCACHE) && HASNCACHE<2
831         KA_T na;                        /* file structure's node address */
832 # endif /* defined(HASNCACHE) && HASNCACHE<2 */
833
834 # if    defined(HASNCACHE) && defined(HASNCVPID)
835         unsigned long id;               /* capability ID */
836 # endif /* defined(HASNCACHE) && defined(HASNCVPID) */
837
838 # if    defined(HASLFILEADD)
839         HASLFILEADD
840 # endif /* defined(HASLFILEADD) */
841
842 # if    defined(HASFSTRUCT)
843         KA_T fsa;                       /* file structure address */
844         long fct;                       /* file structure's f_count */
845         long ffg;                       /* file structure's f_flag */
846         long pof;                       /* process open-file flags */
847         KA_T fna;                       /* file structure node address */
848 # endif /* defined(HASFSTRUCT) */
849
850         struct lfile *next;
851 };
852 extern struct lfile *Lf, *Plf;
853
854
855 struct lproc {
856         char *cmd;                      /* command name */
857  
858 # if    defined(HASSELINUX)
859         char *cntx;                     /* security context */
860 # endif /* defined(HASSELINUX) */
861
862         short sf;                       /* select flags -- SEL* symbols */
863         short pss;                      /* state: 0 = not selected
864                                          *        1 = wholly selected
865                                          *        2 = partially selected */
866 # if    defined(HASEPTOPTS)
867         short pipe;                     /* pipe status -- PS_PIPE* values */
868 # endif /* defined(HASEPTOPTS) */
869
870         int pid;                        /* process ID */
871
872 # if    defined(HASTASKS)
873         int tid;                        /* task ID */
874 # endif /* HASTASKS */
875
876         int pgid;                       /* process group ID */
877         int ppid;                       /* parent process ID */
878         uid_t uid;                      /* user ID */
879
880 # if    defined(HASZONES)
881         char *zn;                       /* zone name */
882 # endif /* defined(HASZONES) */
883
884         struct lfile *file;             /* open files of process */
885 };
886 extern struct lproc *Lp, *Lproc;
887
888 extern int MaxFd;
889 extern char *Memory;
890 extern int MntSup;
891 extern char *MntSupP;
892
893 # if    defined(HASPROCFS)
894 extern struct mounts *Mtprocfs;
895 # endif
896
897 extern int Mxpgid;
898 extern int Mxpid;
899 extern int Mxuid;
900 extern gid_t Mygid;
901 extern int Mypid;
902 extern uid_t Myuid;
903 extern char *Namech;
904 extern size_t Namechl;
905 extern int Ndev;
906
907 # if    defined(HASNLIST)
908 #  if   !defined(NLIST_TYPE)
909 #define NLIST_TYPE      nlist
910 #  endif        /* !defined(NLIST_TYPE) */
911 extern struct NLIST_TYPE *Nl;
912 extern int Nll;
913 # endif /* defined(HASNLIST) */
914 extern long Nlink;
915 extern int Nlproc;
916 extern char *Nmlst;
917 extern int Npgid;
918 extern int Npgidi;
919 extern int Npgidx;
920 extern int Npid;
921 extern int Npidi;
922 extern int Npidx;
923 extern int Npuns;
924 extern int Ntype;
925 extern int Nuid;
926 extern int Nuidexcl;
927 extern int Nuidincl;
928
929 struct nwad {
930         char *arg;                      /* argument */
931         char *proto;                    /* protocol */
932         int af;                         /* address family -- e.g.,
933                                          * AF_INET, AF_INET6 */
934         unsigned char a[MAX_AF_ADDR];   /* address */
935         int sport;                      /* starting port */
936         int eport;                      /* ending port */
937         int f;                          /* find state */
938         struct nwad *next;              /* forward link */
939 };
940 extern struct nwad *Nwad;
941
942 extern int OffDecDig;
943 extern char *Pn;
944
945 # if    defined(HASFSTRUCT)
946 extern struct pff_tab Pff_tab[];        /* file flags table */
947 extern struct pff_tab Pof_tab[];        /* process open file flags table */
948 # endif /* defined(HASFSTRUCT) */
949
950 # if    defined(HASPROCFS)
951 struct procfsid {
952         pid_t pid;                      /* search PID */
953         char *nm;                       /* search name */
954         unsigned char f;                /* match found if == 1 */
955
956 #  if   defined(HASPINODEN)
957         INODETYPE inode;                /* search inode number */
958 #  endif        /* defined(HASPINODEN) */
959
960         struct procfsid *next;          /* forward link */
961 };
962
963 extern int Procfind;
964 extern struct procfsid *Procfsid;
965 extern int Procsrch;
966 # endif /* defined(HASPROCFS) */
967
968 extern int PrPass;
969 extern int RptTm;
970 extern struct l_dev **Sdev;
971 extern int Selall;
972 extern int Selflags;
973 extern int Setgid;
974 extern int Selinet;
975 extern int Setuidroot;
976 extern struct sfile *Sfile;
977 extern struct int_lst *Spgid;
978 extern struct int_lst *Spid;
979 extern struct seluid *Suid;
980 extern char *SzOffFmt_0t;
981 extern char *SzOffFmt_d;
982 extern char *SzOffFmt_dv;
983 extern char *SzOffFmt_x;
984 extern int TaskPrtFl;
985 extern int TcpStAlloc;
986 extern unsigned char *TcpStI;
987 extern int TcpStIn;
988 extern int TcpStOff;
989 extern unsigned char *TcpStX;
990 extern int TcpStXn;
991 extern int TcpNstates;
992 extern char **TcpSt;
993 extern char Terminator;
994 extern int TmLimit;
995 extern int UdpStAlloc;
996 extern unsigned char *UdpStI;
997 extern int UdpStIn;
998 extern int UdpStOff;
999 extern unsigned char *UdpStX;
1000 extern int UdpStXn;
1001 extern int UdpNstates;
1002 extern char **UdpSt;
1003
1004 # if    defined(HASZONES)
1005 typedef struct znhash {
1006         char *zn;                       /* zone name */
1007         int f;                          /* "find" flag (used only in ZoneArg) */
1008         struct znhash *next;            /* next zone hash entry */
1009 } znhash_t;
1010 extern znhash_t **ZoneArg;
1011 # endif /* defined(HASZONES) */
1012
1013 #include "proto.h"
1014 #include "dproto.h"
1015
1016 #endif  /* LSOF_H */