summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2021-12-28 10:01:55 +0900
committerJinWang An <jinwang.an@samsung.com>2021-12-28 10:01:55 +0900
commit251aa3b4092071250ad7d50333b8846f5e34a997 (patch)
treed4f14f2c27eb25c245e786d856aaac0ff5749b0b
parent87a741891d5e52c324ed5d956c04eab8d2714ad8 (diff)
downloadlsof-251aa3b4092071250ad7d50333b8846f5e34a997.tar.gz
lsof-251aa3b4092071250ad7d50333b8846f5e34a997.tar.bz2
lsof-251aa3b4092071250ad7d50333b8846f5e34a997.zip
Imported Upstream version 4.90upstream/4.90
-rw-r--r--00CREDITS8
-rw-r--r--00DCACHE4
-rw-r--r--00DIALECTS2
-rw-r--r--00DIST104
-rw-r--r--00LSOF-L18
-rw-r--r--00PORTING27
-rw-r--r--00README7
-rw-r--r--00TEST8
-rwxr-xr-xConfigure80
-rw-r--r--dialects/aix/dproc.c8
-rw-r--r--dialects/darwin/libproc/Makefile2
-rw-r--r--dialects/darwin/libproc/dfile.c8
-rw-r--r--dialects/darwin/libproc/dproc.c6
-rw-r--r--dialects/darwin/libproc/dstore.c2
-rw-r--r--dialects/darwin/libproc/machine.h2
-rw-r--r--dialects/freebsd/dlsof.h17
-rw-r--r--dialects/freebsd/dmnt.c6
-rw-r--r--dialects/freebsd/dnode.c169
-rw-r--r--dialects/freebsd/dnode1.c32
-rw-r--r--dialects/freebsd/dnode2.c3
-rw-r--r--dialects/freebsd/dproc.c17
-rw-r--r--dialects/freebsd/dproto.h10
-rw-r--r--dialects/freebsd/dsock.c60
-rw-r--r--dialects/freebsd/dstore.c11
-rw-r--r--dialects/freebsd/machine.h13
-rw-r--r--dialects/hpux/pstat/dproc.c4
-rw-r--r--dialects/linux/dmnt.c4
-rw-r--r--dialects/linux/dnode.c194
-rw-r--r--dialects/linux/dproc.c161
-rw-r--r--dialects/linux/dsock.c27
-rw-r--r--dialects/sun/machine.h14
-rw-r--r--lib/ckkv.c2
-rw-r--r--lib/prfp.c27
-rw-r--r--lsof.868
-rw-r--r--lsof.h38
-rw-r--r--lsof.man1338
-rw-r--r--lsof_fields.h38
-rw-r--r--main.c138
-rw-r--r--misc.c34
-rw-r--r--print.c46
-rw-r--r--proc.c171
-rw-r--r--proto.h14
-rw-r--r--store.c49
-rw-r--r--tests/LTlib.c15
-rw-r--r--tests/LsofTest.h8
-rw-r--r--tests/TestDB5
-rw-r--r--usage.c5
-rw-r--r--version2
48 files changed, 2109 insertions, 917 deletions
diff --git a/00CREDITS b/00CREDITS
index ca9194e..9f6205c 100644
--- a/00CREDITS
+++ b/00CREDITS
@@ -93,6 +93,7 @@ provided test systems where I was able to do development work.
Yves Christophe
Richard Chycoski
A. Channing Clark
+ Jorn Clausen
Axel Clauberg
John Clear
David Clissold
@@ -125,6 +126,7 @@ provided test systems where I was able to do development work.
Casper Dik
John DiMarco
Don Draper
+ Bryan Drewery
Michel Dubois
Eric Dumazet
Dick Dunbar
@@ -179,6 +181,7 @@ provided test systems where I was able to do development work.
Chaskiel Grundman
Armin Gruner
David Gutierrez
+ Mateusz Guzik
Robert Hall
Garner Halloran
Adam Hammer
@@ -334,6 +337,7 @@ provided test systems where I was able to do development work.
Andrew Merril
Richard van Meurs
Jim Mewes
+ Conrad Meyer
Gary Millen
Timothy Miller
Davin Milun
@@ -438,6 +442,7 @@ provided test systems where I was able to do development work.
Gerry Singleton
Leonard Sitongia
Kevin Smallwood
+ Gleb Smirnoff
Curt Smith
Ben Smithurst
Douglas R. Smith
@@ -456,6 +461,7 @@ provided test systems where I was able to do development work.
Diana Stockdale
Andreas Stolcke
Jeff Stoner
+ Kristna Streitov
Sushila Subramanian
Jan Ole Suhr
Mike Sullivan
@@ -537,4 +543,4 @@ and I apologize for the error.
Vic Abell <abe@purdue.edu>
-July 7, 2015
+February 14, 2018
diff --git a/00DCACHE b/00DCACHE
index 4382376..b1efa26 100644
--- a/00DCACHE
+++ b/00DCACHE
@@ -727,7 +727,7 @@ machine.h header files.
AIX 5.[12] and 5.3-ML1
FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems
- FreeBSD 5.x, [6789].x and 10 for Alpha, AMD64 and Sparc64-a
+ FreeBSD 5.x, [6789].x and 1[012].x for Alpha, AMD64 and Sparc64
based systems
HP-UX 11.00
NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based
@@ -742,4 +742,4 @@ machine.h header files.
Vic Abell <abe@purdue.edu>
-October 13, 2014
+February 14, 2018
diff --git a/00DIALECTS b/00DIALECTS
index 33364be..2c01779 100644
--- a/00DIALECTS
+++ b/00DIALECTS
@@ -1,4 +1,4 @@
Apple Darwin 9 and Mac OS X 10.[567]
- FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems
+ FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
Linux 2.1.72 and above for x86-based systems
Solaris 9, 10 and 11
diff --git a/00DIST b/00DIST
index bb66615..9c5f0b2 100644
--- a/00DIST
+++ b/00DIST
@@ -118,6 +118,7 @@
4.87, January 2, 2013
4.88, October 13, 2014
4.89, July 7, 2015
+ 4.90, February 14, 2018
Dialects Supported
@@ -129,9 +130,8 @@ version 3, itself a major revision of version 2. Version 4 has
been tested on:
Apple Darwin 9 and Mac OS X 10.[567]
- FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems
- Linux 2.1.72 and above for x86-based systems
- Solaris 9, 10 and 11
+ FreeBSD 10.3, 11.0 and 12.0 for AMD64-based systems
+ Solaris 9
(The pub/tools/unix/lsof/contrib directory on lsof.itap.purdue.edu
contains information on other ports.)
@@ -3693,7 +3693,7 @@ Supplement Regenerated the 4.04 distribution to correct a non-
5.2-CURRENT. Refined it for 5.2.1-RELEASE with testing
help from Scott Ellentuch <tuc@ttsg.com>.
- Added support for FreeBSD 4.10. Larry Rosenmann
+ Added support for FreeBSD 4.10. Larry Rosenman
<ler@lerctr.org> kindly provided a test system.
Added support for NetBSD 2.0 with patches supplied by
@@ -4777,6 +4777,100 @@ Supplement Regenerated the 4.04 distribution to correct a non-
visible to lsof on FreeBSD 11 after a system header file change
hid them.
+4.90 February 14, 2018
+
+ !!!NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ ! !
+ ! It is likely that this is the last lsof revision I !
+ ! will issue, unless serious bugs are detected, Stay !
+ ! tuned to lsof-l for information about future support !
+ ! of lsof. !
+ ! !
+ ! I thank all the many contributors to lsof over the !
+ ! many years (20+?) I have been distributing lsof !
+ ! versions 1, 2, 3 and 4. !
+ ! !
+ ! Vic Abell <abe@purdue.edu> !
+ ! !
+ !!!NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ Taught the Configure script to create a dummy opt_random.h
+ for FreeBSD systems whose <sys/random.h> includes it.
+
+ Added support for the FreeBSD ZFUSE file system.
+
+ Corrected the quoting in a Darwin putchar() statement in the
+ dfile.c source file. Andrew Janke <floss@apjanke.net> reported
+ my error.
+
+ Added support for the FreeBSD DTYPE_PTS file descriptor and
+ for unknown descriptors that reference the kernel's badfileops
+ operation switch. Enabled FreeBSD 12.0 support. Tested the
+ changes on systems provided by Larry Rosenman <ler@lerctr.org>.
+
+ Enhanced -K option with the form "-K i" to direct lsof to
+ (i)gnore tasks. A query from Rachel Kroll <rkroll@fb.com>
+ suggested this option. Linux task reports now include both
+ process and task command names, making lsof's "-c <name>"
+ option work correctly.
+
+ Added a patch to prevent NFS blocking in Linux supplied by
+ Kristna Streitov <kstreitova@suse.com>.
+
+ Installed a FreeBSD patch that prevents examining a TCP state
+ structure during a race condition. The patch was supplied by
+ Bryan Drewery <bdrewery@FreeBSD.org>.
+
+ Updated FreeBSD for new UFS inode structure that lacks an i_dev
+ member in the most recent 12.0-CURRENT. Larry Rosenman
+ <ler@lerctr.org> reported the problem and provided a test
+ system.
+
+ Added "#define KLD_MODULE" to dlsof.h and dnode2.c to prevent
+ <machine/cpuconf.h> from generating an "ARM_NARCH is 0" error.
+ This is needed so lsof can access kernel structures. Larry
+ Rosenman supplied the addition.
+
+ Added recognition of the FreeBSD 11 file system name "nullfs".
+ Jamie Landeg-Jones <jamie@catflap.org> supplied the fix.
+
+ Added a patch from Larry Rosenman <ler@lerctr.org> that is
+ needed on FreeBSD 12 so the lsof compilation can obtain the
+ inpcb and tcpcb structures from their respective header files.
+
+ Updated FreeBSD dmnt.c for the ino64 changes.
+
+ Inserted a patch for Solaris 12.x to avoid compilation errors
+ from <sys/aio_req.h>, based on information provided by Jorn
+ Clausen <joern.clausen@uni-bielefeld.de>. Jorn tested the
+ patch.
+
+ Added performance enhancement that uses the FreeBSD closefrom()
+ and dup2() C library functions when available. The enhancement
+ was supplied by Conrad Meyer <cem@freebsd.org>.
+
+ Corrected FreeBSD lsof's gathering of ZFS file device numbers.
+ Updated lsof test library for FreeBSD.
+
+ Updated socket optons information collection from the socket
+ structure per changes supplied by Gleb Smirnoff
+ <glebius@FreeBSD.org>.
+
+ Added patch to dlsof.h that avoids a _KERNEL conflict with
+ bzero. Mateusz Guzik <mjguzik@gmail.com> supplied the patch.
+
+ Corrected test library to handle 64 bit FreeBSD device numbers.
+
+ Added #defines for FreeBSD 12, src r324225, from Gleb Smirnoff
+ <glebius@FreeBSD.org>.
+
+ Incorporated Linux pseudoterminal endpoint processing (+|-E)
+ provided by Masatake YAMATO <yamato@redhat.com> with access to
+ test systems provided by Peter Schiffer <pschiffe@redhat.com>.
+
+ Corrected Linux command extraction for commands that include
+ parentheses -- e.g., "(sd-pam)".
+
Vic Abell <abe@purdue.edu>
-July 7, 2015
+February 14, 2018
diff --git a/00LSOF-L b/00LSOF-L
index 7a58df6..96147bd 100644
--- a/00LSOF-L
+++ b/00LSOF-L
@@ -2,7 +2,7 @@
The Lsof Mailing List, lsof-l
Information on lsof is available via a GNU Mailman mailing list, named
-lsof-l. The server is located on the host rcac.purdue.edu.
+lsof-l. The server is located on the host lists.purdue.edu.
Subscribing
@@ -10,7 +10,7 @@ Subscribing
You may subscribe to the lsof-l mailing list by sending e-mail to:
- lsof-l-subscribe@rcac.purdue.edu
+ lsof-l-subscribe@lists.purdue.edu
The body of your e-mail may be empty. You will receive a confirmation
reply, explaining one further step you must take to complete your
@@ -27,8 +27,8 @@ information.)
Get Help
========
-More information about the rcac.purdue.edu GNU Mailman server is
-available by sending e-mail to lsof-l-request@rcac.purdue.edu with
+More information about the lists.purdue.edu GNU Mailman server is
+available by sending e-mail to lsof-l-request@lists.purdue.edu with
"help" in the subject line. The body of your e-mail may be empty.
The other information will be delivered by return e-mail.
@@ -44,7 +44,7 @@ The Web Interface
There is a web interface at:
- https://lists.rcac.purdue.edu/listinfo/lsof-l
+ https://lists.purdue.edu/mailman/listinfo/lsof-l
You can use it to manage your lsof-l list entry.
@@ -56,7 +56,7 @@ Once you have subscribed to lsof-l (and have an e-mail confirmation
that your subscription was accepted), you may post messages to the list
by sending e-mail directly to:
- lsof-l@rcac.purdue.edu
+ lsof-l@lists.purdue.edu
I moderate the lsof-l mailing list and try to keep its traffic low,
mainly limiting it to announcements of new revisions, patches and
@@ -77,7 +77,7 @@ Unsubscribing
You can unsubscribe from lsof-l by sending e-mail to:
- lsof-l-unsubscribe@rcac.purdue.edu
+ lsof-l-unsubscribe@lists.purdue.edu
The body of your e-mail may be empty. You will receive a confirmation
reply, explaining one further step you must take to complete the
@@ -89,7 +89,7 @@ Archive
There is an archive; use the link:
- https://lists.rcac.purdue.edu/listinfo/lsof-l
+ https://lists.purdue.edu/mailman/private/lsof-l
The archive link is the first one on the web page. You will need the
password you received or set when you subscribed, or later set via
@@ -97,4 +97,4 @@ lsof-l-request or the web interface.
Vic Abell <abe@purdue.edu>
-May 8, 2008
+September 16, 2015
diff --git a/00PORTING b/00PORTING
index a175d6c..8708e50 100644
--- a/00PORTING
+++ b/00PORTING
@@ -398,9 +398,9 @@ to be compiled and archived to liblsof.a.
USE_LIB_PROCESS_FILE selects it.
FILEPTR, DTYPE_PIPE, HASPIPEFN, DTYPE_GNODE,
- DTYPE_INODE, DTYPE_PORT, DTYPE_VNODE,
+ DTYPE_INODE, DTYPE_PORT, DTYPE_VNODE, DTYPE_PTS,
HASF_VNODE, HASKQUEUE, HASPRIVFILETYPE,
- HASPSXSHM and HASPSXSEM customize it.
+ HASPSXSHM, HASPSXSEM and HASPTSFN customize it.
ptti.c print_tcptpi() function
@@ -700,6 +700,9 @@ possibilities
HAS_AFS enables AFS support code for the dialect.
+ HAS_AIO_REQ_STRUCT is defined for Solaris 10 and above systems that
+ have the aio_req structure definition.
+
HAS_ATOMIC_T indicates the Linux version has an
<asm/atomic.h> header file and it contains
"typedef struct .* atomic_t;"
@@ -726,6 +729,9 @@ possibilities
HASCDRNODE enables/disables readcdrnode() in node.c.
+ HAS_CLOSEFROM is defined when the FreeBSD C library contains the
+ closefrom() function.
+
HAS_CONN_NEW indicates the Solaris version has the new form
of the conn_s structure, introduced in b134 of
Solaris 11. This will always accompany the
@@ -765,6 +771,9 @@ possibilities
<sys/dnlc.h> has a name character pointer
rather than a name character array.
+ HAS_DUP2 is defined when the FreeBSD C library contains the
+ dup2() function.
+
HASEFFNLINK indicates the *BSD system has the i_effnlink
member in the inode structure.
@@ -839,6 +848,9 @@ possibilities
See also the RMNT_EXPDEV and RMNT_FSTYPE
documentation in lib/rmnt.c
+ HASFUSEFS is defined when the FreeBSD system has FUSE file system
+ support.
+
HASGETBOOTFILE indicates the NetBSD or OpenBSD dialect has
a getbootfile() function.
@@ -1011,6 +1023,9 @@ possibilities
HAS_NO_6PPCB is defined if the FreeBSD in_pcb.h has no in6p_ppcb
definition.
+ HAS_NO_IDEV indicates the FreeBSD system's inode has no i_dev
+ member.
+
HAS_NO_ISO_DEV indicates the FreeBSD 6 and higher system has
no i_dev member in its iso_node structure.
@@ -1156,6 +1171,12 @@ possibilities
HASPSXSHM indicates the dialect has support for the POSIX
shared memory file type.
+ HASPTSFN indicates the dialect has a DNODE_PTS file descriptor
+ type and defines the function that processes it.
+
+ HASPTYEPT indicates the Linux dialect has support for the
+ pseudoterminal endpoint option.
+
HASPTYFS indicates the *BSD dialect has a ptyfs file system.
HASRNODE enables/disables readrnode() in node.c.
@@ -1863,4 +1884,4 @@ keep in mind the private, one-man nature of current lsof support.
Vic Abell <abe@purdue.edu>
-July 7, 2015
+February 14, 2018
diff --git a/00README b/00README
index 5d0c388..075c764 100644
--- a/00README
+++ b/00README
@@ -1017,7 +1017,7 @@ test systems.
The FreeBSD distribution header files are augmented by header files
in the dialects/freebsd/include directory.
-David O'Brien maintains the lsof FreeBSD port package.
+Larry Rosenman maintains the lsof FreeBSD port package.
HP-UX
@@ -1456,8 +1456,7 @@ grant read permission to the kernel memory devices.
AIX 4.1.[45], 4.2[.1], and 4.3[.123]
Apple Darwin 7.x for Power Macintosh systems
DEC OSF/1, Digital UNIX, Tru64 UNIX 2.0, 3.2, 4.0, and 5.[01]
- FreeBSD 2.1.6, 2.2[.x], 3.x, 4.x, 5.x and [67].x
- /dev/kmem-based 11.00
+ FreeBSD 2.1.6, 2.2[.x], 3.x, 4.x, 5.x, [6789].x and 1[012].x
NetBSD 1.[456], 2.x and 3.x
NEXTSTEP 3.[13]
OpenBSD 2.[89] and 3.[0-9]
@@ -1523,4 +1522,4 @@ you are trying to configure.
Vic Abell <abe@purdue.edu>
-January 2, 2013
+February 14, 2018
diff --git a/00TEST b/00TEST
index 54f8d22..c465da8 100644
--- a/00TEST
+++ b/00TEST
@@ -363,6 +363,10 @@ The config.cflags file may contain the following C compiler flags.
-DLT_CC is present if the lsof compiler is cc.
+ -DLT_DEV64 is present if the FreeBSD dialect uses a 64
+ devite type.
+
+
-DLT_DIAL_<abbr> always ends in (the <abbr> part) the
"canonical" -- i.e., usually the most
common abbreviation by which the dialect
@@ -908,6 +912,7 @@ base, footprints, and the scripts that support them.
10.0 Amd64, gcc
10.0 Amd64, clang
11.0 Amd64, clang
+ 12.0 Amd64, clang
DEC OSF/1 4.0, cc
HP-UX 10.20, cc LTbigf
10.20, gcc (1) LTbigf
@@ -950,6 +955,7 @@ base, footprints, and the scripts that support them.
2.6.38-686
3.10.004
3.10.08
+ 4.14.14
3.10.0-229.1.2.el7
NEXTSTEP 3.1, gcc LTnfs
NetBSD 1.4.1, Alpha, gcc LTnfs
@@ -1029,4 +1035,4 @@ I was unable to make the test suite run on the following dialects.
Vic Abell <abe@purdue.edu>
-May 11, 2015
+February 14, 2018
diff --git a/Configure b/Configure
index e4a25a2..f3dc281 100755
--- a/Configure
+++ b/Configure
@@ -14,7 +14,7 @@
# shell script, named $LSOF_MK, that places its source modules in this
# directory.
#
-# $Id: Configure,v 1.164 2015/07/07 20:16:58 abe Exp $
+# $Id: Configure,v 1.165 2018/02/14 14:18:48 abe Exp $
# LSOF_CFLAGS_OVERRIDE=1 may be introduced through the environment to cause
# the library Makefile's CFLAGS definition to override any in the
@@ -293,8 +293,8 @@ do
echo "rm -rf AFSHeaders AFSVersion solaris11 version.h vnode_if.h"
rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h
echo "rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h"
- rm -f opt_kdtrace.h
- echo "rm -f opt_kdtrace.h"
+ rm -f opt_kdtrace.h opt_random.h
+ echo "rm -f opt_kdtrace.h opt_random.h"
rm -f dialects/aix/aix5/j2/j2_snapshot.h
echo "rm -f dialects/aix/aix5/j2/j2_snapshot.h"
rm -f dialects/sun/solaris10 # DEBUG -- for s10_44
@@ -1620,6 +1620,10 @@ kernel generation process.
LSOF_TSTBIGF=" "
LSOF_VERS=11000
;;
+ 12*)
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=12000
+ ;;
*)
echo Unknown FreeBSD release: `uname -r`
rm -f $LSOF_HLP
@@ -1631,7 +1635,7 @@ kernel generation process.
# Clear LSOF_UNSUP message for supported versions of FreeBSD.
case $LSOF_VERS in # {
- 4090|8020|8030|8040|9000|10000|11000)
+ 4090|8020|8030|8040|9000|10000|11000|12000)
LSOF_UNSUP=""
;;
esac # }
@@ -1707,6 +1711,22 @@ kernel generation process.
fi # }
fi # }
+ # Check the C library for closefrom and dup2.
+
+ if test -r /usr/lib/libc.a # {
+ then
+ nm /usr/lib/libc.a | grep -q "W dup2"
+ if test $? -eq 0 # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHAS_DUP2"
+ fi # }
+ nm /usr/lib/libc.a | grep -q "W closefrom"
+ if test $? -eq 0 # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHAS_CLOSEFROM"
+ fi # }
+ fi # }
+
# Do FreeBSD version-specific stuff.
case $LSOF_VERS in # {
@@ -1886,6 +1906,19 @@ cpumask_t c;
# Do FreeBSD 6.0 and higher version-specific stuff.
+ if test -r ${LSOF_INCLUDE}/sys/_types.h # {
+ then
+ grep __dev_t ${LSOF_INCLUDE}/sys/_types.h | grep -q 64
+ if test $? -eq 0 # {
+ then
+ if test "X$LSOF_TSTDFLG" = "X" # {
+ then
+ LSOF_TSTDFLG="-DLT_DEV64"
+ else
+ LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_DEV64"
+ fi # }
+ fi # }
+ fi # }
if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h # {
then
grep -q i_din2 ${LSOF_INCLUDE}/ufs/ufs/inode.h
@@ -1893,6 +1926,11 @@ cpumask_t c;
then
LSOF_CFGF="$LSOF_CFGF -DHAS_UFS1_2"
fi # }
+ grep -q i_dev ${LSOF_INCLUDE}/ufs/ufs/inode.h
+ if test $? -ne 0 # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHAS_NO_IDEV"
+ fi # }
fi # }
if test -r ${LSOF_INCLUDE}/sys/conf.h # {
then
@@ -1958,6 +1996,12 @@ FBSD_MINOR3
LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_SX_H"
fi # }
+ # Do FUSE file system test,
+
+ if test -r ${FREEBSD_SYS}/fs/fuse/fuse_node.h # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHASFUSEFS"
+ fi # }
# Do ZFS test. Try for the newer OpenSolaris files first -- i.e.,
# the ones in ${FREEBSD_SYS}/cddl/contrib/opensolaris. If that fails,
# try for the older ones in ${FREEBSD}/contrib/opensolaris.
@@ -1999,6 +2043,15 @@ FBSD_MINOR3
LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_CV_TIMEDWAIT_SBT"
fi # }
fi #}
+ if test -r /usr/include/sys/random.h # {
+ then
+ grep -q opt_random.h /usr/include/sys/random.h
+ if test $? -eq 0 # {
+ then
+ rm -f opt_random.h
+ touch opt_random.h
+ fi # }
+ fi # }
fi # }
if test -r ${LSOF_INCLUDE}/sys/vnode.h # {
then
@@ -2935,6 +2988,17 @@ return(0); }
then
LSOF_CFGF="$LSOF_CFGF -DHASUXSOCKEPT"
fi # }
+
+ # Test for pseudoterminal endpoint support.
+
+ if test -r ${LSOF_INCLUDE}/linux/major.h # {
+ then
+ grep -q TTYAUX_MAJOR ${LSOF_INCLUDE}/linux/major.h
+ if test $? -eq 0 # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHASPTYEPT"
+ fi # }
+ fi # }
LSOF_DIALECT_DIR="linux"
LSOF_CFGF="$LSOF_CFGF -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
;;
@@ -4868,6 +4932,14 @@ return(0); }
LSOF_CFGF="$LSOF_CFGF -DHAS_PC_DIRENTPERSEC"
fi # }
fi # }
+ if test -r ${LSOF_INCLUDE}/sys/aio_req.h # {
+ then
+ grep "struct[ ]aio_req" ${LSOF_INCLUDE}/sys/aio_req.h > /dev/null 2>&1
+ if test $? -eq 0 # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHAS_AIO_REQ_STRUCT"
+ fi # }
+ fi # }
fi # }
if test -r ${LSOF_INCLUDE}/sys/zone.h # {
then
diff --git a/dialects/aix/dproc.c b/dialects/aix/dproc.c
index c951717..eb7fffb 100644
--- a/dialects/aix/dproc.c
+++ b/dialects/aix/dproc.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dproc.c,v 1.26 2008/10/21 16:14:18 abe Exp $";
+static char *rcsid = "$Id: dproc.c,v 1.27 2018/02/14 14:23:27 abe Exp $";
#endif
@@ -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)))
diff --git a/dialects/darwin/libproc/Makefile b/dialects/darwin/libproc/Makefile
index 6433004..a3bdc3c 100644
--- a/dialects/darwin/libproc/Makefile
+++ b/dialects/darwin/libproc/Makefile
@@ -1,7 +1,7 @@
# Darwin libproc-based lsof Makefile
#
-# $Id: Makefile,v 1.7 2009/03/25 19:21:37 abe Exp abe $
+# $Id: Makefile,v 1.8 2018/02/14 14:27:57 abe Exp $
PROG= lsof
diff --git a/dialects/darwin/libproc/dfile.c b/dialects/darwin/libproc/dfile.c
index d7705f6..6b99c66 100644
--- a/dialects/darwin/libproc/dfile.c
+++ b/dialects/darwin/libproc/dfile.c
@@ -36,12 +36,16 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 2005-2007 Apple Inc. and Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dfile.c,v 1.8 2012/04/10 16:41:04 abe Exp abe $";
+static char *rcsid = "$Id: dfile.c,v 1.9 2018/02/14 14:27:57 abe Exp $";
#endif
#include "lsof.h"
+#if defined(PROC_FP_GUARDED)
+#extern struct pff_tab Pgf_tab[];
+#endif /* defined(PROC_FP_GUARDED) */
+
/*
* enter_file_info() -- enter file information
@@ -286,7 +290,7 @@ print_nm(lf)
#if defined(PROC_FP_GUARDED)
if (extra > 1)
- putchar(`,');
+ putchar(',');
if (lf->guardflags) {
struct pff_tab *tp;
long gf;
diff --git a/dialects/darwin/libproc/dproc.c b/dialects/darwin/libproc/dproc.c
index e4a2f00..069dc2b 100644
--- a/dialects/darwin/libproc/dproc.c
+++ b/dialects/darwin/libproc/dproc.c
@@ -37,7 +37,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 2005-2007 Apple Inc. and Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dproc.c,v 1.9 2013/01/02 17:03:05 abe Exp $";
+static char *rcsid = "$Id: dproc.c,v 1.10 2018/02/14 14:27:57 abe Exp $";
#endif
#include "lsof.h"
@@ -221,7 +221,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;
@@ -338,7 +338,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.
diff --git a/dialects/darwin/libproc/dstore.c b/dialects/darwin/libproc/dstore.c
index 8727181..713070c 100644
--- a/dialects/darwin/libproc/dstore.c
+++ b/dialects/darwin/libproc/dstore.c
@@ -37,7 +37,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 2005 Apple Computer, Inc. and Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dstore.c,v 1.4 2008/10/21 16:15:16 abe Exp abe $";
+static char *rcsid = "$Id: dstore.c,v 1.5 2018/02/14 14:27:57 abe Exp $";
#endif
diff --git a/dialects/darwin/libproc/machine.h b/dialects/darwin/libproc/machine.h
index 050a49a..9918eb7 100644
--- a/dialects/darwin/libproc/machine.h
+++ b/dialects/darwin/libproc/machine.h
@@ -35,7 +35,7 @@
/*
- * $Id: machine.h,v 1.10 2013/01/02 17:03:05 abe Exp abe $
+ * $Id: machine.h,v 1.11 2018/02/14 14:27:57 abe Exp $
*/
diff --git a/dialects/freebsd/dlsof.h b/dialects/freebsd/dlsof.h
index b075e6a..bcb59bc 100644
--- a/dialects/freebsd/dlsof.h
+++ b/dialects/freebsd/dlsof.h
@@ -31,7 +31,7 @@
/*
- * $Id: dlsof.h,v 1.47 2015/07/07 20:23:43 abe Exp $
+ * $Id: dlsof.h,v 1.48 2018/02/14 14:26:03 abe Exp $
*/
@@ -87,6 +87,14 @@
#define boolean_t int
# endif /* defined(NEEDS_BOOLEAN_T) */
+/*
+ * Define KLD_MODULE to avoid the error "ARM_NMMUS is 0" from ARM's
+ * <machine/cpuconf.h>.
+ */
+
+#define KLD_MODULE
+
+
#include <sys/conf.h>
# if defined(HAS_VM_MEMATTR_T)
@@ -134,8 +142,10 @@ int getmntinfo(struct statfs **, int);
#include <rpc/types.h>
#include <sys/protosw.h>
#include <sys/socket.h>
+#define _WANT_SOCKET
#include <sys/socketvar.h>
#include <sys/un.h>
+#define _WANT_UNPCB
#include <sys/unpcb.h>
# if FREEBSDV>=3000
@@ -146,12 +156,14 @@ int getmntinfo(struct statfs **, int);
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <net/route.h>
+#define _WANT_INPCB /* for FreeBSD 12 and above */
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_timer.h>
+#define _WANT_TCPCB /* for FreeBSD 12 and above */
#include <netinet/tcp_var.h>
#include <sys/ucred.h>
#include <sys/uio.h>
@@ -476,6 +488,7 @@ struct vop_advlock_args { int dummy; }; /* to pacify lf_advlock() prototype */
# endif /* FREEBSDV<5000 */
# endif /* FREEBSDV>=2020 */
+#undef bzero /* avoid _KERNEL conflict */
#include <string.h>
@@ -561,6 +574,8 @@ struct mounts {
struct mounts *next; /* forward link */
};
+#define X_BADFILEOPS "badfileops"
+extern KA_T X_bfopsa;
#define X_NCACHE "ncache"
#define X_NCSIZE "ncsize"
#define NL_NAME n_name
diff --git a/dialects/freebsd/dmnt.c b/dialects/freebsd/dmnt.c
index b4db313..3459c7c 100644
--- a/dialects/freebsd/dmnt.c
+++ b/dialects/freebsd/dmnt.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dmnt.c,v 1.17 2013/01/02 17:01:43 abe Exp $";
+static char *rcsid = "$Id: dmnt.c,v 1.18 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -329,8 +329,8 @@ no_space_for_mount:
sb.st_mode = S_IFDIR | 0777;
if (!Fwarn) {
(void) fprintf(stderr,
- " assuming \"dev=%x\" from mount table\n",
- sb.st_dev);
+ " assuming \"dev=%lx\" from mount table\n",
+ (unsigned long)sb.st_dev);
}
}
/*
diff --git a/dialects/freebsd/dnode.c b/dialects/freebsd/dnode.c
index 84467cb..bf743df 100644
--- a/dialects/freebsd/dnode.c
+++ b/dialects/freebsd/dnode.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dnode.c,v 1.44 2015/07/07 20:23:43 abe Exp $";
+static char *rcsid = "$Id: dnode.c,v 1.45 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -52,6 +52,11 @@ _PROTOTYPE(static int lkup_dev_tty,(dev_t *dr, INODETYPE *ir));
#endif /* defined(HASFDESCFS) && HASFDESCFS==1 */
+#if defined(HASPTSFN) && defined(DTYPE_PTS)
+#include <sys/tty.h>
+#endif /* defined(HASPTSFN) && defined(DTYPE_PTS) */
+
+
#if defined(HAS_TMPFS)
#define _KERNEL
#include <fs/tmpfs/tmpfs.h>
@@ -62,7 +67,7 @@ _PROTOTYPE(static void get_lock_state,(KA_T f));
/*
- * get_lock_state() -- get the lock state
+ * get_lock_state() - get the lock state
*/
static void
@@ -232,7 +237,7 @@ lkup_dev_tty_again:
#if defined(HASKQUEUE)
/*
- * process_kqueue() -- process kqueue file
+ * process_kqueue() - process kqueue file
*
* Strictly speaking this function should appear in dfile.c, because it is
* a file processing function. However, the Net and Open BSD sources don't
@@ -272,6 +277,7 @@ process_node(va)
struct nfsnode *n;
size_t sz;
char *ty;
+ unsigned char ums;
enum vtype type;
struct vnode *v, vb;
struct l_vfs *vfs;
@@ -320,6 +326,14 @@ process_node(va)
#endif /* defined(HASFDESCFS) */
+#if defined(HASFUSEFS)
+ dev_t fuse_dev;
+ int fuse_dev_def, fuse_stat;
+ INODETYPE fuse_ino;
+ long fuse_links;
+ SZOFFTYPE fuse_sz;
+#endif /* defined(HASFUSEFS) */
+
#if FREEBSDV>=5000
# if defined(HAS_UFS1_2)
int ufst;
@@ -337,8 +351,8 @@ process_node(va)
struct devfs_dirent *d;
char vtbuf[32];
char *vtbp;
- enum vtagtype { VT_DEVFS, VT_FDESC, VT_ISOFS, VT_PSEUDOFS, VT_NFS,
- VT_NULL, VT_TMPFS, VT_UFS, VT_ZFS, VT_UNKNOWN
+ enum vtagtype { VT_DEVFS, VT_FDESC, VT_FUSEFS, VT_ISOFS, VT_PSEUDOFS,
+ VT_NFS, VT_NULL, VT_TMPFS, VT_UFS, VT_ZFS, VT_UNKNOWN
};
# if defined(HAS_TMPFS)
@@ -400,7 +414,7 @@ process_overlaid_node:
* Initialize miscellaneous variables. This is done so that processing an
* overlaid node will be a fresh start.
*/
- devs = rdevs = 0;
+ devs = rdevs = ums = 0;
i = (struct inode *)NULL;
n = (struct nfsnode *)NULL;
Namech[0] = '\0';
@@ -413,6 +427,10 @@ process_overlaid_node:
f = (struct fdescnode *)NULL;
#endif /* defined(HASFDESCFS) */
+#if defined(HASFUSEFS)
+ fuse_dev_def = fuse_stat = 0;
+#endif /* defined(HASFUSEFS) */
+
#if FREEBSDV<5000
m = (struct mfsnode *)NULL;
#else /* FREEBSDV>=5000 */
@@ -577,10 +595,14 @@ process_overlaid_node:
vtag = VT_ISOFS;
else if (!strcmp(vtbuf, "pseudofs"))
vtag = VT_PSEUDOFS;
+ else if (!strcmp(vtbuf, "nullfs"))
+ vtag = VT_NULL;
else if (!strcmp(vtbuf, "null"))
vtag = VT_NULL;
else if (!strcmp(vtbuf, "fdesc"))
vtag = VT_FDESC;
+ else if (!strcmp(vtbuf, "fuse"))
+ vtag = VT_FUSEFS;
else if (!strcmp(vtbuf, "tmpfs"))
vtag = VT_TMPFS;
} else
@@ -631,6 +653,20 @@ process_overlaid_node:
# endif /* FREEBSDV<2000 */
#endif /* defined(HASFDESCFS) */
+#if defined(HASFUSEFS)
+ case VT_FUSEFS:
+ if (read_fuse_node(v, &fuse_dev, &fuse_dev_def, &fuse_ino,
+ &fuse_links, &fuse_sz))
+ {
+ (void) snpf(Namech, Namechl, "no fuse node: %s",
+ print_kptr((KA_T)v->v_data, (char *)NULL, 0));
+ enter_nm(Namech);
+ return;
+ }
+ fuse_stat = 1;
+ break;
+#endif /* defined(HASFUSEFS) */
+
#if defined(HAS9660FS)
case VT_ISOFS:
if (read_iso_node(v, &iso_dev, &iso_dev_def, &iso_ino, &iso_links,
@@ -795,6 +831,7 @@ process_overlaid_node:
# if defined(HAS_UFS1_2)
if (i->i_ump && !kread((KA_T)i->i_ump, (char *)&um, sizeof(um))) {
+ ums = 1;
if (um.um_fstype == UFS1) {
if (i->i_din1
&& !kread((KA_T)i->i_din1, (char *)&d1, sizeof(d1)))
@@ -870,26 +907,33 @@ process_overlaid_node:
} else if (i) {
#if FREEBSDV>=4000
+# if defined(HAS_NO_IDEV)
+ if (ums) {
+ dev = Dev2Udev((KA_T)um.um_dev);
+ devs = 1;
+ }
+# else /* !defined(HAS_NO_IDEV) */
if (i->i_dev
-# if !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV)
+# if !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV)
&& !kread((KA_T)i->i_dev, (char *)&si, sizeof(si))
-# endif /* !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV) */
+# endif/* !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV) */
) {
-# if defined(HAS_NO_SI_UDEV)
-# if defined(HAS_CONF_MINOR) || defined(HAS_CDEV2PRIV)
+# if defined(HAS_NO_SI_UDEV)
+# if defined(HAS_CONF_MINOR) || defined(HAS_CDEV2PRIV)
dev = Dev2Udev((KA_T)i->i_dev);
-# else /* !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV) */
+# else /* !defined(HAS_CONF_MINOR) && !defined(HAS_CDEV2PRIV) */
dev = Dev2Udev(&si);
-# endif /* defined(HAS_CONF_MINOR) || defined(HAS_CDEV2PRIV) */
-# else /* !defined(HAS_NO_SI_UDEV) */
+# endif /* defined(HAS_CONF_MINOR) || defined(HAS_CDEV2PRIV) */
+# else /* !defined(HAS_NO_SI_UDEV) */
dev = si.si_udev;
-# endif /* defined(HAS_NO_SI_UDEV) */
+# endif /* defined(HAS_NO_SI_UDEV) */
devs = 1;
}
+# endif /* defined(HAS_NO_IDEV) */
#else /* FREEBSDV<4000 */
dev = i->i_dev;
devs = 1;
@@ -937,7 +981,14 @@ process_overlaid_node:
* Record information returned by readzfsnode().
*/
if (vfs) {
- dev = vfs->fsid.val[0];
+ union {
+ int32_t val[2];
+ dev_t dev;
+ } vfs_fsid;
+
+ vfs_fsid.val[0] = vfs->fsid.val[0];
+ vfs_fsid.val[1] = vfs->fsid.val[1];
+ dev = vfs_fsid.dev;
devs = 1;
}
if ((type == VCHR) || (type == VBLK)) {
@@ -959,7 +1010,7 @@ process_overlaid_node:
# if HASFDESCFS==1
else
-# endif /* HASFDESFS==1 */
+# endif /* HASFDESCFS==1 */
# endif /* defined(HASFDLINK) */
# if HASFDESCFS==1
@@ -972,7 +1023,7 @@ process_overlaid_node:
devs = Lf->inp_ty = 1;
}
}
-# endif /* HASFDESFS==1 */
+# endif /* HASFDESCFS==1 */
}
#endif /* defined(HASFDESCFS) && (defined(HASFDLINK) || HASFDESCFS==1) */
@@ -984,6 +1035,13 @@ process_overlaid_node:
}
#endif /* defined(HAS9660FS) */
+#if defined(HASFUSEFS)
+ else if (fuse_stat && fuse_dev_def) {
+ dev = fuse_dev;
+ devs = Lf->inp_ty = 1;
+ }
+#endif /* defined(HASFUSEFS) */
+
#if FREEBSDV>=5000
else if (d) {
if (vfs) {
@@ -1074,6 +1132,13 @@ process_overlaid_node:
}
#endif /* defined(HAS9660FS) */
+#if defined(HASFUSEFS)
+ else if (fuse_stat) {
+ Lf->inode = fuse_ino;
+ Lf->inp_ty = 1;
+ }
+#endif /* defined(HASFUSEFS) */
+
#if defined(HASPROCFS)
# if FREEBSDV>=2000
else if (p) {
@@ -1205,8 +1270,16 @@ process_overlaid_node:
Lf->sz = (SZOFFTYPE)iso_sz;
Lf->sz_def = 1;
}
+
#endif /* defined(HAS9660FS) */
+#if defined(HASFUSEFS)
+ else if (fuse_stat) {
+ Lf->sz = (SZOFFTYPE)fuse_sz;
+ Lf->sz_def = 1;
+ }
+#endif /* defined(HASFUSEFS) */
+
}
else if ((type == VCHR || type == VBLK) && !Fsize)
Lf->off_def = 1;
@@ -1265,6 +1338,13 @@ process_overlaid_node:
}
#endif /* defined(HAS9660FS) */
+#if defined(HASFUSEFS)
+ else if (fuse_stat) {
+ Lf->nlink = fuse_links;
+ Lf->nlink_def = 1;
+ }
+#endif /* defined(HASFUSEFS) */
+
#if FREEBSDV>=5000
else if (d) {
Lf->nlink = d->de_links;
@@ -1577,3 +1657,58 @@ process_pipe(pa)
enter_nm(Namech);
}
#endif /* FREEBSDV>=2020 */
+
+
+#if defined(HASPTSFN) && defined(DTYPE_PTS)
+/*
+ * process_pts - process a file structure whose type is DTYPE_PTS
+ */
+
+void process_pts(tp)
+ KA_T tp; /* f_data pointer to tty structure */
+{
+ dev_t dev; /* IFCHR device number */
+ struct tty t; /* tty structure */
+
+ (void) snpf(Lf->type, sizeof(Lf->type), "PTS");
+/*
+ * Read the tty structure. Quit if it can't be read.
+ */
+ if (!tp || kread(tp, (char *)&t, sizeof(t))) {
+ (void) snpf(Namech, Namechl,
+ "can't read DTYPE_PTS tty struct: %s",
+ print_kptr((KA_T)tp, (char *)NULL, 0));
+ enter_nm(Namech);
+ return;
+ }
+/*
+ * Convert the tty's cdev from kernel to user form.
+ *
+ * Set the device number to DevDev, the device number of /dev.
+ *
+ * Set the inode number to the device number.
+ *
+ * Set the file type to N_CHR for a character device (That's what a PTS is.)
+ *
+ * Force the use of offset from file structure.
+ *
+ * Set rdev to the converted device.
+ *
+ * Force the reloading of the device cache.
+ */
+ if ((dev = Dev2Udev((KA_T)t.t_dev)) == NODEV) {
+ (void) snpf(Namech, Namechl,
+ "can't convert device in DTYPE_PTS tty struct: %s",
+ print_kptr((KA_T)tp, (char *)NULL, 0));
+ enter_nm(Namech);
+ return;
+ }
+ Lf->dev = DevDev;
+ Lf->inode = (INODETYPE)dev;
+ Lf->inp_ty = Lf->dev_def = Lf->rdev_def = 1;
+ Lf->ntype = N_CHR;
+ Lf->off_def = 1;
+ Lf->rdev = dev;
+ DCunsafe = 1;
+}
+#endif /* defined(HASPTSFN) && defined(DTYPE_PTS) */
diff --git a/dialects/freebsd/dnode1.c b/dialects/freebsd/dnode1.c
index a5fa225..f78b9f8 100644
--- a/dialects/freebsd/dnode1.c
+++ b/dialects/freebsd/dnode1.c
@@ -35,7 +35,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dnode1.c,v 1.10 2008/10/21 16:16:06 abe Exp abe $";
+static char *rcsid = "$Id: dnode1.c,v 1.11 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -142,3 +142,33 @@ read_iso_node(v, d, dd, ino, nl, sz)
return(0);
}
#endif /* defined(HAS9660FS) */
+
+
+#if defined(HASFUSEFS)
+#include <fs/fuse/fuse_node.h>
+/*
+ * read_fuse_node() -- read FUSE file system fuse_node
+ */
+
+int
+read_fuse_node(v, d, dd, ino, nl, sz)
+ struct vnode *v; /* containing vnode */
+ dev_t *d; /* returned device number */
+ int *dd; /* returned device-defined flag */
+ INODETYPE *ino; /* returned inode number */
+ long *nl; /* returned number of links */
+ SZOFFTYPE *sz; /* returned size */
+{
+ struct fuse_vnode_data fn; /* FUSE node */
+
+ if (!v->v_data
+ || kread((KA_T)v->v_data, (char *)&fn, sizeof(fn)))
+ return(1);
+ *d = fn.cached_attrs.va_fsid;
+ *dd = 1;
+ *ino = (INODETYPE)fn.cached_attrs.va_fileid;
+ *nl = (long)fn.cached_attrs.va_nlink;
+ *sz = (SZOFFTYPE)fn.cached_attrs.va_size;
+ return(0);
+}
+#endif /* defined(HASFUSEFS) */
diff --git a/dialects/freebsd/dnode2.c b/dialects/freebsd/dnode2.c
index 4b6cf9a..d8c9b87 100644
--- a/dialects/freebsd/dnode2.c
+++ b/dialects/freebsd/dnode2.c
@@ -35,7 +35,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 2008 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dnode2.c,v 1.6 2015/07/07 20:23:43 abe Exp $";
+static char *rcsid = "$Id: dnode2.c,v 1.7 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -52,6 +52,7 @@ static char *rcsid = "$Id: dnode2.c,v 1.6 2015/07/07 20:23:43 abe Exp $";
#define VOP_UNLOCK(vp, f) ((void)0)
# endif /* defined(__clang__) */
+#define KLD_MODULE /* for ARM: prevent "ARM_NARCH is 0 " error */
#include <sys/zfs_znode.h>
#undef _KERNEL
diff --git a/dialects/freebsd/dproc.c b/dialects/freebsd/dproc.c
index e2b2d0c..0185686 100644
--- a/dialects/freebsd/dproc.c
+++ b/dialects/freebsd/dproc.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dproc.c,v 1.19 2015/07/07 20:23:43 abe Exp $";
+static char *rcsid = "$Id: dproc.c,v 1.20 2018/02/14 14:26:03 abe Exp $";
#endif
#include "lsof.h"
@@ -190,7 +190,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;
@@ -324,7 +324,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);
@@ -565,6 +565,17 @@ get_kernel_access()
Exit(1);
}
+#if defined(X_BADFILEOPS)
+/*
+ * Get kernel's badfileops address (for process_file()).
+ */
+ if (get_Nl_value(X_BADFILEOPS, (struct drive_Nl *)NULL, &X_bfopsa) < 0
+ || !X_bfopsa)
+ {
+ X_bfopsa = (KA_T)0;
+ }
+#endif /* defined(X_BADFILEOPS) */
+
#if defined(WILLDROPGID)
/*
* Drop setgid permission, if necessary.
diff --git a/dialects/freebsd/dproto.h b/dialects/freebsd/dproto.h
index cc23cf7..ca05356 100644
--- a/dialects/freebsd/dproto.h
+++ b/dialects/freebsd/dproto.h
@@ -33,7 +33,7 @@
/*
- * $Id: dproto.h,v 1.14 2009/03/25 19:23:06 abe Exp $
+ * $Id: dproto.h,v 1.15 2018/02/14 14:26:03 abe Exp $
*/
@@ -53,6 +53,10 @@ _PROTOTYPE(extern int is_file_named,(char *p, int cd));
_PROTOTYPE(extern void process_socket,(KA_T sa));
_PROTOTYPE(extern struct l_vfs *readvfs,(KA_T vm));
+#if defined(HASPTSFN)
+_PROTOTYPE(extern void process_pts,(KA_T ta));
+#endif /* defined(HASPTSFN) */
+
#if defined(HASKQUEUE)
_PROTOTYPE(extern void process_kqueue,(KA_T ka));
#endif /* defined(HASKQUEUE) */
@@ -61,6 +65,10 @@ _PROTOTYPE(extern void process_kqueue,(KA_T ka));
_PROTOTYPE(extern void process_pipe,(KA_T pa));
#endif /* FREEBSDV>=2020 */
+#if defined(HASFUSEFS)
+_PROTOTYPE(extern int read_fuse_node,(struct vnode *v, dev_t *d, int *dd, INODETYPE *ino, long *nl, SZOFFTYPE *sz));
+#endif /* defined(HASFUSEFS) */
+
#if defined(HAS9660FS)
_PROTOTYPE(extern int read_iso_node,(struct vnode *v, dev_t *d, int *dd, INODETYPE *ino, long *nl, SZOFFTYPE *sz));
#endif /* defined(HAS9660FS) */
diff --git a/dialects/freebsd/dsock.c b/dialects/freebsd/dsock.c
index d942602..ee8ced7 100644
--- a/dialects/freebsd/dsock.c
+++ b/dialects/freebsd/dsock.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dsock.c,v 1.30 2015/07/07 20:23:43 abe Exp $";
+static char *rcsid = "$Id: dsock.c,v 1.31 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -79,7 +79,7 @@ static char *rcsid = "$Id: dsock.c,v 1.30 2015/07/07 20:23:43 abe Exp $";
* Local function prototypes
*/
-_PROTOTYPE(static int ckstate,(KA_T ta, struct tcpcb *t, int fam));
+_PROTOTYPE(static int ckstate,(KA_T pcb, KA_T ta, struct tcpcb *t, int fam));
/*
@@ -91,7 +91,8 @@ _PROTOTYPE(static int ckstate,(KA_T ta, struct tcpcb *t, int fam));
*/
static int
-ckstate(ta, t, fam)
+ckstate(pcb, ta, t, fam)
+ KA_T pcb; /* PCB address */
KA_T ta; /* TCP control block address */
struct tcpcb *t; /* TCP control block receptor */
int fam; /* protocol family */
@@ -100,14 +101,18 @@ ckstate(ta, t, fam)
/*
* Read TCP control block.
*/
- if (kread(ta, (char *)t, sizeof(struct tcpcb)))
+ if (kread(ta, (char *)t, sizeof(struct tcpcb))
+ || (KA_T)t->t_inpcb != pcb)
+ {
return(-1);
+ }
if (TcpStXn || TcpStIn) {
/*
* If there are TCP state inclusions or exclusions, check them.
*/
- tsnx = (int)t->t_state + TcpStOff;
+ if ((tsnx = (int)t->t_state + TcpStOff) >= TcpNstates)
+ return(0);
if (TcpStXn) {
if (TcpStX[tsnx]) {
Lf->sf &= ~SELNET;
@@ -236,22 +241,43 @@ process_socket(sa)
#if defined(HASSOOPT)
Lf->lts.ltm = (unsigned int)s.so_linger;
Lf->lts.opt = (unsigned int)s.so_options;
+
+# if __FreeBSD_version>=1200027
+ if (s.so_options & SO_ACCEPTCONN) {
+ Lf->lts.pqlen = (unsigned int)s.sol_incqlen;
+ Lf->lts.qlen = (unsigned int)s.sol_qlen;
+ Lf->lts.qlim = (unsigned int)s.sol_qlimit;
+ } else {
+ Lf->lts.rbsz = (unsigned long)s.so_rcv.sb_mbmax;
+ Lf->lts.sbsz = (unsigned long)s.so_snd.sb_mbmax;
+
+# if defined(HASSBSTATE)
+ Lf->lts.sbs_rcv = s.so_rcv.sb_state;
+ Lf->lts.sbs_snd = s.so_snd.sb_state;
+# endif /* defined(HASSBSTATE) */
+
+ }
+
+# else /* __FreeBSD_version<1200027 */
Lf->lts.pqlen = (unsigned int)s.so_incqlen;
Lf->lts.qlen = (unsigned int)s.so_qlen;
Lf->lts.qlim = (unsigned int)s.so_qlimit;
Lf->lts.rbsz = (unsigned long)s.so_rcv.sb_mbmax;
Lf->lts.sbsz = (unsigned long)s.so_snd.sb_mbmax;
+
+# if defined(HASSBSTATE)
+ Lf->lts.sbs_rcv = s.so_rcv.sb_state;
+ Lf->lts.sbs_snd = s.so_snd.sb_state;
+# endif /* defined(HASSBSTATE) */
+# endif /*__FreeBSD_version>=1200027 */
+
Lf->lts.pqlens = Lf->lts.qlens = Lf->lts.qlims = Lf->lts.rbszs
= Lf->lts.sbszs = (unsigned char)1;
-#endif /* defined(HASSOOPT) */
-#if defined(HASSOSTATE)
+# if defined(HASSOSTATE)
Lf->lts.ss = (unsigned int)s.so_state;
-# if defined(HASSBSTATE)
- Lf->lts.sbs_rcv = s.so_rcv.sb_state;
- Lf->lts.sbs_snd = s.so_snd.sb_state;
-# endif /* defined(HASSBSTATE) */
-#endif /* defined(HASSOSTATE) */
+# endif /* defined(HASSOSTATE) */
+#endif /* defined(HASSOPT) */
/*
* Process socket by the associated domain family.
@@ -306,8 +332,11 @@ process_socket(sa)
*/
if (p.pr_protocol == IPPROTO_TCP) {
if (in6p.in6p_ppcb) {
- if ((ts = ckstate((KA_T)in6p.in6p_ppcb, &t, fam)) == 1)
+ if ((ts = ckstate((KA_T)s.so_pcb, (KA_T)in6p.in6p_ppcb,
+ &t, fam)) == 1)
+ {
return;
+ }
}
}
enter_dev_ch(print_kptr((KA_T)(in6p.in6p_ppcb ? in6p.in6p_ppcb
@@ -357,8 +386,11 @@ process_socket(sa)
}
if (p.pr_protocol == IPPROTO_TCP) {
if (inp.inp_ppcb) {
- if ((ts = ckstate((KA_T)inp.inp_ppcb, &t, fam)) == 1)
+ if ((ts = ckstate((KA_T)s.so_pcb, (KA_T)inp.inp_ppcb,
+ &t, fam)) == 1)
+ {
return;
+ }
}
}
enter_dev_ch(print_kptr((KA_T)(inp.inp_ppcb ? inp.inp_ppcb
diff --git a/dialects/freebsd/dstore.c b/dialects/freebsd/dstore.c
index 99239bd..0de224a 100644
--- a/dialects/freebsd/dstore.c
+++ b/dialects/freebsd/dstore.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dstore.c,v 1.8 2008/04/15 13:31:47 abe Exp $";
+static char *rcsid = "$Id: dstore.c,v 1.9 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -48,6 +48,8 @@ struct file *Cfp; /* curent file's file struct pointer */
struct drive_Nl Drive_Nl[] = {
+ { X_BADFILEOPS, "badfileops" },
+
#if FREEBSDV<2005
{ X_NCACHE, "_nchhead" },
#else /* FREEBSDV>=2005 */
@@ -129,3 +131,10 @@ struct pff_tab Pof_tab[] = {
{ (long)0, NULL }
};
#endif /* defined(HASFSTRUCT) */
+
+
+/*
+ * Kernel's bad file operations address
+ */
+
+KA_T X_bfopsa; /* badfileops kernel address */
diff --git a/dialects/freebsd/machine.h b/dialects/freebsd/machine.h
index be1485a..d47de0c 100644
--- a/dialects/freebsd/machine.h
+++ b/dialects/freebsd/machine.h
@@ -31,7 +31,7 @@
/*
- * $Id: machine.h,v 1.39 2015/07/07 20:23:43 abe Exp $
+ * $Id: machine.h,v 1.40 2018/02/14 14:26:03 abe Exp $
*/
@@ -441,6 +441,17 @@ typedef _Bool bool;
/*
+ * HASPTSFN is defined for dialects that have a DTYPE_PTS file descriptor
+ * type. The definition names the function that processes the type.
+ *
+ *
+ * NOTE: don't forget to define a prototype for this function in dproto.h.
+ */
+
+#define HASPTSFN process_pts
+
+
+/*
* HASRNODE is defined for those dialects that have rnodes.
*/
diff --git a/dialects/hpux/pstat/dproc.c b/dialects/hpux/pstat/dproc.c
index fb0c8e4..a592301 100644
--- a/dialects/hpux/pstat/dproc.c
+++ b/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);
diff --git a/dialects/linux/dmnt.c b/dialects/linux/dmnt.c
index 3bbdd37..87e63db 100644
--- a/dialects/linux/dmnt.c
+++ b/dialects/linux/dmnt.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dmnt.c,v 1.20 2015/07/07 19:47:31 abe Exp $";
+static char *rcsid = "$Id: dmnt.c,v 1.21 2018/02/14 14:26:38 abe Exp $";
#endif
@@ -535,6 +535,8 @@ readmnt()
if ((nfs = strcasecmp(fp[2], "nfs3")))
nfs = strcasecmp(fp[2], "nfs4");
}
+ if (!nfs && !HasNFS)
+ HasNFS = 1;
if (mp) {
/*
diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c
index b2cd77e..ce80b5d 100644
--- a/dialects/linux/dnode.c
+++ b/dialects/linux/dnode.c
@@ -32,12 +32,16 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dnode.c,v 1.25 2015/07/07 19:46:33 abe Exp $";
+static char *rcsid = "$Id: dnode.c,v 1.26 2018/02/14 14:26:38 abe Exp $";
#endif
#include "lsof.h"
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+#include <linux/major.h>
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
/*
* Local definitions
@@ -88,7 +92,11 @@ _PROTOTYPE(static void enter_pinfo,(void));
*/
#if defined(HASEPTOPTS)
-static pxinfo_t **Pinfo = (pxinfo_t **)NULL;
+static pxinfo_t **Pinfo = (pxinfo_t **)NULL; /* pipe endpoint hash buckets */
+# if defined(HASPTYEPT)
+static pxinfo_t **PtyInfo = (pxinfo_t **)NULL; /* pseudoterminal endpoint hash
+ * buckets */
+# endif /* defined(HASPTYEPT) */
#endif /* defined(HASEPTOPTS) */
@@ -202,12 +210,180 @@ enter_pinfo()
}
+#if defined(HASPTYEPT)
+
+
+/*
+ * clear_ptyinfo() -- clear allocated pseudoterminal info
+ */
+
+void
+clear_ptyinfo()
+{
+ int h; /* hash index */
+ pxinfo_t *pi, *pp; /* temporary pointers */
+
+ if (!PtyInfo)
+ return;
+ for (h = 0; h < PINFOBUCKS; h++) {
+ if ((pi = PtyInfo[h])) {
+ do {
+ pp = pi->next;
+ (void) free((FREE_P *)pi);
+ pi = pp;
+ } while (pi);
+ PtyInfo[h] = (pxinfo_t *)NULL;
+ }
+ }
+}
+
+
+/*
+ * enter_ptmxi() -- enter pty info
+ *
+ * entry Lf = local file structure pointer
+ * Lp = local process structure pointer
+ */
+
+void
+enter_ptmxi(mn)
+ int mn; /* minor number of device */
+{
+ int h; /* hash result */
+ struct lfile *lf; /* local file structure pointer */
+ struct lproc *lp; /* local proc structure pointer */
+ pxinfo_t *np, *pi, *pe; /* inode hash pointers */
+
+ if (!PtyInfo) {
+
+ /*
+ * Allocate pipe info hash buckets (but used for pty).
+ */
+ if (!(PtyInfo = (pxinfo_t **)calloc(PINFOBUCKS,
+ sizeof(pxinfo_t *))))
+ {
+ (void) fprintf(stderr,
+ "%s: no space for %d pty info buckets\n", Pn, PINFOBUCKS);
+ Exit(1);
+ }
+ }
+ /*
+ * Make sure this is a unique entry.
+ */
+ for (h = HASHPINFO(mn), pi = PtyInfo[h], pe = (pxinfo_t *)NULL;
+ pi;
+ pe = pi, pi = pi->next
+ ) {
+ lf = pi->lf;
+ lp = &Lproc[pi->lpx];
+ if (pi->ino == mn) {
+ if ((lp->pid == Lp->pid) && !strcmp(lf->fd, Lf->fd))
+ return;
+ }
+ }
+ /*
+ * Allocate, fill and link a new pipe info structure used for pty
+ * to the end of the pty device hash chain.
+ */
+ if (!(np = (pxinfo_t *)malloc(sizeof(pxinfo_t)))) {
+ (void) fprintf(stderr,
+ "%s: no space for pipeinfo for pty, PID %d, FD %s\n",
+ Pn, Lp->pid, Lf->fd);
+ Exit(1);
+ }
+ np->ino = mn;
+ np->lf = Lf;
+ np->lpx = Lp - Lproc;
+ np->next = (pxinfo_t *)NULL;
+ if (pe)
+ pe->next = np;
+ else
+ PtyInfo[h] = np;
+}
+
+
+/*
+ * find_ptyepti() -- find pseudoterminal end point info
+ */
+
+pxinfo_t *
+find_ptyepti(lf, m, pp)
+ struct lfile *lf; /* pseudoterminal's lfile */
+ int m; /* minor number type:
+ * 0 == use tty_index
+ * 1 == use minor device */
+ pxinfo_t *pp; /* previous pseudoterminal info
+ * (NULL == none) */
+{
+ struct lfile *ef; /* pseudoterminal end local file */
+ int h; /* hash result */
+ INODETYPE mn; /* minor number */
+ pxinfo_t *pi; /* pseudoterminal info pointer */
+
+
+ mn = m ? GET_MIN_DEV(lf->rdev) : lf->tty_index;
+ if (PtyInfo) {
+ if (pp)
+ pi = pp;
+ else {
+ h = HASHPINFO(mn);
+ pi = PtyInfo[h];
+ }
+ while (pi) {
+ if (pi->ino == mn) {
+ ef = pi->lf;
+ if (((m && is_pty_ptmx(ef->rdev))
+ || ((!m) && is_pty_slave(GET_MAJ_DEV(ef->rdev))))
+ && strcmp(lf->fd, ef->fd)
+ ) {
+ return(pi);
+ }
+ }
+ pi = pi->next;
+ }
+ }
+ return((pxinfo_t *)NULL);
+}
+
+
/*
- * find_pendinfo() -- find pipe end info
+ * is_pty_slave() -- is a pseudoterminal a slave device
+ */
+
+int
+is_pty_slave(sm)
+ int sm; /* slave major device number */
+{
+ if ((UNIX98_PTY_SLAVE_MAJOR <= sm)
+ && (sm < (UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_SLAVE_MAJOR))
+ ) {
+ return 1;
+ }
+ return 0;
+}
+
+
+/*
+ * is_pty_ptmx() -- is a pseudoterminal a master clone device
+ */
+
+int
+is_pty_ptmx(dev)
+ dev_t dev; /* device number */
+{
+ if ((GET_MAJ_DEV(dev) == TTYAUX_MAJOR) && (GET_MIN_DEV(dev) == 2))
+ return 1;
+ return 0;
+}
+#endif /* defined(HASPTYEPT) */
+
+
+/*
+ * find_pepti() -- find pipe end point info
*/
pxinfo_t *
-find_pendinfo(lf, pp)
+find_pepti(lf, pp)
struct lfile *lf; /* pipe's lfile */
pxinfo_t *pp; /* previous pipe info (NULL == none) */
{
@@ -559,6 +735,16 @@ process_proc_node(p, pbr, s, ss, l, ls)
if (ss & SB_RDEV) {
Lf->rdev = s->st_rdev;
Lf->rdev_def = 1;
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+ if ((Ntype == N_CHR)
+ && is_pty_slave(GET_MAJ_DEV(Lf->rdev))
+ ) {
+ enter_ptmxi(GET_MIN_DEV(Lf->rdev));
+ Lf->sf |= SELPTYINFO;
+ }
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
}
}
if (Ntype == N_REGLR && (HasNFS == 2)) {
diff --git a/dialects/linux/dproc.c b/dialects/linux/dproc.c
index c250fcd..5c10c4f 100644
--- a/dialects/linux/dproc.c
+++ b/dialects/linux/dproc.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dproc.c,v 1.29 2015/07/07 19:46:33 abe Exp $";
+static char *rcsid = "$Id: dproc.c,v 1.30 2018/02/14 14:26:38 abe Exp $";
#endif
#include "lsof.h"
@@ -44,7 +44,17 @@ static char *rcsid = "$Id: dproc.c,v 1.29 2015/07/07 19:46:33 abe Exp $";
#define FDINFO_FLAGS 1 /* fdinfo flags available */
#define FDINFO_POS 2 /* fdinfo position available */
-#define FDINFO_ALL (FDINFO_FLAGS | FDINFO_POS)
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+#define FDINFO_TTY_INDEX 4 /* fdinfo tty-index available */
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+#define FDINFO_ALL (FDINFO_FLAGS | FDINFO_POS | FDINFO_TTY_INDEX)
+#else /* !(defined(HASEPTOPTS) && defined(HASPTYEPT)) */
+#define FDINFO_ALL (FDINFO_FLAGS | FDINFO_POS )
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
#define LSTAT_TEST_FILE "/"
#define LSTAT_TEST_SEEK 1
@@ -60,6 +70,11 @@ static char *rcsid = "$Id: dproc.c,v 1.29 2015/07/07 19:46:33 abe Exp $";
struct l_fdinfo {
int flags; /* flags: line value */
off_t pos; /* pos: line value */
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+ int tty_index; /* pty line index */
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
};
@@ -81,7 +96,7 @@ static short Ckscko; /* socket file only checking status:
*/
_PROTOTYPE(static MALLOC_S alloc_cbf,(MALLOC_S len, char **cbf, MALLOC_S cbfa));
-_PROTOTYPE(static int get_fdinfo,(char *p, struct l_fdinfo *fi));
+_PROTOTYPE(static int get_fdinfo,(char *p, int msk, struct l_fdinfo *fi));
_PROTOTYPE(static int getlinksrc,(char *ln, char *src, int srcl, char **rest));
_PROTOTYPE(static int isefsys,(char *path, char *type, int l,
efsys_list_t **rep, struct lfile **lfr));
@@ -90,7 +105,8 @@ _PROTOTYPE(static int read_id_stat,(char *p, int id, char **cmd, int *ppid,
int *pgid));
_PROTOTYPE(static void process_proc_map,(char *p, struct stat *s, int ss));
_PROTOTYPE(static int process_id,(char *idp, int idpl, char *cmd, UID_ARG uid,
- int pid, int ppid, int pgid, int tid));
+ int pid, int ppid, int pgid, int tid,
+ char *tcmd));
_PROTOTYPE(static int statEx,(char *p, struct stat *s, int *ss));
@@ -182,9 +198,10 @@ void
gather_proc_info()
{
char *cmd, *tcmd;
+ char cmdbuf[MAXPATHLEN];
struct dirent *dp;
unsigned char ht, pidts;
- int n, nl, pgid, pid, ppid, rv, tid, tpgid, tppid, tx;
+ int n, nl, pgid, pid, ppid, prv, rv, tid, tpgid, tppid, tx;
static char *path = (char *)NULL;
static int pathl = 0;
static char *pidpath = (char *)NULL;
@@ -252,7 +269,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;
@@ -301,13 +318,26 @@ gather_proc_info()
continue;
uid = (UID_ARG)sb.st_uid;
ht = pidts = 0;
+ /*
+ * Get the PID's command name.
+ */
+ (void) make_proc_path(pidpath, n, &path, &pathl, "stat");
+ if ((prv = read_id_stat(path, pid, &cmd, &ppid, &pgid)) < 0)
+ cmd = "(unknown)";
#if defined(HASTASKS)
/*
- * If task reporting is selected, check the tasks of the process first,
- * so that the "-p<PID> -aK" options work properly.
+ * Task reporting has been selected, so save the process' command
+ * string, so that task processing won't change it in the buffer of
+ * read_id_stat().
+ *
+ * Check the tasks of the process first, so that the "-p<PID> -aK"
+ * options work properly.
*/
- if ((Selflags & SELTASK)) {
+ else if (!IgnTasks && (Selflags & SELTASK)) {
+ strncpy(cmdbuf, cmd, sizeof(cmdbuf) - 1);
+ cmdbuf[sizeof(cmdbuf) - 1] = '\0';
+ cmd = cmdbuf;
(void) make_proc_path(pidpath, n, &taskpath, &taskpathl,
"task");
tx = n + 4;
@@ -361,8 +391,8 @@ gather_proc_info()
/*
* Attempt to record the task.
*/
- if (!process_id(tidpath, (tx + 1 + nl+ 1), tcmd, uid,
- pid, tppid, tpgid, tid))
+ if (!process_id(tidpath, (tx + 1 + nl+ 1), cmd, uid,
+ pid, tppid, tpgid, tid, tcmd))
{
ht = 1;
}
@@ -375,15 +405,14 @@ 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(path, pid, &cmd, &ppid, &pgid)) >= 0)
- && (rv != 1))
- {
- tid = (Fand && ht && pidts && (Selflags & SELTASK)) ? pid : 0;
- if ((!process_id(pidpath, n, cmd, uid, pid, ppid, pgid, tid))
+ if ((prv >= 0) && (prv != 1)) {
+ tid = (Fand && ht && pidts && !IgnTasks && (Selflags & SELTASK))
+ ? pid : 0;
+ if ((!process_id(pidpath, n, cmd, uid, pid, ppid, pgid, tid,
+ (char *)NULL))
&& tid)
{
Lp->tid = 0;
@@ -398,8 +427,10 @@ gather_proc_info()
*/
static int
-get_fdinfo(p, fi)
+get_fdinfo(p, msk, fi)
char *p; /* path to fdinfo file */
+ int msk; /* mask for information type: e.g.,
+ * the FDINFO_* definition */
struct l_fdinfo *fi; /* pointer to local fdinfo values
* return structure */
{
@@ -414,6 +445,11 @@ get_fdinfo(p, fi)
*/
if (!fi)
return(0);
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+ fi->tty_index = -1;
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
if (!p || !*p || !(fs = fopen(p, "r")))
return(0);
/*
@@ -434,7 +470,7 @@ get_fdinfo(p, fi)
|| !ep || *ep)
continue;
fi->flags = (unsigned int)ul;
- if ((rv |= FDINFO_FLAGS) == FDINFO_ALL)
+ if ((rv |= FDINFO_FLAGS) == msk)
break;
} else if (!strcmp(fp[0], "pos:")) {
@@ -448,6 +484,29 @@ get_fdinfo(p, fi)
fi->pos = (off_t)ull;
if ((rv |= FDINFO_POS) == FDINFO_ALL)
break;
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+ } else if (!strcmp(fp[0], "tty-index:")) {
+
+ /*
+ * Process a "tty-index:" line.
+ */
+ ep = (char *)NULL;
+ if ((ul = strtoul(fp[1], &ep, 0)) == ULONG_MAX
+ || !ep || *ep)
+ continue;
+ fi->tty_index = (int)ul;
+ if (fi->tty_index < 0) {
+
+ /*
+ * Oops! If integer overflow occurred, reset the field.
+ */
+ fi->tty_index = -1;
+ }
+ if ((rv |= FDINFO_TTY_INDEX) == msk)
+ break;
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
}
}
fclose(fs);
@@ -534,7 +593,7 @@ initialize()
if (!OffType) {
(void) snpf(path, sizeof(path), "%s/%d/fdinfo/%d", PROCFS,
Mypid, fd);
- if (get_fdinfo(path, &fi) & FDINFO_POS) {
+ if (get_fdinfo(path, FDINFO_POS, &fi) & FDINFO_POS) {
if (fi.pos == (off_t)LSTAT_TEST_SEEK)
OffType = 2;
}
@@ -797,7 +856,7 @@ open_proc_stream(p, m, buf, sz, act)
*/
static int
-process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid)
+process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid, tcmd)
char *idp; /* pointer to ID's path */
int idpl; /* pointer to ID's path length */
char *cmd; /* pointer to ID's command */
@@ -806,8 +865,9 @@ process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid)
int ppid; /* parent PID */
int pgid; /* parent GID */
int tid; /* task ID, if non-zero */
+ char *tcmd; /* task command, if non-NULL) */
{
- int av;
+ int av = 0;
static char *dpath = (char *)NULL;
static int dpathl = 0;
short efs, enls, enss, lnk, oty, pn, pss, sf;
@@ -854,11 +914,27 @@ process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid)
* 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;
Plf = (struct lfile *)NULL;
+
+#if defined(HASTASKS)
+/*
+ * Enter task information.
+ */
+ Lp->tid = tid;
+ if (tid && tcmd) {
+ if (!(Lp->tcmd = mkstrcpy(tcmd, (MALLOC_S *)NULL))) {
+ (void) fprintf(stderr,
+ "%s: PID %d, TID %d, no space for task name: ",
+ Pn, pid, tid);
+ safestrprt(tcmd, stderr, 1);
+ Exit(1);
+ }
+ }
+#endif /* defined(HASTASKS) */
+
/*
* Process the ID's current working directory info.
*/
@@ -1149,7 +1225,7 @@ process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid)
if (oty) {
(void) make_proc_path(ipath, j, &pathi, &pathil,
fp->d_name);
- if ((av = get_fdinfo(pathi, &fi)) & FDINFO_POS) {
+ if ((av = get_fdinfo(pathi,FDINFO_ALL,&fi)) & FDINFO_POS) {
if (efs) {
if (Foffset) {
lfr->off = (SZOFFTYPE)fi.pos;
@@ -1180,6 +1256,18 @@ process_id(idp, idpl, cmd, uid, pid, ppid, pgid, tid)
ls);
if ((Lf->ntype == N_ANON_INODE) && rest && *rest)
enter_nm(rest);
+
+#if defined(HASEPTOPTS) && defined(HASPTYEPT)
+ else if (Lf->rdev_def
+ && is_pty_ptmx(Lf->rdev)
+ && (av & FDINFO_TTY_INDEX)
+ ) {
+ enter_ptmxi(fi.tty_index);
+ Lf->tty_index = fi.tty_index;
+ Lf->sf |= SELPTYINFO;
+ }
+#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
+
if (Lf->sf)
link_lfile();
}
@@ -1434,7 +1522,7 @@ read_id_stat(p, id, cmd, ppid, pgid)
* type */
{
char buf[MAXPATHLEN], *cp, *cp1, **fp;
- int ch, cx, es, nf;
+ int ch, cx, es, nf, pc;
static char *cbf = (char *)NULL;
static MALLOC_S cbfa = 0;
FILE *fs;
@@ -1474,11 +1562,14 @@ read_id_stat_exit:
if (!cp || (*cp != '('))
goto read_id_stat_exit;
cp++;
+ pc = 1; /* start the parenthesis balance count at 1 */
/*
* Enter the command characters safely. Supply them from the initial read
* of the stat file line, a '\n' if the initial read didn't yield a ')'
* command closure, or by reading the rest of the command a character at
- * a time from the stat file.
+ * a time from the stat file. Count embedded '(' characters and balance
+ * them with embedded ')' characters. The opening '(' starts the balance
+ * count at one.
*/
for (cx = es = 0;;) {
if (!es)
@@ -1487,8 +1578,18 @@ read_id_stat_exit:
if ((ch = fgetc(fs)) == EOF)
goto read_id_stat_exit;
}
- if (ch == ')') /* ')' closes the command */
- break;
+ if (ch == '(') /* a '(' advances the balance count */
+ pc++;
+ if (ch == ')') {
+
+ /*
+ * Balance parentheses when a closure is encountered. When
+ * they are balanced, this is the end of the command.
+ */
+ pc--;
+ if (!pc)
+ break;
+ }
if ((cx + 2) > cbfa)
cbfa = alloc_cbf((cx + 2), &cbf, cbfa);
cbf[cx] = ch;
diff --git a/dialects/linux/dsock.c b/dialects/linux/dsock.c
index b3b45c4..6e6e449 100644
--- a/dialects/linux/dsock.c
+++ b/dialects/linux/dsock.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dsock.c,v 1.41 2015/07/07 19:46:33 abe Exp $";
+static char *rcsid = "$Id: dsock.c,v 1.42 2018/02/14 14:26:38 abe Exp $";
#endif
@@ -572,6 +572,31 @@ check_unix(i)
/*
+ * clear_uxsinfo -- clear allocated UNIX socket info
+ */
+
+void
+clear_uxsinfo()
+{
+ int h; /* hash index */
+ uxsin_t *ui, *up; /* remporary pointers */
+
+ if (!Uxsin)
+ return;
+ for (h = 0; h < INOBUCKS; h++) {
+ if ((ui = Uxsin[h])) {
+ do {
+ up = ui->next;
+ (void) free((FREE_P *)ui);
+ ui = up;
+ } while (ui);
+ Uxsin[h] = (uxsin_t *)NULL;
+ }
+ }
+}
+
+
+/*
* get_ax25() - get /proc/net/ax25 info
*/
diff --git a/dialects/sun/machine.h b/dialects/sun/machine.h
index 1264a09..f02eff5 100644
--- a/dialects/sun/machine.h
+++ b/dialects/sun/machine.h
@@ -31,7 +31,7 @@
/*
- * $Id: machine.h,v 1.47 2011/09/07 19:16:00 abe Exp $
+ * $Id: machine.h,v 1.48 2018/02/14 14:24:07 abe Exp $
*/
#if !defined(LSOF_MACHINE_H)
@@ -50,13 +50,21 @@
# if solaris>=100000
+# if !defined(HAS_AIO_REQ_STRUCT)
/*
- * Define a dummy aio_req structure for Solaris >= 10, because #include'ing
- * <sys/aio_req.h> with _KERNEL defined creates too many problems.
+ * When <sys.aio_req.h> lacks one, define a dummy aio_req structure for
+ * Solaris >= 10 systems.
+ *
+ * If this definition causes compilation errors for <sys/vnode.h>, especially
+ * with Solaris 11, it may be necessary to comment out the following structure
+ * definition. I don't know a test that will determine the possibility of
+ * compilation errors.
*/
typedef struct aio_req { int dummy; } aio_req_t;
+# endif /* !defined(HAS_AIO_REQ_STRUCT) */
+
/*
* Include <sys/utsname.h> so it won't be corrupted for 32 bit compilations
* when _KERNEL is defined for some include files in dlsof.h.
diff --git a/lib/ckkv.c b/lib/ckkv.c
index 876758a..fe36c92 100644
--- a/lib/ckkv.c
+++ b/lib/ckkv.c
@@ -37,7 +37,7 @@
# if !defined(lint)
static char copyright[] =
"@(#) Copyright 1998 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: ckkv.c,v 1.3 2008/10/21 16:12:36 abe Exp $";
+static char *rcsid = "$Id: ckkv.c,v 1.3 2008/10/21 16:12:36 abe Exp abe $";
# endif /* !defined(lint) */
#include "../lsof.h"
diff --git a/lib/prfp.c b/lib/prfp.c
index 2f8d841..fe4812c 100644
--- a/lib/prfp.c
+++ b/lib/prfp.c
@@ -37,7 +37,7 @@
# if !defined(lint)
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: prfp.c,v 1.14 2008/10/21 16:12:36 abe Exp $";
+static char *rcsid = "$Id: prfp.c,v 1.15 2018/02/14 14:21:08 abe Exp $";
# endif /* !defined(lint) */
#include "../lsof.h"
@@ -143,6 +143,18 @@ process_file(fp)
return;
#endif /* defined(DTYPE_PIPE) */
+#if defined(DTYPE_PTS)
+ case DTYPE_PTS:
+# if defined(HASPTSFN)
+ HASPTSFN((KA_T)f.f_data);
+# endif /* defined(HASPTSFN) */
+ return;
+#endif /* defined(DTYPE_PIPE) */
+
+#if defined(DTYPE_FIFO)
+ case DTYPE_FIFO:
+#endif /* defined(DTYPE_FIFO) */
+
#if defined(DTYPE_GNODE)
case DTYPE_GNODE:
#endif /* defined(DTYPE_GNODE) */
@@ -195,9 +207,20 @@ process_file(fp)
#endif /* defined(HASPRIVFILETYPE) */
default:
+
+#if defined(X_BADFILEOPS)
+ if (X_bfopsa && f.f_ops && (X_bfopsa == (KA_T)f.f_ops)) {
+ (void) snpf(Namech, Namechl,
+ "no more information; ty=%d file may be closing",
+ (int)f.f_type);
+ enter_nm(Namech);
+ return;
+ }
+#endif /* defined(X_BADFILEOPS) */
+
if (f.f_type || f.f_ops) {
(void) snpf(Namech, Namechl,
- "%s file struct, ty=%#x, op=%s",
+ "%s file struct, ty=%d, op=%s",
print_kptr(fp, tbuf, sizeof(tbuf)), (int)f.f_type,
print_kptr((KA_T)f.f_ops, (char *)NULL, 0));
enter_nm(Namech);
diff --git a/lsof.8 b/lsof.8
index 56bc582..d15eca7 100644
--- a/lsof.8
+++ b/lsof.8
@@ -1,4 +1,4 @@
-.ds VN 4.89
+.ds VN 4.90
.TH LSOF 8 Revision-\*(VN
\" Register )P is used neither by this file nor any groff macro. However,
\" some versions of nroff require it.
@@ -10,7 +10,7 @@ lsof \- list open files
.SH SYNOPSIS
.B lsof
[
-.B \-?abChKlnNOPRtUvVX
+.B \-?abChlnNOPRtUvVX
] [
.BI -A " A"
] [
@@ -36,6 +36,8 @@ lsof \- list open files
] [
.BI \-k " k"
] [
+.BI \-K " k"
+] [
.BI +|\-L " [l]"
] [
.BI +|\-m " m"
@@ -73,7 +75,7 @@ opened by processes for the following UNIX dialects:
.PP
.nf
Apple Darwin 9 and Mac OS X 10.[567]
- FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems
+ FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
Linux 2.1.72 and above for x86-based systems
Solaris 9, 10 and 11
.fi
@@ -642,13 +644,13 @@ option.)
.TP \w'names'u+4
.B +|-E
.B +E
-specifies that Linux pipe and Linux UNIX socket files should be displayed with
-endpoint information and the files of the endpoints should also be
-displayed.
-Note: UNIX socket file endpoint information is available only when the
+specifies that Linux pipe, Linux UNIX socket and Linux pseudoterminal files
+should be displayed with endpoint information and the files of the endpoints should also be displayed.
+Note: UNIX socket file endpoint information is only available when the
compile flags line of
.B \-v
-output contains HASUXSOCKEPT.
+output contains HASUXSOCKEPT, and psudoterminal endpoint information is only
+available when the compile flags line contains HASPTYEPT.
.IP
Pipe endpoint information is displayed in the NAME column in the
form ``\fIPID,cmd,FDmode\fP'', where
@@ -661,6 +663,21 @@ is the endpoint file's descriptor; and
.I mode
is the endpoint file's access mode.
.IP
+Pseudoterminal
+endpoint information is displayed in the NAME column as
+``->/dev/pts\fImin\fP\ \fIPID,cmd,FDmode\fP'' or ``\fIPID,cmd,FDmode\fP''.
+The first form is for a master device; the second, for a slave device.
+.I min
+is a slave device's minor device number; and
+.I "PID, cmd, FD"
+and
+.I mode
+are the same as with pipe endpoint information.
+Note: psudoterminal endpoint information is only available when the compile
+flags line of
+.B \-V
+output contains HASPTYEPT.
+.IP
UNIX socket file endpoint information is displayed in the NAME column
in the form
.br
@@ -670,7 +687,7 @@ is the socket type;
.I INODE
is the i-node number of the connected socket;
and
-.I "PID, cmd, FD,"
+.I "PID, cmd, FD"
and
.I mode
are the same as with pipe endpoint information.
@@ -1019,7 +1036,7 @@ Here are some sample addresses:
:time \- either TCP, UDP or UDPLITE time service port
.fi
.TP \w'names'u+4
-.B \-K
+.BI \-K " k"
selects the listing of tasks (threads) of processes, on dialects
where task (thread) reporting is supported.
(If help output \- i.e., the output of the
@@ -1029,6 +1046,15 @@ or
options \- shows this option, then task (thread) 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
@@ -1437,6 +1463,10 @@ the option causes open TCP and UDP files to be excluded if their
state name(s) are in the list (\fIs\fP) preceded by a `^'; or
included if their name(s) are not preceded by a `^'.
.IP
+Dialects that support this option may support only one protocol.
+When an unsupported protocol is specified, a message will be
+displayed indicating state names for the protocol are unavailable.
+.IP
When an inclusion list is defined, only network files with state
names in the list will be present in the
.I lsof
@@ -2342,6 +2372,15 @@ supported by the dialect.)
.IP
A blank TID column in Linux indicates a process \- i.e., a non\-task.
.TP
+TASKCMD
+is the task command name.
+Generally this will be the same as the process named in the COMMAND
+column, but some task implementations (e.g., Linux) permit a task to
+change its command name.
+.IP
+The TASKCMD column width is subject to the same size limitation as the
+COMMAND column.
+.TP
ZONE
is the Solaris 10 and higher zone name.
This column must be selected with the
@@ -2679,6 +2718,10 @@ or ``PSXSEM'' for a POSIX semaphore file;
.IP
or ``PSXSHM'' for a POSIX shared memory file;
.IP
+or ``PTS'' for a
+.I /dev/pts
+file;
+.IP
or ``PUSG'' for a
.I /proc/usage
file;
@@ -3211,6 +3254,7 @@ The single character listed first is the field identifier.
l file's lock status
L process login name
m marker between repeated output
+ M the task comMand name
n file name, comment, Internet address
N node identifier (ox<hexadecimal>
o file's offset (decimal)
@@ -3766,8 +3810,8 @@ and be allowed to surrender setgid permission.
AIX 5.[12] and 5.3-ML1
Apple Darwin 7.x Power Macintosh systems
FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems
- FreeBSD 5.x and [6789].x for Alpha, AMD64 and Sparc64-based
- systems
+ FreeBSD 5.x, [6789].x and 1[012].8for Alpha, AMD64 and Sparc64
+ based systems
HP\-UX 11.00
NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based
systems
diff --git a/lsof.h b/lsof.h
index 93fbbeb..06903fa 100644
--- a/lsof.h
+++ b/lsof.h
@@ -31,7 +31,7 @@
/*
- * $Id: lsof.h,v 1.68 2015/07/07 20:16:58 abe Exp $
+ * $Id: lsof.h,v 1.69 2018/02/14 14:19:25 abe Exp $
*/
@@ -86,8 +86,12 @@ struct l_dev {
*/
#define CHEND_PIPE 1 /* pipe endpoint ID */
+#define CHEND_PTY 4 /* pseudoterminal endpoint ID */
#define EPT_PIPE 1 /* process has pipe file */
#define EPT_PIPE_END 2 /* process has pipe end point file */
+#define EPT_PTY 8 /* process has a pseudoterminal file */
+#define EPT_PTY_END 16 /* process has a pseudoterminal end
+ * point file */
# if defined(HASUXSOCKEPT)
#define CHEND_UXS 2 /* UNIX socket endpoint ID */
@@ -382,6 +386,9 @@ static struct utmp dummy_utmp; /* to get login name length */
#define RPTTM 15 /* default repeat seconds */
#define RTD " rtd" /* root directory fd name */
+#define TASKCMDL 9 /* maximum number of characters from
+ * command name to print in TASKCMD
+ * column */
#define TCPTPI_FLAGS 0x0001 /* report TCP/TPI socket options and
* state, and TCP_NODELAY state */
#define TCPTPI_QUEUES 0x0002 /* report TCP/TPI queue lengths */
@@ -455,8 +462,10 @@ extern int PpidColW;
#define SZTTL "SIZE"
#define SZOFFTTL "SIZE/OFF"
extern int SzOffColW;
-#define TIDTTL "TID"
-extern int TidColW;
+#define TASKCMDTTL "TASKCMD"
+extern int TaskCmdColW;
+#define TASKTIDTTL "TID"
+extern int TaskTidColW;
#define TYPETTL "TYPE"
extern int TypeColW;
#define USERTTL "USER"
@@ -490,7 +499,9 @@ extern int ZoneColW;
#define SELTASK 0x4000 /* select tasks (-K) */
#define SELPINFO 0x8000 /* selected for pipe info (cleared in
* link_lfile() */
-#define SELUXSINFO 0x10000 /* selected for UNIX socket info
+#define SELUXSINFO 0x10000 /* selected for UNIX socket info;
+ * cleared in link_lfile() */
+#define SELPTYINFO 0x20000 /* selected for pseudoterminal info;
* cleared in link_lfile() */
#define SELALL (SELCMD|SELCNTX|SELFD|SELNA|SELNET|SELNM|SELNFS|SELPID|SELUID|SELUNX|SELZONE|SELTASK)
#define SELPROC (SELCMD|SELCNTX|SELPGID|SELPID|SELUID|SELZONE|SELTASK)
@@ -513,6 +524,8 @@ struct afsnode { /* AFS pseudo-node structure */
};
# endif /* defined(HAS_AFS) */
+extern int AllProc;
+
# if defined(HAS_STD_CLONE)
struct clone {
int dx; /* index of device entry in Devtp[] */
@@ -568,8 +581,8 @@ struct pff_tab { /* print file flags table structure */
# endif /* defined(HASFSTRUCT) */
# if defined(HASEPTOPTS)
-typedef struct pxinfo { /* hashed pipe or UNIX socket inode
- * information */
+typedef struct pxinfo { /* hashed pipe, UNIX socket or pseudo-
+ * terminal inode information */
INODETYPE ino; /* file's inode */
struct lfile *lf; /* connected peer file */
int lpx; /* connected process index */
@@ -728,6 +741,7 @@ extern struct fieldsel FieldSel[];
extern int Hdr;
enum IDType {PGID, PID};
+extern int IgnTasks;
extern char *InodeFmt_d;
extern char *InodeFmt_x;
extern int LastPid;
@@ -763,6 +777,10 @@ struct lfile {
# if defined(HASEPTOPTS)
unsigned char chend; /* communication channel endpoint
* file */
+# if defined(HASPTYEPT)
+ int tty_index; /* pseudoterminal index of slave side
+ * (if this is the master side) */
+# endif /* defined(HASPTYEPT) */
# endif /* defined(HASEPTOPTS) */
unsigned char rdev_def; /* rdev definition status */
@@ -908,6 +926,7 @@ struct lproc {
# if defined(HASTASKS)
int tid; /* task ID */
+ char *tcmd; /* task command name */
# endif /* HASTASKS */
int pgid; /* process group ID */
@@ -1005,8 +1024,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;
@@ -1018,7 +1038,9 @@ extern char *SzOffFmt_0t;
extern char *SzOffFmt_d;
extern char *SzOffFmt_dv;
extern char *SzOffFmt_x;
-extern int TaskPrtFl;
+extern int TaskCmdLim;
+extern int TaskPrtCmd;
+extern int TaskPrtTid;
extern int TcpStAlloc;
extern unsigned char *TcpStI;
extern int TcpStIn;
diff --git a/lsof.man b/lsof.man
index b9d925a..3cd65c6 100644
--- a/lsof.man
+++ b/lsof.man
@@ -9,20 +9,20 @@ NAME
lsof - list open files
SYNOPSIS
- lsof [ -?abChKlnNOPRtUvVX ] [ -A A ] [ -c c ] [ +c c ] [
- +|-d d ] [ +|-D D ] [ +|-e s ] [ +|-E ] [ +|-f [cfgGn] ] [
- -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ +|-m
- m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t[m<fmt>]] ] [ -s
- [p:s] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl] ]
- [ -z [z] ] [ -Z [Z] ] [ -- ] [names]
+ lsof [ -?abChlnNOPRtUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d
+ d ] [ +|-D D ] [ +|-e s ] [ +|-E ] [ +|-f [cfgGn] ] [ -F [f]
+ ] [ -g [s] ] [ -i [i] ] [ -k k ] [ -K k ] [ +|-L [l] ] [
+ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t[m<fmt>]] ] [
+ -s [p:s] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl]
+ ] [ -z [z] ] [ -Z [Z] ] [ -- ] [names]
DESCRIPTION
- Lsof revision 4.89 lists on its standard output file infor-
+ Lsof revision 4.90 lists on its standard output file infor-
mation about files opened by processes for the following
UNIX dialects:
Apple Darwin 9 and Mac OS X 10.[567]
- FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems
+ FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
Linux 2.1.72 and above for x86-based systems
Solaris 9, 10 and 11
@@ -60,7 +60,7 @@ OPTIONS
-SunOS 5.9 Last change: Revision-4.89 1
+SunOS 5.9 Last change: Revision-4.90 1
@@ -126,7 +126,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 2
+SunOS 5.9 Last change: Revision-4.90 2
@@ -192,7 +192,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 3
+SunOS 5.9 Last change: Revision-4.90 3
@@ -258,7 +258,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 4
+SunOS 5.9 Last change: Revision-4.90 4
@@ -324,7 +324,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 5
+SunOS 5.9 Last change: Revision-4.90 5
@@ -390,7 +390,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 6
+SunOS 5.9 Last change: Revision-4.90 6
@@ -456,7 +456,7 @@ Maintenance Procedures LSOF(8)
-SunOS 5.9 Last change: Revision-4.89 7
+SunOS 5.9 Last change: Revision-4.90 7
@@ -485,12 +485,15 @@ Maintenance Procedures LSOF(8)
information might be made available via the +|-m m
option.)
- +|-E +E specifies that Linux pipe and Linux UNIX socket
- files should be displayed with endpoint information
- and the files of the endpoints should also be
- displayed. Note: UNIX socket file endpoint infor-
- mation is available only when the compile flags
- line of -v output contains HASUXSOCKEPT.
+ +|-E +E specifies that Linux pipe, Linux UNIX socket and
+ Linux pseudoterminal files should be displayed with
+ endpoint information and the files of the endpoints
+ should also be displayed. Note: UNIX socket file
+ endpoint information is only available when the
+ compile flags line of -v output contains HASUX-
+ SOCKEPT, and psudoterminal endpoint information is
+ only available when the compile flags line contains
+ HASPTYEPT.
Pipe endpoint information is displayed in the NAME
column in the form ``PID,cmd,FDmode'', where PID is
@@ -498,41 +501,51 @@ Maintenance Procedures LSOF(8)
cess command; FD is the endpoint file's descriptor;
and mode is the endpoint file's access mode.
+ Pseudoterminal endpoint information is displayed in
+ the NAME column as ``->/dev/ptsmin PID,cmd,FDmode''
+ or ``PID,cmd,FDmode''. The first form is for a
+ master device; the second, for a slave device. min
+ is a slave device's minor device number; and PID,
+ cmd, FD and mode are the same as with pipe endpoint
+ information. Note: psudoterminal endpoint informa-
+ tion is only available when the compile flags line
+ of -V output contains HASPTYEPT.
+
UNIX socket file endpoint information is displayed
in the NAME column in the form
``type=TYPE ->INO=INODE PID,cmd,FDmode'', where
TYPE is the socket type; INODE is the i-node number
- of the connected socket; and PID, cmd, FD, and mode
+ of the connected socket; and PID, cmd, FD and mode
are the same as with pipe endpoint information.
Note: UNIX socket file endpoint information is
available only when the compile flags line of -v
- output contains HASUXSOCKEPT.
- Multiple occurrences of this information can appear
- in a file's NAME column.
- -E specfies that Linux pipe and Linux UNIX socket
- files should be displayed with endpoint informa-
- tion, but not the files of the endpoints.
- +|-f [cfgGn]
- f by itself clarifies how path name arguments are
- to be interpreted. When followed by c, f, g, G, or
- n in any combination it specifies that the listing
+SunOS 5.9 Last change: Revision-4.90 8
-SunOS 5.9 Last change: Revision-4.89 8
+Maintenance Procedures LSOF(8)
-Maintenance Procedures LSOF(8)
+ output contains HASUXSOCKEPT.
+ Multiple occurrences of this information can appear
+ in a file's NAME column.
+ -E specfies that Linux pipe and Linux UNIX socket
+ files should be displayed with endpoint informa-
+ tion, but not the files of the endpoints.
+ +|-f [cfgGn]
+ f by itself clarifies how path name arguments are
+ to be interpreted. When followed by c, f, g, G, or
+ n in any combination it specifies that the listing
of kernel file structure information is to be
enabled (`+') or inhibited (`-').
@@ -572,33 +585,33 @@ Maintenance Procedures LSOF(8)
structure information:
- c file structure use count (not Linux)
- f file structure address (not Linux)
- g file flag abbreviations (Linux 2.6.22 and up)
- G file flags in hexadecimal (Linux 2.6.22 and up)
- n file structure node address (not Linux)
- When the prefix is minus (`-') the same characters
- disable the listing of the indicated values.
- File structure addresses, use counts, flags, and
- node addresses may be used to detect more readily
- identical files inherited by child processes and
- identical files in use by different processes.
+SunOS 5.9 Last change: Revision-4.90 9
-SunOS 5.9 Last change: Revision-4.89 9
+Maintenance Procedures LSOF(8)
-Maintenance Procedures LSOF(8)
+ c file structure use count (not Linux)
+ f file structure address (not Linux)
+ g file flag abbreviations (Linux 2.6.22 and up)
+ G file flags in hexadecimal (Linux 2.6.22 and up)
+ n file structure node address (not Linux)
+ When the prefix is minus (`-') the same characters
+ disable the listing of the indicated values.
+ File structure addresses, use counts, flags, and
+ node addresses may be used to detect more readily
+ identical files inherited by child processes and
+ identical files in use by different processes.
Lsof column output can be sorted by output columns
holding the values and listed to identify identical
file use, or lsof field output can be parsed by an
@@ -638,33 +651,33 @@ Maintenance Procedures LSOF(8)
When the field selection character list contains
the single character `?', lsof will display a help
- list of the field identification characters.
- (Escape the `?' character as your shell requires.)
- -g [s] excludes or selects the listing of files for the
- processes whose optional process group IDentifica-
- tion (PGID) numbers are in the comma-separated set
- s - e.g., ``123'' or ``123,^456''. (There should
- be no spaces in the set.)
- PGID numbers that begin with `^' (negation)
- represent exclusions.
- Multiple PGID numbers are joined in a single ORed
+SunOS 5.9 Last change: Revision-4.90 10
-SunOS 5.9 Last change: Revision-4.89 10
+Maintenance Procedures LSOF(8)
-Maintenance Procedures LSOF(8)
+ list of the field identification characters.
+ (Escape the `?' character as your shell requires.)
+ -g [s] excludes or selects the listing of files for the
+ processes whose optional process group IDentifica-
+ tion (PGID) numbers are in the comma-separated set
+ s - e.g., ``123'' or ``123,^456''. (There should
+ be no spaces in the set.)
+ PGID numbers that begin with `^' (negation)
+ represent exclusions.
+ Multiple PGID numbers are joined in a single ORed
set before participating in AND option selection.
However, PGID exclusions are applied without ORing
or ANDing and take effect before other selection
@@ -704,23 +717,10 @@ Maintenance Procedures LSOF(8)
46 specifies the IP version, IPv4 or IPv6
that applies to the following address.
'6' may be be specified only if the UNIX
- dialect supports IPv6. If neither '4' nor
- '6' is specified, the following address
- applies to all IP versions.
- protocol is a protocol name - TCP, UDP
- hostname is an Internet host name. Unless a
- specific IP version is specified, open
- network files associated with host names
- of all versions will be selected.
- hostaddr is a numeric Internet IPv4 address in
- dot form; or an IPv6 numeric address in
- colon form, enclosed in brackets, if the
- UNIX dialect supports IPv6. When an IP
- version is selected, only its numeric
-SunOS 5.9 Last change: Revision-4.89 11
+SunOS 5.9 Last change: Revision-4.90 11
@@ -731,6 +731,19 @@ Maintenance Procedures LSOF(8)
+ dialect supports IPv6. If neither '4' nor
+ '6' is specified, the following address
+ applies to all IP versions.
+ protocol is a protocol name - TCP, UDP
+ hostname is an Internet host name. Unless a
+ specific IP version is specified, open
+ network files associated with host names
+ of all versions will be selected.
+ hostaddr is a numeric Internet IPv4 address in
+ dot form; or an IPv6 numeric address in
+ colon form, enclosed in brackets, if the
+ UNIX dialect supports IPv6. When an IP
+ version is selected, only its numeric
addresses may be specified.
service is an /etc/services name - e.g., smtp -
or a list of them.
@@ -770,44 +783,49 @@ Maintenance Procedures LSOF(8)
signs. There may be no embedded spaces, and all
service names must belong to the specified proto-
col. Since service names may contain embedded
- minus signs, the starting entry of a range can't be
- a service name; it can be a port number, however.
- Here are some sample addresses:
- -i6 - IPv6 only
- TCP:25 - TCP and port 25
- @1.2.3.4 - Internet IPv4 host address 1.2.3.4
- @[3ffe:1ebc::1]:1234 - Internet IPv6 host address
- 3ffe:1ebc::1, port 1234
- UDP:who - UDP who service port
- TCP@lsof.itap:513 - TCP, port 513 and host name lsof.itap
- tcp@foo:1-10,smtp,99 - TCP, ports 1 through 10,
+SunOS 5.9 Last change: Revision-4.90 12
-SunOS 5.9 Last change: Revision-4.89 12
+Maintenance Procedures LSOF(8)
-Maintenance Procedures LSOF(8)
+ minus signs, the starting entry of a range can't be
+ a service name; it can be a port number, however.
+ Here are some sample addresses:
+ -i6 - IPv6 only
+ TCP:25 - TCP and port 25
+ @1.2.3.4 - Internet IPv4 host address 1.2.3.4
+ @[3ffe:1ebc::1]:1234 - Internet IPv6 host address
+ 3ffe:1ebc::1, port 1234
+ UDP:who - UDP who service port
+ TCP@lsof.itap:513 - TCP, port 513 and host name lsof.itap
+ tcp@foo:1-10,smtp,99 - TCP, ports 1 through 10,
service name smtp, port 99, host name foo
tcp@bar:1-smtp - TCP, ports 1 through smtp, host bar
:time - either TCP, UDP or UDPLITE time service port
- -K selects the listing of tasks (threads) of
+ -K k selects the listing of tasks (threads) of
processes, on dialects where task (thread) report-
ing is supported. (If help output - i.e., the out-
put of the -h or -? options - shows this option,
then task (thread) reporting is supported by the
dialect.)
+ If -K is followed by a value, k, it must be ``i''.
+ That causes lsof to ignore tasks, particularly in
+ the default, list-everything case when no other
+ options are specified.
+
When -K and -a are both specified on Linux, and the
tasks of a main process are selected by other
options, the main process will also be listed as
@@ -831,6 +849,20 @@ Maintenance Procedures LSOF(8)
names. It is also useful when login name lookup is
working improperly or slowly.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 13
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
+|-L [l] enables (`+') or disables (`-') the listing of file
link counts, where they are available - e.g., they
aren't available for sockets, or most FIFOs and
@@ -849,20 +881,6 @@ Maintenance Procedures LSOF(8)
files on the specified file system.
For other link count comparisons, use field output
-
-
-
-SunOS 5.9 Last change: Revision-4.89 13
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
(-F) and a post-processing script or program.
+|-m m specifies an alternate kernel memory file or
@@ -897,6 +915,20 @@ Maintenance Procedures LSOF(8)
-h or -? options to see if the +m and +m m options
are available.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 14
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
+|-M Enables (+) or disables (-) the reporting of port-
mapper registrations for local TCP, UDP and UDPLITE
ports, where port mapping is supported. (See the
@@ -915,20 +947,6 @@ Maintenance Procedures LSOF(8)
or enabling it when already enabled is acceptable.
When portmapper registration reporting is enabled,
lsof displays the portmapper registration (if any)
-
-
-
-SunOS 5.9 Last change: Revision-4.89 14
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
for local TCP, UDP or UDPLITE ports in square
brackets immediately following the port numbers or
service names - e.g., ``:1234[name]'' or
@@ -963,6 +981,20 @@ Maintenance Procedures LSOF(8)
tration reporting issues.
Portmapper registration reporting is supported only
+
+
+
+SunOS 5.9 Last change: Revision-4.90 15
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
on dialects that have RPC header files. (Some
Linux distributions with GlibC 2.14 do not have
them.) When portmapper registration reporting is
@@ -981,20 +1013,6 @@ Maintenance Procedures LSOF(8)
changed to OFFSET. Note: on some UNIX dialects
lsof can't obtain accurate or consistent file
offset information from its kernel data sources,
-
-
-
-SunOS 5.9 Last change: Revision-4.89 15
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
sometimes just for particular kinds of files (e.g.,
socket files.) Consult the lsof FAQ (The FAQ sec-
tion gives its location.) for more information.
@@ -1030,6 +1048,19 @@ Maintenance Procedures LSOF(8)
option in the output of the -h or -? option to
determine the default that is in effect.
+
+
+SunOS 5.9 Last change: Revision-4.90 16
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
-O directs lsof to bypass the strategy it uses to
avoid being blocked by some kernel operations -
i.e., doing them in forked child processes. See
@@ -1048,19 +1079,6 @@ Maintenance Procedures LSOF(8)
e.g., ``123'' or ``123,^456''. (There should be no
spaces in the set.)
-
-
-SunOS 5.9 Last change: Revision-4.89 16
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
PID numbers that begin with `^' (negation)
represent exclusions.
@@ -1095,6 +1113,20 @@ Maintenance Procedures LSOF(8)
zero if any open files were ever listed; one, if
none were ever listed.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 17
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
Lsof marks the end of each listing: if field out-
put is in progress (the -F, option has been speci-
fied), the default marker is `m'; otherwise the
@@ -1113,20 +1145,6 @@ Maintenance Procedures LSOF(8)
format, ``%n''. Note also that when <fmt> contains
spaces or other characters that affect the shell's
interpretation of arguments, <fmt> must be quoted
-
-
-
-SunOS 5.9 Last change: Revision-4.89 17
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
appropriately.
Repeat mode reduces lsof startup overhead, so it is
@@ -1161,9 +1179,28 @@ Maintenance Procedures LSOF(8)
a colon (`:') and a comma-separated protocol state
name list, the option causes open TCP and UDP files
to be excluded if their state name(s) are in the
+
+
+
+SunOS 5.9 Last change: Revision-4.90 18
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
list (s) preceded by a `^'; or included if their
name(s) are not preceded by a `^'.
+ Dialects that support this option may support only
+ one protocol. When an unsupported protocol is
+ specified, a message will be displayed indicating
+ state names for the protocol are unavailable.
+
When an inclusion list is defined, only network
files with state names in the list will be present
in the lsof output. Thus, specifying one state
@@ -1179,20 +1216,6 @@ Maintenance Procedures LSOF(8)
trolled by the specified exclusions and inclusions,
the -i option must be specified, too. If only a
single protocol's files are to be listed, add its
-
-
-
-SunOS 5.9 Last change: Revision-4.89 18
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
name as an argument to the -i option.
For example, to list only network files with TCP
@@ -1222,6 +1245,20 @@ Maintenance Procedures LSOF(8)
The -o (without a following decimal digit count)
and -s option (without a following protocol and
state name list) are mutually exclusive; they can't
+
+
+
+SunOS 5.9 Last change: Revision-4.90 19
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
both be specified. When neither is specified, lsof
displays whatever value - size or offset - is
appropriate and available for the type of file.
@@ -1245,20 +1282,6 @@ Maintenance Procedures LSOF(8)
addresses. In normal output the information
appears in parentheses, each item except TCP or TPI
state name identified by a keyword, followed by
-
-
-
-SunOS 5.9 Last change: Revision-4.89 19
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
`=', separated from others by a single space:
@@ -1288,6 +1311,20 @@ Maintenance Procedures LSOF(8)
f selects reporting of socket options,
states and values, and TCP flags and
+
+
+
+SunOS 5.9 Last change: Revision-4.90 20
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
values.
q selects queue length reporting.
s selects connection state reporting.
@@ -1311,20 +1348,6 @@ Maintenance Procedures LSOF(8)
TCP flags and one TCP value may be reported (when
available in the UNIX dialect) in the form of the
names that commonly appear after SO_, so_, SS_,
-
-
-
-SunOS 5.9 Last change: Revision-4.89 20
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
TCP_ and TF_ in the dialect's header files - most
often <sys/socket.h>, <sys/socketvar.h> and
<netinet/tcp_var.h>. Consult those header files
@@ -1354,6 +1377,20 @@ Maintenance Procedures LSOF(8)
SNDBUF send buffer length (SO_SNDBUF)
Details on what socket options and values, socket
+
+
+
+SunOS 5.9 Last change: Revision-4.90 21
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
states, and TCP flags and values may be displayed
for particular UNIX dialects may be found in the
answer to the ``Why doesn't lsof report socket
@@ -1378,19 +1415,6 @@ Maintenance Procedures LSOF(8)
in a single ORed set before participating in AND
option selection.
-
-
-SunOS 5.9 Last change: Revision-4.89 21
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
If a login name or user ID is preceded by a `^', it
becomes a negation - i.e., files of processes owned
by the login name or user ID will never be listed.
@@ -1419,6 +1443,20 @@ Maintenance Procedures LSOF(8)
names, Internet addresses or files, login names,
NFS files, PIDs, PGIDs, and UIDs.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 22
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
When other options are ANDed to search options, or
compile-time options restrict the listing of some
files, lsof may not report that it failed to find a
@@ -1444,19 +1482,6 @@ Maintenance Procedures LSOF(8)
when they are already disabled or enabling them
when already enabled is acceptable.
-
-
-SunOS 5.9 Last change: Revision-4.89 22
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
The -t option selects the -w option.
-x [fl] may accompany the +d and +D options to direct their
@@ -1484,6 +1509,20 @@ Maintenance Procedures LSOF(8)
reporting of executed text file and shared library
references.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 23
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
WARNING: because this option uses the kernel
readx() function, its use on a busy AIX system
might cause an application process to hang so com-
@@ -1510,19 +1549,6 @@ Maintenance Procedures LSOF(8)
an AIX kernel directory search kernel error, known
as the Stale Segment ID bug.
-
-
-SunOS 5.9 Last change: Revision-4.89 23
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
The readx() function, used by lsof or any other
program to access some sections of kernel virtual
memory, can trigger the Stale Segment ID bug. It
@@ -1549,6 +1575,20 @@ Maintenance Procedures LSOF(8)
has an extremely large number of open TCP, UDP and
UDPLITE files, the processing of whose information
in the /proc/net/tcp* and /proc/net/udp* files
+
+
+
+SunOS 5.9 Last change: Revision-4.90 24
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
would take lsof a long time, and whose reporting is
not of interest.
@@ -1575,20 +1615,6 @@ Maintenance Procedures LSOF(8)
-z [z] specifies how Solaris 10 and higher zone informa-
tion is to be handled.
-
-
-
-SunOS 5.9 Last change: Revision-4.89 24
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
Without a following argument - e.g., NO z - the
option specifies that zone names are to be listed
in the ZONE output column.
@@ -1614,14 +1640,28 @@ Maintenance Procedures LSOF(8)
The -Z option may be followed by a wildcard secu-
rity context name, Z. That causes lsof to list
- only open files for processes in that security con-
- text. Multiple -Z Z option and argument pairs may
- be specified to form a list of security contexts.
- Any open file of any process in any of the security
- contexts will be listed, subject to other condi-
- tions specified by other options and arguments.
- Note that Z can be A:B:C or *:B:C or A:B:* or *:*:C
- to match against the A:B:C context.
+ only open files for processes in that security
+
+
+
+SunOS 5.9 Last change: Revision-4.90 25
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
+ context. Multiple -Z Z option and argument pairs
+ may be specified to form a list of security con-
+ texts. Any open file of any process in any of the
+ security contexts will be listed, subject to other
+ conditions specified by other options and argu-
+ ments. Note that Z can be A:B:C or *:B:C or A:B:*
+ or *:*:C to match against the A:B:C context.
-- The double minus sign option is a marker that sig-
nals the end of the keyed options. It may be used,
@@ -1641,20 +1681,6 @@ Maintenance Procedures LSOF(8)
list all the files open on the file system. To be
considered a file system, the name must match a
mounted-on directory name in mount(8) output, or
-
-
-
-SunOS 5.9 Last change: Revision-4.89 25
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
match the name of a block device associated with a
mounted-on directory name. The +|-f option may be
used to force lsof to consider a name a file system
@@ -1681,6 +1707,20 @@ Maintenance Procedures LSOF(8)
in the kernel socket structure. (See the next
paragraph for an exception to that rule for Linux.)
Specifying a relative path - e.g., ./file - in
+
+
+
+SunOS 5.9 Last change: Revision-4.90 26
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
place of the file's absolute path - e.g., /tmp/file
- won't work because lsof must match the characters
you specify with what it finds in the kernel UNIX
@@ -1707,20 +1747,6 @@ Maintenance Procedures LSOF(8)
open files whose device and inode match that of the
specified path name.
-
-
-
-SunOS 5.9 Last change: Revision-4.89 26
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
If you have also specified the -b option, the only
names you may safely specify are file systems for
which your mount table supplies alternate device
@@ -1747,6 +1773,20 @@ AFS
Lsof may have trouble identifying all aspects of AFS files
in supported dialects when AFS kernel support is implemented
+
+
+
+SunOS 5.9 Last change: Revision-4.90 27
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
via dynamic modules whose addresses do not appear in the
kernel's variable name list. In that case, lsof may have to
guess at the identity of AFS files, and might not be able to
@@ -1773,20 +1813,6 @@ SECURITY
Lsof has three features that may cause security concerns.
First, its default compilation mode allows anyone to list
all open files with it. Second, by default it creates a
-
-
-
-SunOS 5.9 Last change: Revision-4.89 27
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
user-readable and user-writable device cache file in the
home directory of the real user ID that executes lsof. (The
list-all-open-files and device cache features may be dis-
@@ -1812,6 +1838,21 @@ Maintenance Procedures LSOF(8)
gives the status of the HASSECURITY and HASNOSOCKSECURITY
definitions.
+
+
+
+
+SunOS 5.9 Last change: Revision-4.90 28
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
See the Security section of the 00README file of the lsof
distribution for information on building lsof with the
HASSECURITY and HASNOSOCKSECURITY options enabled.
@@ -1840,19 +1881,6 @@ Maintenance Procedures LSOF(8)
of the lsof distribution and the lsof FAQ (The FAQ section
gives its location.)
-
-
-SunOS 5.9 Last change: Revision-4.89 28
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
WHEN IN DOUBT, YOU CAN TEMPORARILY DISABLE THE USE OF THE
DEVICE CACHE FILE WITH THE -Di OPTION.
@@ -1876,6 +1904,21 @@ OUTPUT
form (e.g., ``\xab''). Space is non-printable in the COM-
MAND column (``\x20'') and printable elsewhere.
+
+
+
+
+SunOS 5.9 Last change: Revision-4.90 29
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
For some dialects - if HASSETLOCALE is defined in the
dialect's machine.h header file - lsof will print the
extended 8 bit characters of a language locale. The lsof
@@ -1906,19 +1949,6 @@ OUTPUT
tions in the lsof FAQ (The FAQ section gives its location.)
for more information.
-
-
-SunOS 5.9 Last change: Revision-4.89 29
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
Lsof dynamically sizes the output columns each time it runs,
guaranteeing that each column is a minimum size. It also
guarantees that each column is separated from its predeces-
@@ -1941,6 +1971,20 @@ Maintenance Procedures LSOF(8)
If a zero w value is specified to the +c w
option, the column contains all the characters of
the name of the UNIX command associated with the
+
+
+
+SunOS 5.9 Last change: Revision-4.90 30
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
process.
All command name characters maintained by the
@@ -1963,6 +2007,14 @@ Maintenance Procedures LSOF(8)
A blank TID column in Linux indicates a process -
i.e., a non-task.
+ TASKCMD is the task command name. Generally this will be
+ the same as the process named in the COMMAND
+ column, but some task implementations (e.g.,
+ Linux) permit a task to change its command name.
+
+ The TASKCMD column width is subject to the same
+ size limitation as the COMMAND column.
+
ZONE is the Solaris 10 and higher zone name. This
column must be selected with the -z option.
@@ -1972,19 +2024,6 @@ Maintenance Procedures LSOF(8)
the -Z option is inhibited when SELinux is dis-
abled in the running Linux kernel.
-
-
-SunOS 5.9 Last change: Revision-4.89 30
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
PPID is the Parent Process IDentification number of
the process. It is only displayed when the -R
option has been specified.
@@ -1998,6 +2037,20 @@ Maintenance Procedures LSOF(8)
reported by ps(1). However, on Linux USER is the
user ID number or login that owns the directory
in /proc where lsof finds information about the
+
+
+
+SunOS 5.9 Last change: Revision-4.90 31
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
process. Usually that is the same value reported
by ps(1), but may differ when the process has
changed its effective user ID. (See the -l
@@ -2037,20 +2090,6 @@ Maintenance Procedures LSOF(8)
lock characters, describing the type of lock
applied to the file:
-
-
-
-SunOS 5.9 Last change: Revision-4.89 31
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
N for a Solaris NFS lock of unknown type;
r for read lock on part of the file;
R for a read lock on the entire file;
@@ -2064,6 +2103,20 @@ Maintenance Procedures LSOF(8)
entire file;
space if there is no lock.
+
+
+
+SunOS 5.9 Last change: Revision-4.90 32
+
+
+
+
+
+
+Maintenance Procedures LSOF(8)
+
+
+
See the LOCKS section for more information on the
lock information character.
@@ -2104,31 +2157,32 @@ Maintenance Procedures LSOF(8)
or ``DOOR'' for a VDOOR file;
+ or ``FIFO'' for a FIFO special file;
+ or ``KQUEUE'' for a BSD style kernel event queue
+ file;
-SunOS 5.9 Last change: Revision-4.89 32
+ or ``LINK'' for a symbolic link file;
+ or ``MPB'' for a multiplexed block file;
+ or ``MPC'' for a multiplexed character file;
+ or ``NOFD'' for a Linux /proc/<PID>/fd directory
-Maintenance Procedures LSOF(8)
+SunOS 5.9 Last change: Revision-4.90 33
- or ``FIFO'' for a FIFO special file;
- or ``KQUEUE'' for a BSD style kernel event queue
- file;
- or ``LINK'' for a symbolic link file;
- or ``MPB'' for a multiplexed block file;
+Maintenance Procedures LSOF(8)
+
- or ``MPC'' for a multiplexed character file;
- or ``NOFD'' for a Linux /proc/<PID>/fd directory
that can't be opened -- the directory path
appears in the NAME column, followed by an error
message;
@@ -2169,31 +2223,31 @@ Maintenance Procedures LSOF(8)
or ``PLDR'' for a /proc/lpw directory;
+ or ``PLDT'' for a /proc/ldt file;
+ or ``PLPI'' for a /proc/lpsinfo file;
+ or ``PLST'' for a /proc/lstatus file;
-SunOS 5.9 Last change: Revision-4.89 33
+ or ``PLU'' for a /proc/lusage file;
+ or ``PLWG'' for a /proc/gwindows file;
+ or ``PLWI'' for a /proc/lwpsinfo file;
-Maintenance Procedures LSOF(8)
+SunOS 5.9 Last change: Revision-4.90 34
- or ``PLDT'' for a /proc/ldt file;
- or ``PLPI'' for a /proc/lpsinfo file;
- or ``PLST'' for a /proc/lstatus file;
- or ``PLU'' for a /proc/lusage file;
+Maintenance Procedures LSOF(8)
- or ``PLWG'' for a /proc/gwindows file;
- or ``PLWI'' for a /proc/lwpsinfo file;
or ``PLWS'' for a /proc/lwpstatus file;
@@ -2235,29 +2289,31 @@ Maintenance Procedures LSOF(8)
or ``PSXSEM'' for a POSIX semaphore file;
+ or ``PSXSHM'' for a POSIX shared memory file;
+
+ or ``PTS'' for a /dev/pts file;
+ or ``PUSG'' for a /proc/usage file;
+ or ``PW'' for a /proc/watch file;
-SunOS 5.9 Last change: Revision-4.89 34
+ or ``PXMP'' for a /proc/xmap file;
+ or ``REG'' for a regular file;
+SunOS 5.9 Last change: Revision-4.90 35
-Maintenance Procedures LSOF(8)
- or ``PSXSHM'' for a POSIX shared memory file;
- or ``PUSG'' for a /proc/usage file;
- or ``PW'' for a /proc/watch file;
+Maintenance Procedures LSOF(8)
- or ``PXMP'' for a /proc/xmap file;
- or ``REG'' for a regular file;
or ``SMT'' for a shared memory transport file;
@@ -2301,10 +2357,20 @@ Maintenance Procedures LSOF(8)
BAS block, test, and set in use
BKIU block if in use
BL use block offsets
+ BSK block seek
+ CA copy avoid
+ CIO concurrent I/O
+ CLON clone
+ CLRD CL read
+ CR create
+ DF defer
+ DFI defer IND
+ DFLU data flush
+ DIR direct
-SunOS 5.9 Last change: Revision-4.89 35
+SunOS 5.9 Last change: Revision-4.90 36
@@ -2315,16 +2381,6 @@ Maintenance Procedures LSOF(8)
- BSK block seek
- CA copy avoid
- CIO concurrent I/O
- CLON clone
- CLRD CL read
- CR create
- DF defer
- DFI defer IND
- DFLU data flush
- DIR direct
DLY delay
DOCL do clone
DSYN data-only integrity
@@ -2367,10 +2423,20 @@ Maintenance Procedures LSOF(8)
REV revoked
RSH shared read
RSYN read synchronization
+ RW read and write access
+ SL shared lock
+ SNAP cooked snapshot
+ SOCK socket
+ SQSH Sequent shared set on open
+ SQSV Sequent SVM set on open
+ SQR Sequent set repair on open
+ SQS1 Sequent full shared open
+ SQS2 Sequent partial shared open
+ STPI stop I/O
-SunOS 5.9 Last change: Revision-4.89 36
+SunOS 5.9 Last change: Revision-4.90 37
@@ -2381,16 +2447,6 @@ Maintenance Procedures LSOF(8)
- RW read and write access
- SL shared lock
- SNAP cooked snapshot
- SOCK socket
- SQSH Sequent shared set on open
- SQSV Sequent SVM set on open
- SQR Sequent set repair on open
- SQS1 Sequent full shared open
- SQS2 Sequent partial shared open
- STPI stop I/O
SWR synchronous read
SYN file integrity while writing
TCPM avoid TCP collision
@@ -2433,29 +2489,29 @@ Maintenance Procedures LSOF(8)
ally a concatenation of device and node number)
when n has been specified to +f;
+ DEVICE contains the device numbers, separated by commas,
+ for a character special, block special, regular,
+ directory or NFS file;
+ or ``memory'' for a memory file system node under
+ Tru64 UNIX;
+ or the address of the private data area of a
+ Solaris socket stream;
-SunOS 5.9 Last change: Revision-4.89 37
+SunOS 5.9 Last change: Revision-4.90 38
-Maintenance Procedures LSOF(8)
- DEVICE contains the device numbers, separated by commas,
- for a character special, block special, regular,
- directory or NFS file;
+Maintenance Procedures LSOF(8)
- or ``memory'' for a memory file system node under
- Tru64 UNIX;
- or the address of the private data area of a
- Solaris socket stream;
or a kernel reference address that identifies the
file (The kernel reference address may be used
@@ -2499,30 +2555,30 @@ Maintenance Procedures LSOF(8)
and an offset (i.e., its title is SIZE/OFF).
If the -o option is specified, lsof always
+ displays the file offset (or nothing if no offset
+ is available) and labels the column OFFSET. The
+ offset always begins with ``0t'' or ``0x'' as
+ described above.
+ The lsof user can control the switch from ``0t''
+ to ``0x'' with the -o o option. Consult its
+ description for more information.
+ If the -s option is specified, lsof always
-SunOS 5.9 Last change: Revision-4.89 38
+SunOS 5.9 Last change: Revision-4.90 39
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- displays the file offset (or nothing if no offset
- is available) and labels the column OFFSET. The
- offset always begins with ``0t'' or ``0x'' as
- described above.
- The lsof user can control the switch from ``0t''
- to ``0x'' with the -o o option. Consult its
- description for more information.
- If the -s option is specified, lsof always
displays the file size (or nothing if no size is
available) and labels the column SIZE. The -o
and -s options are mutually exclusive; they can't
@@ -2565,10 +2621,20 @@ Maintenance Procedures LSOF(8)
network file; the local host name or IP number is
followed by a colon (':'), the port, ``->'', and
the two-part remote address; IP addresses may be
+ reported as numbers or names, depending on the
+ +|-M, -n, and -P options; colon-separated IPv6
+ numbers are enclosed in square brackets; IPv4
+ INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED
+ addresses, and zero port numbers are represented
+ by an asterisk ('*'); a UDP destination address
+ may be followed by the amount of time elapsed
+ since the last packet was sent to the destina-
+ tion; TCP, UDP and UDPLITE remote addresses may
+ be followed by TCP/TPI information in parentheses
-SunOS 5.9 Last change: Revision-4.89 39
+SunOS 5.9 Last change: Revision-4.90 40
@@ -2579,16 +2645,6 @@ Maintenance Procedures LSOF(8)
- reported as numbers or names, depending on the
- +|-M, -n, and -P options; colon-separated IPv6
- numbers are enclosed in square brackets; IPv4
- INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED
- addresses, and zero port numbers are represented
- by an asterisk ('*'); a UDP destination address
- may be followed by the amount of time elapsed
- since the last packet was sent to the destina-
- tion; TCP, UDP and UDPLITE remote addresses may
- be followed by TCP/TPI information in parentheses
- state (e.g., ``(ESTABLISHED)'', ``(Unbound)''),
queue sizes, and window sizes (not all dialects)
- in a fashion similar to what netstat(1)
@@ -2632,28 +2688,29 @@ Maintenance Procedures LSOF(8)
followed by fourteen comma-separated bytes of a
non-Internet raw socket address;
+ or the HP-UX x.25 local address, followed by the
+ virtual connection number (if any), followed by
+ the remote address (if any);
+ or ``(dead)'' for disassociated Tru64 UNIX files
+ - typically terminal files that have been flagged
+ with the TIOCNOTTY ioctl and closed by daemons;
-SunOS 5.9 Last change: Revision-4.89 40
+ or ``rd=<offset>'' and ``wr=<offset>'' for the
+SunOS 5.9 Last change: Revision-4.90 41
-Maintenance Procedures LSOF(8)
- or the HP-UX x.25 local address, followed by the
- virtual connection number (if any), followed by
- the remote address (if any);
+Maintenance Procedures LSOF(8)
+
- or ``(dead)'' for disassociated Tru64 UNIX files
- - typically terminal files that have been flagged
- with the TIOCNOTTY ioctl and closed by daemons;
- or ``rd=<offset>'' and ``wr=<offset>'' for the
values of the read and write offsets of a FIFO;
or ``clone n:/dev/event'' for SCO OpenServer file
@@ -2697,29 +2754,29 @@ Maintenance Procedures LSOF(8)
vnode addresses. <direction> will be ``<-'' if <address2>
has been fattach'ed to this vnode whose address is
<address1>; and ``->'' if <address1>, the vnode address of
+ this vnode, has been fattach'ed to <address2>. <address1>
+ may be omitted if it already appears in the DEVICE column.
+ Lsof may add two parenthetical notes to the NAME column for
+ open Solaris 10 files: ``(?)'' if lsof considers the path
+ name of questionable accuracy; and ``(deleted)'' if the -X
+ option has been specified and lsof detects the open file's
+ path name has been deleted. Consult the lsof FAQ (The FAQ
+ section gives its location.) for more information on these
-SunOS 5.9 Last change: Revision-4.89 41
+SunOS 5.9 Last change: Revision-4.90 42
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- this vnode, has been fattach'ed to <address2>. <address1>
- may be omitted if it already appears in the DEVICE column.
- Lsof may add two parenthetical notes to the NAME column for
- open Solaris 10 files: ``(?)'' if lsof considers the path
- name of questionable accuracy; and ``(deleted)'' if the -X
- option has been specified and lsof detects the open file's
- path name has been deleted. Consult the lsof FAQ (The FAQ
- section gives its location.) for more information on these
NAME column additions.
LOCKS
@@ -2763,29 +2820,29 @@ OUTPUT FOR OTHER PROGRAMS
It is possible to think of field output as process and file
sets. A process set begins with a field whose identifier is
`p' (for process IDentifier (PID)). It extends to the
+ beginning of the next PID field or the beginning of the
+ first file set of the process, whichever comes first.
+ Included in the process set are fields that identify the
+ command, the process group IDentification (PGID) number, the
+ task (thread) ID (TID), and the user ID (UID) number or
+ login name.
+ A file set begins with a field whose identifier is `f' (for
+ file descriptor). It is followed by lines that describe the
-SunOS 5.9 Last change: Revision-4.89 42
+SunOS 5.9 Last change: Revision-4.90 43
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- beginning of the next PID field or the beginning of the
- first file set of the process, whichever comes first.
- Included in the process set are fields that identify the
- command, the process group IDentification (PGID) number, the
- task (thread) ID (TID), and the user ID (UID) number or
- login name.
- A file set begins with a field whose identifier is `f' (for
- file descriptor). It is followed by lines that describe the
file's access mode, lock state, type, device, size, offset,
inode, protocol, name and stream module names. It extends
to the beginning of the next file or process set, whichever
@@ -2829,10 +2886,19 @@ Maintenance Procedures LSOF(8)
K tasK ID
k link count
l file's lock status
+ L process login name
+ m marker between repeated output
+ M the task comMand name
+ n file name, comment, Internet address
+ N node identifier (ox<hexadecimal>
+ o file's offset (decimal)
+ p process ID (always selected)
+ P protocol name
+ r raw device number (0x<hexadecimal>)
-SunOS 5.9 Last change: Revision-4.89 43
+SunOS 5.9 Last change: Revision-4.90 44
@@ -2843,14 +2909,6 @@ Maintenance Procedures LSOF(8)
- L process login name
- m marker between repeated output
- n file name, comment, Internet address
- N node identifier (ox<hexadecimal>
- o file's offset (decimal)
- p process ID (always selected)
- P protocol name
- r raw device number (0x<hexadecimal>)
R parent process ID
s file's size (decimal)
S file's stream identification
@@ -2895,29 +2953,29 @@ Maintenance Procedures LSOF(8)
device numbers; file inode number and protocol name; file
name and stream identification; file size and offset. One
or the other member of these mutually exclusive sets will
+ appear in field output, but not both.
+ Normally lsof ends each field with a NL (012) character.
+ The 0 (zero) field identifier character may be specified to
+ change the field terminator character to a NUL (000). A NUL
+ terminator may be easier to process with xargs (1), for
+ example, or with programs whose quoting mechanisms may not
+ easily cope with the range of characters in the field
-SunOS 5.9 Last change: Revision-4.89 44
+SunOS 5.9 Last change: Revision-4.90 45
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- appear in field output, but not both.
- Normally lsof ends each field with a NL (012) character.
- The 0 (zero) field identifier character may be specified to
- change the field terminator character to a NUL (000). A NUL
- terminator may be easier to process with xargs (1), for
- example, or with programs whose quoting mechanisms may not
- easily cope with the range of characters in the field out-
- put. When the NUL field terminator is in use, lsof ends
+ output. When the NUL field terminator is in use, lsof ends
each process and file set with a NL (012).
Three aids to producing programs that can process lsof field
@@ -2961,26 +3019,27 @@ BLOCKS AND TIMEOUTS
file system information, it normally continues, although
with less information available to display about open files.
+ Lsof can also be directed to avoid the protection of timers
+ and child processes when using the kernel functions that
+ might block by specifying the -O option. While this will
+ allow lsof to start up with less overhead, it exposes lsof
+ completely to the kernel situations that might block it.
+ Use this option cautiously.
-SunOS 5.9 Last change: Revision-4.89 45
+SunOS 5.9 Last change: Revision-4.90 46
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
+
- Lsof can also be directed to avoid the protection of timers
- and child processes when using the kernel functions that
- might block by specifying the -O option. While this will
- allow lsof to start up with less overhead, it exposes lsof
- completely to the kernel situations that might block it.
- Use this option cautiously.
AVOIDING KERNEL BLOCKS
You can use the -b option to tell lsof to avoid using kernel
@@ -3027,10 +3086,17 @@ ALTERNATE DEVICE NUMBERS
lsof will report the device number it obtained. (You can
suppress the report by specifying the -w option.)
+ You can assist this process if your mount table is supported
+ with an /etc/mtab or /etc/mnttab file that contains an
+ options field by adding a ``dev=xxxx'' field for mount
+ points that do not have one in their options strings. Note:
+ you must be able to edit the file - i.e., some mount tables
+ like recent Solaris /etc/mnttab or Linux /proc/mounts are
+ read-only and can't be modified.
-SunOS 5.9 Last change: Revision-4.89 46
+SunOS 5.9 Last change: Revision-4.90 47
@@ -3041,14 +3107,6 @@ Maintenance Procedures LSOF(8)
- You can assist this process if your mount table is supported
- with an /etc/mtab or /etc/mnttab file that contains an
- options field by adding a ``dev=xxxx'' field for mount
- points that do not have one in their options strings. Note:
- you must be able to edit the file - i.e., some mount tables
- like recent Solaris /etc/mnttab or Linux /proc/mounts are
- read-only and can't be modified.
-
You may also be able to supply device numbers using the +m
and +m m options, provided they are supported by your
dialect. Check the output of lsof's -h or -? options to see
@@ -3092,11 +3150,19 @@ Maintenance Procedures LSOF(8)
``assuming "dev=xxxx" from ...''.
KERNEL NAME CACHE
+ Lsof is able to examine the kernel's name cache or use other
+ kernel facilities (e.g., the ADVFS 4.x tag_to_path() func-
+ tion under Tru64 UNIX) on some dialects for most file system
+ types, excluding AFS, and extract recently used path name
+ components from it. (AFS file system path lookups don't use
+ the kernel's name cache; some Solaris VxFS file system
+ operations apparently don't use it, either.)
-SunOS 5.9 Last change: Revision-4.89 47
+
+SunOS 5.9 Last change: Revision-4.90 48
@@ -3107,14 +3173,6 @@ Maintenance Procedures LSOF(8)
- Lsof is able to examine the kernel's name cache or use other
- kernel facilities (e.g., the ADVFS 4.x tag_to_path() func-
- tion under Tru64 UNIX) on some dialects for most file system
- types, excluding AFS, and extract recently used path name
- components from it. (AFS file system path lookups don't use
- the kernel's name cache; some Solaris VxFS file system
- operations apparently don't use it, either.)
-
Lsof reports the complete paths it finds in the NAME column.
If lsof can't report all components in a path, it reports in
the NAME column the file system name, followed by a space,
@@ -3159,27 +3217,27 @@ Maintenance Procedures LSOF(8)
If you want to know why lsof can't report path name com-
ponents for some dialects, see the lsof FAQ (The FAQ section
+ gives its location.)
+DEVICE CACHE FILE
+ Examining all members of the /dev (or /devices) node tree
+ with stat(2) functions can be time consuming. What's more,
+ the information that lsof needs - device number, inode
+ number, and path - rarely changes.
-SunOS 5.9 Last change: Revision-4.89 48
+SunOS 5.9 Last change: Revision-4.90 49
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- gives its location.)
-DEVICE CACHE FILE
- Examining all members of the /dev (or /devices) node tree
- with stat(2) functions can be time consuming. What's more,
- the information that lsof needs - device number, inode
- number, and path - rarely changes.
Consequently, lsof normally maintains an ASCII text file of
cached /dev (or /devices) information (exception: the
@@ -3225,28 +3283,27 @@ DEVICE CACHE FILE
When a new device is added to the system, the device cache
file may need to be recreated. Since lsof compares the
mtime of the device cache file with the mtime and ctime of
+ the /dev (or /devices) directory, it usually detects that a
+ new device has been added; in that case lsof issues a warn-
+ ing message and attempts to rebuild the device cache file.
+ Whenever lsof writes a device cache file, it sets its owner-
+ ship to the real UID of the executing process, and its per-
+ mission modes to 0600, this restricting its reading and
+ writing to the file's owner.
-SunOS 5.9 Last change: Revision-4.89 49
-
+SunOS 5.9 Last change: Revision-4.90 50
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- the /dev (or /devices) directory, it usually detects that a
- new device has been added; in that case lsof issues a warn-
- ing message and attempts to rebuild the device cache file.
- Whenever lsof writes a device cache file, it sets its owner-
- ship to the real UID of the executing process, and its per-
- mission modes to 0600, this restricting its reading and
- writing to the file's owner.
LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS
Two permissions of the lsof executable affect its ability to
@@ -3277,8 +3334,8 @@ LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS
AIX 5.[12] and 5.3-ML1
Apple Darwin 7.x Power Macintosh systems
FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems
- FreeBSD 5.x and [6789].x for Alpha, AMD64 and Sparc64-based
- systems
+ FreeBSD 5.x, [6789].x and 1[012].8for Alpha, AMD64 and Sparc64
+ based systems
HP-UX 11.00
NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based
systems
@@ -3290,29 +3347,29 @@ LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS
Solaris 2.6, 8, 9 and 10
Tru64 UNIX 5.1
+ (Note: lsof for AIX 5L and above needs setuid-root permis-
+ sion if its -X option is used.)
+ Lsof for these dialects does not support a device cache, so
+ the permissions given to the executable don't apply to the
+ device cache file.
+ Linux
-SunOS 5.9 Last change: Revision-4.89 50
+SunOS 5.9 Last change: Revision-4.90 51
-Maintenance Procedures LSOF(8)
- (Note: lsof for AIX 5L and above needs setuid-root permis-
- sion if its -X option is used.)
+Maintenance Procedures LSOF(8)
- Lsof for these dialects does not support a device cache, so
- the permissions given to the executable don't apply to the
- device cache file.
- Linux
DEVICE CACHE FILE PATH FROM THE -D OPTION
The -D option provides limited means for specifying the dev-
@@ -3356,11 +3413,20 @@ DEVICE CACHE FILE PATH FROM THE -D OPTION
only to a path it considers legitimate for the lsof process
effective and real UIDs.
+DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE
+ Lsof's second choice for the device cache file is the con-
+ tents of the LSOFDEVCACHE environment variable. It avoids
+ this choice if the lsof process is setuid-root, or the real
+ UID of the process is root.
+ A further restriction applies to a device cache file path
+ taken from the LSOFDEVCACHE environment variable: lsof will
+ not write a device cache file to the path if the lsof pro-
+ cess doesn't surrender its setgid permission. (See the LSOF
-SunOS 5.9 Last change: Revision-4.89 51
+SunOS 5.9 Last change: Revision-4.90 52
@@ -3371,16 +3437,6 @@ Maintenance Procedures LSOF(8)
-DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE
- Lsof's second choice for the device cache file is the con-
- tents of the LSOFDEVCACHE environment variable. It avoids
- this choice if the lsof process is setuid-root, or the real
- UID of the process is root.
-
- A further restriction applies to a device cache file path
- taken from the LSOFDEVCACHE environment variable: lsof will
- not write a device cache file to the path if the lsof pro-
- cess doesn't surrender its setgid permission. (See the LSOF
PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS section for
information on implementations that don't surrender their
setgid permission.)
@@ -3423,30 +3479,30 @@ PERSONAL DEVICE CACHE PATH (DEFAULT)
cache file. This is the only time lsof uses two paths when
reading the device cache file.
+ The hostname part of the second component is the base name
+ of the executing host, as returned by gethostname(2). The
+ base name is defined to be the characters preceding the
+ first `.' in the gethostname(2) output, or all the gethost-
+ name(2) output if it contains no `.'.
+ The device cache file belongs to the user ID and is readable
+ and writable by the user ID alone - i.e., its modes are
+ 0600. Each distinct real user ID on a given host that exe-
+ cutes lsof has a distinct device cache file. The hostname
-SunOS 5.9 Last change: Revision-4.89 52
+SunOS 5.9 Last change: Revision-4.90 53
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- The hostname part of the second component is the base name
- of the executing host, as returned by gethostname(2). The
- base name is defined to be the characters preceding the
- first `.' in the gethostname(2) output, or all the gethost-
- name(2) output if it contains no `.'.
- The device cache file belongs to the user ID and is readable
- and writable by the user ID alone - i.e., its modes are
- 0600. Each distinct real user ID on a given host that exe-
- cutes lsof has a distinct device cache file. The hostname
part of the path distinguishes device cache files in an
NFS-mounted home directory into which device cache files are
written from several different hosts.
@@ -3489,30 +3545,30 @@ MODIFIED PERSONAL DEVICE CACHE PATH
lsof process is setuid-root or when the real UID of the pro-
cess is root.
+ Lsof will not write to a modified personal device cache file
+ path if the lsof process doesn't surrender setgid permis-
+ sion. (See the LSOF PERMISSIONS THAT AFFECT DEVICE CACHE
+ FILE ACCESS section for a list of implementations that nor-
+ mally don't surrender their setgid permission.)
+ If, for example, you want to create a sub-directory of per-
+ sonal device cache file paths by using the LSOFPERSDCPATH
+ environment variable to name it, and lsof doesn't surrender
+ its setgid permission, you will have to allow lsof to create
-SunOS 5.9 Last change: Revision-4.89 53
+SunOS 5.9 Last change: Revision-4.90 54
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- Lsof will not write to a modified personal device cache file
- path if the lsof process doesn't surrender setgid permis-
- sion. (See the LSOF PERMISSIONS THAT AFFECT DEVICE CACHE
- FILE ACCESS section for a list of implementations that nor-
- mally don't surrender their setgid permission.)
- If, for example, you want to create a sub-directory of per-
- sonal device cache file paths by using the LSOFPERSDCPATH
- environment variable to name it, and lsof doesn't surrender
- its setgid permission, you will have to allow lsof to create
device cache files at the standard personal path and move
them to your subdirectory with shell commands.
@@ -3554,31 +3610,30 @@ DIAGNOSTICS
definition. In this case, the output from the help options
will include the message:
+ Inaccessible /dev warnings are disabled.
+ Inaccessible device warning messages usually disappear after
+ lsof has created a working device cache file.
+EXAMPLES
+ For a more extensive set of examples, documented more fully,
+ see the 00QUICKSTART file of the lsof distribution.
-
-SunOS 5.9 Last change: Revision-4.89 54
+ To list all open files, use:
+SunOS 5.9 Last change: Revision-4.90 55
-Maintenance Procedures LSOF(8)
- Inaccessible /dev warnings are disabled.
- Inaccessible device warning messages usually disappear after
- lsof has created a working device cache file.
+Maintenance Procedures LSOF(8)
-EXAMPLES
- For a more extensive set of examples, documented more fully,
- see the 00QUICKSTART file of the lsof distribution.
- To list all open files, use:
lsof
@@ -3621,29 +3676,30 @@ EXAMPLES
lsof /u/abe/foo
+ To send a SIGHUP to the processes that have /u/abe/bar open,
+ use:
+ kill -HUP `lsof -t /u/abe/bar`
+ To find any open file, including an open UNIX domain socket
+ file, with the name /dev/log, use:
-SunOS 5.9 Last change: Revision-4.89 55
+ lsof /dev/log
+SunOS 5.9 Last change: Revision-4.90 56
-Maintenance Procedures LSOF(8)
- To send a SIGHUP to the processes that have /u/abe/bar open,
- use:
- kill -HUP `lsof -t /u/abe/bar`
- To find any open file, including an open UNIX domain socket
- file, with the name /dev/log, use:
+Maintenance Procedures LSOF(8)
+
- lsof /dev/log
To find processes with open files on the NFS file system
named /nfs/mount/point whose server is inaccessible, and
@@ -3687,30 +3743,29 @@ Maintenance Procedures LSOF(8)
To find an IP version 6 socket file (when the UNIX dialect
supports IPv6) by its associated numeric colon-form address,
+ use:
+ lsof -i@[0:1:2:3:4:5:6:7]
+ To find an IP version 6 socket file (when the UNIX dialect
+ supports IPv6) by an associated numeric colon-form address
+ that has a run of zeroes in it - e.g., the loop-back address
+ - use:
-SunOS 5.9 Last change: Revision-4.89 56
-
+ lsof -i@[::1]
+SunOS 5.9 Last change: Revision-4.90 57
-Maintenance Procedures LSOF(8)
- use:
- lsof -i@[0:1:2:3:4:5:6:7]
+Maintenance Procedures LSOF(8)
- To find an IP version 6 socket file (when the UNIX dialect
- supports IPv6) by an associated numeric colon-form address
- that has a run of zeroes in it - e.g., the loop-back address
- - use:
- lsof -i@[::1]
To obtain a repeat mode marker line that contains the
current time, use:
@@ -3753,31 +3808,30 @@ BUGS
The support for /proc file systems is available only for BSD
and Tru64 UNIX dialects, Linux, and dialects derived from
+ SYSV R4 - e.g., FreeBSD, NetBSD, OpenBSD, Solaris, UnixWare.
+ Some /proc file items - device number, inode number, and
+ file size - are unavailable in some dialects. Searching for
+ files in a /proc file system may require that the full path
+ name be specified.
+ No text (txt) file descriptors are displayed for Linux
+ processes. All entries for files other than the current
+ working directory, the root directory, and numerical file
+ descriptors are labeled mem descriptors.
-SunOS 5.9 Last change: Revision-4.89 57
+SunOS 5.9 Last change: Revision-4.90 58
-Maintenance Procedures LSOF(8)
+Maintenance Procedures LSOF(8)
- SYSV R4 - e.g., FreeBSD, NetBSD, OpenBSD, Solaris, UnixWare.
- Some /proc file items - device number, inode number, and
- file size - are unavailable in some dialects. Searching for
- files in a /proc file system may require that the full path
- name be specified.
-
- No text (txt) file descriptors are displayed for Linux
- processes. All entries for files other than the current
- working directory, the root directory, and numerical file
- descriptors are labeled mem descriptors.
Lsof can't search for Tru64 UNIX named pipes by name,
because their kernel implementation of lstat(2) returns an
@@ -3820,30 +3874,30 @@ FAQ
Frequently-asked questions and their answers (an FAQ) are
available in the 00FAQ file of the lsof distribution.
+ That file is also available via anonymous ftp from
+ lsof.itap.purdue.edu at pub/tools/unix/lsofFAQ. The URL is:
+ ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
-SunOS 5.9 Last change: Revision-4.89 58
+FILES
+ /dev/kmem kernel virtual memory device
+ /dev/mem physical memory device
+ /dev/swap system paging device
+SunOS 5.9 Last change: Revision-4.90 59
-Maintenance Procedures LSOF(8)
- That file is also available via anonymous ftp from
- lsof.itap.purdue.edu at pub/tools/unix/lsofFAQ. The URL is:
- ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
-FILES
- /dev/kmem kernel virtual memory device
+Maintenance Procedures LSOF(8)
- /dev/mem physical memory device
- /dev/swap system paging device
.lsof_hostname lsof's device cache file (The suffix,
hostname, is the first component of the
@@ -3885,20 +3939,6 @@ DISTRIBUTION
README.lsof_<version> and the other 00* files of the distri-
bution before sending questions to the author.
-
-
-
-SunOS 5.9 Last change: Revision-4.89 59
-
-
-
-
-
-
-Maintenance Procedures LSOF(8)
-
-
-
SEE ALSO
Not all the following manual pages may exist in every UNIX
dialect to which lsof has been ported.
@@ -3914,47 +3954,7 @@ SEE ALSO
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-SunOS 5.9 Last change: Revision-4.89 60
+SunOS 5.9 Last change: Revision-4.90 60
diff --git a/lsof_fields.h b/lsof_fields.h
index 9517a58..81b72ee 100644
--- a/lsof_fields.h
+++ b/lsof_fields.h
@@ -32,7 +32,7 @@
/*
- * $Id: lsof_fields.h,v 1.13 2014/10/13 22:36:20 abe Exp $
+ * $Id: lsof_fields.h,v 1.14 2018/02/14 14:19:25 abe Exp $
*/
@@ -113,68 +113,72 @@
#define LSOF_FIX_MARK 13
#define LSOF_FNM_MARK "marker between repeated output"
+#define LSOF_FID_TCMD 'M'
+#define LSOF_FIX_TCMD 14
+#define LSOF_FNM_TCMD "task comMand name"
+
#define LSOF_FID_NAME 'n'
-#define LSOF_FIX_NAME 14
+#define LSOF_FIX_NAME 15
#define LSOF_FNM_NAME "comment, name, Internet addresses"
#define LSOF_FID_NI 'N'
-#define LSOF_FIX_NI 15
+#define LSOF_FIX_NI 16
#define LSOF_FNM_NI "file struct node ID as 0x<hex>"
#define LSOF_FID_OFFSET 'o'
-#define LSOF_FIX_OFFSET 16
+#define LSOF_FIX_OFFSET 17
#define LSOF_FNM_OFFSET "file offset as 0t<dec> or 0x<hex>"
#define LSOF_FID_PID 'p'
-#define LSOF_FIX_PID 17
+#define LSOF_FIX_PID 18
#define LSOF_FNM_PID "process ID (PID)"
#define LSOF_FID_PGID 'g'
-#define LSOF_FIX_PGID 18
+#define LSOF_FIX_PGID 19
#define LSOF_FNM_PGID "process group ID (PGID)"
#define LSOF_FID_PROTO 'P'
-#define LSOF_FIX_PROTO 19
+#define LSOF_FIX_PROTO 20
#define LSOF_FNM_PROTO "protocol name"
#define LSOF_FID_RDEV 'r'
-#define LSOF_FIX_RDEV 20
+#define LSOF_FIX_RDEV 21
#define LSOF_FNM_RDEV "raw device number as 0x<hex>"
#define LSOF_FID_PPID 'R'
-#define LSOF_FIX_PPID 21
+#define LSOF_FIX_PPID 22
#define LSOF_FNM_PPID "paRent PID"
#define LSOF_FID_SIZE 's'
-#define LSOF_FIX_SIZE 22
+#define LSOF_FIX_SIZE 23
#define LSOF_FNM_SIZE "file size"
#define LSOF_FID_STREAM 'S'
-#define LSOF_FIX_STREAM 23
+#define LSOF_FIX_STREAM 24
#define LSOF_FNM_STREAM "stream module and device names"
#define LSOF_FID_TYPE 't'
-#define LSOF_FIX_TYPE 24
+#define LSOF_FIX_TYPE 25
#define LSOF_FNM_TYPE "file type"
#define LSOF_FID_TCPTPI 'T'
-#define LSOF_FIX_TCPTPI 25
+#define LSOF_FIX_TCPTPI 26
#define LSOF_FNM_TCPTPI "TCP/TPI info"
#define LSOF_FID_UID 'u'
-#define LSOF_FIX_UID 26
+#define LSOF_FIX_UID 27
#define LSOF_FNM_UID "user ID (UID)"
#define LSOF_FID_ZONE 'z'
-#define LSOF_FIX_ZONE 27
+#define LSOF_FIX_ZONE 28
#define LSOF_FNM_ZONE "zone name"
#define LSOF_FID_CNTX 'Z'
-#define LSOF_FIX_CNTX 28
+#define LSOF_FIX_CNTX 29
#define LSOF_FNM_CNTX "security context"
#define LSOF_FID_TERM '0'
-#define LSOF_FIX_TERM 29
+#define LSOF_FIX_TERM 30
#define LSOF_FNM_TERM "(zero) use NUL field terminator instead of NL"
#endif /* !defined(LSOF_FORMAT_H) */
diff --git a/main.c b/main.c
index 78fdac1..3c42b9d 100644
--- a/main.c
+++ b/main.c
@@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: main.c,v 1.57 2015/07/07 20:16:58 abe Exp $";
+static char *rcsid = "$Id: main.c,v 1.58 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -120,10 +120,17 @@ main(argc, argv)
*
* Make sure umask allows lsof to define its own file permissions.
*/
+
if ((MaxFd = (int) GET_MAX_FD()) < 53)
MaxFd = 53;
+
+#if defined(HAS_CLOSEFROM)
+ (void) closefrom(3);
+#else /* !defined(HAS_CLOSEFROM) */
for (i = 3; i < MaxFd; i++)
(void) close(i);
+#endif /* !defined(HAS_CLOSEFROM) */
+
while (((i = open("/dev/null", O_RDWR, 0)) >= 0) && (i < 2))
;
if (i < 0)
@@ -190,7 +197,7 @@ main(argc, argv)
#endif /* defined(HASKOPT) */
#if defined(HASTASKS)
- "K",
+ "K:",
#else /* !defined(HASTASKS) */
"",
#endif /* defined(HASTASKS) */
@@ -279,7 +286,7 @@ main(argc, argv)
GOx2 = GObk[1];
}
} else {
- CmdLim = atoi(GOv);
+ CmdLim = TaskCmdLim = atoi(GOv);
#if defined(MAXSYSCMDL)
if (CmdLim > MAXSYSCMDL) {
@@ -458,6 +465,11 @@ main(argc, argv)
continue;
#endif /* !defined(HASPPID) */
+#if !defined(HASTASKS)
+ if (FieldSel[i].id == LSOF_FID_TCMD)
+ continue;
+#endif /* !defined(HASTASKS) */
+
#if !defined(HASFSTRUCT)
if (FieldSel[i].id == LSOF_FID_CT
|| FieldSel[i].id == LSOF_FID_FA
@@ -512,6 +524,11 @@ main(argc, argv)
continue;
#endif /* !defined(HASPPID) */
+#if !defined(HASTASKS)
+ if (FieldSel[i].id == LSOF_FID_TCMD)
+ continue;
+#endif /* !defined(HASTASKS) */
+
#if !defined(HASFSTRUCT)
if (FieldSel[i].id == LSOF_FID_CT
|| FieldSel[i].id == LSOF_FID_FA
@@ -591,10 +608,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':
@@ -982,6 +1016,11 @@ main(argc, argv)
}
}
/*
+ * If IgnTasks is set, remove SELTASK from SelAll and SelProc.
+ */
+ SelAll = IgnTasks ? (SELALL & ~SELTASK) : SELALL;
+ SelProc = IgnTasks ? (SELPROC & ~SELTASK) : SELPROC;
+/*
* Check for argument consistency.
*/
if (Cmdnx && Cmdni) {
@@ -1159,12 +1198,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.
@@ -1297,47 +1336,76 @@ main(argc, argv)
* printing.
*
* Lf contents must be preserved, since they may point to a
- * malloc()'d area, and since Lf is used throughout the print
+ * malloc()'d area, and since Lf is used throughout the printing
+ * of the selected processes.
*/
if (FeptE) {
lf = Lf;
-
/*
- * Check the files that have been selected for printing by
- * by some selection criterion other than being a pipe.
+ * Scan all selected processes.
*/
for (i = 0; i < Nlproc; i++) {
Lp = (Nlproc > 1) ? slp[i] : &Lproc[i];
- if (Lp->pss && (Lp->ept & EPT_PIPE))
- (void) process_pinfo(0);
+
+ /*
+ * For processes that have been selected for printing
+ * and have files that are the end point(s) of pipe(s),
+ * process the file endpoints.
+ */
+ if (Lp->pss && (Lp->ept & EPT_PIPE))
+ (void) process_pinfo(0);
+
+# if defined(HASUXSOCKEPT)
+ /*
+ * For processes that have been selected for printing
+ * and have files that are the end point(s) of UNIX
+ * socket(s), process the file endpoints.
+ */
+ if (Lp->pss && (Lp->ept & EPT_UXS))
+ (void) process_uxsinfo(0);
+# endif /* defined(HASUXSOCKEPT) */
+
+# if defined(HASPTYEPT)
+ /*
+ * For processes that have been selected for printing
+ * and have files that are the end point(s) of pseudo-
+ * terminal files(s), process the file endpoints.
+ */
+ if (Lp->pss && (Lp->ept & EPT_PTY))
+ (void) process_ptyinfo(0);
+# endif /* defined(HASPTYEPT) */
+
}
/*
- * In a second pass, process unselected endpoint files,
+ * In a second pass, look for unselected endpoint files,
* possibly selecting them for printing.
*/
for (i = 0; i < Nlproc; i++) {
Lp = (Nlproc > 1) ? slp[i] : &Lproc[i];
- if (Lp->ept & EPT_PIPE_END)
- (void) process_pinfo(1);
- }
+
+ /*
+ * Process pipe endpoints.
+ */
+ if (Lp->ept & EPT_PIPE_END)
+ (void) process_pinfo(1);
# if defined(HASUXSOCKEPT)
- /*
- * Process UNIX socket endpoint files in a similar fashion.
- */
- for (i = 0; i < Nlproc; i++) {
- Lp = (Nlproc > 1) ? slp[i] : &Lproc[i];
- if (Lp->pss && (Lp->ept & EPT_UXS))
- (void) process_uxsinfo(0);
- }
- for (i = 0; i < Nlproc; i++) {
- Lp = (Nlproc > 1) ? slp[i] : &Lproc[i];
- if (Lp->ept & EPT_UXS_END) {
- (void) process_uxsinfo(1);
- }
- }
+ /*
+ * Process UNIX socket endpoints.
+ */
+ if (Lp->ept & EPT_UXS_END)
+ (void) process_uxsinfo(1);
# endif /* defined(HASUXSOCKEPT) */
+# if defined(HASPTYEPT)
+ /*
+ * Process pseudo-terminal endpoints.
+ */
+ if (Lp->ept & EPT_PTY_END)
+ (void) process_ptyinfo(1);
+# endif /* defined(HASPTYEPT) */
+
+ }
Lf = lf;
}
#endif /* defined(HASEPTOPTS) */
@@ -1371,6 +1439,14 @@ main(argc, argv)
#if defined(HASEPTOPTS)
(void) clear_pinfo();
+
+# if defined(HASUXSOCKEPT)
+ (void) clear_uxsinfo();
+# endif /* defined(HASUXSOCKEPT) */
+
+# if defined(HASEPTOPTS)
+ (void) clear_ptyinfo();
+# endif /* defined(HASEPTOPTS) */
#endif /* defined(HASEPTOPTS) */
if (rc) {
diff --git a/misc.c b/misc.c
index 8a47ce9..1682797 100644
--- a/misc.c
+++ b/misc.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: misc.c,v 1.28 2014/10/13 22:36:20 abe Exp $";
+static char *rcsid = "$Id: misc.c,v 1.29 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -247,6 +247,7 @@ doinchild(fn, fp, rbuf, rbln)
int rbln; /* response buffer length */
{
int en, rv;
+
/*
* Check reply buffer size.
*/
@@ -292,13 +293,40 @@ doinchild(fn, fp, rbuf, rbln)
* Begin the child process.
*/
- int fd, r_al, r_rbln;
+ int r_al, r_rbln;
char r_arg[MAXPATHLEN+1], r_rbuf[MAXPATHLEN+1];
int (*r_fn)();
/*
* Close sufficient open file descriptors except Pipes[0] and
* Pipes[3].
*/
+
+#if defined(HAS_DUP2) && defined(HAS_CLOSEFROM)
+ int rc;
+
+ rc = dup2(Pipes[0], 0);
+ if (rc < 0) {
+ (void) fprintf(stderr,
+ "%s: can't dup Pipes[0] to fd 0: %s\n",
+ Pn, strerror(errno));
+ Exit(1);
+ }
+ Pipes[0] = 0;
+ rc = dup2(Pipes[3], 1);
+ if (rc < 0) {
+ (void) fprintf(stderr,
+ "%s: can't dup Pipes.[3] to fd 1: %s\n",
+ Pn, strerror(errno));
+ Exit(1);
+ }
+ Pipes[3] = 1;
+ (void) closefrom(2);
+ Pipes[1] = -1;
+ Pipes[2] = -1;
+
+#else /* !defined(HAS_DUP2) && !defined(HAS_CLOSEFROM) */
+ int fd;
+
for (fd = 0; fd < MaxFd; fd++) {
if (fd == Pipes[0] || fd == Pipes[3])
continue;
@@ -316,6 +344,8 @@ doinchild(fn, fp, rbuf, rbln)
(void) close(Pipes[2]);
Pipes[2] = -1;
}
+#endif /* defined(HAS_DUP2) && defined(HAS_CLOSEFROM) */
+
/*
* Read function requests, process them, and return replies.
*/
diff --git a/print.c b/print.c
index 6d227bc..f661766 100644
--- a/print.c
+++ b/print.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: print.c,v 1.55 2013/01/02 17:14:59 abe Exp $";
+static char *rcsid = "$Id: print.c,v 1.56 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -678,8 +678,10 @@ print_file()
PIDTTL);
#if defined(HASTASKS)
- if (TaskPrtFl)
- (void) printf(" %*s", TidColW, TIDTTL);
+ if (TaskPrtTid)
+ (void) printf(" %*s", TaskTidColW, TASKTIDTTL);
+ if (TaskPrtCmd)
+ (void) printf(" %-*.*s", TaskCmdColW, TaskCmdColW, TASKCMDTTL);
#endif /* defined(HASTASKS) */
#if defined(HASZONES)
@@ -766,20 +768,35 @@ print_file()
#if defined(HASTASKS)
/*
- * Size or print task ID.
+ * Size or print task ID and command name.
*/
if (!PrPass) {
+ if ((cp = Lp->tcmd)) {
+ len = safestrlen(cp, 2);
+ if (TaskCmdLim && (len > TaskCmdLim))
+ len = TaskCmdLim;
+ if (len > TaskCmdColW)
+ TaskCmdColW = len;
+ TaskPrtCmd = 1;
+ }
if (Lp->tid) {
(void) snpf(buf, sizeof(buf), "%d", Lp->tid);
- if ((len = strlen(buf)) > TidColW)
- TidColW = len;
- TaskPrtFl = 1;
+ if ((len = strlen(buf)) >TaskTidColW)
+ TaskTidColW = len;
+ TaskPrtTid = 1;
+ }
+ } else {
+ if (TaskPrtTid) {
+ if (Lp->tid)
+ (void) printf(" %*d", TaskTidColW, Lp->tid);
+ else
+ (void) printf(" %*s", TaskTidColW, "");
+ }
+ if (TaskPrtCmd) {
+ cp = Lp->tcmd ? Lp->tcmd : "";
+ printf(" ");
+ safestrprtn(cp, TaskCmdColW, stdout, 2);
}
- } else if (TaskPrtFl) {
- if (Lp->tid)
- (void) printf(" %*d", TidColW, Lp->tid);
- else
- (void) printf(" %*s", TidColW, "");
}
#endif /* defined(HASTASKS) */
@@ -1279,7 +1296,7 @@ print_init()
*/
PrPass = (Ffield || Fterse) ? 1 : 0;
LastPid = -1;
- TaskPrtFl = 0;
+ TaskPrtCmd = TaskPrtTid = 0;
/*
* Size columns by their titles.
*/
@@ -1301,7 +1318,8 @@ print_init()
SzOffColW = strlen(SZOFFTTL);
#if defined(HASTASKS)
- TidColW = strlen(TIDTTL);
+ TaskCmdColW = strlen(TASKCMDTTL);
+ TaskTidColW = strlen(TASKTIDTTL);
#endif /* defined(HASTASKS) */
TypeColW = strlen(TYPETTL);
diff --git a/proc.c b/proc.c
index 8d40aa4..34cb4b8 100644
--- a/proc.c
+++ b/proc.c
@@ -32,12 +32,16 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: proc.c,v 1.49 2015/07/07 20:16:58 abe Exp $";
+static char *rcsid = "$Id: proc.c,v 1.50 2018/02/14 14:20:14 abe Exp $";
#endif
#include "lsof.h"
+#if defined(HASPTYEPT)
+_PROTOTYPE(static void prt_ptyinfo,(pxinfo_t *pp, int prt_edev, int ps));
+#endif /* defined(HASPTYEPT) */
+
/*
* add_nma() - add to NAME column addition
@@ -306,6 +310,7 @@ alloc_lproc(pid, pgid, ppid, uid, cmd, pss, sf)
#if defined(HASTASKS)
Lp->tid = 0;
+ Lp->tcmd = (char *)NULL;
#endif /* defined(HASTASKS) */
Lp->pgid = pgid;
@@ -499,7 +504,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;
@@ -565,6 +570,14 @@ free_lproc(lp)
(void) free((FREE_P *)lp->cmd);
lp->cmd = (char *)NULL;
}
+
+#if defined(HASTASKS)
+ if (lp->tcmd) {
+ (void) free((FREE_P *)lp->tcmd);
+ lp->tcmd = (char *)NULL;
+ }
+#endif /* defined(HASTASKS) */
+
}
@@ -649,7 +662,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);
@@ -743,13 +756,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);
@@ -909,6 +922,18 @@ link_lfile()
}
# endif /* defined(HASUXSOCKEPT) */
+# if defined(HASPTYEPT)
+/*
+ * Process pseudoterminal endpoint files the same way by clearing the SELPINFO
+ * flag and setting the EPT_PTY flag, letting a later call to process_ptyinfo()
+ * set selection flags.
+ */
+ if (Lf->sf & SELPTYINFO) {
+ Lp->ept |= EPT_PTY;
+ Lf->sf &= ~SELPTYINFO;
+ }
+# endif /* defined(HASPTYEPT) */
+
}
#endif /* defined(HASEPTOPTS) */
@@ -967,7 +992,7 @@ process_pinfo(f)
* its being a pipe. Look up the pipe's endpoints.
*/
do {
- if ((pp = find_pendinfo(Lf, pp))) {
+ if ((pp = find_pepti(Lf, pp))) {
/*
* This pipe endpoint is linked to the selected pipe
@@ -1008,7 +1033,7 @@ process_pinfo(f)
Lf->sf = Selflags;
Lp->pss |= PS_SEC;
do {
- if ((pp = find_pendinfo(Lf, pp))) {
+ if ((pp = find_pepti(Lf, pp))) {
ep = &Lproc[pp->lpx];
ef = pp->lf;
for (i = 0; i < (FDLEN - 1); i++) {
@@ -1155,6 +1180,8 @@ print_proc()
#if defined(HASTASKS)
if (FieldSel[LSOF_FIX_TID].st && Lp->tid)
(void) printf("%c%d%c", LSOF_FID_TID, Lp->tid, Terminator);
+ if (FieldSel[LSOF_FIX_TCMD].st && Lp->tcmd)
+ (void) printf("%c%s%c", LSOF_FID_TCMD, Lp->tcmd, Terminator);
#endif /* defined(HASTASKS) */
#if defined(HASZONES)
@@ -1371,3 +1398,131 @@ print_proc()
}
return(rv);
}
+
+
+#if defined(HASPTYEPT)
+/*
+ * process_ptyinfo() -- process pseudoterminal info, adding it to selected files and
+ * selecting pseudoterminal end files (if requested)
+ */
+
+void
+process_ptyinfo(f)
+ int f; /* function:
+ * 0 == process selected pseudoterminal
+ * 1 == process end point */
+{
+ pxinfo_t *pp; /* previous pseudoterminal info */
+ int mos; /* master or slave indicator
+ * 0 == slave; 1 == master */
+ int pc; /* print count */
+
+ if (!FeptE)
+ return;
+ for (Lf = Lp->file; Lf; Lf = Lf->next) {
+ if (Lf->rdev_def && is_pty_ptmx(Lf->rdev))
+ mos = 1;
+ else if (Lf->rdev_def && is_pty_slave(GET_MAJ_DEV(Lf->rdev)))
+ mos = 0;
+ else
+ continue;
+
+ pp = (pxinfo_t *)NULL;
+ switch(f) {
+ case 0:
+
+ /*
+ * Process already selected pseudoterminal file.
+ */
+ if (is_file_sel(Lp, Lf)) {
+
+ /*
+ * This file has been selected by some criterion other than
+ * its being a pseudoterminal. Look up the pseudoterminal's
+ * endpoints.
+ */
+ pc = 1;
+ do {
+ if ((pp = find_ptyepti(Lf, !mos, pp))) {
+
+ /*
+ * This pseudoterminal endpoint is linked to the
+ * selected pseudoterminal file. Add its PID, FD and
+ * access mode to the name column addition.
+ */
+ prt_ptyinfo(pp, (mos && pc), (FeptE == 2));
+ pp = pp->next;
+ pc = 0;
+ }
+ } while (pp);
+ }
+ break;
+ case 1:
+ if (!is_file_sel(Lp, Lf) && (Lf->chend & CHEND_PTY)) {
+
+ /*
+ * This is an unselected end point file. Select it and add
+ * its end point information to its name column addition.
+ */
+ Lf->sf = Selflags;
+ Lp->pss |= PS_SEC;
+ pc = 1;
+ do {
+ if ((pp = find_ptyepti(Lf, !mos, pp))) {
+ prt_ptyinfo(pp, (mos && pc), 0);
+ pp = pp->next;
+ pc = 0;
+ }
+ } while (pp);
+ }
+ break;
+ }
+ }
+}
+
+
+/*
+ * prt_ptyinfo() -- print pseudoterminal information
+ */
+
+static void
+prt_ptyinfo(pp, prt_edev, ps)
+ pxinfo_t *pp; /* peer info */
+ int prt_edev; /* print the end point device file */
+ int ps; /* processing status:
+ * 0 == process immediately
+ * 1 == process later */
+{
+ struct lproc *ep; /* pseudoterminal endpoint process */
+ struct lfile *ef; /* pseudoterminal endpoint file */
+ int i; /* temporary index */
+ char nma[1024]; /* name addition buffer */
+
+ ep = &Lproc[pp->lpx];
+ ef = pp->lf;
+ for (i = 0; i < (FDLEN - 1); i++) {
+ if (ef->fd[i] != ' ')
+ break;
+ }
+ if (prt_edev) {
+ (void) snpf(nma, sizeof(nma) - 1, "->/dev/pts/%d %d,%.*s,%s%c",
+ Lf->tty_index,
+ ep->pid, CmdLim, ep->cmd, &ef->fd[i],
+ ef->access);
+ } else {
+ (void) snpf(nma, sizeof(nma) - 1, "%d,%.*s,%s%c",
+ ep->pid, CmdLim, ep->cmd, &ef->fd[i],
+ ef->access);
+ }
+ (void) add_nma(nma, strlen(nma));
+ if (ps) {
+
+ /*
+ * Endpoint files have been selected, so mark this
+ * one for selection later. Set the type to PTY.
+ */
+ ef->chend = CHEND_PTY;
+ ep->ept |= EPT_PTY_END;
+ }
+}
+#endif /* defined(HASPTYEPT) */
diff --git a/proto.h b/proto.h
index 15a2673..75c74a1 100644
--- a/proto.h
+++ b/proto.h
@@ -31,7 +31,7 @@
/*
- * $Id: proto.h,v 1.38 2015/07/07 20:16:58 abe Exp $
+ * $Id: proto.h,v 1.39 2018/02/14 14:20:14 abe Exp $
*/
@@ -112,12 +112,21 @@ _PROTOTYPE(extern void find_ch_ino,(void));
# if defined(HASEPTOPTS)
_PROTOTYPE(extern void clear_pinfo,(void));
-_PROTOTYPE(extern pxinfo_t *find_pendinfo,(struct lfile *lf, pxinfo_t *pp));
+_PROTOTYPE(extern pxinfo_t *find_pepti,(struct lfile *lf, pxinfo_t *pp));
_PROTOTYPE(extern void process_pinfo,(int f));
# if defined(HASUXSOCKEPT)
+_PROTOTYPE(extern void clear_uxsinfo,(void));
_PROTOTYPE(extern struct uxsin *find_uxsepti,(struct lfile *lf));
_PROTOTYPE(extern void process_uxsinfo,(int f));
# endif /* defined(HASUXSOCKEPT) */
+# if defined(HASPTYEPT)
+_PROTOTYPE(extern void clear_ptyinfo,(void));
+_PROTOTYPE(extern void enter_ptmxi,(int mn));
+_PROTOTYPE(extern pxinfo_t *find_ptyepti,(struct lfile *lf,int m,pxinfo_t *pp));
+_PROTOTYPE(extern int is_pty_slave,(int sm));
+_PROTOTYPE(extern int is_pty_ptmx,(dev_t dev));
+_PROTOTYPE(extern void process_ptyinfo,(int f));
+# endif /* defined(HASPTYEPT) */
# endif /* defined(HASEPTOPTS) */
_PROTOTYPE(extern void free_lproc,(struct lproc *lp));
@@ -140,6 +149,7 @@ _PROTOTYPE(extern int hashbyname,(char *nm, int mod));
_PROTOTYPE(extern void hashSfile,(void));
_PROTOTYPE(extern void initialize,(void));
_PROTOTYPE(extern int is_cmd_excl,(char *cmd, short *pss, short *sf));
+_PROTOTYPE(extern int is_file_sel,(struct lproc *lp, struct lfile *lf));
_PROTOTYPE(extern int is_nw_addr,(unsigned char *ia, int p, int af));
#if defined(HASTASKS)
diff --git a/store.c b/store.c
index dcc6555..0bf3fa7 100644
--- a/store.c
+++ b/store.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: store.c,v 1.43 2015/07/07 20:16:58 abe Exp $";
+static char *rcsid = "$Id: store.c,v 1.44 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -43,6 +43,8 @@ static char *rcsid = "$Id: store.c,v 1.43 2015/07/07 20:16:58 abe Exp $";
* 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 */
@@ -218,26 +220,28 @@ struct fieldsel FieldSel[] = {
{ LSOF_FID_LOCK, 0, LSOF_FNM_LOCK, NULL, 0 }, /* 11 */
{ LSOF_FID_LOGIN, 0, LSOF_FNM_LOGIN, NULL, 0 }, /* 12 */
{ LSOF_FID_MARK, 1, LSOF_FNM_MARK, NULL, 0 }, /* 13 */
- { LSOF_FID_NAME, 0, LSOF_FNM_NAME, NULL, 0 }, /* 14 */
- { LSOF_FID_NI, 0, LSOF_FNM_NI, &Fsv, FSV_NI }, /* 15 */
- { LSOF_FID_OFFSET, 0, LSOF_FNM_OFFSET, NULL, 0 }, /* 16 */
- { LSOF_FID_PID, 1, LSOF_FNM_PID, NULL, 0 }, /* 17 */
- { LSOF_FID_PGID, 0, LSOF_FNM_PGID, &Fpgid, 1 }, /* 18 */
- { LSOF_FID_PROTO, 0, LSOF_FNM_PROTO, NULL, 0 }, /* 19 */
- { LSOF_FID_RDEV, 0, LSOF_FNM_RDEV, NULL, 0 }, /* 20 */
- { LSOF_FID_PPID, 0, LSOF_FNM_PPID, &Fppid, 1 }, /* 21 */
- { LSOF_FID_SIZE, 0, LSOF_FNM_SIZE, NULL, 0 }, /* 22 */
- { LSOF_FID_STREAM, 0, LSOF_FNM_STREAM, NULL, 0 }, /* 23 */
- { LSOF_FID_TYPE, 0, LSOF_FNM_TYPE, NULL, 0 }, /* 24 */
- { LSOF_FID_TCPTPI, 0, LSOF_FNM_TCPTPI, &Ftcptpi, TCPTPI_ALL }, /* 25 */
- { LSOF_FID_UID, 0, LSOF_FNM_UID, NULL, 0 }, /* 26 */
- { LSOF_FID_ZONE, 0, LSOF_FNM_ZONE, &Fzone, 1 }, /* 27 */
- { LSOF_FID_CNTX, 0, LSOF_FNM_CNTX, &Fcntx, 1 }, /* 28 */
- { LSOF_FID_TERM, 0, LSOF_FNM_TERM, NULL, 0 }, /* 29 */
+ { LSOF_FID_TCMD, 0, LSOF_FNM_TCMD, NULL, 0 }, /* 14 */
+ { LSOF_FID_NAME, 0, LSOF_FNM_NAME, NULL, 0 }, /* 15 */
+ { LSOF_FID_NI, 0, LSOF_FNM_NI, &Fsv, FSV_NI }, /* 16 */
+ { LSOF_FID_OFFSET, 0, LSOF_FNM_OFFSET, NULL, 0 }, /* 17 */
+ { LSOF_FID_PID, 1, LSOF_FNM_PID, NULL, 0 }, /* 18 */
+ { LSOF_FID_PGID, 0, LSOF_FNM_PGID, &Fpgid, 1 }, /* 19 */
+ { LSOF_FID_PROTO, 0, LSOF_FNM_PROTO, NULL, 0 }, /* 20 */
+ { LSOF_FID_RDEV, 0, LSOF_FNM_RDEV, NULL, 0 }, /* 21 */
+ { LSOF_FID_PPID, 0, LSOF_FNM_PPID, &Fppid, 1 }, /* 22 */
+ { LSOF_FID_SIZE, 0, LSOF_FNM_SIZE, NULL, 0 }, /* 23 */
+ { LSOF_FID_STREAM, 0, LSOF_FNM_STREAM, NULL, 0 }, /* 24 */
+ { LSOF_FID_TYPE, 0, LSOF_FNM_TYPE, NULL, 0 }, /* 25 */
+ { LSOF_FID_TCPTPI, 0, LSOF_FNM_TCPTPI, &Ftcptpi, TCPTPI_ALL }, /* 26 */
+ { LSOF_FID_UID, 0, LSOF_FNM_UID, NULL, 0 }, /* 27 */
+ { LSOF_FID_ZONE, 0, LSOF_FNM_ZONE, &Fzone, 1 }, /* 28 */
+ { LSOF_FID_CNTX, 0, LSOF_FNM_CNTX, &Fcntx, 1 }, /* 29 */
+ { LSOF_FID_TERM, 0, LSOF_FNM_TERM, NULL, 0 }, /* 30 */
{ ' ', 0, NULL, NULL, 0 }
};
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;
@@ -323,8 +327,9 @@ int RptTm = 0; /* repeat time -- set by -r */
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 */
@@ -346,7 +351,11 @@ char *SzOffFmt_dv = (char *)NULL;
/* SZOFFTYPE %*d printf specification */
char *SzOffFmt_x = (char *)NULL;
/* SZOFFTYPE %#x printf specification */
-int TaskPrtFl = 0; /* task print flag */
+int TaskCmdColW = 0; /* task command column width */
+int TaskCmdLim = TASKCMDL; /* TASKCMD column width limit (same as
+ * CmdLim) */
+int TaskPrtCmd = 0; /* task print task command flag */
+int TaskPrtTid = 0; /* task print TID flag */
int TcpStAlloc = 0; /* allocated (possibly unused) entries in TCP
* state tables */
unsigned char *TcpStI = (unsigned char *)NULL;
@@ -363,7 +372,7 @@ int TcpNstates = 0; /* number of TCP states -- either in
char **TcpSt = (char **)NULL; /* local TCP state names, indexed by system
* state value */
char Terminator = '\n'; /* output field terminator */
-int TidColW = 0; /* TID column width */
+int TaskTidColW = 0; /* task TID column width */
int TmLimit = TMLIMIT; /* Readlink() and stat() timeout (seconds) */
int TypeColW; /* TYPE column width */
int UdpStAlloc = 0; /* allocated (possibly unused) entries in UDP
diff --git a/tests/LTlib.c b/tests/LTlib.c
index be15af1..1c0d960 100644
--- a/tests/LTlib.c
+++ b/tests/LTlib.c
@@ -99,6 +99,21 @@ static char copyright[] =
#endif /* defined(LT_DIAL_bsdi) */
+#if defined(LT_DIAL_freebsd)
+/*
+ *FreeBSD-specific items
+*/
+
+#undef XDINDEV
+#define XDINDEV 16
+# if defined(LT_DEV64)
+#undef X2DEV_T
+#define X2DEV_T unsigned long long
+#define major_X(dp, em) ((int)((x2dev(dp, em) >> 32) & 0xffffffff))
+# endif /* defined(LT_DEV64) */
+#endif /* defined(LT_DIAL_freebsd) */
+
+
#if defined(LT_DIAL_osr)
/*
* OpenUNIX-specific items
diff --git a/tests/LsofTest.h b/tests/LsofTest.h
index e1d149c..d1a9c96 100644
--- a/tests/LsofTest.h
+++ b/tests/LsofTest.h
@@ -31,7 +31,7 @@
/*
- * $Id: LsofTest.h,v 1.12 2008/07/05 16:21:07 abe Exp $
+ * $Id: LsofTest.h,v 1.13 2018/02/14 14:21:44 abe Exp $
*/
@@ -77,6 +77,12 @@
#include <signal.h>
#include <sys/types.h>
+
+#if defined(LT_DIAL_linux) && LT_VERS>=414014
+#undef major
+#include <sys/sysmacros.h>
+#endif /* defined(LT_DIAL_linux) && LT_VERS>=414014 */
+
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/tests/TestDB b/tests/TestDB
index 4e6a44a..480bc2b 100644
--- a/tests/TestDB
+++ b/tests/TestDB
@@ -5,7 +5,7 @@
#
# See Add2TestDB for a script that will build a line for this file.
#
-# $Id: TestDB,v 1.40 2015/07/07 20:22:07 abe Exp $
+# $Id: TestDB,v 1.41 2018/02/14 14:21:44 abe Exp $
LT_AIXA=0 LT_BIGF LT_CC LT_DIAL_aix LT_KMEM LT_VERS=4320
LT_AIXA=0 LT_BIGF LT_CC LT_DIAL_aix LT_KMEM LT_VERS=4330
@@ -65,6 +65,8 @@ LT_BIGF LT_CC LT_DIAL_freebsd LT_KMEM LT_VERS=10000
LT_BIGF LT_DIAL_freebsd LT_GCC LT_KMEM LT_VERS=10000
LT_BIGF LT_CC LT_DIAL_freebsd LT_KMEM LT_VERS=11000
LT_BIGF LT_DIAL_freebsd LT_GCC LT_KMEM LT_VERS=11000
+LT_BIGF LT_CC LT_DIAL_freebsd LT_KMEM LT_VERS=12000
+LT_BIGF LT_CC LT_DEV64 LT_DIAL_freebsd LT_KMEM LT_VERS=12000
LT_BIGF LT_CC LT_DIAL_hpux LT_KMEM LT_VERS=1020 _LARGEFILE64_SOURCE
LT_BIGF LT_DIAL_hpux LT_GCC LT_KMEM LT_VERS=1020 _LARGEFILE64_SOURCE
LT_BIGF LT_CC LT_DIAL_hpux LT_KMEM LT_VERS=1100 _LARGEFILE64_SOURCE
@@ -92,6 +94,7 @@ LT_BIGF LT_CC LT_DIAL_linux LT_VERS=26038 _FILE_OFFSET_BITS=64
LT_BIGF LT_CC LT_DIAL_linux LT_VERS=310000 _FILE_OFFSET_BITS=64
LT_BIGF LT_CC LT_DIAL_linux LT_VERS=310004 _FILE_OFFSET_BITS=64
LT_BIGF LT_CC LT_DIAL_linux LT_VERS=31008 _FILE_OFFSET_BITS=64
+LT_BIGF LT_CC LT_DIAL_linux LT_VERS=414014 _FILE_OFFSET_BITS=64
LT_BIGF LT_CC LT_DIAL_netbsd LT_KMEM LT_VERS=1005000
LT_BIGF LT_CC LT_DIAL_netbsd LT_KMEM LT_VERS=1006000
LT_BIGF LT_CC LT_DIAL_netbsd LT_KMEM LT_VERS=2000000
diff --git a/usage.c b/usage.c
index 5c92e46..7edcfde 100644
--- a/usage.c
+++ b/usage.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1998 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: usage.c,v 1.32 2014/10/13 22:36:20 abe Exp $";
+static char *rcsid = "$Id: usage.c,v 1.33 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -550,7 +550,8 @@ usage(xv, fh, version)
col = print_in_col(col, buf);
#if defined(HASTASKS)
- col = print_in_col(col, "-K list tasKs (threads)");
+/* 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");
diff --git a/version b/version
index 369cc11..2363e67 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-.ds VN 4.89
+.ds VN 4.90