|
|
932381 |
diff -up ./lsof.8.ori ./lsof.8
|
|
|
932381 |
--- ./lsof.8.ori 2018-02-20 16:45:18.347856323 +0100
|
|
|
932381 |
+++ ./lsof.8 2018-02-20 16:45:26.204823914 +0100
|
|
|
932381 |
@@ -6,7 +6,7 @@ lsof \- list open files
|
|
|
932381 |
.SH SYNOPSIS
|
|
|
932381 |
.B lsof
|
|
|
932381 |
[
|
|
|
932381 |
-.B \-?abChKlnNOPRtUvVX
|
|
|
932381 |
+.B \-?abChlnNOPRtUvVX
|
|
|
932381 |
] [
|
|
|
932381 |
.BI -A " A"
|
|
|
932381 |
] [
|
|
|
932381 |
@@ -30,6 +30,8 @@ lsof \- list open files
|
|
|
932381 |
] [
|
|
|
932381 |
.BI \-k " k"
|
|
|
932381 |
] [
|
|
|
932381 |
+.BI \-K " k"
|
|
|
932381 |
+] [
|
|
|
932381 |
.BI +|\-L " [l]"
|
|
|
932381 |
] [
|
|
|
932381 |
.BI +|\-m " m"
|
|
|
932381 |
@@ -963,7 +965,7 @@ Here are some sample addresses:
|
|
|
932381 |
:time \- either TCP, UDP or UDPLITE time service port
|
|
|
932381 |
.fi
|
|
|
932381 |
.TP \w'names'u+4
|
|
|
932381 |
-.B \-K
|
|
|
932381 |
+.BI \-K " k"
|
|
|
932381 |
selects the listing of tasks (threads) of processes, on dialects
|
|
|
932381 |
where task (thread) reporting is supported.
|
|
|
932381 |
(If help output \- i.e., the output of the
|
|
|
932381 |
@@ -973,6 +975,15 @@ or
|
|
|
932381 |
options \- shows this option, then task (thread) reporting is
|
|
|
932381 |
supported by the dialect.)
|
|
|
932381 |
.IP
|
|
|
932381 |
+If
|
|
|
932381 |
+.B \-K
|
|
|
932381 |
+is followed by a value,
|
|
|
932381 |
+.IR k ,
|
|
|
932381 |
+it must be ``i''. That causes
|
|
|
932381 |
+.I lsof
|
|
|
932381 |
+to ignore tasks, particularly in the default, list\-everything case
|
|
|
932381 |
+when no other options are specified.
|
|
|
932381 |
+.IP
|
|
|
932381 |
When
|
|
|
932381 |
.B \-K
|
|
|
932381 |
and
|
|
|
932381 |
diff -up ./lsof.h.ori ./lsof.h
|
|
|
932381 |
--- ./lsof.h.ori 2018-02-19 17:41:00.082833606 +0100
|
|
|
932381 |
+++ ./lsof.h 2018-02-19 18:39:40.336086710 +0100
|
|
|
932381 |
@@ -491,6 +491,8 @@ struct afsnode { /* AFS pseudo-node st
|
|
|
932381 |
};
|
|
|
932381 |
# endif /* defined(HAS_AFS) */
|
|
|
932381 |
|
|
|
932381 |
+extern int AllProc;
|
|
|
932381 |
+
|
|
|
932381 |
# if defined(HAS_STD_CLONE)
|
|
|
932381 |
struct clone {
|
|
|
932381 |
int dx; /* index of device entry in Devtp[] */
|
|
|
932381 |
@@ -672,6 +674,7 @@ extern struct fieldsel FieldSel[];
|
|
|
932381 |
extern int Hdr;
|
|
|
932381 |
|
|
|
932381 |
enum IDType {PGID, PID};
|
|
|
932381 |
+extern int IgnTasks;
|
|
|
932381 |
extern char *InodeFmt_d;
|
|
|
932381 |
extern char *InodeFmt_x;
|
|
|
932381 |
extern int LastPid;
|
|
|
932381 |
@@ -938,8 +941,9 @@ extern int Procsrch;
|
|
|
932381 |
extern int PrPass;
|
|
|
932381 |
extern int RptTm;
|
|
|
932381 |
extern struct l_dev **Sdev;
|
|
|
932381 |
-extern int Selall;
|
|
|
932381 |
+extern int SelAll;
|
|
|
932381 |
extern int Selflags;
|
|
|
932381 |
+extern int SelProc;
|
|
|
932381 |
extern int Setgid;
|
|
|
932381 |
extern int Selinet;
|
|
|
932381 |
extern int Setuidroot;
|
|
|
932381 |
diff -up ./main.c.ori ./main.c
|
|
|
932381 |
--- ./main.c.ori 2018-02-19 17:20:33.058670928 +0100
|
|
|
932381 |
+++ ./main.c 2018-02-19 18:26:41.245793075 +0100
|
|
|
932381 |
@@ -181,7 +181,7 @@ main(argc, argv)
|
|
|
932381 |
#endif /* defined(HASKOPT) */
|
|
|
932381 |
|
|
|
932381 |
#if defined(HASTASKS)
|
|
|
932381 |
- "K",
|
|
|
932381 |
+ "K:",
|
|
|
932381 |
#else /* !defined(HASTASKS) */
|
|
|
932381 |
"",
|
|
|
932381 |
#endif /* defined(HASTASKS) */
|
|
|
932381 |
@@ -575,10 +575,27 @@ main(argc, argv)
|
|
|
932381 |
#endif /* defined(HASKOPT) */
|
|
|
932381 |
|
|
|
932381 |
#if defined(HASTASKS)
|
|
|
932381 |
- case 'K':
|
|
|
932381 |
+ case 'K':
|
|
|
932381 |
+ if (!GOv || *GOv == '-' || *GOv == '+') {
|
|
|
932381 |
Ftask = 1;
|
|
|
932381 |
+ IgnTasks = 0;
|
|
|
932381 |
Selflags |= SELTASK;
|
|
|
932381 |
- break;
|
|
|
932381 |
+ if (GOv) {
|
|
|
932381 |
+ GOx1 = GObk[0];
|
|
|
932381 |
+ GOx2 = GObk[1];
|
|
|
932381 |
+ }
|
|
|
932381 |
+ } else {
|
|
|
932381 |
+ if (!strcasecmp(GOv, "i")) {
|
|
|
932381 |
+ Ftask = 0;
|
|
|
932381 |
+ IgnTasks = 1;
|
|
|
932381 |
+ Selflags &= ~SELTASK;
|
|
|
932381 |
+ } else {
|
|
|
932381 |
+ (void) fprintf(stderr,
|
|
|
932381 |
+ "%s: -K not followed by i (but by %s)\n", Pn, GOv);
|
|
|
932381 |
+ err = 1;
|
|
|
932381 |
+ }
|
|
|
932381 |
+ }
|
|
|
932381 |
+ break;
|
|
|
932381 |
#endif /* defined(HASTASKS) */
|
|
|
932381 |
|
|
|
932381 |
case 'l':
|
|
|
932381 |
@@ -966,6 +983,11 @@ main(argc, argv)
|
|
|
932381 |
}
|
|
|
932381 |
}
|
|
|
932381 |
/*
|
|
|
932381 |
+ * If IgnTasks is set, remove SELTASK from SelAll and SelProc.
|
|
|
932381 |
+ */
|
|
|
932381 |
+ SelAll = IgnTasks ? (SELALL & ~SELTASK) : SELALL;
|
|
|
932381 |
+ SelProc = IgnTasks ? (SELPROC & ~SELTASK) : SELPROC;
|
|
|
932381 |
+/*
|
|
|
932381 |
* Check for argument consistency.
|
|
|
932381 |
*/
|
|
|
932381 |
if (Cmdnx && Cmdni) {
|
|
|
932381 |
@@ -1143,12 +1165,12 @@ main(argc, argv)
|
|
|
932381 |
"%s: no select options to AND via -a\n", Pn);
|
|
|
932381 |
usage(1, 0, 0);
|
|
|
932381 |
}
|
|
|
932381 |
- Selflags = SELALL;
|
|
|
932381 |
+ Selflags = SelAll;
|
|
|
932381 |
} else {
|
|
|
932381 |
if (GOx1 >= argc && (Selflags & (SELNA|SELNET)) != 0
|
|
|
932381 |
&& (Selflags & ~(SELNA|SELNET)) == 0)
|
|
|
932381 |
Selinet = 1;
|
|
|
932381 |
- Selall = 0;
|
|
|
932381 |
+ AllProc = 0;
|
|
|
932381 |
}
|
|
|
932381 |
/*
|
|
|
932381 |
* Get the device for DEVDEV_PATH.
|
|
|
932381 |
diff -up ./proc.c.ori ./proc.c
|
|
|
932381 |
--- ./proc.c.ori 2018-02-19 18:39:57.188006540 +0100
|
|
|
932381 |
+++ ./proc.c 2018-02-19 18:44:33.993689693 +0100
|
|
|
932381 |
@@ -498,7 +498,7 @@ examine_lproc()
|
|
|
932381 |
* o listing is selected by an ANDed option set (not all options)
|
|
|
932381 |
* that includes a single PID selection -- this one.
|
|
|
932381 |
*/
|
|
|
932381 |
- if ((Lp->sf & SELPID) && !Selall) {
|
|
|
932381 |
+ if ((Lp->sf & SELPID) && !AllProc) {
|
|
|
932381 |
if ((Selflags == SELPID)
|
|
|
932381 |
|| (Fand && (Selflags & SELPID))) {
|
|
|
932381 |
sbp = 1;
|
|
|
932381 |
@@ -648,7 +648,7 @@ is_file_sel(lp, lf)
|
|
|
932381 |
}
|
|
|
932381 |
#endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
|
|
|
932381 |
|
|
|
932381 |
- if (Selall)
|
|
|
932381 |
+ if (AllProc)
|
|
|
932381 |
return(1);
|
|
|
932381 |
if (Fand && ((lf->sf & Selflags) != Selflags))
|
|
|
932381 |
return(0);
|
|
|
932381 |
@@ -742,13 +742,13 @@ is_proc_excl(pid, pgid, uid, pss, sf)
|
|
|
932381 |
* network selections from the file flags, so that the tests in is_file_sel()
|
|
|
932381 |
* work as expected.
|
|
|
932381 |
*/
|
|
|
932381 |
- if (Selall) {
|
|
|
932381 |
+ if (AllProc) {
|
|
|
932381 |
*pss = PS_PRI;
|
|
|
932381 |
|
|
|
932381 |
#if defined(HASSECURITY) && defined(HASNOSOCKSECURITY)
|
|
|
932381 |
- *sf = SELALL & ~(SELNA | SELNET);
|
|
|
932381 |
+ *sf = SelAll & ~(SELNA | SELNET);
|
|
|
932381 |
#else /* !defined(HASSECURITY) || !defined(HASNOSOCKSECURITY) */
|
|
|
932381 |
- *sf = SELALL;
|
|
|
932381 |
+ *sf = SelAll;
|
|
|
932381 |
#endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
|
|
|
932381 |
|
|
|
932381 |
return(0);
|
|
|
932381 |
diff -up ./store.c.ori ./store.c
|
|
|
932381 |
--- ./store.c.ori 2018-02-19 18:39:50.532038205 +0100
|
|
|
932381 |
+++ ./store.c 2018-02-19 18:42:57.828147181 +0100
|
|
|
932381 |
@@ -43,6 +43,8 @@ static char *rcsid = "$Id: store.c,v 1.4
|
|
|
932381 |
* Global storage definitions
|
|
|
932381 |
*/
|
|
|
932381 |
|
|
|
932381 |
+int AllProc = 1; /* all processes are selected (default) */
|
|
|
932381 |
+
|
|
|
932381 |
#if defined(HASBLKDEV)
|
|
|
932381 |
struct l_dev *BDevtp = (struct l_dev *)NULL;
|
|
|
932381 |
/* block device table pointer */
|
|
|
932381 |
@@ -236,6 +238,7 @@ struct fieldsel FieldSel[] = {
|
|
|
932381 |
};
|
|
|
932381 |
|
|
|
932381 |
int Hdr = 0; /* header print status */
|
|
|
932381 |
+int IgnTasks = 0; /* ignore tasks when non-zero */
|
|
|
932381 |
char *InodeFmt_d = (char *) NULL;
|
|
|
932381 |
/* INODETYPE decimal printf specification */
|
|
|
932381 |
char *InodeFmt_x = (char *) NULL;
|
|
|
932381 |
@@ -320,8 +323,9 @@ int RptTm = 0; /* repeat time -- set b
|
|
|
932381 |
struct l_dev **Sdev = (struct l_dev **)NULL;
|
|
|
932381 |
/* pointer to Devtp[] pointers, sorted
|
|
|
932381 |
* by device */
|
|
|
932381 |
-int Selall = 1; /* all processes are selected (default) */
|
|
|
932381 |
+int SelAll = 0; /* SELALL flags, modified by IgnTasks */
|
|
|
932381 |
int Selflags = 0; /* selection flags -- see SEL* in lsof.h */
|
|
|
932381 |
+int SelProc = 0; /* SELPROC flags, modified by IgnTasks */
|
|
|
932381 |
int Setgid = 0; /* setgid state */
|
|
|
932381 |
int Selinet = 0; /* select only Internet socket files */
|
|
|
932381 |
int Setuidroot = 0; /* setuid-root state */
|
|
|
932381 |
diff -up ./dialects/linux/dproc.c.ori ./dialects/linux/dproc.c
|
|
|
932381 |
--- ./dialects/linux/dproc.c.ori 2018-02-21 14:32:56.779061847 +0100
|
|
|
932381 |
+++ ./dialects/linux/dproc.c 2018-02-21 16:10:53.896590180 +0100
|
|
|
932381 |
@@ -228,7 +228,7 @@ gather_proc_info()
|
|
|
932381 |
* If only ORed process selection options have been specified,
|
|
|
932381 |
* enable conditional file skipping and socket file only checking.
|
|
|
932381 |
*/
|
|
|
932381 |
- if ((Selflags & SELFILE) || !(Selflags & SELPROC))
|
|
|
932381 |
+ if ((Selflags & SELFILE) || !(Selflags & SelProc))
|
|
|
932381 |
Cckreg = Ckscko = 0;
|
|
|
932381 |
else
|
|
|
932381 |
Cckreg = Ckscko = 1;
|