Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
lsof
lsof_4.84-ignore_tasks.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File lsof_4.84-ignore_tasks.patch of Package lsof
Index: lsof_4.84_src/usage.c =================================================================== --- lsof_4.84_src.orig/usage.c +++ lsof_4.84_src/usage.c @@ -530,7 +530,8 @@ usage(xv, fh, version) col = print_in_col(col, buf); #if defined(HASTASKS) - col = print_in_col(col, "-K list tasKs"); +/* 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"); Index: lsof_4.84_src/store.c =================================================================== --- lsof_4.84_src.orig/store.c +++ lsof_4.84_src/store.c @@ -43,6 +43,8 @@ static char *rcsid = "$Id: store.c,v 1.3 * Global storage definitions */ +int AllProc = 1; /* all processes are selected (default) */ + #if defined(HASBLKDEV) struct l_dev *BDevtp = (struct l_dev *)NULL; /* block device table pointer */ @@ -232,6 +234,7 @@ struct fieldsel FieldSel[] = { }; int Hdr = 0; /* header print status */ +int IgnTasks = 0; /* ignore tasks when non-zero */ char *InodeFmt_d = (char *) NULL; /* INODETYPE decimal printf specification */ char *InodeFmt_x = (char *) NULL; @@ -314,8 +317,9 @@ int RptTm = 0; /* repeat time -- set b struct l_dev **Sdev = (struct l_dev **)NULL; /* pointer to Devtp[] pointers, sorted * by device */ -int Selall = 1; /* all processes are selected (default) */ +int SelAll = 0; /* SELALL flags, modified by IgnTasks */ int Selflags = 0; /* selection flags -- see SEL* in lsof.h */ +int SelProc = 0; /* SELPROC flags, modified by IgnTasks */ int Setgid = 0; /* setgid state */ int Selinet = 0; /* select only Internet socket files */ int Setuidroot = 0; /* setuid-root state */ Index: lsof_4.84_src/proc.c =================================================================== --- lsof_4.84_src.orig/proc.c +++ lsof_4.84_src/proc.c @@ -498,7 +498,7 @@ examine_lproc() * o listing is selected by an ANDed option set (not all options) * that includes a single PID selection -- this one. */ - if ((Lp->sf & SELPID) && !Selall) { + if ((Lp->sf & SELPID) && !AllProc) { if ((Selflags == SELPID) || (Fand && (Selflags & SELPID))) { sbp = 1; @@ -648,7 +648,7 @@ is_file_sel(lp, lf) } #endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */ - if (Selall) + if (AllProc) return(1); if (Fand && ((lf->sf & Selflags) != Selflags)) return(0); @@ -742,13 +742,13 @@ is_proc_excl(pid, pgid, uid, pss, sf) * network selections from the file flags, so that the tests in is_file_sel() * work as expected. */ - if (Selall) { + if (AllProc) { *pss = PS_PRI; #if defined(HASSECURITY) && defined(HASNOSOCKSECURITY) - *sf = SELALL & ~(SELNA | SELNET); + *sf = SelAll & ~(SELNA | SELNET); #else /* !defined(HASSECURITY) || !defined(HASNOSOCKSECURITY) */ - *sf = SELALL; + *sf = SelAll; #endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */ return(0); Index: lsof_4.84_src/main.c =================================================================== --- lsof_4.84_src.orig/main.c +++ lsof_4.84_src/main.c @@ -175,7 +175,7 @@ main(argc, argv) #endif /* defined(HASKOPT) */ #if defined(HASTASKS) - "K", + "K:", #else /* !defined(HASTASKS) */ "", #endif /* defined(HASTASKS) */ @@ -556,10 +556,27 @@ main(argc, argv) #endif /* defined(HASKOPT) */ #if defined(HASTASKS) - case 'K': + case 'K': + if (!GOv || *GOv == '-' || *GOv == '+') { Ftask = 1; + IgnTasks = 0; Selflags |= SELTASK; - break; + if (GOv) { + GOx1 = GObk[0]; + GOx2 = GObk[1]; + } + } else { + if (!strcasecmp(GOv, "i")) { + Ftask = 0; + IgnTasks = 1; + Selflags &= ~SELTASK; + } else { + (void) fprintf(stderr, + "%s: -K not followed by i (but by %s)\n", Pn, GOv); + err = 1; + } + } + break; #endif /* defined(HASTASKS) */ case 'l': @@ -943,6 +960,12 @@ main(argc, argv) err = 1; } } + +/* + * If IgnTasks is set, remove SELTASK from SelAll and SelProc. + */ + SelAll = IgnTasks ? (SELALL & ~SELTASK) : SELALL; + SelProc = IgnTasks ? (SELPROC & ~SELTASK) : SELPROC; /* * Check for argument consistency. */ @@ -1092,12 +1115,12 @@ main(argc, argv) "%s: no select options to AND via -a\n", Pn); usage(1, 0, 0); } - Selflags = SELALL; + Selflags = SelAll; } else { if (GOx1 >= argc && (Selflags & (SELNA|SELNET)) != 0 && (Selflags & ~(SELNA|SELNET)) == 0) Selinet = 1; - Selall = 0; + AllProc = 0; } /* * Get the device for DEVDEV_PATH. Index: lsof_4.84_src/lsof.h =================================================================== --- lsof_4.84_src.orig/lsof.h +++ lsof_4.84_src/lsof.h @@ -489,6 +489,8 @@ struct afsnode { /* AFS pseudo-node st }; # endif /* defined(HAS_AFS) */ +extern int AllProc; + # if defined(HAS_STD_CLONE) struct clone { int dx; /* index of device entry in Devtp[] */ @@ -655,6 +657,7 @@ extern struct fieldsel FieldSel[]; extern int Hdr; enum IDType {PGID, PID}; +extern int IgnTasks; extern char *InodeFmt_d; extern char *InodeFmt_x; @@ -920,8 +923,9 @@ extern int Procsrch; extern int PrPass; extern int RptTm; extern struct l_dev **Sdev; -extern int Selall; +extern int SelAll; extern int Selflags; +extern int SelProc; extern int Setgid; extern int Selinet; extern int Setuidroot; Index: lsof_4.84_src/lsof.8 =================================================================== --- lsof_4.84_src.orig/lsof.8 +++ lsof_4.84_src/lsof.8 @@ -6,7 +6,7 @@ lsof \- list open files .SH SYNOPSIS .B lsof [ -.B \-?abChKlnNOPRtUvVX +.B \-?abChlnNOPRtUvVX ] [ .BI -A " A" ] [ @@ -28,6 +28,8 @@ lsof \- list open files ] [ .BI \-k " k" ] [ +.BI \-K " k" +] [ .BI +|\-L " [l]" ] [ .BI +|\-m " m" @@ -914,7 +916,7 @@ Here are some sample addresses: :time \- either TCP, UDP or UDPLITE time service port .fi .TP \w'names'u+4 -.B \-K +.B \-K " k" This option selects the listing of tasks of processes, on dialects where task reporting is supported. (If help output \- i.e., the output of the @@ -924,6 +926,15 @@ or options \- shows this option, then task reporting is supported by the dialect.) .IP +If +.B \-K +is followed by a value, +.IR k , +it must be ``i''. That causes +.I lsof +to ignore tasks, particularly in the default, list\-everything case +when no other options are specified. +.IP When .B \-K and Index: lsof_4.84_src/dialects/hpux/pstat/dproc.c =================================================================== --- lsof_4.84_src.orig/dialects/hpux/pstat/dproc.c +++ lsof_4.84_src/dialects/hpux/pstat/dproc.c @@ -212,7 +212,7 @@ gather_proc_info() * If only ORed process selection options have been specified, * enable conditional file skipping and socket file only checking. */ - if ((Selflags & SELFILE) || !(Selflags & SELPROC)) + if ((Selflags & SELFILE) || !(Selflags & SelProc)) cckreg = ckscko = 0; else cckreg = ckscko = 1; @@ -247,7 +247,7 @@ gather_proc_info() * socket file only checking, based on the process' selection * status. */ - ckscko = (sf & SELPROC) ? 0 : 1; + ckscko = (sf & SelProc) ? 0 : 1; } alloc_lproc((int)p->pst_pid, (int)p->pst_pgrp, (int)p->pst_ppid, (UID_ARG)p->pst_uid, p->pst_ucomm, (int)pss, (int)sf); Index: lsof_4.84_src/dialects/linux/dproc.c =================================================================== --- lsof_4.84_src.orig/dialects/linux/dproc.c +++ lsof_4.84_src/dialects/linux/dproc.c @@ -226,7 +226,7 @@ gather_proc_info() * If only ORed process selection options have been specified, * enable conditional file skipping and socket file only checking. */ - if ((Selflags & SELFILE) || !(Selflags & SELPROC)) + if ((Selflags & SELFILE) || !(Selflags & SelProc)) Cckreg = Ckscko = 0; else Cckreg = Ckscko = 1; @@ -281,7 +281,7 @@ gather_proc_info() * If task reporting is selected, check the tasks of the process first, * so that the "-p<PID> -aK" options work properly. */ - if ((Selflags & SELTASK)) { + if (!IgnTasks && (Selflags & SELTASK)) { (void) make_proc_path(pidpath, n, &taskpath, &taskpathl, "task"); tx = n + 4; @@ -349,14 +349,15 @@ gather_proc_info() /* * If the main process is a task and task selection has been specified * along with option ANDing, enter the main process temporarily as a - * task, so that the "-aK" option set lists the main process along + * task, so that the "-aK" option set lists the main process along * with its tasks. */ + (void) make_proc_path(pidpath, n, &path, &pathl, "stat"); if (((rv = read_id_stat(0, path, pid, &cmd, &ppid, &pgid)) >= 0) && (rv != 1)) { - tid = (Fand && ht && pidts && (Selflags & SELTASK)) ? pid : 0; + tid = (Fand && ht && pidts && !IgnTasks && (Selflags & SELTASK)) ? pid : 0; if ((!process_id(pidpath, n, cmd, uid, pid, ppid, pgid, tid)) && tid) { @@ -734,7 +735,7 @@ process_id(idp, idpl, cmd, uid, pid, ppi * socket file only checking, based on the process' selection * status. */ - Ckscko = (sf & SELPROC) ? 0 : 1; + Ckscko = (sf & SelProc) ? 0 : 1; } alloc_lproc(pid, pgid, ppid, uid, cmd, (int)pss, (int)sf); Lp->tid = tid; Index: lsof_4.84_src/dialects/freebsd/dproc.c =================================================================== --- lsof_4.84_src.orig/dialects/freebsd/dproc.c +++ lsof_4.84_src/dialects/freebsd/dproc.c @@ -177,7 +177,7 @@ gather_proc_info() * If only ORed process selection options have been specified, * enable conditional file skipping and socket file only checking. */ - if ((Selflags & SELFILE) || !(Selflags & SELPROC)) + if ((Selflags & SELFILE) || !(Selflags & SelProc)) cckreg = ckscko = 0; else cckreg = ckscko = 1; @@ -283,7 +283,7 @@ gather_proc_info() * socket file only checking, based on the process' selection * status. */ - ckscko = (sf & SELPROC) ? 0 : 1; + ckscko = (sf & SelProc) ? 0 : 1; } alloc_lproc(p->P_PID, pgid, ppid, (UID_ARG)uid, p->P_COMM, (int)pss, (int)sf); Index: lsof_4.84_src/dialects/darwin/libproc/dproc.c =================================================================== --- lsof_4.84_src.orig/dialects/darwin/libproc/dproc.c +++ lsof_4.84_src/dialects/darwin/libproc/dproc.c @@ -210,7 +210,7 @@ gather_proc_info() * If only ORed process selection options have been specified, * enable conditional file skipping and socket file only checking. */ - if ((Selflags & SELFILE) || !(Selflags & SELPROC)) + if ((Selflags & SELFILE) || !(Selflags & SelProc)) cckreg = ckscko = 0; else cckreg = ckscko = 1; @@ -327,7 +327,7 @@ gather_proc_info() * socket file only checking, based on the process' selection * status. */ - ckscko = (sf & SELPROC) ? 0 : 1; + ckscko = (sf & SelProc) ? 0 : 1; } /* * Get root and current directory information. Index: lsof_4.84_src/dialects/aix/dproc.c =================================================================== --- lsof_4.84_src.orig/dialects/aix/dproc.c +++ lsof_4.84_src/dialects/aix/dproc.c @@ -409,7 +409,7 @@ gather_proc_info() * If only ORed process selection options have been specified, * enable conditional file skipping and socket file only checking. */ - if ((Selflags & SELFILE) || !(Selflags & SELPROC)) + if ((Selflags & SELFILE) || !(Selflags & SelProc)) cckreg = ckscko = 0; else cckreg = ckscko = 1; @@ -537,7 +537,7 @@ gather_proc_info() * socket file only checking, based on the process' selection * status. */ - ckscko = (sf & SELPROC) ? 0 : 1; + ckscko = (sf & SelProc) ? 0 : 1; } #else /* AIXV>=4300 */ @@ -557,7 +557,7 @@ gather_proc_info() * socket file only checking, based on the process' selection * status. */ - ckscko = (sf & SELPROC) ? 0 : 1; + ckscko = (sf & SelProc) ? 0 : 1; } if (!fds) { if (!(fds = (struct FDSINFO *)malloc((MALLOC_S)FDSINFOSIZE)))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor