File: usage.c

package info (click to toggle)
lsof 4.91+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,984 kB
  • sloc: ansic: 68,893; sh: 6,862; makefile: 1,682; perl: 1,099; awk: 214
file content (979 lines) | stat: -rw-r--r-- 24,503 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
/*
 * usage.c - usage functions for lsof
 */


/*
 * Copyright 1998 Purdue Research Foundation, West Lafayette, Indiana
 * 47907.  All rights reserved.
 *
 * Written by Victor A. Abell
 *
 * This software is not subject to any license of the American Telephone
 * and Telegraph Company or the Regents of the University of California.
 *
 * Permission is granted to anyone to use this software for any purpose on
 * any computer system, and to alter it and redistribute it freely, subject
 * to the following restrictions:
 *
 * 1. Neither the authors nor Purdue University are responsible for any
 *    consequences of the use of this software.
 *
 * 2. The origin of this software must not be misrepresented, either by
 *    explicit claim or by omission.  Credit to the authors and Purdue
 *    University must appear in documentation and sources.
 *
 * 3. Altered versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 *
 * 4. This notice may not be removed or altered.
 */

#ifndef lint
static char copyright[] =
"@(#) Copyright 1998 Purdue Research Foundation.\nAll rights reserved.\n";
static char *rcsid = "$Id: usage.c,v 1.33 2018/02/14 14:20:14 abe Exp $";
#endif


#include "lsof.h"
#include "version.h"


/*
 * Local function prototypes
 */

_PROTOTYPE(static char *isnullstr,(char *s));
_PROTOTYPE(static int print_in_col,(int col, char *cp));
_PROTOTYPE(static void report_HASDCACHE,(int type, char *ttl, char *det));
_PROTOTYPE(static void report_HASKERNIDCK,(char *pfx, char *verb));
_PROTOTYPE(static void report_SECURITY,(char *pfx, char *punct));
_PROTOTYPE(static void report_WARNDEVACCESS,(char *pfx, char *verb,
					     char *punct));


/*
 * isnullstr() - is it a null string?
 */

static char *
isnullstr(s)
	char *s;			/* string pointer */
{
	if (!s)
		return((char *)NULL);
	while (*s) {
		if (*s != ' ')
			return(s);
		s++;
	}
	return((char *)NULL);
}


/*
 * print_in_col() -- print character string in help column
 */

static int
print_in_col(col, cp)
	int col;				/* column number */
	char *cp;				/* what to print */
{
	if (cp && *cp) {
	    switch (col) {
	    case 1:
		(void) fprintf(stderr, "  %-23.23s", cp);
		break;
	    case 2:
		(void) fprintf(stderr, "  %-25.25s", cp);
		break;
	    default:
		(void) fprintf(stderr, "  %s\n", cp);
		col = 0;
	    }
	    col++;
	}
	return(col);
}


/*
 * report_HASDCACHE() -- report device cache file state
 */

static void
report_HASDCACHE(type, ttl, det)
	int type;				/* type: 0 == read path report
						 *       1 == full report */
	char *ttl;				/* title lines prefix
						 * (NULL if none) */
	char *det;				/* detail lines prefix
						 * (NULL if none) */
{

#if	defined(HASDCACHE)
	char *cp;
	int dx;

# if	defined(WILLDROPGID)
	int saved_Setgid = Setgid;

	Setgid = 0;
# endif	/* defined(WILLDROPGID) */

	if (type) {

	/*
	 * Report full device cache information.
	 */
	    (void) fprintf(stderr, "%sDevice cache file read-only paths:\n",
		ttl ? ttl : "");
	    if ((dx = dcpath(1, 0)) < 0)
		(void) fprintf(stderr, "%snone\n", det ? det : "");
	    else {
		(void) fprintf(stderr, "%sNamed via -D: %s\n",
		    det ? det : "",
		    DCpath[0] ? DCpath[0] : "none");

# if	defined(HASENVDC)
		(void) fprintf(stderr,
		    "%sNamed in environment variable %s: %s\n",
		    det ? det : "",
		    HASENVDC, DCpath[1] ? DCpath[1] : "none");
# endif	/* defined(HASENVDC) */

# if	defined(HASSYSDC)
		if (DCpath[2])
		    (void) fprintf(stderr,
			"%sSystem-wide device cache: %s\n",
			det ? det : "",
			DCpath[2]);
# endif	/* defined(HASSYSDC) */

# if	defined(HASPERSDC)
		(void) fprintf(stderr,
		    "%sPersonal path format (HASPERSDC): \"%s\"\n",
		    det ? det : "",
		    HASPERSDC);
#  if	defined(HASPERSDCPATH)
		(void) fprintf(stderr,
		    "%sModified personal path environment variable: %s\n",
		    det ? det : "",
		    HASPERSDCPATH);
		cp = getenv(HASPERSDCPATH);
		(void) fprintf(stderr, "%s%s value: %s\n",
		    det ? det : "",
		    HASPERSDCPATH, cp ? cp : "none");
#  endif	/* defined(HASPERSDCPATH) */
		(void) fprintf(stderr, "%sPersonal path: %s\n",
		    det ? det : "",
		    DCpath[3] ? DCpath[3] : "none");
# endif	/* defined(HASPERSDC) */
	    }
	    (void) fprintf(stderr, "%sDevice cache file write paths:\n",
		ttl ? ttl : "");
	    if ((dx = dcpath(2, 0)) < 0)
		(void) fprintf(stderr, "%snone\n", det ? det : "");
	    else {
		(void) fprintf(stderr, "%sNamed via -D: %s\n",
		    det ? det : "",
		    DCstate == 2 ? "none"
				 : DCpath[0] ? DCpath[0] : "none");

# if	defined(HASENVDC)
		(void) fprintf(stderr,
		    "%sNamed in environment variable %s: %s\n",
		    det ? det : "",
		    HASENVDC, DCpath[1] ? DCpath[1] : "none");
# endif	/* defined(HASENVDC) */

# if	defined(HASPERSDC)
		(void) fprintf(stderr,
		    "%sPersonal path format (HASPERSDC): \"%s\"\n",
		    det ? det : "",
		    HASPERSDC);
#  if	defined(HASPERSDCPATH)
		(void) fprintf(stderr,
		    "%sModified personal path environment variable: %s\n",
		    det ? det : "",
		    HASPERSDCPATH);
		cp = getenv(HASPERSDCPATH);
		(void) fprintf(stderr, "%s%s value: %s\n",
		    det ? det : "",
		    HASPERSDCPATH, cp ? cp : "none");
#  endif	/* defined(HASPERSDCPATH) */
		 (void) fprintf(stderr, "%sPersonal path: %s\n",
		    det ? det : "",
		    DCpath[3] ? DCpath[3] : "none");
# endif	/* defined(HASPERSDC) */
	    }
	} else {

	/*
	 * Report device cache read file path.
	 */

# if	defined(HASENVDC) || defined(HASPERSDC) || defined(HASSYSDC)
	    cp = NULL;
#  if	defined(HASENVDC)
	    if ((dx = dcpath(1, 0)) >= 0)
		cp = DCpath[1];
#  endif	/* defined(HASENVDC) */
#  if	defined(HASSYSDC)
	    if (!cp)
		cp = HASSYSDC;
#  endif	/* defined(HASSYSDC) */
#  if	defined(HASPERSDC)
	    if (!cp && dx != -1 && (dx = dcpath(1, 0)) >= 0)
		cp = DCpath[3];
#  endif	/* defined(HASPERSDC) */
	    if (cp)
		(void) fprintf(stderr,
		    "%s%s is the default device cache file read path.\n",
		    ttl ? ttl : "",
		    cp
		);
# endif    /* defined(HASENVDC) || defined(HASPERSDC) || defined(HASSYSDC) */
	}

# if	defined(WILLDROPGID)
	Setgid = saved_Setgid;
# endif	/* defined(WILLDROPGID) */

#endif	/* defined(HASDCACHE) */

}


/*
 * report_HASKERNIDCK() -- report HASKERNIDCK state
 */

static void
report_HASKERNIDCK(pfx, verb)
	char *pfx;				/* prefix (NULL if none) */
	char *verb;				/* verb (NULL if none) */
{
	(void) fprintf(stderr, "%sernel ID check %s%s%s.\n",
	    pfx ? pfx : "",
	    verb ? verb : "",
	    verb ? " " : "",

#if	defined(HASKERNIDCK)
		"enabled"
#else	/* !defined(HASKERNIDCK) */
		"disabled"
#endif	/* defined(HASKERNIDCK) */

	    );
}


/*
 * report_SECURITY() -- report *SECURITY states
 */

static void
report_SECURITY(pfx, punct)
	char *pfx;				/* prefix (NULL if none) */
	char *punct;				/* short foem punctuation
						 * (NULL if none) */
{
	fprintf(stderr, "%s%s can list all files%s",
	    pfx ? pfx : "",

#if	defined(HASSECURITY)
	    "Only root",
# if	defined(HASNOSOCKSECURITY)
	    ", but anyone can list socket files.\n"
# else	/* !defined(HASNOSOCKSECURITY) */
	    punct ? punct : ""
# endif	/* defined(HASNOSOCKSECURITY) */
#else	/* !defined(HASSECURITY) */
	    "Anyone",
	    punct ? punct : ""
#endif	/* defined(HASSECURITY) */

	);
}


/*
 * report_WARNDEVACCESS() -- report WEARNDEVACCESS state
 */

static void
report_WARNDEVACCESS(pfx, verb, punct)
	char *pfx;				/* prefix (NULL if none) */
	char *verb;				/* verb (NULL if none) */
	char *punct;				/* punctuation */
{
	(void) fprintf(stderr, "%s/dev warnings %s%s%s%s",
	    pfx ? pfx : "",
	    verb ? verb : "",
	    verb ? " " : "",

#if	defined(WARNDEVACCESS)
	    "enabled",
#else	/* !defined(WARNDEVACCESS) */
	    "disabled",
#endif	/* defined(WARNDEVACCESS) */

	    punct);
}


/*
 * usage() - display usage and exit
 */

void
usage(xv, fh, version)
	int xv;				/* exit value */
	int fh;				/* ``-F ?'' status */
	int version;			/* ``-v'' status */
{
	char buf[MAXPATHLEN+1], *cp, *cp1, *cp2;
	int col, i;

	if (Fhelp || xv) {
	    (void) fprintf(stderr, "%s %s\n latest revision: %s\n",
		Pn, LSOF_VERSION, LSOF_URL);
	    (void) fprintf(stderr, " latest FAQ: %sFAQ\n", LSOF_URL);
	    (void) fprintf(stderr, " latest man page: %slsof_man\n", LSOF_URL);
	    (void) fprintf(stderr,
		" usage: [-?ab%sh%slnNoOP%s%stUvV%s]",

#if	defined(HASNCACHE)
		"C",
#else	/* !defined(HASNCACHE) */
		"",
#endif	/* defined(HASNCACHE) */

#if	defined(HASTASKS)
		"K",
#else	/* !defined(HASTASKS) */
		"",
#endif	/* defined(HASTASKS) */

#if	defined(HASPPID)
		"R",
#else	/* !defined(HASPPID) */
		"",
#endif	/* defined(HASPPID) */

#if	defined(HASTCPUDPSTATE)
		"",
#else	/* !defined(HASTCPUDPSTATE) */
		"s",
#endif	/* defined(HASTCPUDPSTATE) */

#if	defined(HASXOPT)
# if	defined(HASXOPT_ROOT)
		(Myuid == 0) ? "X" : ""
# else	/* !defined(HASXOPT_ROOT) */
		"X"
# endif	/* defined(HASXOPT_ROOT) */
#else	/* !defined(HASXOPT) */
		""
#endif	/* defined(HASXOPT) */

	    );

#if	defined(HAS_AFS) && defined(HASAOPT)
	    (void) fprintf(stderr, " [-A A]");
#endif	/* defined(HAS_AFS) && defined(HASAOPT) */

	    (void) fprintf(stderr, " [+|-c c] [+|-d s] [+%sD D]%s",
#if	defined(HASDCACHE)
		"|-",
#else	/* !defined(HASDCACHE) */
		"",
#endif	/* defined(HASDCACHE) */

#if	defined(HASEPTOPTS)
		" [+|-E]"
#else	/* !defined(HASEPTOPTS) */
		""
#endif	/* defined(HASEPTOPTS) */

		);

	    (void) fprintf(stderr,
		" %s[+|-f%s%s%s%s%s%s]\n [-F [f]] [-g [s]] [-i [i]]",

#if	defined(HASEOPT)
		"[+|-e s] ",
#else	/* !defined(HASEOPT) */
		"",
#endif	/* defined(HASEOPT) */

#if	defined(HASFSTRUCT)
		"[",

# if	defined(HASNOFSCOUNT)
		"",
# else	/* !defined(HASNOFSCOUNT) */
		"c",
# endif	/* defined(HASNOFSCOUNT) */

# if	defined(HASNOFSADDR)
		"",
# else	/* !defined(HASNOFSADDR) */
		"f",
# endif	/* defined(HASNOFSADDR) */

# if	defined(HASNOFSFLAGS)
		"",
# else	/* !defined(HASNOFSFLAGS) */
		"gG",
# endif	/* defined(HASNOFSFLAGS) */

# if	defined(HASNOFSNADDR)
		"",
# else	/* !defined(HASNOFSNADDR) */
		"n",
# endif	/* defined(HASNOFSNADDR) */

		"]"
#else	/* !defined(HASFSTRUCT) */
		"", "", "", "", "", ""
#endif	/* defined(HASFSTRUCT) */

		);

#if	defined(HASKOPT)
	    (void) fprintf(stderr, " [-k k]");
#endif	/* defined(HASKOPT) */

	    (void) fprintf(stderr, " [+|-L [l]]");

#if	defined(HASMOPT) || defined(HASMNTSUP)
	    (void) fprintf(stderr,
# if	defined(HASMOPT)
#  if	defined(HASMNTSUP)
		" [+|-m [m]]"
#  else	/* !defined(HASMNTSUP) */
		" [-m m]"
#  endif	/* defined(HASMNTSUP) */
# else	/* !defined(HASMOPT) */
		" [+m [m]]"
# endif	/* defined(HASMOPT) */
		);
#endif	/* defined(HASMOPT) || defined(HASMNTSUP) */

#if	!defined(HASNORPC_H)
	    (void) fprintf(stderr, " [+|-M]");
#endif	/* !defined(HASNORPC_H) */

	    (void) fprintf(stderr,
		" [-o [o]] [-p s]\n [+|-r [t]]%s [-S [t]] [-T [t]]",

#if	defined(HASTCPUDPSTATE)
		" [-s [p:s]]"
#else	/* !defined(HASTCPUDPSTATE) */
		""
#endif	/* defined(HASTCPUDPSTATE) */

		);
	    (void) fprintf(stderr, " [-u s] [+|-w] [-x [fl]]");

#if	defined(HASZONES)
	    (void) fprintf(stderr, " [-z [z]]");
#else	/* !defined(HASZONES) */
# if	defined(HASSELINUX)
	    if (CntxStatus)
		(void) fprintf(stderr, " [-Z [Z]]");
# endif	/* defined(HASSELINUX) */
#endif	/* defined(HASZONES) */

	    (void) fprintf(stderr, " [--] [names]\n");
	}
	if (xv && !Fhelp) {
	    (void) fprintf(stderr,
		"Use the ``-h'' option to get more help information.\n");
	    if (!fh)
    		Exit(xv);
	}
	if (Fhelp) {
	    (void) fprintf(stderr,
		"Defaults in parentheses; comma-separated set (s) items;");
	    (void) fprintf(stderr, " dash-separated ranges.\n");
	    col = print_in_col(1, "-?|-h list help");
	    col = print_in_col(col, "-a AND selections (OR)");
	    col = print_in_col(col, "-b avoid kernel blocks");
	    col = print_in_col(col,  "-c c  cmd c ^c /c/[bix]");
	    (void) snpf(buf, sizeof(buf), "+c w  COMMAND width (%d)", CMDL);
	    col = print_in_col(col, buf);

#if	defined(HASNCACHE)
	   col = print_in_col(col, "-C no kernel name cache");
#endif	/* defined(HASNCACHE) */

	    col = print_in_col(col, "+d s  dir s files");
	    col = print_in_col(col,  "-d s  select by FD set");
	    col = print_in_col(col,  "+D D  dir D tree *SLOW?*");

#if	defined(HASDCACHE)
	    if (Setuidroot)
		cp = "?|i|r";

# if	!defined(WILLDROPGID)
	    else if (Myuid)
		cp = "?|i|r<path>";
# endif	/* !defined(WILLDROPGID) */

	    else
		cp = "?|i|b|r|u[path]";
	    (void) snpf(buf, sizeof(buf), "-D D  %s", cp);
#else	/* !defined(HASDCACHE) */
	    buf[0] = '\0';
#endif	/* defined(HASDCACHE) */

	    col = print_in_col(col, buf);

#if	defined(HASEOPT)
	    col = print_in_col(col, "+|-e s  exempt s *RISKY*");
#endif	/* defined(HASEOPT) */

	    (void) snpf(buf, sizeof(buf), "-i select IPv%s files",

#if	defined(HASIPv6)
			  "[46]"
#else	/* !defined(HASIPv6) */
			  "4"
#endif	/* defined(HASIPv6) */

			  );
	    col = print_in_col(col, buf);

#if	defined(HASTASKS)
/* DEBUG	    col = print_in_col(col, "-K list tasKs (threads)");	*/
	    col = print_in_col(col, "-K [i] list|(i)gn tasKs");
#endif	/* defined(HASTASKS) */

	    col = print_in_col(col, "-l list UID numbers");
	    col = print_in_col(col, "-n no host names");
	    col = print_in_col(col, "-N select NFS files");
	    col = print_in_col(col, "-o list file offset");
	    col = print_in_col(col, "-O no overhead *RISKY*");
	    col = print_in_col(col, "-P no port names");

#if	defined(HASPPID)
	     col = print_in_col(col, "-R list paRent PID");
#endif	/* defined(HASPPID) */

	    col = print_in_col(col,  "-s list file size");
	    col = print_in_col(col,  "-t terse listing");
	    col = print_in_col(col,  "-T disable TCP/TPI info");
	    col = print_in_col(col,  "-U select Unix socket");
	    col = print_in_col(col,  "-v list version info");
	    col = print_in_col(col,  "-V verbose search");
	    (void) snpf(buf, sizeof(buf), "+|-w  Warnings (%s)",

#if	defined(WARNINGSTATE)
		"-");
#else	/* !defined(WARNINGSTATE) */
		"+");
#endif	/* defined(WARNINGSTATE) */

	    col = print_in_col(col, buf);

#if	defined(HASXOPT)
# if	defined(HASXOPT_ROOT)
	    if (Myuid == 0)
		(void) snpf(buf, sizeof(buf), "-X %s", HASXOPT);
	    else
		buf[0] = '\0';
# else	/* !defined(HASXOPT_ROOT) */
	    (void) snpf(buf, sizeof(buf), "-X %s", HASXOPT);
# endif	/* defined(HASXOPT_ROOT) */
# else	/* !defined(HASXOPT) */
	    buf[0] = '\0';
#endif	/* defined(HASXOPT) */

	    col = print_in_col(col, buf);

#if	defined(HASZONES)
	    col = print_in_col(col, "-z z  zone [z]");
#endif	/* defined(HASZONES) */

#if	defined(HASSELINUX)
	    col = print_in_col(col, "-Z Z  context [Z]");
#endif	/* defined(HASSELINUX) */

	    col = print_in_col(col, "-- end option scan");
	    if (col != 1)
		(void) fprintf(stderr, "\n");

#if	defined(HASEPTOPTS)
	    (void) fprintf(stderr, "  %-36.36s  %s\n",
		"-E display endpoint info",
		"+E display endpoint info and files"
	    );
#endif	/* defined(HASEPTOPTS) */

	    (void) fprintf(stderr, "  %-36.36s",
		"+f|-f  +filesystem or -file names");

#if	defined(HASFSTRUCT)
	    (void) fprintf(stderr,
		"  +|-f[%s%s%s%s]%s%s%s%s %s%s%s%s%s%s%s\n",

# if	defined(HASNOFSCOUNT)
		"",
# else	/* !defined(HASNOFSCOUNT) */
		"c",
# endif	/* defined(HASNOFSCOUNT) */

# if	defined(HASNOFSADDR)
		"",
# else	/* !defined(HASNOFSADDR) */
		"f",
# endif	/* defined(HASNOFSADDR) */

# if	defined(HASNOFSFLAGS)
		"",
# else	/* !defined(HASNOFSFLAGS) */
		"gG",
# endif	/* defined(HASNOFSFLAGS) */

# if	defined(HASNOFSNADDR)
		"",
# else	/* !defined(HASNOFSNADDR) */
		"n",
# endif	/* defined(HASNOFSNADDR) */

# if	defined(HASNOFSCOUNT)
		"",
# else	/* !defined(HASNOFSCOUNT) */
		" Ct",
# endif	/* defined(HASNOFSCOUNT) */

# if	defined(HASNOFSADDR)
		"",
# else	/* !defined(HASNOFSADDR) */
		" Fstr",
# endif	/* defined(HASNOFSADDR) */

# if	defined(HASNOFSFLAGS)
		"",
# else	/* !defined(HASNOFSFLAGS) */
		" flaGs",
# endif	/* defined(HASNOFSFLAGS) */

# if	defined(HASNOFSNADDR)
		"",
# else	/* !defined(HASNOFSNADDR) */
		" Node",
# endif	/* defined(HASNOFSNADDR) */

		Fsv ? "(" : "",
		(Fsv & FSV_CT) ? "C" : "",
		(Fsv & FSV_FA) ? "F" : "",
		((Fsv & FSV_FG) && FsvFlagX)  ? "g" : "",
		((Fsv & FSV_FG) && !FsvFlagX) ? "G" : "",
		(Fsv & FSV_NI) ? "N" : "",
		Fsv ? ")" : "");
#else	/* !defined(HASFSTRUCT) */
	    putc('\n', stderr);
#endif	/* defined(HASFSTRUCT) */

	    (void) fprintf(stderr, "  %-36.36s",
		"-F [f] select fields; -F? for help");

#if	defined(HASKOPT)
	    (void) fprintf(stderr,
		"  -k k   kernel symbols (%s)\n",
		Nmlst ? Nmlst
# if	defined(N_UNIX)
		      : N_UNIX
# else	/* !defined(N_UNIX) */
		      : (Nmlst = get_nlist_path(1)) ? Nmlst
						    : "none found"
# endif	/* defined(N_UNIX) */

	    );
#else	/* !defined(HASKOPT) */
	    putc('\n', stderr);
#endif	/* defined(HASKOPT) */

	    (void) fprintf(stderr,
		"  +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0)\n");

#if	defined(HASMOPT) || defined(HASMNTSUP)
# if	defined(HASMOPT)
	    (void) snpf(buf, sizeof(buf), "-m m   kernel memory (%s)", KMEM);
# else	/* !defined(HASMOPT) */
	    buf[0] = '\0';
# endif	/* defined(HASMOPT) */

	    (void) fprintf(stderr, "  %-36.36s", buf);

# if	defined(HASMNTSUP)
	    (void) fprintf(stderr, "  +m [m] use|create mount supplement\n");
# else	/* !defined(HASMNTSUP) */
	    (void) fprintf(stderr, "\n");
# endif	/* defined(HASMNTSUP) */
#endif	/* defined(HASMOPT) || defined(HASMNTSUP) */

#if	!defined(HASNORPC_H)
	    (void) snpf(buf, sizeof(buf), "+|-M   portMap registration (%s)",

# if	defined(HASPMAPENABLED)
		"+"
# else	/* !defined(HASPMAPENABLED) */
		"-"
# endif	/* defined(HASPMAPENABLED) */

	    );
#else	/* defined(HASNORPC_H) */
	    buf[0] = '\0';
#endif	/* !defined(HASNORPC_H) */

	    (void) fprintf(stderr, "  %-36.36s", buf);
	    (void) snpf(buf, sizeof(buf), "-o o   o 0t offset digits (%d)",
		OFFDECDIG);
	    (void) fprintf(stderr, "  %s\n", buf);
	    (void) fprintf(stderr, "  %-36.36s",
		"-p s   exclude(^)|select PIDs");
	    (void) fprintf(stderr, "  -S [t] t second stat timeout (%d)\n",
		TMLIMIT);
	    (void) snpf(buf, sizeof(buf),
		"-T %s%ss%s TCP/TPI %s%sSt%s (s) info",

#if	defined(HASSOOPT) || defined(HASSOSTATE) || defined(HASTCPOPT)
		"f",
#else	/* !defined(HASSOOPT) && !defined(HASSOSTATE) && !defined(HASTCPOPT)*/
		"",
#endif	/* defined(HASSOOPT) || defined(HASSOSTATE) || defined(HASTCPOPT)*/

#if 	defined(HASTCPTPIQ)
		"q",
#else	/* !defined(HASTCPTPIQ) */
		" ",
#endif	/* defined(HASTCPTPIQ) */

#if 	defined(HASTCPTPIW)
		"w",
#else	/* !defined(HASTCPTPIW) */
		"",
#endif	/* defined(HASTCPTPIW) */

#if	defined(HASSOOPT) || defined(HASSOSTATE) || defined(HASTCPOPT)
		"Fl,",
#else	/* !defined(HASSOOPT) && !defined(HASSOSTATE) && !defined(HASTCPOPT)*/
		"",
#endif	/* defined(HASSOOPT) || defined(HASSOSTATE) || defined(HASTCPOPT)*/

#if 	defined(HASTCPTPIQ)
		"Q,",
#else	/* !defined(HASTCPTPIQ) */
		"",
#endif	/* defined(HASTCPTPIQ) */

#if 	defined(HASTCPTPIW)
		",Win"
#else	/* !defined(HASTCPTPIW) */
		""
#endif	/* defined(HASTCPTPIW) */

	    );
	    (void) fprintf(stderr, "  %s\n", buf);

#if	defined(HAS_AFS) && defined(HASAOPT)
	    (void) fprintf(stderr,
		"  -A A   AFS name list file (%s)\n", AFSAPATHDEF);
#endif	/* defined(HAS_AFS) && defined(HASAOPT) */

	    (void) fprintf(stderr,
		"  -g [s] exclude(^)|select and print process group IDs\n");
	    (void) fprintf(stderr, "  -i i   select by IPv%s address:",

#if	defined(HASIPv6)
			  "[46]"
#else	/* !defined(HASIPv6) */
			  "4"
#endif	/* defined(HASIPv6) */

			  );
	    (void) fprintf(stderr,
		" [%s][proto][@host|addr][:svc_list|port_list]\n",

#if	defined(HASIPv6)
		"46"
#else	/* !defined(HASIPv6) */
		"4"
#endif	/* defined(HASIPv6) */

		);

	    (void) fprintf(stderr,
		"  +|-r [%s] repeat every t seconds (%d); %s",

#if	defined(HAS_STRFTIME)
		"t[m<fmt>]",
#else	/* !defined(has_STRFTIME) */
		"t",
#endif	/* defined(HAS_STRFTIME) */

		RPTTM,
		" + until no files, - forever.\n");

#if	defined(HAS_STRFTIME)
	    (void) fprintf(stderr,
		"       An optional suffix to t is m<fmt>; m must separate %s",
		"t from <fmt> and\n");
	    (void) fprintf(stderr, "      <fmt> is an strftime(3) format %s",
		"for the marker line.\n");
#endif	/* defined(HAS_STRFTIME) */

#if	defined(HASTCPUDPSTATE)
	    (void) fprintf(stderr,
		"  -s p:s  exclude(^)|select protocol (p = TCP|UDP) states");
	    (void) fprintf(stderr, " by name(s).\n");
#endif	/* defined(HASTCPUDPSTATE) */

	    (void) fprintf(stderr,
		"  -u s   exclude(^)|select login|UID set s\n");
	    (void) fprintf(stderr,
		"  -x [fl] cross over +d|+D File systems or symbolic Links\n");
	    (void) fprintf(stderr,
		"  names  select named files or files on named file systems\n");
	    (void) report_SECURITY(NULL, "; ");
	    (void) report_WARNDEVACCESS(NULL, NULL, ";");
	    (void) report_HASKERNIDCK(" k", NULL);
	    (void) report_HASDCACHE(0, NULL, NULL);

#if	defined(DIALECT_WARNING)
	    (void) fprintf(stderr, "WARNING: %s\n", DIALECT_WARNING);
#endif	/* defined(DIALECT_WARNING) */

	}
	if (fh) {
	    (void) fprintf(stderr, "%s:\tID    field description\n", Pn);
	    for (i = 0; FieldSel[i].nm; i++) {

#if	!defined(HASPPID)
		if (FieldSel[i].id == LSOF_FID_PPID)
		    continue;
#endif	/* !defined(HASPPID) */

#if	!defined(HASFSTRUCT)
		if (FieldSel[i].id == LSOF_FID_FA
		||  FieldSel[i].id == LSOF_FID_CT
		||  FieldSel[i].id == LSOF_FID_FG
		||  FieldSel[i].id == LSOF_FID_NI)
		    continue;
#else	/* defined(HASFSTRUCT) */
# if	defined(HASNOFSADDR)
		if (FieldSel[i].id == LSOF_FID_FA)
		    continue;
# endif	/* defined(HASNOFSADDR) */

# if	defined(HASNOFSCOUNT)
		if (FieldSel[i].id == LSOF_FID_CT)
		    continue;
# endif	/* !defined(HASNOFSCOUNT) */

# if	defined(HASNOFSFLAGS)
		if (FieldSel[i].id == LSOF_FID_FG)
		    continue;
# endif	/* defined(HASNOFSFLAGS) */

# if	defined(HASNOFSNADDR)
		if (FieldSel[i].id == LSOF_FID_NI)
		    continue;
# endif	/* defined(HASNOFSNADDR) */
#endif	/* !defined(HASFSTRUCT) */

#if	!defined(HASZONES)
		if (FieldSel[i].id == LSOF_FID_ZONE)
		    continue;
#endif	/* !defined(HASZONES) */
 
#if	defined(HASSELINUX)
		if ((FieldSel[i].id == LSOF_FID_CNTX) && !CntxStatus)
		    continue;
#else	/* !defined(HASSELINUX) */
		if (FieldSel[i].id == LSOF_FID_CNTX)
		    continue;
#endif	/* !defined(HASSELINUX) */

		(void) fprintf(stderr, "\t %c    %s\n",
		    FieldSel[i].id, FieldSel[i].nm);
	    }
	}

#if	defined(HASDCACHE)
	if (DChelp)
	    report_HASDCACHE(1, NULL, "    ");
#endif	/* defined(HASDCACHE) */

	if (version) {

	/*
	 * Display version information in reponse to ``-v''.
	 */
	    (void) fprintf(stderr, "%s version information:\n", Pn);
	    (void) fprintf(stderr, "    revision: %s\n", LSOF_VERSION);
	    (void) fprintf(stderr, "    latest revision: %s\n", LSOF_URL);
	    (void) fprintf(stderr, "    latest FAQ: %sFAQ\n",
		LSOF_URL);
	    (void) fprintf(stderr, "    latest man page: %slsof_man\n",
		LSOF_URL);

#if	defined(LSOF_CINFO)
	    if ((cp = isnullstr(LSOF_CINFO)))
		(void) fprintf(stderr, "    configuration info: %s\n", cp);
#endif	/* defined(LSOF_CINFO) */

	    if ((cp = isnullstr(LSOF_CCDATE)))
		(void) fprintf(stderr, "    constructed: %s\n", cp);
	    cp = isnullstr(LSOF_HOST);
	    if (!(cp1 = isnullstr(LSOF_LOGNAME)))
		cp1 = isnullstr(LSOF_USER);
	    if (cp || cp1) {
		if (cp && cp1)
		    cp2 = "by and on";
		else if (cp)
		    cp2 = "on";
		else
		    cp2 = "by";
		(void) fprintf(stderr, "    constructed %s: %s%s%s\n",
		    cp2,
		    cp1 ? cp1 : "",
		    (cp && cp1) ? "@" : "",
		    cp  ? cp  : ""
		);
	    }

#if	defined(LSOF_BLDCMT)
	    if ((cp = isnullstr(LSOF_BLDCMT)))
		(void) fprintf(stderr, "    builder's comment: %s\n", cp);
#endif	/* defined(LSOF_BLDCMT) */

	    if ((cp = isnullstr(LSOF_CC)))
		(void) fprintf(stderr, "    compiler: %s\n", cp);
	    if ((cp = isnullstr(LSOF_CCV)))
		(void) fprintf(stderr, "    compiler version: %s\n", cp);
	    if ((cp = isnullstr(LSOF_CCFLAGS)))
		(void) fprintf(stderr, "    compiler flags: %s\n", cp);
	    if ((cp = isnullstr(LSOF_LDFLAGS)))
		(void) fprintf(stderr, "    loader flags: %s\n", cp);
	    if ((cp = isnullstr(LSOF_SYSINFO)))
		(void) fprintf(stderr, "    system info: %s\n", cp);
	    (void) report_SECURITY("    ", ".\n");
	    (void) report_WARNDEVACCESS("    ", "are", ".\n");
	    (void) report_HASKERNIDCK("    K", "is");

#if	defined(DIALECT_WARNING)
	    (void) fprintf(stderr, "    WARNING: %s\n", DIALECT_WARNING);
#endif	/* defined(DIALECT_WARNING) */

	    (void) report_HASDCACHE(1, "    ", "\t");
	}
	Exit(xv);
}