blob: 06a5ae9208942a75ddef8a2950e1afcd9710afd0 [file] [log] [blame]
preludedrewb89fbe42010-12-30 20:19:26 -07001
2 Frequently Asked Questions about lsof
3
4**********************************************************************
5| The latest release of lsof is always available via anonymous ftp |
6| from lsof.itap.purdue.edu. Look in pub/lsof.README for its |
7| location. |
8**********************************************************************
9
10______________________________________________________________________
11
12This file contains frequently asked questions about lsof and answers
13to them.
14
15Vic Abell <abe@purdue.edu>
16July 29, 2010
17______________________________________________________________________
18
19Table of Contents:
20
211.0 General Concepts
221.1 Lsof -- what is it?
231.2 Where do I get lsof?
241.2.1 Are there mirror sites?
251.2.2 Are lsof executables available?
261.2.3 How do I check the validity of an lsof distribution?
271.2.4 Why can't I get the sum(1) result reported in
28 README.lsof_<revision>?
291.2.5 Why won't gpg accept the lsof-signing PGP public key?
301.3 Where can I get more lsof documentation?
311.4 How do I report an lsof bug?
321.5 Where can I get the lsof FAQ?
331.5.1 How timely is the on-line FAQ?
341.6 Is there a test suite?
351.7 Is lsof vulnerable to the standard I/O descriptor attack?
361.8 Can I alter lsof's make(1) behavior?
371.9 Is there an lsof license?
381.10 Language locale support
391.10.1 Does lsof support language locales? How do I use the support?
401.10.2 Does lsof support wide characters in language locales?
411.11 Are any files in the lsof distribution copyrighted?
421.12 Are there other lsof-related resources?
431.13 What does the "WARNING: unsupported dialect or version" mean?
44
452.0 Lsof Ports
462.1 What ports exist?
472.2 What about a new port?
482.2.1 User-contributed Ports
492.3 Why isn't there an AT&T SVR4 port?
502.4 Why isn't there an SGI IRIX port?
512.5 Why does lsof's Configure script report "WARNING: unsupported
52 dialect or version"?
53
543.0 Lsof Problems
553.1 Configuration Problems
563.1.1 Why can't Configure determine the UNIX dialect version?
573.2 Compilation Problems
583.2.1 Why does the compiler complain about missing header files?
593.2.2 Why does gcc complain about the contents of header files
60 distributed by the system's vendor?
613.2.3 Other header file problems
623.3 Why doesn't lsof report full path names?
633.3.1 Why do lsof -r reports show different path names?
643.3.2 Why does lsof report the wrong path names?
653.3.3 Why doesn't lsof report path names for unlinked (rm'd) files?
663.3.4 Why doesn't lsof report the "correct" hard linked file path
67 name?
683.3.5 When will lsof report path names for deleted files?
693.4 Why is lsof so slow?
703.5 Why doesn't lsof's setgid or setuid permission work?
713.6 Does lsof have security problems?
723.7 Will lsof show remote hosts using files via NFS?
733.8 Why doesn't lsof report locks held on NFS files?
743.8.1 Why does lsof report a one byte lock on byte zero as a full
75 file lock?
763.9 Why does lsof report different values for open files on the
77 same file system (the automounter phenomenon)?
783.10 Why don't lsof and netstat output match?
793.10.1 Why can't lsof find accesses to some TCP and UDP ports?
803.11 Why does lsof update the device cache file?
813.12 Why doesn't lsof report state for UDP socket files?
823.13 I am editing a file with vi; why doesn't lsof find the file?
833.14 Why doesn't lsof report TCP/TPI window and queue sizes for my
84 dialect?
853.14.1 Why doesn't lsof report socket options, socket states, and TCP
86 flags and values for my dialect?
873.14.2 Why doesn't lsof report the partial listen queue connection
88 count for my dialect?
893.15 What does "no more information" in the NAME column mean?
903.16 Why doesn't lsof find a process that ps finds?
913.17 Why doesn't -V report a search failure?
923.18 Portmap problems
933.18.1 Why isn't a name displayed for the portmap registration?
943.18.2 How can I display only portmap registrations?
953.18.3 Why doesn't lsof report portmap registrations for some ports?
963.19 Why is `lsof | wc` bigger than my system's open file limit?
973.20 Why doesn't lsof report file offset (position)?
983.20.1 What does lsof report for size when the file doesn't really have
99 one?
1003.21 Problems with path name arguments
1013.21.1 How do I ask lsof to search a file system?
1023.21.2 Why doesn't lsof find all the open files in a file system?
1033.21.3 Why does the lsof exit code report it didn't find open files
104 when some files were listed?
1053.21.4 Why won't lsof find all the open files in a directory?
1063.21.5 Why are the +D and +d options so slow?
1073.21.6 Why do the +D and +d options produce warning messages?
1083.22 Why can't my C compiler find the rpcent structure definition?
1093.23 Why doesn't lsof report fully on file "foo" on UNIX dialect
110 "bar?"
1113.24 Why do I get a complaint when I execute lsof that some library
112 file can't be found?
1133.25 Why does lsof complain it can't open files?
1143.26 Why does lsof warn "compiled for x ... y; this is z."?
1153.27 How can I disable the kernel identity check?
1163.28 Why don't ps(1) and lsof agree on the owner of a process?
1173.29 Why doesn't lsof find an open socket file whose connection
118 state is past CLOSE_WAIT?
1193.30 Why don't machine.h definitions work when the surrounding
120 comments are removed?
1213.31 What do "can't read inpcb at 0x...", "no protocol control
122 block", "no PCB, CANTSENDMORE, CANTRCVMORE", etc. mean?
1233.32 What do the "unknown file system type" warnings mean?
1243.33 Installation
1253.33.1 How do I install lsof?
1263.33.2 How do I install a common lsof when I have machines that
127 need differently constructed lsof binaries?
1283.34 Why do lsof 4.53 and above reject device cache files built
129 by earlier lsof revisions?
1303.35 What do "like block special" and "like character special" mean
131 in the NAME column?
1323.36 Why does an lsof make fail because of undefined symbols?
1333.37 Command Regular Expressions (REs)
1343.37.1 What are basic and extended regular expressions?
1353.37.2 Why can't I put a slash in a command regular expression?
1363.37.3 Why does lsof say my command regular expression wasn't found?
1373.38 Why doesn't lsof report on shared memory segments?
1383.39 Why does lsof report two instances of itself?
1393.40 Why does lsof report '\n' in device cache file error messages?
1403.41 Kernel Symbol and Address Problems
1413.41.1 What does "lsof: WARNING: name cache hash size length error: 0"
142 mean?
1433.41.2 Why does lsof produce "garbage" output?
1443.42 Why does lsof report open files when run as super user that
145 it doesn't report when run with lesser privileges?
1463.43 Test Suite Problems
1473.43.1 Errors all tests can report:
1483.43.1.1 Why do tests complain "ERROR!!! can't execute ../lsof"?
1493.43.1.2 Why do tests complain "ERROR!!! can't find ..." a file?
1503.43.1.3 Why do some tests fail to compile?
1513.43.1.4 Why do some tests always fail?
1523.43.1.5 Why does the test suite say it hasn't been validated on
153 my dialect?
1543.43.1.6 Why do the tests complain they can't stat() or open()
155 /dev/mem or /dev/kmem?
1563.43.2 LTbigf test issues
1573.43.2.1 Why does the LTbigf test say that the dialect doesn't
158 support large files?
1593.43.2.2 Why does LTbigf complain about operations on its config.LTbigf*
160 file?
1613.43.2.3 Why does LTbigf warn that lsof doesn't return file offsets?
1623.43.3 Why does the LTbasic test complain "ERROR!!! lsof this ..."
163 and "ERROR!!! lsof that ..."?
1643.43.4 LTnfs test issues
1653.43.4.1 Why does the LTnfs test complain "couldn't find NFS file ..."?
1663.43.5 LTnlink test issues
1673.43.5.1 Why does the LTnlink test complain that its test file is on
168 an NFS file system?
1693.43.5.2 Why does LTnlink delay and report "waiting for link count
170 update: ..."?
1713.43.5.3 Why does LTnlink fail because of an unlink error?
1723.43.6 LTdnlc test issues
1733.43.6.1 Why won't the LTdnlc test run?
1743.43.6.2 What does the LTdnlc test mean by "... <path> found: 100.00%"?
1753.43.6.3 Why does the DNLC test fail?
1763.43.7 Why hasn't the test suite been qualified for 64 bit HP-UX
177 11 when lsof is compiled with gcc?
1783.43.8 LTszoff test issues
1793.43.8.1 Why does LTszoff warn that lsof doesn't return file offsets?
1803.43.9 LTlock test issues
1813.44 File descriptor list (the ``-d'' option) problems
1823.44.1 Why does lsof reject a ``-d'' FD list?
1833.44.2 Why are file descriptors other than those in my FD list
184 reported?
1853.45 How can I supply device numbers for inaccessible NFS file
186 systems?
1873.46 Why won't lsof find open files on over-mounted file systems?
1883.47 What can be done when lsof reports no more space?
1893.48 What if the lsof build encounters ar and ld problems?
190
1914.0 AIX Problems
1924.1 What is the Stale Segment ID bug and why is -X needed?
1934.1.1 Stale Segment ID APAR
1944.2 Gcc Work-around for AIX 4.1x
1954.3 Gcc and AIX 4.2
1964.4 Why won't lsof's Configure allow the use of gcc for AIX
197 below 4.1?
1984.5 What is an AIX SMT file type?
1994.6 Why does AIX lsof start so slowly?
2004.7 Why does exec complain it can't find libc.a[shr.o]?
2014.8 What does lsof mean when it says, "TCP no PCB, CANTSENDMORE,
202 CANTRCVMORE" in a socket file's NAME column?
2034.9 When the -X option is used on AIX 4.3.3, why does lsof disable
204 it, saying "WARNING: user struct mismatch; -X option disabled?"
2054.10 Why doesn't the -X option work on my AIX 5L or 5.[123] system?
2064.11 Why doesn't /usr/bin/oslevel report the correct AIX version?
2074.11.1 Why doesn't /usr/bin/oslevel report the correct AIX version
208 on AIX 5.1?
2094.12 Why does lsof for AIX 5.1 or above Power architecture
210 complain about kernel bit size?
2114.13 What can't gcc be used to compile lsof on the ia64 architecture
212 for AIX 5 and above?
2134.14 Why does lsof get a segmentation fault when compiled with gcc
214 for a 64 bit Power architecture AIX 5.1 kernel?
2154.15 Why does lsof ignore AFS on my AIX system?
2164.16 Why does lsof report "system paging space is low" and exit?
2174.17 Why does lsof have compilation and execution problems on AIX
218 5.3 above maintenance level 1?
219
2205.0 Apple Darwin Problems
2215.1 What do /dev/kmem-based and libproc-based mean?
2225.2 /dev/kmem-based Apple Darwin Questions
2235.2.1 Why does Configure ask for a path to the Darwin XNU kernel
224 header files?
2255.2.1.1 Why does Configure complain that Darwin XNU kernel header
226 files are missing?
2275.2.2 Why doesn't Apple Darwin lsof report text file information?
2285.2.3 Why doesn't Apple Darwin lsof support IPv6?
2295.2.4 Why does lsof complain about a mismatch between the release
230 for which lsof was compiled and the booted Mac OS X release?
2315.2.5 Why does lsof for Apple Darwin 8 and higher report
232 "stat(...): ..." in the NAME column?
2335.2.6 What are the limitations of Apple Darwin lsof link count
234 reporting?
2355.3 Libproc-based Apple Darwin Questions
236
2376.0 BSD/OS BSDI Problems
2386.0.5 Statement of deprecation
239
2407.0 DEC OSF/1, Digital UNIX, and Tru64 UNIX Problems
2417.1 Why does lsof complain about non-existent /dev/fd entries?
2427.2 Why does the Digital UNIX V3.2 ld complain about Ots* symbols?
2437.3 Why can't lsof locate named pipes (FIFOs) under V3.2?
2447.4 Why does lsof use the wrong configuration header files?
245 For example, why can't the lsof compilation find cpus.h?
2467.5 Why does lsof indicate incomplete paths with " -- " for Tru64
247 UNIX 5.1 files?
2487.6 Why doesn't lsof report link count, node number, and size
249 for some Tru64 5.x CFS files?
2507.7 Why does lsof say it can't read the kernel name list or
251 proc table on Digital UNIX 4.x or Tru64 UNIX?
252
2538.0 FreeBSD Problems
2548.1 Why doesn't lsof report on open kernfs files?
2558.2 Why doesn't lsof work on my FreeBSD system?
2568.3 Why doesn't lsof work on the RELEASE version of CURRENT?
2578.4 Why can't kvm_open() can't find some file?
2588.5 FreeBSD ZFS Problems
2598.5.1 Why does FreeBSD lsof report "WARNING: no ZFS support has been
2608.6 Why can't Configure create lsof_owner.h for FreeBSD 6 and above?
2618.6.1 Why are there lockf structure compiler errors for FreeBSD 6.0
262 and higher lsof?
2638.6.2 Why don't /usr/src/sys/sys/lockf.h and /usr/include/sys/lockf.h
264 match?
265
2669.0 HP-UX Problems
2679.1 What do /dev/kmem-based and PSTAT-based mean?
2689.2 /dev/kmem-based HP-UX lsof Questions
2699.2.1 Why doesn't a /dev/kmem-based HP-UX lsof compilation use -O?
2709.2.2 Why doesn't the /dev/kmem-based CCITT support work under 10.x?
2719.2.3 Why can't /dev/kmem-based lsof be compiled with `cc -Aa` or
272 `gcc -ansi` under HP-UX 10.x?
2739.2.4 Why does /dev/kmem-based lsof complain about no C compiler?
2749.2.5 Why does Configure complain about q4 for /dev/kmem-based lsof
275 for HP-UX 11?
2769.2.6 When compiling /dev/kmem-based lsof for HP-UX 11 what do the
277 "aCC runtime: ERROR..." messages mean?
2789.2.7 Why doesn't /dev/kmem-based lsof for HP-UX 11 report VxFS file
279 link counts, node numbers, and sizes correctly?
2809.2.8 Why can't /dev/kmem-based lsof be built with gcc for 64 bit
281 HP-UX 11?
2829.2.8.1 How can I acquire a gcc for building lsof for 64 bit HP-UX 11?
2839.2.9 Why does /dev/kmem-based lsof for HP-UX 11 report "unknown file
284 system type" for VxFS files?
2859.2.10 Why does the ANSI-C compiler complain about comments in HP-UX
286 11 header files?
2879.2.11 Why does dnode1.c cause the HP-UX 11 compiler to complain that
288 <sys/fs/vx_inode.h> is missing or incorrect?
2899.3 PSTAT-based HP-UX lsof Questions
2909.3.1 Why does PSTAT-based lsof complain about pst_static and
291 other PSTAT structures?
2929.3.2 Why does PSTAT-based lsof complain it can't read pst_*
293 structures?
2949.3.3 Why does PSTAT-based lsof rebuild the device cache file
295 after each reboot?
2969.3.4 Why doesn't PSTAT-based lsof report TCP addresses for
297 telnetd's open socket files?
2989.3.5 Why does PSTAT-based lsof cause an HP-UX 11.11 kernel panic?
2999.3.6 Why doesn't PSTAT-based lsof report a CWD that is on a loopback
300 (LOFS) file system?
3019.3.7 Why do some swinstall packages for PSTAT-based HP-UX 11.11
302 packages complain about setgid and setuid bits?
3039.3.8 Why won't the bundled C compiler build PSTAT-based lsof for
304 PA-RISC HP-UX 11.23?
3059.3.9 Why won't gcc build PSTAT-based lsof for PA-RISC HP-UX 11.23?
3069.3.10 Why does PSTAT-based lsof complain, "FATAL: pst_stream_size
307 should be: 672; is 72" on HP-UX 11.11 and above?
3089.4 Why won't the HP-UX depot install?
309
31010.0 Linux Problems
31110.1 What do /dev/kmem-based and /proc-based lsof mean?
31210.2 /proc-based Linux lsof Questions
31310.2.1 Why doesn't /proc-based lsof report file offsets (positions)?
31410.2.2 Why does /proc-based lsof report "can't identify protocol" for
315 some socket files?
31610.2.3 Why does /proc-based lsof warn about unsupported formats?
31710.2.4 Why does /proc-based lsof report "(deleted)" after a path name?
31810.2.5 Why doesn't /proc-based lsof report full open file information
319 for all processes?
32010.2.6 Why won't Customize offer to change HASDCACHE or WARNDEVACCESS
321 for /proc-based lsof?
32210.2.7 /proc-based lsof Linux NFS questions
32310.2.7.1 Why can't lsof find files on an accessible NFS file system?
32410.2.7.2 Why can't lsof find files on an inaccessible NFS file system?
32510.2.8 Why doesn't /proc-based Linux lsof report socket options and
326 values, socket state flags, and TCP options and values?
32710.2.9 Does /proc-based Linux lsof use a device cache?
32810.2.10 Why doesn't /proc-based Linux lsof report any or all file structure
329 values for its +fcfgGn option?
33010.3 Special Linux file types
33110.3.1 Why is ``DEL'' reported as a Linux file type?
33210.3.2 Why is ``unknown'' reported as a Linux file type?
33310.4 Linux ``mem'' Entry Problems
33410.4.1 What do ``path dev=xxx'' and ``path inode=yyy'' mean in the
335 NAME column of Linux ``mem'' file types?
33610.4.2 Why is neither link count nor size reported for some Linux
337 ``DEL'' and ``mem'' file types?
33810.5 Special Linux NAME column messages
33910.5.1 What does ``(stat: xxx)'' mean in the NAME column of Linux
340 files?
34110.5.2 What does ``(readlink: xxx)'' mean in the NAME column of
342 Linux files?
34310.6 Why is ``NOFD'' reported as a Linux file type?
34410.7 Why does Linux lsof report a NAME column value that begins with
345 ``/proc''?
34610.8 Linux /proc/net/tcp* and /proc/net/udp* issues
34710.8.1 Why use the Linux -X option?
34810.8.2 Why does lsof say ``-i is useless when -X is specified''?
34910.8.3 Why does lsof say ``can't identify protocol (-X specified)''?
350
35111.0 NetBSD Problems
35211.1 Why doesn't lsof report on open kernfs files?
35311.2 Why doesn't lsof report on open files on: file descriptor
354 file systems; /proc file systems; 9660 (CD-ROM) file systems;
355 MS-DOS (floppy disk) file systems; or kernel file systems?
35611.3 Why does lsof produce confusing results for nullfs file
357 systems?
35811.4 NetBSD header file problems
35911.4.1 Why can't the compiler find some NetBSD header files?
36011.4.2 Why does NetBSD lsof produce incorrect output?
36111.5 Why isn't lsof feature xxx enabled for NetBSD?
362
36312.0 NEXTSTEP and OPENSTEP Problems
36412.1 Why can't lsof report on 3.1 lockf() or fcntl(F_SETLK)
365 locks?
36612.2 Why doesn't lsof compile for NEXTSTEP with AFS?
367
36813.0 OpenBSD Problems
36913.1 Why doesn't lsof support kernfs on my OpenBSD system?
37013.2 Will lsof work on OpenBSD on non-x86-based architectures?
37113.3 <sys/pipe.h> problems
37213.3.1 Why does the compiler claim nbpg isn't defined?
37313.3.2 What value should I assign to nbpg?
37413.4 Why doesn't lsof report on open MS-DOS file system (floppy
375 disk) files?
37613.5 Why isn't lsof feature xxx enabled for OpenBSD?
377
37814.0 Output problems
37914.1 Why do the lsof column sizes change?
38014.2 Why does the offset have ``0t' and ``0x'' prefixes?
38114.3 What are the values printed in the FILE_FLAG column
382 and why is 0x<value> sometimes included?
38314.3.1 Why doesn't lsof display FILE_FLAG values for my dialect?
38414.4 Network Addresses
38514.4.1 Why does lsof's -n option cause IPv4 addresses, mapped to
386 IPv6, to be displayed in IPv6 notation?
38714.5 Why does lsof output \x, ^x, or \xnn for characters
388 sometimes?
38914.5.1 Why is space considered a non-printable character in command
390 names?
39114.6 Why doesn't lsof print all the characters of a command name?
39214.7 Why does lsof reject some -c command names, saying their lengths
393 are "> what system provides (nn)"?
39414.8 Why does lsof sometimes print TYPE numbers instead of names?
39514.9 Marker line format problems
39614.9.1 Why won't lsof accept a marker line format?
39714.9.2 Why does lsof reject the NL (%n) marker line format?
39814.10 How are protocol state name exclusion and inclusion used?
39914.10.1 Why doesn't my dialect support state name exclusion and inclusion?
400
40115.0 Pyramid Version Problems
40215.0.5 Statement of deprecation
403
40416.0 SCO Problems
40516.1 SCO OpenServer Problems
40616.1.1 How can I avoid segmentation faults when compiling lsof?
40716.1.2 Where is libsocket.a?
40816.1.3 Why do I get "warning C4200" messages when I compile lsof?
40916.2 SCO|Caldera UnixWare Problems
41016.2.1 Why doesn't lsof compile on my UnixWare 7.1.1 or above
411 system?
41216.2.2 Why does lsof complain about node_self() on my UnixWare
413 7.1.1 or above system?
41416.2.3 Why does UnixWare 7.1.1 or above complain about -lcluster,
415 node_self(), or libcluster.so?
41616.2.4 Why does UnixWare 7.1.1 or above lsof complain it can't
417 read the kernel name list?
41816.2.5 Why doesn't lsof report link count, node number, and size
419 for some UnixWare 7.1.1 or above CFS files?
42016.2.6 Why doesn't lsof report open files on all UnixWare 7.1.1
421 NonStop Cluster (NSC) nodes?
42216.2.7 Why doesn't lsof report the UnixWare 7.1.1 NonStop Cluster
423 (NSC) node a process is using?
42416.2.8 Why does the compiler complain about missing UnixWare 2.1[.x]
425 header files?
426
42717.0 Sun Problems
42817.0.5 Statement of deprecation
42917.1 My Sun gcc-compiled lsof doesn't work -- why?
43017.2 How can I make lsof compile with gcc under Solaris 2.[456],
431 2.5.1, 7, 8 or 9?
43217.3 Why does Solaris Sun C complain about system header files?
43317.4 Why doesn't lsof work under my Solaris 2.4 system?
43417.5 Where are the Solaris header files?
43517.6 Where is the Solaris /usr/src/uts/<architecture>/sys/machparam.h?
43617.7 Why does Solaris lsof say ``can't read proc table''?
43717.8 Why does Solaris lsof complain about a bad cached clone device?
43817.9 Why doesn't Solaris make generate .o files?
43917.10 Why does lsof report some Solaris 2.3 and 2.4 lock types as `N'?
44017.11 Why does lsof Configure say "WARNING: no cc in ..."?
44117.12 Solaris 7, 8 and 9 Problems
44217.12.1 Why does lsof say the compiler isn't adequate for Solaris
443 7, 8 or 9?
44417.12.2 Why does Solaris 7, 8 or 9 lsof say "FATAL: lsof was compiled
445 for..."?
44617.12.3 How do I build lsof for a 64 bit Solaris kernel under a 32
447 bit Solaris kernel?
44817.12.4 How do I install lsof for Solaris 7, 8 or 9?
44917.12.5 Why does my Solaris 7, 8 or 9 system say it cannot execute
450 lsof?
45117.12.6 What gcc will produce 64 bit Solaris 7, 8 and 9 executables?
45217.12.7 Why does lsof on my Solaris 7, 8 or 9 system say, "can't
453 read namelist from /dev/ksyms?"
45417.13 Solaris and COMMON
45517.13.1 What does COMMON mean in the NAME column for a Solaris VCHR
456 file?
45717.13.2 Why does a COMMON Solaris VCHR file sometimes seem to have an
458 incorrect minor device number?
45917.14 Why don't lsof and Solaris pfiles reports always match?
46017.15 Why does lsof say, "kvm_open(namelist=default, core=default):
461 Permission denied?"
46217.16 Why is lsof slow on my busy Solaris UFS file system?
46317.17 Why is lsof so slow on my Solaris 8 or 9 system?
46417.18 Solaris and VxFS
46517.18.1 Why doesn't lsof support VxFS 3.4 on Solaris 2.6, and above?
46617.18.2 Why does lsof report "vx_inode: vxfsu_get_ioffsets error"
467 for open Solaris 2.6 and above VxFS 3.4 and above files?
46817.18.3 Why does Solaris Configure claim there is no VxFS library?
46917.18.4 Why doesn't Solaris lsof report VxFS path name components?
47017.18.5 Why does Solaris 10 lsof report scrambled VxFS paths?
47117.19 Large file problems
47217.19.1 Why does lsof complain it can't stat(2) a Solaris 2.5.1
473 large file?
47417.20 Why does lsof get a segmentation fault on 64 bit Solaris
475 8 using NIS+?
47617.21 Will lsof crash the Solaris kernel?
47717.22 Why does lsof on Solaris 7, 8, or 9 report a kvm_open()
478 failure?
47917.23 Solaris and SAM-FS
48017.23.1 Why does Solaris lsof report "(limited SAM-FS info)"?
48117.23.2 Why can't lsof locate named SAM-FS files?
48217.24 Lsof and Solaris 10 zones
48317.24.1 How can I make lsof list the Solaris zone?
48417.24.2 Why doesn't lsof work in a Solaris 10 zone?
48517.24.3 Why does lsof complain it can't stat() Solaris 10 zone file
486 systems?
48717.25 Solaris 10 problems
48817.25.1 Why does Solaris 10 lsof sometimes report the wrong path name?
48917.25.2 Why does Solaris 10 lsof sometimes report only the mounted-on
490 directory and device?
49117.25.3 What does "(deleted)" mean in the NAME column of a Solaris 10
492 open file?
49317.25.4 What does "(?)" mean in the NAME column of a Solaris 10 open
494 file?
49517.26 Solaris contract file problems
49617.26.1 Why doesn't lsof report size, link count and node number for
497 Solaris 10 contract files?
49817.26.2 Why can't lsof locate a Solaris 10 contract file by path name?
49917.27 Solaris 10 ZFS probblems
50017.27.1 Why does Configure ask for the location of ZFS header files?
50117.27.2 Why do -h and -v output warn about possibly inaccurate ZFS
502 structure definitions?
50317.27.3 Why don't the Open Solaris ZFS header files provide correct
504 ZFS kernel structure definitions?
50517.28 Problems with Solaris 9 and above
50617.28.1 Why does the compiler complain about lgrp_root on Solaris 9
507 and above?
508
50918.0 Lsof Features
51018.1 Why doesn't lsof doesn't report on /proc entries on my
511 system?
51218.2 How do I disable the device cache file feature or alter
513 it's behavior?
51418.2.1 What's the risk with a perverted device cache file?
51518.2.2 How do I put the full host name in a personal device cache file
516 path?
51718.2.3 How do I put the personal device cache file in /tmp?
51818.3 Why doesn't lsof know about AFS files on my favorite dialect?
51918.3.1 Why doesn't lsof report node numbers for all AFS volume files,
520 or how do I reveal dynamic module addresses to lsof?
521______________________________________________________________________
522
523
5241.0 General Concepts
525
5261.1 Lsof -- what is it?
527
528 Lsof is a UNIX-specific tool. Its name stands for LiSt
529 Open Files, and it does just that. It lists information
530 about files that are open by the processes running on a
531 UNIX system.
532
533 See the lsof man page, the 00DIST file, the 00QUICKSTART
534 file, and the 00README file of the lsof distribution for
535 more information.
536
5371.2 Where do I get lsof?
538
539 Lsof is available via anonymous ftp from lsof.itap.purdue.edu.
540 Look in the pub/tools/unix/lsof sub-directory.
541
542 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof
543
544 Bzip2'd, compressed and gzip'd tar files with GPG certificates
545 are available.
546
5471.2.1 Are there mirror sites?
548
549 On April 28, 2009 these sites appeared to have the lastest
550 lsof revision:
551
552 ftp://ftp.fu-berlin.de/pub/unix/tools/lsof
553 ftp://sunsite.ualberta.ca/pub/Mirror/lsof
554
5551.2.2 Are lsof executables available?
556
557 Some lsof executables are available in the subdirectory
558 tree pub/tools/unix/lsof/binaries These are neither guaranteed
559 to be current nor cover every dialect and machine architecture.
560
561 I don't recommend you use pre-compiled lsof binaries; I
562 recommend you obtain the sources and build your own binary.
563 Even if you're a Sun user without a Sun C compiler, you
564 can use gcc to compile lsof.
565
566 If you must use a binary file, please be conscious of the
567 security and configuration implications in using an executable
568 of unknown or different origin. The lsof binaries are
569 accompanied by GPG certificates. Please use them!
570
571 Three additional cautions apply to executables:
572
573 1. Don't try to use an lsof executable, compiled for one
574 version of a UNIX dialect, on another. Patches can
575 make the dialect version different.
576
577 2. If you want to use an lsof binary on multiple systems,
578 they must be running the same dialect OS version and
579 have the same patches and feature support.
580
5811.2.3 How do I check the validity of an lsof distribution?
582
583 There are two ways to check the validity of an lsof
584 distribution:
585
586 1. Follow the instructions in the CHECKSUMS_<revision>
587 file found with the lsof distribution.
588
589 Checking with GPG is the best method.
590
591 2. Follow the instructions in the "Security" section of the
592 README.lsof_<revision> file found inside the lsof
593 distribution.
594
595 Again, checking with GPG is the best method.
596
5971.2.4 Why can't I get the sum(1) result reported in
598 README.lsof_<revision>?
599
600 The "Security" section of the README.lsof_<revision> file found
601 inside the lsof distribution gives md5, sum, and GPG certificate
602 information.
603
604 The simplest, the sum(1) signature, seems to be the trickiest.
605 That's because there are different sum(1) methods, BSD systems
606 usually have cksum(1) instead of sum(1), and different systems
607 compute the block size value differently.
608
609 First, the lsof sum results are computed with the old,
610 "alternate" algorithm. On newer systems, you can use sum's
611 "-r" option to get that computation result.
612
613 Second, on BSD systems you usually must use cksum(1) instead
614 of sum(1), because they have no sum(1). To tell cksum(1)
615 to use the old, "alternate" algorithm, use its "-o1" option.
616
617 Third, the second value that sum reports, the block count, may
618 be computed differently on different systems -- usually block
619 size is considered to be 512 or 1,024. The lsof block counts
620 were computed on a system with a sum(1) option that considers
621 block size to be 512. The BSD system cksum(1) -o1 option
622 considers block size to be 1,024. If your sum(1) or cksum(1)
623 doesn't report a block count that matches the sum(1) signature
624 given in README.lsof_<revision>, check its man page to see what
625 block size it uses, then adjust its reported block count
626 appropriately.
627
6281.2.5 Why won't gpg accept the lsof-signing PGP public key?
629
630 An older PGP key that once signed lsof distributions is
631 included in lsof revisions prior to 4.70. The PGP key is
632 indeed my key, but is incompatible with GPG. It was created
633 about ten years ago and is still acceptable to PGP versions
634 2.6.2 through 6.5.2.
635
636 Lsof revisions 4.70 and above are signed with a copy of my PGP
637 key that has been made acceptable for use with GPG by importing
638 it under GPG's "--allow-non-selfsigned-uid" option.
639
640 You can find my GPG compatible key in lsof revisions 4.70 and
641 above and at:
642
643 ftp://lsof.itap.purdue.edu/pub/Victor_A_Abell.gpg
644
645 If you have an older lsof revision with my PGP key, there are
646 two possible ways to use it:
647
648 * Use it with a PGP version from 2.6.2 through 6.5.2.
649
650 * Use GPG's "--allow-non-selfsigned-uid" option when you
651 import my PGP key into your GPG key ring.
652
653 $ gpg --allow-non-selfsigned-uid --import Victor_A_Abell.pgp
654
6551.3 Where can I get more lsof documentation?
656
657 A significant set of documentation may be found in the lsof
658 distribution (See "Where can I get lsof?). There is a
659 manual page, copious documentation in files whose names
660 begin with 00, and a copy of this FAQ in the file 00FAQ
661 (perhaps slightly less recent than this file if you're
662 reading it via a web browser.)
663
664 Two URLs provide some documentation that appears in the
665 lsof distribution:
666
667 FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
668
669 man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
670
6711.4 How do I report an lsof bug?
672
673 If you believe you have discovered a bug in lsof, you can
674 report it via e-mail to <abe@purdue.edu>. Do NOT report lsof
675 bugs to the UNIX dialect vendor. Make sure "lsof" appears in
676 the "Subject:" line so my e-mail filter won't classify your
677 letter as Spam.
678
679 Before you send me a bug report, please read the "Bug Reports"
680 section of the 00README file of the lsof distribution. It
681 lists the steps you should take before and when reporting a
682 suspected bug.
683
6841.5 Where can I get the lsof FAQ?
685
686 This lsof FAQ is available in the file 00FAQ in the lsof
687 distribution and at the URL:
688
689 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
690
6911.5.1 How timely is the on-line FAQ?
692
693 The on-line FAQ is sometimes too timely. :-)
694
695 I update it as soon as new information is available. That may
696 include information about support that won't appear in the lsof
697 source distribution until the next revision. If you encounter
698 something like that, please send me e-mail at <abe@purdue.edu>. I
699 may be able to point you at a pre-release distribution that contains
700 the support of interest. Make sure "lsof" appears in the "Subject:"
701 line so my e-mail filter won't classify your letter as Spam.
702
7031.6 Is there a test suite?
704
705 Yes, as of lsof revision 4.63 there's an automated lsof
706 test suite in the tests/ sub-directory of the lsof top-level
707 directory.
708
709 More information on using the test suite, what it does,
710 how to use it and how to configure it may be found in the
711 00TEST file of the lsof distribution. That file also
712 explains where the test suite has been tested.
713
714 Frequently asked questions about the test suite will be
715 asked and answered here in the FAQ. (See "Test Suite
716 Problems.")
717
718 After lsof has been configured with the Configure script,
719 lsof can be made and tested with:
720
721 $ make
722 $ cd tests
723 $ make
724
725 Under normal conditions -- i.e., unless the lsof tree has
726 been cleaned or purged severely -- all tests or individual
727 tests may be run by:
728
729 $ cd test
730 $ make
731 or
732 $ <run a single test> (See 00TEST.)
733
7341.7 Is lsof vulnerable to the standard I/O descriptor attack?
735
736 Lsof revisions 4.63 and above are not vulnerable.
737
738 Lsof revisions 4.62 and below are vulnerable, but no damage
739 scenarios have so far been demonstrated.
740
741 The standard I/O descriptor attack is a local programmed
742 assault on setuid and setgid programs that tricks them into
743 opening a sensitive file with write access on a standard
744 descriptor, usually stderr (2), and writing error messages
745 to stderr. If the attacker can control the content of the
746 error message, the attacker may gain elevated privileges.
747
748 The attack was first described in Pine Internet Advisory
749 PINE-CERT-20020401, available at:
750
751 http://www.pine.nl/advisories/pine-cert-20020401.txt
752
753 If you are using an lsof revision below 4.63, you should
754 remove any setuid or setgid permissions you might have
755 given its executable. Then you should upgrade to lsof
756 revision 4.63.
757
7581.8 Can I alter lsof's make(1) behavior?
759
760 Yes. There are at least two ways to do that.
761
762 You can put replacements for lsof Makefile strings in your
763 environment. If you specify the -e make option, make will
764 give environment variable values precedence over strings
765 from the Makefile. For example, to change the compiler
766 string CC from the environment, you might do this with the
767 Bourne shell:
768
769 $ CC=foobar; export CC
770 $ make -e
771
772 You can also replace lsof Makefile strings in the make
773 command invocation. Here's the previous example done that
774 way:
775
776 $ make CC=foobar
777
778 Changing the CFGF, CFGL, and DEBUG strings used in lsof
779 Makefiles, either from the environment or from the make
780 invocation, can significantly alter lsof make(1) behavior.
781 I commonly use DEBUG to change the -O option to -g so I
782 can build an lsof executable for debugging -- e.g.,
783
784 $ make DEBUG=-g
785
786 (Look for DEBUG in this FAQ for other examples of its use.)
787
788 Consult the Makefiles to see what CFGL, CFGL, and other
789 lsof Makefile strings contain, and to see what influence
790 their alteration might have on lsof make(1) behavior.
791
7921.9 Is there an lsof license?
793
794 No.
795
796 The only restriction on the use or redistribution of lsof
797 is contained in this copyright statement, found in every
798 lsof source file. (The copyright year in or format of the
799 notice may vary slightly.)
800
801 /*
802 * Copyright 2002 Purdue Research Foundation, West Lafayette,
803 * Indiana 47907. All rights reserved.
804 *
805 * Written by Victor A. Abell
806 *
807 * This software is not subject to any license of the American
808 * Telephone and Telegraph Company or the Regents of the
809 * University of California.
810 *
811 * Permission is granted to anyone to use this software for
812 * any purpose on any computer system, and to alter it and
813 * redistribute it freely, subject to the following
814 * restrictions:
815 *
816 * 1. Neither the authors nor Purdue University are responsible
817 * for any consequences of the use of this software.
818 *
819 * 2. The origin of this software must not be misrepresented,
820 * either by explicit claim or by omission. Credit to the
821 * authors and Purdue University must appear in documentation
822 * and sources.
823 *
824 * 3. Altered versions must be plainly marked as such, and must
825 * not be misrepresented as being the original software.
826 *
827 * 4. This notice may not be removed or altered.
828 */
829
8301.10 Language locale support
831
8321.10.1 Does lsof support language locales? How do I use the support?
833
834 Most UNIX dialect versions of lsof support 8 bit language
835 locale characters -- e.g., the ability to print 8 bit
836 characters that have accents and other marks over them.
837
838 See the answer to the "Does lsof support wide characters in
839 language locales?" question for information on when lsof's
840 language locale support covers characters wider than 8 bits.
841
842 To see if lsof supports language locales for your dialect, look
843 in the dialect's machine.h header file for the HASSETLOCALE
844 definition. If it is present and not disabled, then lsof has
845 language locale support for the dialect.
846
847 To enable lsof's language locale support, you must specify in a
848 locale environment variable (e.g., LANG) a language locale
849 known to your system that supports the printing of marked
850 characters -- e.g, en_US. (On some dialects locale(1) may be
851 used to list the known language locales.)
852
853 Note that LANG=C and LANG=POSIX are NOT language locales that
854 support the printing of marked characters.
855
856 If the language locale doesn't support the printing of marked
857 characters, lsof's OUTPUT of them follows the rules for
858 non-printable characters described in the OUTPUT section of
859 lsof(8).
860
861 Consult your dialect's setlocale(3) man page for the names of
862 environment variables other than LANG -- e.g., LC_ALL,
863 LC_TYPE, etc. -- which may be used to define language locales.
864
8651.10.2 Does lsof support wide characters in language locales?
866
867 When lsof's language locale support is enabled with the
868 HASSETLOCALE definition, for selected dialects lsof will also
869 print wide characters (e.g., from UTF-8) when iswprint(3)
870 reports them to be printable.
871
872 Wide character support is available when HASWIDECHAR is defined
873 in a dialect's machine.h header file. As of this writing on
874 July 22, 2004, the following dialect versions have wide character
875 support:
876
877 AIX >= 4.3.2
878 Apple Darwin >= 7.3.0
879 FreeBSD >= 5.2
880 HP-UX >= 11.00
881 /proc-based Linux
882 NetBSD >= 1.6
883 SCO OpenServer >= 5.0.6
884 Solaris >= 2.6
885 Tru64 UNIX 5.1
886
8871.11 Are any files in the lsof distribution copyrighted?
888
889 Yes. Most files carry the copyright of the Purdue Research
890 Foundation and may be redistributed under the terms that
891 accompany the copyright notice. Those terms may also be found
892 in the answer to the question, "Is there an lsof license?")
893
894 A few files carry other copyright notices. Some are BSD
895 notices and they explain the terms under which they are
896 included in the lsof distribution.
897
898 Those that carry vendor copyright notices have been reproduced
899 in their original or modified forms with permission from the
900 copyright owners. That permission is indicated in the README
901 files that accompany the files.
902
9031.12 Are there other lsof-related resources?
904
905 There are other resources available, connected to lsof. Among
906 them are FreeBSD and Linux packages whose products use lsof and
907 two particularly interesting resources.
908
909 The two interesting resources are a Gnome Tool Kit (GTK) GUI
910 for lsof and a Perl wrapper module.
911
912 The GTK GUI is called Glsof and was developed by Gnele. It can
913 be found at:
914
915 http://www.sourceforge.net
916
917 The Perl wrapper module by Marc Beyer can be found at:
918
919 http://search.cpan.org/dist/Unix-Lsof/
920
9211.13 What does the "WARNING: unsupported dialect or version" mean?
922
923 The lsof configure script issues that message for UNIX dialects
924 or their versions where I have been unable to test the current
925 revision of lsof. The message doesn't mean that lsof won't
926 work, just that I have no direct evidence that it will.
927
928 If the COnfigure script succeeds, except for the warning, try
929 compiling) lsof. If that succeeds, try the lsof test suite.
930
9312.0 Lsof Ports
932
9332.1 What ports exist?
934
935 The pub/lsof.README file carries the latest port information:
936
937 AIX 5.[23] and 5.3
938 FreeBSD 4.9 for x86-based systems
939 FreeBSD 7.[0123] and 8.0 for AMD64-based systems
940 Linux 2.1.72 and above for x86-based systems
941 Solaris 9, 10 and 11
942
943 In the above list the only UNIX dialects present are ones for
944 which I test the current lsof revision. Lsof may still support
945 unlisted dialect versions -- e.g., HP-UX 10.20, Solaris 7, etc.
946 -- but I don't have access to systems where I could test lsof
947 on them, so I can't claim lsof works on them. If your dialect
948 isn't in the list, you should try building lsof on it anyway.
949
950 Lsof version 4 predecessors, versions 2 and 3, may support older
951 version of some dialects. Contact me via e-mail at <abe@purdue.edu>
952 if you're interested in their distributions. Make sure "lsof"
953 appears in the "Subject:" line so my e-mail filter won't classify
954 your letter as Spam.
955
9562.2 What about a new port?
957
958 The 00PORTING file in the distribution gives hints on doing
959 a port. I will consider doing a port in exchange for
960 permanent access to a test host. I require permanent access
961 so I can test new lsof revisions, because I will not offer
962 distributions of dialect ports I cannot upgrade and test.
963
9642.2.1 User-contributed Ports
965
966 Sometimes I receive contributions of ports of lsof to
967 systems where I can't test future revisions of lsof. Hence,
968 I don't incorporate these contributions into my lsof
969 distribution.
970
971 However, I do make descriptions of these contributions
972 available. You can find them in the 00INDEX and README
973 files at:
974
975 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/contrib
976
977 Consult the 00INDEX file in the contrib/ directory for a
978 list of the available contributions and consult README
979 there for information on how to obtain them.
980
9812.3 Why isn't there an AT&T SVR4 port?
982
983 I haven't produced an AT&T SVR4 port because I haven't seen
984 a UNIX dialect that is strictly limited to the AT&T System
985 V, Release 4 source code. Every one I have seen is a
986 derivative with vendor additions.
987
988 The vendor additions are significant to lsof because they
989 affect the internal kernel structures with which lsof does
990 business. While some vendor derivatives of SVR4 are similar,
991 each one I have encounted so far has been different enough
992 from its siblings to require special source code.
993
994 If you're interested in an SVR4 version of lsof, here are
995 some existing ports you might consider:
996
997 DC/OSx (This obsolete port is only available upon
998 special request.)
999 Reliant UNIX (This obsolete port is only available
1000 upon special request.)
1001 SCO|Caldera UnixWare (This is the most likely choice.)
1002 Solaris
1003
10042.4 Why isn't there an SGI IRIX port?
1005
1006 Lsof support for IRIX was terminated at lsof revision 4.36,
1007 because it had become increasingly difficult for me to
1008 obtain information on the IRIX kernel structures lsof needs
1009 to access.
1010
1011 At IRIX 6.5 I decided the obstacles were too large for me
1012 to overcome, and I stopped supporting lsof on IRIX. I have
1013 sources to the last revision of lsof (4.36) for IRIX, but
1014 that version of lsof does not work on IRIX 6.5 and is
1015 vulnerable to the standard I/O descriptor attack. (See
1016 the "Is lsof vulnerable to the standard I/O descriptor
1017 attack?" Q&A for more information.) Contact me to discuss
1018 obtaining those sources.
1019
1020 If you wish to pursue the issue, don't contact me, contact
1021 SGI. This case was opened with SGI on the subject:
1022
1023 Case ID: 0982584
1024 Category: Unix
1025 Priority: 30-Moderate Impact
1026
1027 Problem Summary:
1028 kernel structure header files needed for continued lsof
1029 support
1030
1031 Problem Description:
1032 Email In 07/17/98 19:09:23
1033
10342.5 Why does lsof's Configure script report "WARNING: unsupported
1035 dialect or version"?
1036
1037 Lsof's Configure script issues this message when it encounters
1038 a dialect or its version that lsof once supported, but no
1039 longer does. Usually I drop support for a dialect or version
1040 when I can no longer test lsof on it.
1041
1042 However, it's worth trying to compile and use lsof. Be sure to
1043 run the test suite. (See the answer to the "Is there a test
1044 suite? question for information on the test suite.)
1045
1046 If you have problems with an unsupported dialect or version,
1047 contact me via e-mail at <abe@purdue.edu> and I may be able to help.
1048 Make sure "lsof" appears in the "Subject:" line so my e-mail filter
1049 won't classify your letter as Spam.
1050
1051
10523.0 Lsof Problems
1053
10543.1 Configuration Problems
1055
10563.1.1 Why can't Configure determine the UNIX dialect version?
1057
1058 The lsof Configure script uses UNIX shell commands, often in a
1059 command pipeline, to determine the UNIX dialect version.
1060 (Consult the dialect stanza in Configure to determine which
1061 commands are used.) If Configure can't determine the dialect
1062 version, probably one of the commands is not behaving as
1063 Configure expects.
1064
1065 Symptoms of the failure include Configure warning messages and
1066 incorrect version definitions in the Makefile CFLAGS.
1067
1068 If you suspect that the lsof Configure script is failing to
1069 determine the dialect version correctly, try running the
1070 commands from Configure stanza one at a time. That will
1071 usually reveal the source of the problem. Be particularly
1072 mindful that the PATH environment variable can cause commands
1073 to be executed from non-standard directories.
1074
1075 If you can't determine the source of the problem, there is a
1076 work-around. You can supply the UNIX dialect version in the
1077 LSOF_VSTR environment variable. Use Configure as a guide to
1078 forming what it expects in LSOF_VSTR. There is also some
1079 information on LSOF_VSTR in the 00XCONFIG documentation file
1080 of the lsof distribution.
1081
10823.2 Compilation Problems
1083
10843.2.1 Why does the compiler complain about missing header files?
1085
1086 When you use make to build lsof, the compiler may complain
1087 that it can't find header files -- e.g.,
1088
1089 $ make
1090 (cd lib; make DEBUG="-O" CFGF="-DAIXA=0 -DAIXV=4330 \
1091 -DLSOF_VSTR=\"4.3.3.0\"")
1092 gcc -DAIXA=0 -DAIXV=4330 -DLSOF_VSTR="4.3.3.0" -O \
1093 -c ckkv.c
1094 In file included from ckkv.c:33: ../machine.h:70: \
1095 sys/types.h: A file or directory in the path name \
1096 does not exist. \
1097
1098 That type of complaint doesn't represent an lsof problem.
1099 It represents a problem with a missing system header file
1100 that probably should be found in /usr/include or in the
1101 system source tree.
1102
1103 As a first step try using find(1) to locate the problem
1104 header file. If it's a system header file and can't be
1105 found, here are some possible causes:
1106
1107 1. The file set, RPM or package containing the header files
1108 has not been installed. Instructions for doing that
1109 are specific to the UNIX dialect and beyond the scope
1110 of this document.
1111
1112 2. If the compiler is gcc, the private gcc header files:
1113
1114 * May not have been installed;
1115
1116 * May have been installed incorrectly;
1117
1118 * May not have been updated properly after the last
1119 compiler or system update;
1120
1121 * Ones from a previous installation may not have been
1122 removed.
1123
1124 A path leading to the gcc private header files can be
1125 found with `gcc -v`. Consult the gcc documentation for
1126 instructions on proper installation of the private gcc
1127 header files.
1128
1129 3. On some dialects -- e.g., FreeBSD, NetBSD, OpenBSD --
1130 lsof may need to use header files that are located in
1131 the system source tree -- /sys or /usr/src/sys, for
1132 example. Make sure the system source tree has been
1133 installed.
1134
11353.2.2 Why does gcc complain about the contents of header files
1136 distributed by the system's vendor?
1137
1138 When you use make to build lsof and gcc to compile it, gcc
1139 may complain that it finds errors in system header files
1140 -- e.g.,
1141
1142 $ make
1143 (cd lib; make DEBUG="-O" CFGF="-Dsolaris=80000 \
1144 -DHASPR_GWINDOWS -m64 -DHASIPv6 -DHAS_VSOCK \
1145 -DLSOF_VSTR=\"5.8\"")
1146 gcc -Dsolaris=80000 -DHASPR_GWINDOWS -m64 -DHASIPv6 \
1147 -DHAS_VSOCK -DLSOF_VSTR="5.8" -O -c dvch.c
1148 In file included from /usr/include/sys/proc.h:31, \
1149 from /homes/abe/gnu/gcc-3.2.1/lib/gcc-lib/sparcv9-sun-solaris2/ \
1150 3.2.1/include/sys/user.h:267, from /usr/include/kvm.h:13, \
1151 from ../dlsof.h:53, from ../lsof.h:172, from dvch.c:43: \
1152 /homes/abe/gnu/gcc-3.2.1/lib/gcc-lib/sparcv9-sun-solaris2/\
1153 3.2.1/include/sys/task.h:59: parse error before "uint_t"
1154
1155 Errors like the above are most likely not problems in the
1156 system's header files, but in the private copies of them
1157 that were created when gcc was made or installed. Note
1158 the presense of
1159 ".../gcc-3.2.1/lib/gcc-lib/sparcv9-sun-solaris2/3.2.1/include/..."
1160 in the paths for user.h and task.h. It indicates both
1161 header files are gcc-specific.
1162
1163 To solve errors like this requires comparing the header
1164 files in the vendor's /usr/include tree to the gcc-specific
1165 ones in gcc's private gcc-lib/.../include tree. It may be
1166 necessary to regenerate gcc-specific header files, correct
1167 them or remove them. See the gcc distribution for the
1168 appropriate tools.
1169
1170 A possible temporary work-around is to direct gcc to use
1171 the vendor's header files instead of its temporary ones by
1172 declaring -I/usr/include in the compilation flags.
1173
11743.2.3 Other header file problems
1175
1176 Don't overlook any vendor tools that might validate the
1177 vendor header files installed on the system -- e.g., the
1178 Solaris pkgchk tool can be used to check the header files
1179 that were installed from the SUNWhea package.
1180
1181 For other header file problems contact me at <abe@purdue.edu>.
1182 Please follow the reporting guidelines in the "How do I
1183 report an lsof bug?" section of this FAQ.
1184
11853.3 Why doesn't lsof report full path names?
1186
1187 Lsof reports the full path name when it is specified as a
1188 search argument for open files that match the argument.
1189 However, if the argument is a file system mounted-on
1190 directory, and lsof finds additional path name components
1191 from the kernel name cache, it will report them.
1192
1193 Lsof reports path name for file system types that have path
1194 name lookup features -- e.g., some versions of AdvFS for
1195 Digital and Tru64 UNIX. The Linux /proc-based lsof reports
1196 full path names, because the Linux /proc file system provides
1197 them. Lsof on recent builds of Solaris 10 also report full
1198 path names, because those Solaris kernels record the full path
1199 name in the vnode structure.
1200
1201 Otherwise, lsof uses the kernel name cache, where it exists
1202 and can be accessed, and reports some or all path name
1203 components (e.g., the sys and proc.h components of
1204 /usr/include/sys/proc.h) for these dialects:
1205
1206 Apple Darwin
1207 DC/OSx
1208 FreeBSD
1209 HP-UX, /dev/kmem and PSTAT based
1210 Linux, /dev/kmem-based
1211 NetBSD
1212 NEXTSTEP
1213 OpenBSD
1214 OPENSTEP
1215 Reliant UNIX
1216 SCO OpenServer
1217 SCO|Caldera UnixWare
1218 Solaris 2.x, 7, 8 and 9 (except for some VxFS versions;
1219 see the "Why doesn't Solaris
1220 lsof report VxFS path name
1221 components?" section for more
1222 information)
1223 Solaris 10 (early builds) Tru64 UNIX
1224
1225 As far as I can determine, AFS path lookups don't share in
1226 kernel name cache operations, so lsof can't identify open AFS
1227 path name components. Apparently Solaris VxFS versions 4 and
1228 above don't share in kernel name cache operations, either, so
1229 lsof can't display path name components for those open files.
1230
1231 Since the size of the kernel name cache is limited and the
1232 cache is in constant flux, it does not always contain the names
1233 of all components in an open file's path; sometimes it contains
1234 none of them.
1235
1236 Lsof reports the file system directory name and whatever
1237 components of the file's path it finds in the cache, starting
1238 with the last component and working backwards through the
1239 directories that contain it. If lsof finds no path
1240 components, lsof reports the file system device name instead.
1241
1242 When lsof does report some path components in the NAME
1243 column, it prefixes them with the file system directory
1244 name, followed by " -- ", followed by the components --
1245 e.g., /usr -- sys/path.h for /usr/include/sys/path.h. The
1246 " -- " is omitted when lsof finds all the path name components
1247 of a file's name.
1248
1249 The PSTAT-based HP-UX lsof relies on kernel name cache
1250 contents, too, even though its information comes to lsof
1251 via pstat() function calls. Consequently, PSTAT-based
1252 HP-UX lsof won't always report full paths, but may use the
1253 " -- " partial path name notation, or may occasionally
1254 report no path name at all but just the file system mounted-on
1255 directory and device names.
1256
1257 Lsof can't obtain path name components from the kernel name
1258 caches of the following dialects:
1259
1260 AIX
1261
1262 Only the Linux kernel records full path names in the
1263 structures it maintains about open files; instead, most
1264 kernels convert path names to device and node number doublets
1265 and use them for subsequent file references once files have
1266 been opened.
1267
1268 To convert the device and node number doublet into a
1269 complete path name, lsof would have to start at the root
1270 node (root directory) of the file system on which the node
1271 resides, and search every branch for the node, building
1272 possible path names along the way. That would be a time
1273 consuming operation and require access to the raw disk
1274 device (usually implying setuid-root permission).
1275
1276 If the prospect of all that local disk activity doesn't
1277 concern you, think about the cost when the device is
1278 NFS-mounted.
1279
1280 Try using the file system mount point and node number lsof
1281 reports as parameters to find -- e.g.,
1282
1283 $ find <mount_point> -inum <node_number> -print
1284
1285 and you may get an appreciation of what a file system
1286 directory tree search would cost.
1287
12883.3.1 Why do lsof -r reports show different path names?
1289
1290 When you run lsof with its repeat (``-r'') option, you may
1291 notice that the extent to which it reports path names for
1292 the same files may vary from cycle to cycle. That happens
1293 because other processes are making kernel calls affecting
1294 the cache and causing entries to be removed from and added
1295 to it.
1296
12973.3.2 Why does lsof report the wrong path names?
1298
1299 Under some circumstances lsof may report an incorrect path
1300 name component, especially for files in a rapidly changing
1301 directory like /tmp.
1302
1303 In a rapidly changing directory, like /tmp, if the kernel
1304 doesn't clear the cache entry when it removes a file, a
1305 new file may be given the same keys and lead lsof to believe
1306 that the old cache entry with the same keys belongs to the
1307 new file.
1308
1309 Lsof tries to avoid this error by purging duplicate entries
1310 from its copy of the kernel name cache when they have the
1311 same device and inode number, but different names.
1312
1313 This error is less likely to occur in UNIX dialects where the
1314 keys to the name cache are node address and possibly a
1315 capability ID. The Apple Darwin, Digital UNIX, FreeBSD, HP-UX,
1316 NEXTSTEP, OPENSTEP, Solaris, Tru64 UNIX, and UnixWare dialects
1317 use node address. Apple Darwin, FreeBSD, NetBSD, OpenBSD,
1318 Tru64 UNIX, and also use a capability ID to further identify
1319 name cache entries.
1320
13213.3.3 Why doesn't lsof report path names for unlinked (rm'd) files?
1322
1323 When lsof gets path name components from the kernel's name
1324 cache, it does not report the path names of a file that has
1325 been unlinked from its parent directory -- e.g., deleted via
1326 rm, or the unlink() system call -- even when some process may
1327 still hold the file open; lsof reports only the file system's
1328 mounted-on directory and device. That's because path name
1329 components are removed from the kernel name cache when the file
1330 is unlinked.
1331
1332 Unlinked open files are sometimes used by applications for
1333 temporary, but invisible storage (i.e., ls won't show them,
1334 and no other process can open them.) However, they may
1335 occasionally consume disk space to excess and cause concern
1336 for a system administrator, who will be unable to locate
1337 them with find, ls, du, or other tools that rely on finding
1338 files by examining the directory tree.
1339
1340 By using lsof's +L option you can see the link count of
1341 open files -- in the NLINK column. An unlinked file will
1342 have an NLINK value of zero. By using the option +L1 you
1343 can tell lsof to display only files whose link count is
1344 less than one (i.e., zero).
1345
1346 There are some UNIX dialect-specific exceptions to lsof's
1347 inability to report unlinked path names. They are described in
1348 the answer to the "When will lsof report path names for deleted
1349 files?" question.
1350
13513.3.4 Why doesn't lsof report the "correct" hard linked file path
1352 name?
1353
1354 When lsof reports a rightmost path name component for a
1355 file with hard links, the component may come from the
1356 kernel's name cache. Since the key which connects an open
1357 file to the kernel name cache may be the same for each
1358 differently named hard link, lsof may report only one name
1359 for all open hard-linked files. Sometimes that will be
1360 "correct" in the eye of the beholder; sometimes it will
1361 not. Remember, the file identification keys significant
1362 to the kernel are the device and node numbers, and they're
1363 the same for all the hard linked names.
1364
13653.3.5 When will lsof report path names for deleted files?
1366
1367 Lsof will report path names for deleted files for two
1368 dialects: Linux and later builds of Solaris 10.
1369
1370 Deleted Linux path names are reported by default and have
1371 "(deleted)" at their ends.
1372
1373 The display of Solaris 10 deleted path names may be selected
1374 with the -X option. When selected they are also reported with
1375 "(deleted)" at their ends.
1376
13773.4 Why is lsof so slow?
1378
1379 Lsof may appear to be slow if network address to host name
1380 resolution is slow. This can happen, for example, when the
1381 name server is unreachable, or when a Solaris PPP cache daemon
1382 is malfunctioning.
1383
1384 To see if name lookup is causing lsof to be slow, turn it off
1385 with the ``-n'' option.
1386
1387 Port service name lookup or portmap registration lookup may
1388 also be causes of slow-down. To suppress port service name
1389 lookup, specify the ``-P'' option.
1390
1391 Lsof doesn't usually make direct portmap calls -- only when +M
1392 is specified, or when HASPMAPENABLED is defined during lsof
1393 construction. (The lsof help panel, produced with `lsof -h`
1394 will display the default portmap registration reporting
1395 state.) The quickest first step in checking if lsof is slow
1396 because of the portmapper is to use lsof's ``-M'' option.
1397
1398 Lsof may be slow if UID to login name lookups are slow.
1399 Suppress them with ``-l''.
1400
1401 On dialects where lsof uses the kernel name cache, try
1402 disabling its use with ``-C''. (You can tell if lsof uses the
1403 kernel name cache by looking for ``-C'' in lsof's ``-h''
1404 output.) Of course, disabling kernel name cache use will mean
1405 that lsof won't report full or partial path names, just file
1406 system and character device names.
1407
1408 If you're just interested in the open files of one process, try
1409 using the ``-p <Process-ID>'' option to limit lsof to that
1410 process. (The ``-p'' option may also be followed with a list
1411 of Process-IDs.)
1412
1413 If you're interested in including or excluding certain
1414 commands, try lsof's "-c[^]cmd" option.
1415
1416 If you're interested in certain Internet TCP and UDP states
1417 (e.g., ESTABLISHED) or in excluding some (e.g., CLOSE_WAIT), try
1418 lsof's "-s p:s" option. More information on it may be found in
1419 the answer to the "How are protocol state name exclusion and
1420 inclusion used?" question.
1421
1422 Your UNIX dialect may not support "-s p:s" and its associated
1423 performance improvments to Internet-only file processing. You
1424 can find more information on those topics in the answer to the
1425 "Why doesn't my dialect support state name exclusion and
1426 inclusion?" question.
1427
1428 Older AIX lsof may be slow to start because of its oslevel
1429 identity comparison. (Newer AIX lsof uses uname(2).) See the
1430 "Why does AIX lsof start so slowly?" and "Why does lsof warn
1431 "compiled for x ... y; this is z.?" sections for more
1432 information.
1433
14343.5 Why doesn't lsof's setgid or setuid permission work?
1435
1436 If you install lsof on an NFS file system that has been
1437 mounted with the nosuid option, lsof may not be able to
1438 use the setgid or setuid permission you give it, complaining
1439 it can't open the kernel memory device -- e.g., /dev/kmem.
1440
1441 The only solution is to install lsof on a file system that
1442 doesn't inhibit setgid or setuid permission.
1443
14443.6 Does lsof have security problems?
1445
1446 I don't think so. However, lsof does usually start with
1447 setgid permission, and sometimes with setuid-root permission.
1448 Any program that has setgid or setuid-root permission,
1449 should always be regarded with suspicion.
1450
1451 Lsof drops setgid power, holding it only while it opens
1452 access to kernel memory devices (e.g., /dev/kmem, /dev/mem,
1453 /dev/swap). That allows lsof to bypass the weaker security
1454 of access(2) in favor of the stronger checks the kernel
1455 makes when it examines the right of the lsof process to
1456 open files declared with -k and -m. Lsof also restricts
1457 some device cache file naming options when it senses the
1458 process has setuid-root power.
1459
1460 On a few dialects lsof requires setuid-root permission
1461 during its full execution in order to access files in the
1462 /proc file system. These dialects include:
1463
1464 DC/OSx 1.1 for Pyramid systems
1465 Reliant UNIX 5.4[34] for Pyramid systems
1466
1467 When lsof runs with setuid-root permission it severely
1468 restricts all file accesses it might be asked to make with
1469 its options.
1470
1471 The device cache file (typically .lsof_hostname in the home
1472 directory of the real user ID that executes lsof) has 0600
1473 modes. (The suffix, hostname, is the first component of
1474 the host's name returned by gethostname(2).) However, even
1475 when lsof runs setuid-root, it makes sure the file's
1476 ownerships are changed to that of the real user and group.
1477 In addition, lsof checks the file carefully before using
1478 it (See the question "How do I disable the device cache
1479 file feature or alter it's behavior?" for a description of
1480 the checks.); discards the file if it fails the scrutiny;
1481 complains about the condition of the file; then rebuilds
1482 the file.
1483
1484 See the 00DCACHE file of the lsof distribution for more
1485 information about device cache file handling and the risks
1486 associated with the file.
1487
14883.7 Will lsof show remote hosts using files via NFS?
1489
1490 No. Remember, lsof displays open files for the processes
1491 of the host on which it runs. If the host on which lsof
1492 is running is an NFS server, the remote NFS client processes
1493 that are accessing files on the server leave no process
1494 records on the server for lsof to examine.
1495
14963.8 Why doesn't lsof report locks held on NFS files?
1497
1498 Generally lock information held by local processes on remote
1499 NFS files is not recorded by the UNIX dialect kernel. Hence,
1500 lsof can't report it.
1501
1502 One exception is some patch levels of Solaris 2.3, and all
1503 versions of Solaris 2.4 and above. Lsof for those dialects
1504 does report on locks held by local processes on remotely
1505 mounted NFS files.
1506
15073.8.1 Why does lsof report a one byte lock on byte zero as a full
1508 file lock?
1509
1510 When a process has a lock of length one, starting at byte
1511 zero, lsof can't distinguish it from a full file lock.
1512 That's because most UNIX dialects represent both locks the
1513 same way in their file lock (flock or eflock) structures.
1514
15153.9 Why does lsof report different values for open files on the
1516 same file system (the automounter phenomenon)?
1517
1518 On UNIX dialects where file systems may be mounted by an
1519 automounter with the ``direct'' type, lsof may sometimes
1520 report difference DEVICE, SIZE/OFF, INODE and NAME values
1521 when asked to report files open on the file system.
1522
1523 This happens because some files open on the file system --
1524 e.g., the current directory of a shell that changed its
1525 directory to the file system as the file system's first
1526 reference -- may be characterized in the kernel with
1527 temporary automounter node information. The cd doesn't
1528 cause the file system to be mounted.
1529
1530 A subsequent reference to the file system -- e.g., an ls
1531 of any place in it -- will cause the file system to be
1532 mounted. Processes with files open to the mounted file
1533 system are characterized in the kernel with data that
1534 reflects the mounted file system's parameters.
1535
1536 Unfortunately some kernels (e.g., some versions of Solaris
1537 2.x) don't revisit the process that did only a change-directory
1538 for the purpose of updating the data associated with the
1539 open directory file. The file continues to be characterized
1540 with temporary automounter information until it does another
1541 directory change, even a trivial ``cd .''.
1542
1543 Lsof will report on both reference types, when supplied
1544 the file system name as an argument, but the data lsof
1545 reports will reflect what it finds in the kernel. For the
1546 different types lsof will display different data, including
1547 different major and minor device numbers in the DEVICE
1548 column, different lengths in the SIZE/OFF column, different
1549 node numbers in the INODE column, and slightly different
1550 file system names in the NAME column.
1551
1552 In contrast, fuser, where available, can only report on
1553 one reference type when supplied the file system name as
1554 an argument. Usually it will report on the one that is
1555 associated with the mounted file system information. If
1556 the only reference type is the temporary automounter one,
1557 fuser will often be silent about it.
1558
15593.10 Why don't lsof and netstat output match?
1560
1561 Lsof and netstat output don't match because lsof reports
1562 the network information it finds in open file system objects
1563 -- e.g., socket files -- while netstat often gets its
1564 information from separate kernel tables.
1565
1566 The information available to netstat may describe network
1567 activities never or no longer associated with open files,
1568 but necessary for proper network state machine operation.
1569
1570 For example, a TCP connection in the FIN_WAIT_[12] state
1571 may no longer have an associated open file, because the
1572 connection has been closed at the application layer and is
1573 now being closed at the TCP/IP protocol layer.
1574
15753.10.1 Why can't lsof find accesses to some TCP and UDP ports?
1576
1577 Lsof stands for LiSt Open Files. If there is no open file
1578 connected to a TCP or UDP port, lsof won't find it. That's
1579 the most common reason why lsof doesn't find a port netstat
1580 might report open.
1581
1582 One reason I've found on some UNIX dialects is that their
1583 kernels set aside TCP and UDP ports for communicating with
1584 support activities, running in application layer servers
1585 -- the automounter daemons, and the NFS biod and nfsd
1586 daemons are examples. Netstat may report the ports are in
1587 use, but lsof doesn't.
1588
1589 Another reason is that netstat may also be able to report
1590 a port is open on a particular dialect, because it uses a
1591 source of data different from what lsof uses -- e.g.,
1592 netstat might examine kernel tables or use streams messages
1593 to MIB2, while lsof relies on the information it finds in
1594 open file structures and their descendants.
1595
1596 Sometimes it's possible to search the data netstat and lsof
1597 use. For example, on Linux /proc/tcp and /proc/udp can be
1598 examined. There might an entry there for a particular
1599 protocol and port, but if the line on which the port appears
1600 doesn't have an inode number that matches an inode number
1601 of an open file, lsof won't be able to identify the process
1602 using the port.
1603
1604 This is a tough question to which there is no easy answer.
1605
16063.11 Why does lsof update the device cache file?
1607
1608 At the end of the lsof output you may see the message:
1609
1610 lsof: WARNING: /Homes/abe/.lsof_vic was updated.
1611
1612 In this message /Homes/abe/.lsof_vic is the path to the
1613 private device cache file for login abe. (See 00DCACHE.)
1614
1615 Lsof issues this message when it finds it necessary to
1616 recheck the system device directory (e.g., /dev or /devices)
1617 and rebuild the device cache file during the open file
1618 scan. Lsof may need to do these things it finds that a
1619 device directory node has changed, or if it cannot find a
1620 device in the cache.
1621
16223.12 Why doesn't lsof report state for UDP socket files?
1623
1624 Lsof reports UDP TPI connection state -- TS_IDLE (Idle),
1625 TS_BOUND (Bound), etc. -- for some, but not all dialects.
1626 TPI state is stream-based TCP/IP information that isn't
1627 available in many dialects.
1628
1629 A fairly weak general rule is if netstat(1) reports UDP
1630 TPI state, lsof may be able to report it, too. But don't
1631 be surprised if lsof fails to report UDP TPI state for your
1632 dialect. Other factors influence lsof's ability to report
1633 UDP TPI state, including the availability of state number
1634 data in kernel structures, and state number to state name
1635 conversion data.
1636
16373.13 I am editing a file with vi; why doesn't lsof find the file?
1638
1639 Classic implementations of vi usually don't keep open the file
1640 being edited. (Newer ones may do so in order to maintain an
1641 advisory lock.) Instead classic vi opens the file, makes a
1642 temporary copy (usually in /tmp or /usr/tmp), and does its work
1643 in that file. When you save the file being edited from a
1644 classic vi implementation, it reopens and rewrites the file.
1645
1646 During a classic vi session, except for the brief periods when
1647 vi is reading or rewriting the file, lsof won't find an open
1648 reference to the file from the vi process, because there is
1649 none.
1650
16513.14 Why doesn't lsof report TCP/TPI window and queue sizes for my
1652 dialect?
1653
1654 Lsof only reports TCP/TPI window sizes for Solaris, because
1655 only its netstat reports them. The intent of providing
1656 TCP/TPI information in lsof NAME column output is to make
1657 it easier to match netstat output to lsof output.
1658
1659 In general lsof only reports queue sizes for both TCP and
1660 UDP (TPI) connections on BSD-derived UNIX dialects, where
1661 both sets of values appear in kernel socket queue structures.
1662 SYSV-derived UNIX dialects whose TCP/IP implementations
1663 are based on streams generally provide only TCP queue sizes,
1664 not UDP (TPI) ones.
1665
1666 While you may find that netstat on some SYSV-derived UNIX
1667 dialects with streams TCP/IP may report UDP (TPI) queue
1668 sizes, you will probably also find that the sizes are always
1669 zero -- netstat supplies a constant zero for UDP (TPI)
1670 queue sizes to make its headers align the same for TCP and
1671 UDP (TPI) connections. Solaris seems to get it right --
1672 i.e., its netstat does not report UDP (TPI) queue sizes.
1673
1674 When in doubt, I chose to avoid reporting UDP (TPI) queue
1675 sizes for UNIX dialects whose netstat-reported values I
1676 knew to be a constant zero or whose origin I couldn't
1677 determine. OSR is a dialect in this category.
1678
16793.14.1 Why doesn't lsof report socket options, socket states, and TCP
1680 flags and values for my dialect?
1681
1682 The lsof -T argument, 'f', that selects the reporting of socket
1683 options, socket states and TCP flags was implemented at lsof
1684 revision 4.71 for the following UNIX dialects, providing the
1685 indicated information:
1686
1687 AIX 4.3.2 and 5.1 and above
1688 All socket options and values, socket states, and TCP
1689 flags and values described in lsof(8) are reported.
1690 Apple Darwin 7.2 and above
1691 All socket options and values, socket states, and TCP
1692 flags and values described in lsof(8) are reported.
1693 Digital UNIX and Tru64 UNIX 4.0
1694 All socket options and values, socket states, and TCP
1695 flags and values described in lsof(8) are reported.
1696 FreeBSD 4.9 and above
1697 All socket options and values, socket states, and TCP
1698 flags and values described in lsof(8) are reported.
1699 HP-UX 11.00 (/dev/kmem-based lsof)
1700 All socket options and values are reported. No socket
1701 states are reported. Only the TF_NODELAY TCP flag and
1702 the TF_MSS value are reported.
1703 HP-UX 11.11 and iiiv2 (PSTAT-based lsof)
1704 All socket options and values, and socket states are
1705 reported. No TCP flags or values are reported.
1706 Linux
1707 No socket options and values, socket states, or TCP
1708 flags and values are reported. The support for "-Tf"
1709 could not be added to Linux, because socket options,
1710 socket states, and TCP flags and values are not
1711 available via the /proc file system.
1712 NetBSD 1.6G and above
1713 All socket options and values, socket states, and TCP
1714 flags and values described in lsof(8) are reported.
1715 OpenBSD 3.4 and above
1716 All socket options and values, socket states, and TCP
1717 flags and values described in lsof(8) are reported.
1718 OPENSTEP 4.2
1719 All socket options and values, socket states, and TCP
1720 flags and values described in lsof(8) are reported.
1721 OpenUNIX 8
1722 All socket options and values, socket states, and TCP
1723 flags and values described in lsof(8) are reported.
1724 SCO OpenServer Release 5.0.6
1725 All socket options and values, socket states, and TCP
1726 flags and values described in lsof(8) are reported.
1727 Solaris 2.6, 8 and above
1728 The socket option display is limited to BROADCAST,
1729 DEBUG, DGRAM_ERRIND, DONTROUTE and OOBINLINE. Socket
1730 values are limited to KEEPALIVE and LINGER. No socket
1731 states are reported. The TCP DELACK, NODELAY and
1732 SENTFIN flags are reported. The TCP MSS value is
1733 reported.
1734 UnixWare 7.1.[134]
1735 All socket options and values, socket states, and TCP
1736 flags and values described in lsof(8) are reported.
1737
17383.14.2 Why doesn't lsof report the partial listen queue connection
1739 count for my dialect?
1740
1741 The reporting of partial listen queue connections was added to
1742 -Tf processing at lsof revision 4.76. Currently it is reported
1743 for these dialects:
1744
1745 AIX 4.3.2
1746 This dialect is no longer supported, so no attempt
1747 was made to add partial listen queue length support
1748 for it.
1749 AIX 5.1 and above
1750 Partial listen queue information is available.
1751 Apple Darwin 7.2 and above
1752 Partial listen queue information is available.
1753 Digital UNIX 4.0
1754 This dialect is no longer supported, so no attempt
1755 was made to add partial listen queue length support
1756 for it.
1757 FreeBSD 4.9 and above
1758 Partial listen queue information is available.
1759 HP-UX 11.00 (/dev/kmem-based lsof)
1760 No partial listen queue information is available.
1761 HP-UX 11.11 and iiiv2 (PSTAT-based lsof)
1762 No partial listen queue information is available.
1763 Linux
1764 No partial listen queue information is available.
1765 NetBSD 1.6G and above
1766 Partial listen queue information is available.
1767 OpenBSD 3.4 and above
1768 Partial listen queue information is available.
1769 OPENSTEP 4.2
1770 Partial listen queue information is available.
1771 OpenUNIX 8
1772 This dialect is no longer supported, so no attempt
1773 was made to add partial listen queue length support
1774 for it.
1775 SCO OpenServer Release 5.0.6
1776 No partial listen queue information is available.
1777 Solaris 2.6, 8 and above
1778 Partial listen queue information is available.
1779 Tru64 UNIX 5.0
1780 This dialect is no longer supported, so no attempt
1781 was made to add partial listen queue length support
1782 for it.
1783 Tru64 UNIX 5.1
1784 Partial listen queue information is available.
1785 UnixWare 7.1.[134]
1786 Partial listen queue information is available.
1787
1788
17893.15 What does "no more information" in the NAME column mean?
1790
1791 When lsof can find no successor structures -- a gnode,
1792 inode, socket, or vnode -- connected to the file structure
1793 of an open descriptor of a process, it reports "no more
1794 information" in the NAME column. The TYPE, DEVICE, SIZE/OFF,
1795 and INODE columns will be blank.
1796
1797 Because the file structure is supposed to contain a pointer
1798 to the next structure of a file's processing support, if
1799 the pointer is NUL, lsof can go no further.
1800
1801 Some UNIX dialects have file structures for system processes
1802 -- e.g., the sched process -- that have no successor
1803 structure pointers. The "no more information" NAME will
1804 commonly appear for these processes in lsof output.
1805
1806 It may also be the case that lsof has read the file structure
1807 while it is being assembled and before a successor structure
1808 pointer value has been set. The "no more information" NAME
1809 will again result.
1810
1811 Unless lsof output is filled with "no more information"
1812 NAME column messages, the appearance of a few should be no
1813 cause for alarm.
1814
18153.16 Why doesn't lsof find a process that ps finds?
1816
1817 If lsof fails to display open files for a process that ps
1818 indicates exists, there may be several reasons for the
1819 difference.
1820
1821 The process may be a "zombie" for which ps displays the
1822 "(defunct)" state. In that case, the process has exited
1823 and has no open file information lsof can display. It does
1824 still have a process structure, sufficient for the needs
1825 of ps.
1826
1827 Another possible explanation is that kernel tables and
1828 structures may have been changing when lsof looked for the
1829 process, making lsof unable to find all relevant process
1830 structures. Try repeating the lsof request.
1831
18323.17 Why doesn't -V report a search failure?
1833
1834 The usual reason that -V won't report a search failure is
1835 that lsof located the search item, but was prevented from
1836 listing it by an option that doesn't participate in search
1837 failure reporting.
1838
1839 For example, this lsof invocation:
1840
1841 $ lsof -V -i TCP@foobar -a -d 999
1842
1843 won't report it can't find the Internet address TCP@foobar,
1844 even if there is an open file connected to that address,
1845 unless the open file also has a file descriptor number of
1846 999 (the ``-a -d 999'' options).
1847
1848 Compile-time options can also affect -V results in much the
1849 same way. For example, if HASSECURITY and HASNOSOCKSECURITY
1850 are defined at compile time, this lsof invocation, run by a
1851 non-root user:
1852
1853 $ lsof -V -c inetd
1854
1855 won't report that it can't find the inetd command, even if
1856 there is a process running the inetd command, because the
1857 HASSECURITY and HASNOSOCKSECURITY options prevent the
1858 listing of all but the socket files of another user, and
1859 no socket file selector (e.g., "-i") was specified.
1860
1861
18623.18 Portmap problems
1863
18643.18.1 Why isn't a name displayed for the portmap registration?
1865
1866 When portmap registration reporting is enabled, any time
1867 there is a registration for a local TCP or UDP port, lsof
1868 displays it in square brackets, following the port number
1869 or service name -- e.g., ``:1234[name]'' or ``:name[100083]''.
1870
1871 The TCP or UDP port number or service number (what follows
1872 the `:') is displayed under the control of the lsof -P
1873 option. The registration identity is held by the portmapper
1874 and may be a name or a number, depending on how the
1875 registration's owner declared it. Lsof reports what the
1876 port map holds and cannot derive a registration name from
1877 a registration number.
1878
1879 Lsof can be compiled with registration reporting enabled
1880 or disabled by default, under the control of the HASPMAPENABLED
1881 #define (usually in machine.h). The lsof help panel (`lsof
1882 -h`) will show the default. Lsof is distributed with
1883 reporting disabled by default.
1884
18853.18.2 How can I display only portmap registrations?
1886
1887 Lsof doesn't have an option that will display only TCP or
1888 UDP ports with portmap registrations. The +M option only
1889 enables the reporting of registration information when
1890 Internet socket files are displayed; +M doesn't select
1891 the displaying of Internet socket files -- the -i option
1892 does that.
1893
1894 This simple lsof pipe to grep will do the job:
1895
1896 $ lsof -i +M | grep "\["
1897
1898 This works because -i selects Internet socket files, +M
1899 enables portmap registration reporting, and only output
1900 lines with opening square brackets will have registrations.
1901
1902 When portmap registration reporting is enabled by default,
1903 because the lsof builder constructed it that way, +M is
1904 not necessary. (The lsof help panel, produced with `lsof
1905 -h` will display the default portmapper registration
1906 reporting state.) However, specifying +M when reporting
1907 is already enabled is acceptable, as is specifying -M when
1908 reporting is already disabled.
1909
1910 Digression: lsof will accept `+' or `-' as a prefix to most
1911 options. (That isn't documented in the man page or help
1912 panel to reduce confusion and complexity.) The -i option
1913 is as acceptable as +i, so the above example could be
1914 written a little more tersely as:
1915
1916 $ lsof +Mi | grep "\["
1917
1918 But be careful to use the ``Mi'' ordering, since ``iM''
1919 implies M is an address argument to `i'.
1920
19213.18.3 Why doesn't lsof report portmap registrations for some ports?
1922
1923 Lsof reports portmap registrations for local TCP and UDP
1924 ports only. It identifies local ports this way:
1925
1926 * The port appears in the local address section of the
1927 kernel structure that contains it.
1928
1929 * The port appears in the foreign address section of a
1930 kernel structure whose local and foreign Internet
1931 addresses are the same.
1932
1933 * The port appears in the foreign address section of a
1934 kernel address structure whose Internet address is
1935 INADDR_LOOPBACK (127.0.0.1).
1936
1937 Following these rules, lsof ignores foreign portmapped
1938 ports. That's done for reasons of efficiency and possible
1939 security prohibitions. Contacting all remote portmappers
1940 could take a long time and be blocked by network difficulties
1941 (i.e., be inefficient). Many firewalls block portmapper
1942 access for security reasons.
1943
1944 Lsof may occasionally ignore portmap registration information
1945 for a legitimate local port by virtue of its local port
1946 rules. This can happen when a port appears in the foreign
1947 part of its kernel structure and the local and foreign
1948 Internet addresses don't match (perhaps because they're on
1949 different interfaces), and the foreign Internet address
1950 isn't INADDR_LOOPBACK (127.0.0.1).
1951
19523.19 Why is `lsof | wc` bigger than my system's open file limit?
1953
1954 There is a strong temptation to count open files by piping
1955 lsof output to wc. If your purpose is to compare the number
1956 you get to some Unix system parameter that defines the
1957 number of open files your system can have, resist the
1958 temptation.
1959
1960 One reason is that lsof reports a number of "files" that
1961 don't occupy Unix file table space -- current working
1962 directories, root directories, jail directories, text files,
1963 library files, memory mapped files are some. Another reason
1964 is that lsof can report a file shared by more than one
1965 process that itself occupies only one file table slot.
1966
1967 If you want to know the number of open files that occupy
1968 file table slots, use the +ff option and process the lsof
1969 output's FILE_ADDR column information with standard Unix
1970 tools like cut, grep, sed, and sort.
1971
1972 You might also consider using use lsof's field output with
1973 +ff, selecting the file struct address with -FF, and
1974 processing the output with an AWK or Perl script. See the
1975 list_fields.awk, list_fields.perl, and shared.perl5 scripts
1976 in the scripts/ subdirectory of the lsof distribution for
1977 hints on file struct post-processing filters.
1978
19793.20 Why doesn't lsof report file offset (position)?
1980
1981 Lsof won't report a file offset (position) value if the -s
1982 option has been specified, or if the dialect doesn't support
1983 the displaying of file offset (position).
1984
1985 That lsof is reporting only file size is indicated by the
1986 fact that the appropriate column header says SIZE instead
1987 of SIZE/OFF.
1988
1989 If lsof doesn't support the displaying of file offset
1990 (position) -- e.g., for Linux /proc-based lsof -- the -h
1991 or -? output panel won't list the -o option.
1992
1993 Sometimes the availability of file offset information
1994 depends on the dialect's kernel. This is particularly true
1995 for socket file offsets.
1996
1997 Maintenance of offsets for pseudo-terminal devices varies
1998 by UNIX dialect and is related to how the dialect kernel
1999 implements pseudo-terminal support. Kernels like AIX, for
2000 example, that short-circuit the transfer of data between
2001 socket and pseudo devices to reduce TCP/IP daemon interrupt
2002 rates won't advance offsets in the TCP/IP daemon socket
2003 files. Instead they will advance offsets in the open
2004 standard I/O files of the shell child precess where the
2005 pseudo-terminal devices are used.
2006
2007 When in doubt about the behavior of lsof in reporting file
2008 offset information, do some carefully measured experiments,
2009 consult the lsof sources, or contact me at <abe@purdue.edu>
2010 to discuss the matter. Please follow the reporting guidelines
2011 in the "How do I report an lsof bug?" section of this FAQ.
2012
20133.20.1 What does lsof report for size when the file doesn't really have
2014 one?
2015
2016 When a file has no true size -- e.g., it's a socket, a
2017 FIFO, or a pipe -- lsof tries to report the information it
2018 finds in the kernel that describes the contents of associated
2019 kernel buffers.
2020
2021 Thus, for example, size for most TCP/IP files is socket
2022 buffer size. The size of the socket read buffer is reported
2023 for read-only files; the size of the write buffer for
2024 write-only files; and the sum of the buffers sizes for
2025 read-write files.
2026
20273.21 Problems with path name arguments
2028
20293.21.1 How do I ask lsof to search a file system?
2030
2031 You can ask lsof to search for all open files on a file
2032 system by specifying its mounted path name as an lsof
2033 argument -- e.g.,
2034
2035 $ lsof /
2036
2037 Output of the mount command will show file system mounted
2038 path names. It will also show the mounted-on device path
2039 for the file system.
2040
2041 If the mounted-on device is a block device (the permission
2042 field in output of `ls -l <device>` starts with a `b/),
2043 you can specify it's name, too -- e.g.,
2044
2045 $ lsof /dev/sd0a
2046
2047 If the mounted-on device isn't a block device -- for example,
2048 some UNIX dialects call a CD-ROM device a character device
2049 (ls output starts with a `c') -- you can force lsof to
2050 assume that the specified device names a file system with
2051 the +f option -- e.g.,
2052
2053 $ lsof +f -- /dev/sd0a
2054
2055 (Note: you must use ``--'' after +f or -f if a file name
2056 follows immediately, because +f and -f can be followed by
2057 characters that specify flag output selections.)
2058
2059 When you use +f and lsof can't match the device to a file
2060 system, lsof will issue a complaint.
2061
2062 The +f option may be used in some dialects to ask lsof to
2063 search for an NFS file system by its server name and server
2064 mount point. If the mount application reports an NFS file
2065 system mounted-on value that way, then this sample lsof
2066 request should work.
2067
2068 $ lsof +f -- fleet:/home/fleet/u5
2069
2070 Finally, you can use -f if you don't want a mounted file
2071 system path name to be considered a request to report all
2072 open files on the file system. This is useful when you
2073 want to know if anyone is using the file system's mounted
2074 path name. This example directs lsof to report on open
2075 access to the `/' directory, including when it's being used
2076 as a current working or root directory.
2077
2078 $ lsof -f -- /
2079
2080 The lsof -f option performs the same function as -f does
2081 in some fuser implementations. However, since the lsof -c
2082 option was chosen for another purpose before the `f' option
2083 was added to lsof, +f was selected as the analogue to the
2084 fuser -c option. (Sorry for the potential confusion.)
2085
20863.21.2 Why doesn't lsof find all the open files in a file system?
2087
2088 Lsof may not find all the open files in a file system for
2089 several reasons.
2090
2091 First, some processes with files open on the file system
2092 may have been changing status when lsof examined the process
2093 table, and lsof "missed" them. Remember, the kernel changes
2094 much faster than lsof can respond to the changes.
2095
2096 Second, be sure you have specified the file system correctly.
2097 Perhaps you specified a file instead. You can use lsof's
2098 -V option to have lsof report in detail on what it couldn't
2099 find. Make sure the report for the file system you specified
2100 says "file system." Here's some -V output:
2101
2102 $ /lsof -V /tmp ./lsof.h ./lsof
2103 COMMAND PID USER FD TYPE DEVICE SIZE/OFF INODE NAME
2104 lsof 2688 abe txt VREG 18,1,7 1428583 226641 ./lsof
2105 lsof 2689 abe txt VREG 18,1,7 1428583 226641 ./lsof
2106 lsof: no file use located: ./lsof.h
2107
2108 You can also use lsof's +f option to force it to consider
2109 a path name as a file system. If lsof can't find a file
2110 system by the specified name, it will issue a complaint --
2111 e.g.,
2112
2113 $ lsof +f -- /usr
2114 lsof: not a file system: /usr
2115
2116 (/usr is a directory in the / file system.)
2117
21183.21.3 Why does the lsof exit code report it didn't find open files
2119 when some files were listed?
2120
2121 Sometimes lsof will list some open files, yet return a
2122 non-zero exit code, suggesting it hasn't found all the
2123 specified files.
2124
2125 The first thing you should when you suspect lsof is incorrect
2126 is to repeat the request, adding the -V option. In the
2127 resulting report you may find that your file system
2128 specification really wasn't a file system specification,
2129 just a file specification.
2130
2131 Finally, if you specify two files or two file systems twice,
2132 lsof will credit all matches to the first of the two and
2133 believe that there were no matches for the second. It's
2134 possible to specify a single file system twice with different
2135 path names by using both its mounted directory path name
2136 and mounted-one device name.
2137
2138 $ lsof +f -V spcuna:/sysprog /sysprog
2139 COMMAND PID USER FD TYPE DEVICE SIZE/OFF INODE NAME
2140 ksh 11092 abe cwd VDIR 39,0,1 1536 226562 /sysprog
2141 (spcuna:/sysprog)
2142 ...
2143 lsof: no file system use located: spcuna:/sysprog
2144
2145 All matches were credited to /sysprog; none to spcuna:/sysprog.
2146
21473.21.4 Why won't lsof find all the open files in a directory?
2148
2149 When you give lsof a simple directory path name argument
2150 (not a file system mounted-on name), you are asking it to
2151 search for processes that have the directory open as a
2152 file, or as a process-specific directory -- e.g., root or
2153 current working directory.
2154
2155 If you want to list instances of open files inside the
2156 directory, you need to specify the individual path names
2157 of those files, or use the lsof +D and +d options.
2158
2159 See the answer to the question "Why are the +D and +d
2160 options so slow?" before you use +D or +d casually.
2161
2162 See the answer to the question "Why do the +D and +d options
2163 produce warning messages?" for an explanation of some
2164 process authority limitations of +D and +d.
2165
21663.21.5 Why are the +D and +d options so slow?
2167
2168 The +D and +d options cause lsof to build a path name search
2169 list for a specified directory. +D causes lsof to descend
2170 the directory to its furthest subdirectory, while +d
2171 restricts it to the top level. In both cases, the specified
2172 directory itself is included in the search list. In both
2173 symbolic links are ignored.
2174
2175 Building such a search list can take considerable time,
2176 especially when the specified directory contains many files
2177 and subdirectories -- lsof must call the system readlink()
2178 and stat() functions for each file and directory. Storing
2179 the search list can cause lsof to use more than its normal
2180 amount of dynamic memory -- each file recorded in the search
2181 list consumes dynamic memory for its path name, characteristics,
2182 and search linkages. Using the list means lsof must search
2183 it for every open file in the system.
2184
2185 Building the search list for a directory specified on some
2186 file systems can be slow -- e.g., for an NFS directory with
2187 many files. Some file systems have special logging features
2188 that can introduce additional delays to the building of
2189 the search list -- e.g., NFS logging, or logging on a
2190 Solaris UFS file system. The bottom line is that slow
2191 search list construction may not be so much an lsof problem
2192 as a file system problem. (Hint: if you're using Solaris
2193 UFS logging, consider specifying the "logging,noatime"
2194 option pair to reduce the number of atime writes to the
2195 UFS logging queue and disk.)
2196
2197 A somewhat risky way to speed up lsof's building of the
2198 search list is to use lsof's ``-O'' option. It forces lsof
2199 to do all system calls needed to build the search list
2200 directly, rather than in a child process. While direct
2201 system calls are much faster, they can block in the kernel
2202 -- e.g., when an NFS server stops responding -- stopping
2203 lsof until the kernel operation unblocks.
2204
2205 As an example of the load +D can impose, consider that an
2206 `lsof +D /` on a lightly loaded NeXT '040 cube with a 1GB
2207 root file system disk took 4+ minutes of real time. It
2208 also generated several hundred error messages about files
2209 and directories the lsof process didn't have permission to
2210 access with stat(2).
2211
2212 The bottom line is that +D and +d should be used cautiously.
2213 +D is more costly than +d for deeply nested directory trees,
2214 because of the full directory descent it causes. So use
2215 +d where possible. And you might need to consider the
2216 performance of the file system that holds the directory
2217 you name with +d or +D.
2218
2219 In view of these warnings, when is it appropriate to use
2220 +D or +d? Probably the most appropriate time is when you
2221 would specify the directory's contents to lsof with a shell
2222 globbing construct -- e.g., `lsof *`. If that's what you
2223 need to do, `lsof +d .` is probably more efficient than
2224 having the shell produce a directory list, form it into an
2225 argument vector, and pass the vector to lsof for it to
2226 unravel.
2227
2228 See the answer to the question "Why do the +D and +d options
2229 produce warning messages?" for an explanation of some
2230 process authority limitations of +D and +d.
2231
22323.21.6 Why do the +D and +d options produce warning messages?
2233
2234 +D and +d option processing is limited by the authority of
2235 the lsof process -- i.e., lsof can only examine (with
2236 lstat(2) and stat(2)) files the owner of the process can
2237 access.
2238
2239 If the ownership, group membership, or permissions of the
2240 specified directory, file within it, or directory within
2241 it prevents the owner of the lsof process from using lstat(2)
2242 or stat(2) on it, lsof will issue a warning message, naming
2243 the path and giving the system's (lstat(2's or stat(2)'s)
2244 reason (errno explanation text) for refusing access.
2245
2246 As an example, assume user abc has a subdirectory in /tmp,
2247 owned by abc and readable, writable and searchable by only
2248 its owner. If user def asks lsof to search for all /tmp
2249 references with +D or +d, lsof will be unable to lstat(2)
2250 or stat(2) anything in abc's private subdirectory, and will
2251 issue an appropriate warning.
2252
2253 Lsof warnings can usually be suppressed with the -w option.
2254 However, using -w with +D or +d means that there will be
2255 no indication why lsof couldn't find an open reference to
2256 a restricted directory or something contained in it.
2257
2258 Hint: if you need to use +D or +d and avoid authority
2259 warnings, and if you have super-user power, su and use lsof
2260 with +D or +d as root.
2261
22623.22 Why can't my C compiler find the rpcent structure definition?
2263
2264 When you try to compile lsof your compiler may complain
2265 that the rpcent structure is undefined. The complaints
2266 may look like this:
2267
2268 >print.c: In function `fill_portmap':
2269 >print.c:213: dereferencing pointer to incomplete type
2270 >...
2271
2272 The most likely cause is that someone has allowed a BIND
2273 installation to update /usr/include/netdb.h (or perhaps
2274 /usr/include/rpc/netdb.h), removing the rpcent structure
2275 definition that lsof expects to find there.
2276
2277 Only Solaris has an automatic work-around. (See dlsof.h
2278 in dialects/sun.). The Solaris work-around succeeds because
2279 there is another header file, <rpc/rpcent.h>, with the rpcent
2280 structure definition, and there is a Solaris C pre-processor
2281 test that can tell when the BIND <netdb.h> is in place and
2282 hence <rpc/rpcent.h> must be included.
2283
2284 Doubtlessly there are similar work-arounds possible in
2285 other UNIX dialects whose header files have been "touched"
2286 by BIND, but in general I recommend restoration of the
2287 vendor's <netdb.h> and any other header files BIND might
2288 have replaced. (I think BIND replaces <resolv.h>,
2289 <sys/bitypes.h>, <sys/cdefs.h> -- and maybe others.)
2290
22913.23 Why doesn't lsof report fully on file "foo" on UNIX dialect
2292 "bar?"
2293
2294 Lsof sometimes won't report much information on a given
2295 file, or may even report an error message in its NAME
2296 column. That's usually because the file is of a special
2297 type -- e.g., in a file system specific to the UNIX dialect
2298 -- and I haven't used a system where the file appeared
2299 during my testing.
2300
2301 If you encounter such a situation, send me e-mail at
2302 <abe@purdue.edu> and we may be able to devise an addition to
2303 lsof that will report on the file in question. Please follow
2304 the reporting guidelines in the "How do I report an lsof bug?"
2305 section of this FAQ. Make sure "lsof" appears in the
2306 "Subject:" line so my e-mail filter won't classify your letter
2307 as Spam.
2308
23093.24 Why do I get a complaint when I execute lsof that some library
2310 file can't be found?
2311
2312 On systems where the LIBPATH (or the equivalent) environment
2313 variable is used to record the library search path in
2314 executable files when they are built, an incorrect value
2315 may make it impossible for the system to find the shared
2316 libraries needed to load lsof for execution.
2317
2318 This may be particularly true on systems like AIX >= 4.1.4,
2319 where the lsof Makefile takes the precautionary step of
2320 using the -bnolibpath loader flag to insure that the path
2321 to the private static lsof library is not recorded in the
2322 lsof binary. Should LIBPATH be invalid when lsof is built,
2323 it will be recorded in the lsof binary as the default
2324 library path search order and lead to an inability to find
2325 libraries when lsof is executed.
2326
2327 So, if you get missing library complaints when you try to
2328 execute lsof, check LIBPATH, or whatever environment variable
2329 is used on your system to define library search order in
2330 executable files. Use the tools at your disposal to look
2331 at the library paths recorded in the lsof binary -- e.g.,
2332 chatr on HP-UX, dump on AIX, ldd on Solaris.
2333
2334 Make sure, too, that when the correct library search path
2335 has been recorded in the executable file, the required
2336 library files exist at one or more of the search paths.
2337
2338
23393.25 Why does lsof complain it can't open files?
2340
2341 When lsof begins execution, unless it has been asked to
2342 report only help or version information, typically it will
2343 attempt to access kernel memory and symbol files -- e.g.,
2344 /unix, /dev/kmem. Even though lsof needs only permission
2345 to open these files for reading, read access to them might
2346 be restricted by ownerships and permission modes.
2347
2348 So the first step to diagnosing lsof problems with opening
2349 files is to use ls(1) to examine the ownerships and permission
2350 modes of the files that lsof wants to open. You may find
2351 that lsof needs to be installed with some type of special
2352 ownership or permission modes to enable it to open the
2353 necessary files for reading. See the "Installing Lsof"
2354 section of 00README for more information.
2355
23563.26 Why does lsof warn "compiled for x ... y; this is z."?
2357
2358 Unless warnings are suppressed (with -w) or the kernel
2359 identity check symbol (HASKERNIDCK) definition has been
2360 deleted, all but one lsof dialect version (exception:
2361 /proc-based Linux lsof) compare the identity of the running
2362 kernel to that of the one for which lsof was constructed.
2363 If the identities don't match, lsof issues a warning like
2364 this:
2365
2366 lsof: WARNING: compiled for Solaris release 5.7; this is 5.6.
2367
2368 Two kernel identity differences can generate this warning
2369 -- the version number and the release number.
2370
2371 Build and running identity differences are usually significant,
2372 because they usually indicate kernels whose structures are
2373 different -- kernel structures commonly change at dialect
2374 version releases. Since lsof reads data from the kernel
2375 in the form of structures, it is sensitive to changes in
2376 them. The general rule is that an lsof compiled for one
2377 UNIX dialect version will not work correctly when run on
2378 a different version.
2379
2380 There are three work-arounds: 1) use -w to suppress the
2381 warning -- and risk missing other warnings; 2) permanently
2382 disable the identity check by deleting the definition of
2383 HASKERNIDCK in the dialect's machine.h header file -- with
2384 the same risk; or 3) rebuild lsof on the system where it
2385 is to be run. (Deleting HASKERNIDCK can be done with the
2386 Customize script or by editing machine.h.)
2387
2388 Generally checking kernel identity is a quick operation
2389 for lsof. However, it is potentially slow under AIX, where
2390 lsof must run /usr/bin/oslevel. To speed up lsof, use -w
2391 to suppress the /usr/bin/oslevel test. See "Why does AIX
2392 lsof start so slowly?" for more information.
2393
23943.27 How can I disable the kernel identity check?
2395
2396 The kernel identity check is controlled by the HASKERNIDCK
2397 definition. When it is defined, most dialects (exclusion:
2398 /proc-based Linux lsof) will compare the build-time kernel
2399 identity with the run-time one.
2400
2401 To disable the kernel identity check, disable the HASKERNIDCK
2402 definition in the dialect's machine.h header file. The
2403 Customize script can be used to do that in its section
2404 about the kernel identity check.
2405
2406 Caution: while disabling the kernel identity check may
2407 result in smaller lsof startup overhead, it comes with the
2408 risk of executing an lsof that may produce warning messages,
2409 error messages, incorrect output, or no output at all.
2410
24113.28 Why don't ps(1) and lsof agree on the owner of a process?
2412
2413 Generally the user ID lsof reports in its USER column is
2414 the process effective user ID, as found in the process
2415 structure. Sometimes that may not agree with what ps(1)
2416 reports for the same process.
2417
2418 There are sundry reasons for the difference. Sometimes
2419 ps(1) uses a different source for process information,
2420 e.g., the /proc file system or the psinfo structure.
2421 Sometimes the kernel is lax or confused (e.g., Solaris
2422 2.5.1) about what ID to report as the effective user ID.
2423 Sometimes the system carries only one user ID in its process
2424 structure (some BSD derivatives), leaving lsof no choice.
2425
2426 The differences between lsof and ps(1) user identifications
2427 should be small and normally it will be apparent that the
2428 confusion is over a process whose application has changed
2429 to an effective user ID different from the real one.
2430
24313.29 Why doesn't lsof find an open socket file whose connection
2432 state is past CLOSE_WAIT?
2433
2434 TCP/IP connections in states past CLOSE_WAIT -- e.g.,
2435 FIN_WAIT_1, CLOSING, LAST_ACK, FIN_WAIT_2, and TIME_WAIT
2436 -- don't always have open files associated with them. When
2437 they don't, lsof can't identify them. When the connection
2438 state advances from CLOSE_WAIT, sometimes the open file
2439 associated with the connection is deleted.
2440
24413.30 Why don't machine.h definitions work when the surrounding
2442 comments are removed?
2443
2444 The machine.h header files in dialect subdirectories have
2445 some commented-out definitions like:
2446
2447 /* #define HASSYSDC "/your/choice/of/path */
2448
2449 You can't simply remove the comments and expect the definition
2450 to work. That's intended to make you think about what
2451 value you are assigning to the symbol. The assigned value
2452 might have a system-specific convention. HASSYSDC, for
2453 example, might be /var/db/lsof.dc for FreeBSD, but it might
2454 be /var/adm/lsof.dc for Solaris.
2455
2456 Symbols defined in the lsof documentation are described in
2457 00PORTING, other machine.h comments, and other lsof
2458 documentation files. HASSYSDC, for example, is discussed
2459 in 00DCACHE. When comments and documentation don't suffice,
2460 consult the source code for hints on how the symbol is
2461 used.
2462
24633.31 What do "can't read inpcb at 0x...", "no protocol control
2464 block", "no PCB, CANTSENDMORE, CANTRCVMORE", etc. mean?
2465
2466 Sometimes lsof will report "can't read inpcb at 0x00000000",
2467 "no protocol control block", "no PCB, CANTSENDMORE,
2468 CANTRCVMORE" or a similar message in the NAME column for
2469 open TCP socket files. These messages mean the file's socket
2470 structure lacks a pointer to the INternet Protocol Control
2471 Block (inpcb) where lsof expects to find connection addresses
2472 -- local and foreign ports, local and foreign IP addresses.
2473 The socket file has probably been submitted to the shutdown(2)
2474 function for processing.
2475
2476 In some implementations lsof issues the "no PCB, CANTSENDMORE,
2477 CANTRCVMORE" message, which tries to explain the absence
2478 of a protocol control block by showing the socket state
2479 settings that have been made by the shutdown(2) function.
2480
2481 If a non-zero address follows the "0x" in the "can't read
2482 inpcb" message, it means lsof couldn't read inpcb contents
2483 from the indicated address in kernel memory.
2484
24853.32 What do the "unknown file system type" warnings mean?
2486
2487 Lsof may report a message similar to"
2488
2489 unknown file system type, v_op: 0x10472f10
2490
2491 in the NAME column for some files.
2492
2493 This means that lsof has encountered a vnode for the file
2494 whose operation switch address (from v_op) references a
2495 file system type for which there is no support in lsof.
2496 After lsof identifies the file system type, it uses
2497 pre-compiled code to locate the file system specific node
2498 for the file where lsof finds information like file size,
2499 device number, node number, etc.
2500
2501 To get some idea of what the file system type might be,
2502 use nm on your kernel symbol file to locate the symbol name
2503 that corresponds to the v_op address -- e.g., on Solaris
2504 do:
2505
2506 $ nm -x /dev/ksyms | grep 0x10472f10
2507 0x10472f10 ... |file_system_name_vnodeops
2508
2509 Where "file_system_name" is the clue to the unsupported
2510 file system.
2511
2512 Lsof doesn't use the v_op address to identify file system
2513 types on all dialects. Sometimes it uses an index number
2514 it finds in the vnode. It will translate that symbol to
2515 a short name in the warning message -- e.g., "nfs3" -- if
2516 possible.
2517
25183.33 Installation
2519
25203.33.1 How do I install lsof?
2521
2522 There is no "standard" way to install lsof. Too much
2523 depends on local conditions for me to be able to provide
2524 working install rules in the lsof make files. (The skeleton
2525 install rules you will find just give "hints.") See the
2526 "Installing Lsof" section of 00README for a fuller explanation.
2527
2528 To install lsof you will need to consider these questions:
2529
2530 * Who should be able to use lsof? (See HASSECURITY and
2531 HASNOSOCKSECURITY in the "Security" section of 00README.)
2532
2533 * Where should lsof be installed? This is a decision
2534 mostly dictated by local conditions. Somewhere in
2535 /usr/local -- etc/ or sbin/ -- is a common choice.
2536
2537 * What permissions should I give the lsof executable?
2538 The answer to this varies by dialect. The make files
2539 have install rules that give hints. The "Installing
2540 Lsof" section of 00README gives information, too.
2541
2542 * What if I want to install lsof in a shared file system
2543 for machines that require different lsof configurations?
2544 See the next question and answer, "How do I install a
2545 common lsof when I have machines that need differently
2546 constructed lsof binaries?"
2547
25483.33.2 How do I install a common lsof when I have machines that
2549 need differently constructed lsof binaries?
2550
2551 A dilemma that faces some system administrators when they
2552 install lsof in a shared file system -- e.g., NFS -- is
2553 that they must have different lsof executables for different
2554 systems.
2555
2556 The answer is to build an lsof wrapper script that is
2557 executed in place of lsof. The script can use system
2558 commands to determine which lsof binary should be executed.
2559
2560 Consider this example. You have HP-UX machines with 32
2561 and 64 bit kernels that share the /usr/local/sbin directory
2562 where you want to install lsof. Consequently, on each
2563 system you must use a different lsof executable, built for
2564 the system's bit size. (That's because lsof reads kernel
2565 structures, sized by the kernel's bit size.)
2566
2567 One answer is to install three things in /usr/local/sbin:
2568 1) a 32 bit lsof as lsof32; 2) a 64 bit lsof as lsof64;
2569 and 3) an lsof script. The script might look like this
2570 one, based on work by Amir J. Katz:
2571
2572 #!/bin/sh
2573 x=`/usr/bin/getconf KERNEL_BITS` # returns 32 or 64
2574 if /usr/bin/test "X$x" = "X32"
2575 then
2576 lsof32 $*
2577 else
2578 if /usr/bin/test "X$x" = "X64"
2579 then
2580 lsof64 $*
2581 else
2582 echo "Can't determine which lsof executable to use;"
2583 echo "getconf KERNEL_BITS says: $x"
2584 exit 1
2585 fi
2586 fi
2587
2588 Solaris users should consult "How do I install lsof for
2589 Solaris 7, 8 or 9?" for information on a similar trick
2590 using the Solaris isaexec command.
2591
2592 Users of other dialects might be able to use a command like
2593 uname(1) that can identify a distinguishing feature of the
2594 system to be incorporated in pre-installed lsof executable
2595 names. For example, use `uname -r` and install binaries
2596 with suffixes that match `uname -r` output.
2597
25983.34 Why do lsof 4.53 and above reject device cache files built
2599 by earlier lsof revisions?
2600
2601 When lsof revisions 4.53 run and encounter a device cache
2602 file built by an earlier revision, it will reject the file
2603 and build a new one. The rejection will be advertised with
2604 these messages:
2605
2606 lsof: WARNING: no /dev device in <name>: 2 sections
2607 ...
2608 lsof: WARNING: created device cache file: <name>
2609
2610 This happens because the header line of the device cache
2611 file was changed at revision 4.53 to contain the number of
2612 the device on which the device directory resides. The old
2613 device cache file header line -- the "2 sections" line in
2614 the above warning message, node reads "2 sections, dev=600".
2615
2616 This is not a serious problem, since lsof automatically
2617 rebuilds the device cache file with the correct header
2618 line.
2619
26203.35 What do "like block special" and "like character special" mean
2621 in the NAME column?
2622
2623 When lsof comes across an open block or character file
2624 whose device, raw device and inode place it somewhere other
2625 than /dev (or /devices), lsof doesn't report the /dev (or
2626 /devices) name in the NAME column. Instead lsof reports
2627 the file system name and device or path name in the NAME
2628 column and parenthetically adds "like block special <path>"
2629 or "like character special <path>".
2630
2631 The value for <path> will point to a block or character
2632 device in /dev (or /devices) whose raw device number matches
2633 that of the open file being reported, but whose device
2634 number or node number (or both) don't match.
2635
2636 Such an open file is connected to a device node that has
2637 been created in a directory other than /dev (or /devices.)
2638 See mknod(8) for information on how such nodes are created.
2639 (Generally one needs root power to create device nodes with
2640 mknod.)
2641
26423.36 Why does an lsof make fail because of undefined symbols?
2643
2644 When lsof is compiled via the `make` step and the final
2645 load step fails because of missing symbols, the problem
2646 may not be lsof. The problem may be that ld, called by
2647 the compiler as part of the `make` step, can't find some
2648 library that lsof needs.
2649
2650 First check the last compiler line of the make operation
2651 -- e.g., the last line with cc or gcc in it before the
2652 undefined symbol report -- for loader arguments, i.e.,
2653 ones beginning with "-l". Except for "-llsof" the rest
2654 name system libraries. ("-L./lib" precedes "-llsof" to
2655 tell the loader its location.)
2656
2657 Check that all the named system libraries exist. Look in
2658 /lib and /usr/lib as a start, but that may not be the only
2659 place system libraries live. Consult your dialect's
2660 documentation, e.g., the compiler and loader man pages,
2661 for other possible locations.
2662
2663 If some system library doesn't exist, that may mean it was
2664 never installed or was removed. You'll have to re-install
2665 the missing library.
2666
2667 You may find that all the system libraries lsof uses exist.
2668 Your next step might be to use nm and grep to see if any
2669 of them contain the undefined symbols.
2670
2671 $ nm library | grep symbol
2672
2673 If the undefined symbol exists in some library named by
2674 the lsof make step, then you might have a problem with some
2675 environment variable that controls the load step. The most
2676 common is LD_LIBRARY_PATH. It may have a setting that
2677 causes ld to ignore a directory containing a library lsof
2678 names. If this is the case, try unsetting LD_LIBRARY_PATH
2679 in the environment of the ld process -- e.g., do:
2680
2681 $ unset LD_LIBRARY_PATH
2682 or
2683 % unsetenv LD_LIBRARY_PATH
2684
2685 Consult your ld man page for other environment variables
2686 that might affect library searching -- e.g., LIBPATH, LPATH,
2687 SHLIB_PATH, etc.
2688
2689 If the undefined function doesn't exist in any libraries
2690 lsof names, check other libraries. See if the function
2691 has a man page that names its library. If the latter is
2692 true, please let me know, because that is an lsof problem
2693 I need to fix.
2694
2695 If none of these solutions work for you, send me some
2696 documentation via e-mail at <abe@purdue.edu>. Include `uname
2697 -a` output, the output of the lsof `Configure ...` and `make`
2698 steps, and the contents of the environment in force when the
2699 `make` step was executed -- e.g., `env` or `printenv` output.
2700 If you've located the libraries lsof names, send me that
2701 information, too. Make sure "lsof" appears in the "Subject:"
2702 line so my e-mail filter won't classify your letter as Spam.
2703
27043.37 Command Regular Expressions (REs)
2705
27063.37.1 What are basic and extended regular expressions?
2707
2708 Lsof's ``-c'' option allows the specification of regular
2709 expressions (REs), enclosed in two slash ('/') characters and
2710 followed by these modifiers:
2711
2712 b the RE is a basic RE.
2713 i ignore case.
2714 x the RE is an extended RE (the default).
2715
2716 Note: the characters of the regular expression may need to
2717 be quoted to prevent their expansion by the shell.
2718
2719 Example: this RE is an extended RE that matches exactly
2720 four characters, whose third may be an upper ('O') or lower
2721 case ('o') oh:
2722
2723 -c /^..o.$/i
2724
2725 For simplicity's sake, an RE that is acceptable to egrep(1)
2726 is usually called an extended RE.
2727
2728 REs suitable for the old line editor, ed(1), are often
2729 called basic REs (and sometimes also called obsolete).
2730
2731 These are some ways basic REs usually differ from extended
2732 REs. (There are other differences.)
2733
2734 * `|', `+', `?', '{', and '}' are ordinary characters.
2735
2736 * `^' is an ordinary character except at the beginning of
2737 the RE.
2738
2739 * `$' is an ordinary character except at the end of the
2740 RE.
2741
2742 * `*' is an ordinary character if it appears at the
2743 beginning of the RE.
2744
2745 For more information on REs and the distinction between
2746 basic and extended REs, consult your dialect's man pages
2747 for ed(1), egrep(1), sed(1), and possibly regex(5) or
2748 regex(7).
2749
27503.37.2 Why can't I put a slash in a command regular expression?
2751
2752 Since a UNIX command name is the last part of a path to
2753 the command's executable, the lsof command regular expression
2754 (RE) syntax uses slash ('/') to mark the beginning and end
2755 of an RE. Slash may not appear in the RE and the `\'
2756 back-slash escape is ineffective for "hiding" it.
2757
2758 More likely than not, if you try to put a slash in an lsof
2759 command RE, you'll get this response:
2760
2761 $ lsof -s/.\// ...
2762 lsof: invalid regexp modifier: /
2763
2764 Lsof is complaining the the first character it found after
2765 the second slash isn't an lsof command RE modifier -- 'b',
2766 'i', or 'x'.
2767
27683.37.3 Why does lsof say my command regular expression wasn't found?
2769
2770 When you use both forms of lsof's -c option --
2771 ``-c <command>'' and ``-c /RE/[m]'' -- and ask that lsof
2772 do a verbose search (``-V''), you may be surprised that
2773 lsof will say that the regular expression wasn't found.
2774
2775 This can happen if the ``-c <command>'' form matches first,
2776 because then the ``-c/RE/[m]'' test will never have been
2777 applied. For example:
2778
2779 $ ./lsof -clsof -c/^..o.$/ -V -adcwd
2780 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
2781 lsof 7850 abe cwd VDIR 6,0 2048 96442 / (/dev/sd0a)
2782 lsof: no command found for regex: ^..o.$
2783
2784 The ``-clsof'' option matched first, so the ``-c/^..o.$/
2785 option wasn't tested.
2786
27873.38 Why doesn't lsof report on shared memory segments?
2788
2789 Lsof reports on shared memory segments only if they're
2790 associated with an open file. That's consistent with lsof's
2791 mission -- to LiSt Open Files. Shared memory segments with
2792 no file associations aren't open files.
2793
2794 That's not to say that a report on shared memory segments
2795 and their associated processes wouldn't be useful. But it
2796 calls for a new tool, not more baggage for lsof.
2797
27983.39 Why does lsof report two instances of itself?
2799
2800 When you ask lsof to report all open files and it has
2801 permission to do so, you may see two lsof processes in the
2802 output. The processes are connected via pipes -- e.g.,
2803 here's an HP-UX 11 example.
2804
2805 COMMAND PID USER FD TYPE DEVICE ...
2806 ...
2807 lsof 29450 abe 7w PIPE 0x48732408 ...
2808 lsof 29450 abe 8r PIPE 0x48970808 ...
2809 ...
2810 lsof 29451 abe 6r PIPE 0x48732408 ...
2811 lsof 29451 abe 9w PIPE 0x48970808 ...
2812
2813 The first process will usually be the lsof you initiated;
2814 the second, an lsof child process that is used to isolate
2815 its parent process from kernel functions that can block --
2816 e.g., readlink() or stat().
2817
2818 Information to and from the kernel functions is exchanged
2819 via the two pipes. When the parent process detects that
2820 the child process has become blocked, it attempts to kill
2821 the child. Depending on the UNIX dialect that may succeed
2822 or fail, but the parent won't be blocked in any event.
2823
2824 See the "BLOCKS AND TIMEOUTS" and "AVOIDING KERNEL BLOCKS"
2825 sections of the lsof man page for more information on why
2826 the child process is used and how you can specify lsof
2827 options to avoid it. (Caution: that may be risky.)
2828
28293.40 Why does lsof report '\n' in device cache file error messages?
2830
2831 Lsof revisions prior to 4.58 may report '\n' in error
2832 messages it delivers about problems in the device cache
2833 file -- e.g.,
2834
2835 lsof: WARNING: no ...: 4 sections\n
2836
2837 That's deliberately done to show the exact contents of the
2838 device cache file line about which lsof is complaining,
2839 including its terminating NL (New Line) '\n' character.
2840 In the above example the line in the device cache file
2841 causing the lsof complaint contains "4 sections" and ends
2842 with a '\n'.
2843
2844 At revision 4.58 and above, device cache error messages
2845 like the one in the above example have been changed to
2846 read:
2847
2848 lsof: WARNING: no ...: line "4 sections"
2849
2850 The terminal '\n' is no longer reported, the line contents
2851 are enclosed in double quote marks ('"'), and the word
2852 "line" has been added as a prefix to denote that what
2853 follows is a line from the device cache file.
2854
28553.41 Kernel Symbol and Address Problems
2856
28573.41.1 What does "lsof: WARNING: name cache hash size length error: 0"
2858 mean?
2859
2860 When run on some systems, lsof may issue this warning:
2861
2862 lsof: WARNING: name cache hash size length error: 0
2863
2864 That is an example from a FreeBSD system where lsof reads
2865 the kernel's _nchash variable and finds its value is zero.
2866
2867 Similar warnings include:
2868
2869 WARNING: kernel name cache size:
2870 WARNING: can't read kernel's name cache:
2871 WARNING: no name cache address
2872 WARNING: name cache hash size length error:
2873 WARNING: unusable name cache size:
2874
2875 These warnings are issued when lsof is attempting to read
2876 the kernel's name cache information. They are usually the
2877 result of a mis-match between the addresses for kernel
2878 symbols lsof gets via nlist(2) and the addresses in use by
2879 the kernel.
2880
2881 Lsof usually gets kernel symbol addresses from what it
2882 believes to be the kernel boot file. In FreeBSD, for
2883 example, that's the path returned by getbootfile(3), usually
2884 /kernel. The boot file can have other names in other UNIX
2885 dialects -- /unix, /vmunix, /bsd, /netbsd, /mach, /stand/vmunix,
2886 etc.
2887
2888 Lsof will get incorrect (mismatched) addresses from the
2889 boot file if it has been replaced by a newer one which
2890 hasn't yet been booted -- e.g., if this is done in FreeBSD:
2891
2892 # mv /kernel /kernel.OLD
2893 # mv /kernel.NEW /kernel
2894
2895 Until the FreeBSD system is rebooted, the booted kernel is
2896 /kernel.OLD, but getbootfile() says it is /kernel. If
2897 symbol addresses important to lsof in /kernel.OLD and
2898 /kernel don't match, the lsof WARNING messages result.
2899
29003.41.2 Why does lsof produce "garbage" output?
2901
2902 Kernel name cache warnings may not be the only sign that
2903 lsof is using incorrect symbol addresses to read kernel
2904 values. If there's no reasonable test lsof can make on
2905 what it reads from the kernel, it may issue other warnings
2906 or even report nonsensical results.
2907
2908 The warnings may appear on STDERR, such as:
2909
2910 lsof: can't read proc table info
2911
2912 Or the warnings may appear in the NAME column as messages
2913 saying lsof can't read or interpret some kernel structure --
2914 e.g.,
2915
2916 ... NAME
2917 ... can't read file struct from 0x12345
2918
2919 One possible work-around is to point lsof's kernel symbol
2920 address gathering at the proper boot file. That can be
2921 done with lsof's -k option -- e.g.,
2922
2923 $ lsof -k /kernel.OLD
2924
2925 The best work-around is to make sure the standard boot file
2926 is properly sited -- e.g., if you've moved a new /kernel
2927 in place, boot it.
2928
29293.42 Why does lsof report open files when run as super user that
2930 it doesn't report when run with lesser privileges?
2931
2932 The most likely cause is that the HASSECURITY option was
2933 selected when the lsof executable was built.
2934
2935 If HASSECURITY is defined when lsof is built, and lsof is
2936 run with the privileges of a non-ROOT user, it will only
2937 list open files belonging to the user. The same lsof
2938 executable, when run with root user privileges, will list
2939 all open files.
2940
2941 However, if HASSECURITY and HASNOSOCKSECURITY are both
2942 defined when lsof is built, lsof will list open files
2943 belonging to the user and will also list anyone else's open
2944 socket files, provided their listing is selected with the
2945 "-i" option.
2946
2947 So first ask yourself if the process whose open files lsof
2948 won't list belong to a user other than the one under which
2949 you're running lsof, and are not open socket files. If
2950 either is true, use lsof's help (-h or -?) option and look
2951 for a line near the bottom of the help panel that says:
2952
2953 "... can list all files..."
2954
2955 If the leading "..." says "Only root" then HASSECURITY was
2956 defined when lsof was built. If the trailing "..." says
2957 ", but anyone can list socket files" then HASNOSOCKSECURITY
2958 was also defined.
2959
2960 Should you want an lsof not built with HASSECURITY defined,
2961 rerun the lsof Configure script. If you let Configure do
2962 customization, make sure you answer 'n' when it asks if
2963 you want to enable HASSECURITY and HASNOSOCKSECURITY. If
2964 you don't need to do customization, you can rebuild lsof
2965 with the "-n" option to Configure. Here's an example of
2966 such a rebuild sequence:
2967
2968 $ Configure -clean
2969 $ Configure -n <dialect-abbreviation>
2970 $ make
2971
2972 More information on the HASSECURITY and HASNOSOCKSECURITY
2973 options may be found in the "Security" section of the
2974 00README file of the lsof distribution.
2975
29763.43 Test Suite Problems
2977
29783.43.1 Errors all tests can report:
2979
29803.43.1.1 Why do tests complain "ERROR!!! can't execute ../lsof"?
2981
2982 All tests in the test suite expect an executable lsof file
2983 to exist in the tests parent directory, ../lsof.
2984
2985 If there's none there, the tests/Makefile has a rule to
2986 make it, but there are probably circumstances where that
2987 rule may fail.
2988
2989 The work-around is to re-Configure and re-make lsof, then
2990 run the test suite.
2991
29923.43.1.2 Why do tests complain "ERROR!!! can't find ..." a file?
2993
2994 Many tests create (or use from a supplied environment
2995 variable path) a test file and use lsof to find it. When
2996 lsof can't file the file, the tests report the error with
2997 messages of the form:
2998
2999 ERROR!!! can't find ... : <some file path>
3000 or
3001 ERROR!!! lsof couldn't find ...
3002
3003 These type of error messages mean that the lsof field output
3004 delivered to the test didn't contain a file that the test
3005 could identify as the one it intended lsof to find. It
3006 might also mean that the process information -- command
3007 name, PID or parent PID -- didn't match what the test
3008 expected.
3009
3010 This could imply a bug in the test or a bug in lsof. Try
3011 using lsof to find a known file that is open. For example,
3012 while in the tests sub-directory, do this:
3013
3014 $ sleep 30 < Makefile
3015 $ ../lsof Makefile
3016
3017 If lsof doesn't report that Makefile is open, then the
3018 fault may be with lsof. If lsof reports the file is open,
3019 search further in the test code for the failure cause.
3020
30213.43.1.3 Why do some tests fail to compile?
3022
3023 If a test suite program fails to compile, it may be because
3024 I've never had an opportunity to compile the test on the
3025 particular UNIX version you are using.
3026
3027 See Appendix B in 00TEST for a list of the UNIX dialects
3028 where the test suite has been validate.
3029
30303.43.1.4 Why do some tests always fail?
3031
3032 There are several tests in the optional group that have
3033 conflicting or special requirements:
3034
3035 LTbigf needs a dialect and file system that support
3036 large files.
3037
3038 LTlock won't work if the tests/ sub-directory is
3039 on an NFS file system.
3040
3041 LTnfs won't work if the tests/ sub-directory is
3042 not on an NFS file system.
3043
3044 So for two tests in particular, LTlock and LTnfs, one will
3045 generally fail.
3046
3047 Some failing tests can be run successfully by supplying to
3048 them a path to the appropriate type of file system with
3049 the -p option.
3050
30513.43.1.5 Why does the test suite say it hasn't been validated on
3052 my dialect?
3053
3054 When you use the default rule of the test suite's Makefile,
3055 it may issue this complaint:
3056
3057 $ cd tests
3058 $ make
3059 !!!WARNING!!!
3060
3061 This dialect or its particular version may not have
3062 been validated with the lsof test suite. Consequently
3063 some tests may fail or may not even compile.
3064
3065 !!!WARNING!!!
3066
3067 You are then given the opportunity to answer 'y' to have
3068 the test suite operation continue.
3069
3070 This message means that the tests/TestDB file in the tests
3071 sub-directory doesn't show that the test suite has been
3072 run with the combination of compiler flags found in
3073 tests/config.cflags. The tests might nor run; they may
3074 encounter compiler failures.
3075
3076 See 00TEST for more information on the UNIX dialects where
3077 the test suite has been validated and on the workings of
3078 TestDB and its supporting scripts.
3079
3080 When the tests/Makefile "auto" rule is used, the message
3081 is more terse and the condition is fatal.
3082
3083 This suite has not been validated on:
3084
3085 <dialect_description>
3086
3087 No opportunity to continue is offered.
3088
3089 The tests/Makefile "silent" rule will skip checking for
3090 the validation footprint.
3091
30923.43.1.6 Why do the tests complain they can't stat() or open()
3093 /dev/mem or /dev/kmem?
3094
3095 When the tests detect that lsof for the dialect reads its
3096 information from kernel memory (i.e., the LT_KMEM definition
3097 is present in tests/config.cflags), and when the lsof
3098 executable path is ../lsof, the tests make sure they can
3099 stat() and open() for read access the relevant kernel memory
3100 devices, /dev/kmem and possibly /dev/mem.
3101
3102 If those stat() or open() operations fail, the tests issue
3103 an error message and quit. The message explains why the
3104 system rejected the operation in terms of system "errno"
3105 symbols and messages. More often than not the explanation
3106 will be that the process lacks permission to access the
3107 indicated device node.
3108
3109 One work-around is to give the lsof executable being tested
3110 the necessary permission -- e.g., via chgrp, chmod, etc.
3111 -- and set its path in the LT_LSOF_PATH environment variable.
3112 (See 00TEST.)
3113
3114 Another work-around is to make sure the process that runs
3115 the tests has the necessary permissions -- e.g., run it as
3116 root, or enable the process login to access the resources.
3117 For example, I can run the tests on my personal work-station
3118 because /dev/kmem and /dev/mem are readable by the "kmem"
3119 group and my login is in that group.
3120
3121
31223.43.2 LTbigf test issues
3123
31243.43.2.1 Why does the LTbigf test say that the dialect doesn't
3125 support large files?
3126
3127 Large file support is defined dialect by dialect in the
3128 lsof source files and Configure script. If large file
3129 support isn't defined there, it isn't defined in the LTbigf
3130 test.
3131
3132 If you think that's wrong for a particular dialect, contact me
3133 via e-mail at <abe@purdue.edu>. Make sure "lsof" appears in the
3134 "Subject:" line so my e-mail filter won't classify your letter
3135 as Spam.
3136
31373.43.2.2 Why does LTbigf complain about operations on its config.LTbigf*
3138 file?
3139
3140 The LTbigf must be able to write a large file test (size
3141 > 32 bits) and seek within it and the process file ulimit
3142 size must permit the operation. If the default location
3143 for the test file, tests/, isn't on a file system enabled
3144 for large file operations or if the process ulimit file
3145 block size is too small, lsof will get file operation
3146 errors, particularly when seeking
3147
3148 There may be a work-around. Specify the path to a file
3149 LTbigf can write in a file system enabled for large file
3150 operations a the -poption. Make sure that the ulimit file
3151 block size permits writing a large file. For example,
3152 presuming /scratch23 is large-file-enabled, and presuming
3153 you have permission to raise the ulimit file block size,
3154 this shell commands will allow the LTbigf test to run on
3155 AIX:
3156
3157 $ ./LTbigf -p /scratch23/abe/bigfile
3158
3159 (Note: syntax for the ulimit command varies by dialect and
3160 by shell. Discovering the proper variant is left to the
3161 reader.)
3162
3163 More information on this subject can be found in the LTbigf
3164 description in the 00TEST file. If course, the LTbigf.c
3165 source file in tests/ is the ultimate source of information,
3166
31673.43.2.3 Why does LTbigf warn that lsof doesn't return file offsets?
3168
3169 On some dialects (e.g., Linux) lsof can't report file
3170 offsets, because the data access method underlying lsof
3171 doesn't provide them. If LTbigf knows that lsof can't
3172 report file offsets for the dialect, it issues this warning:
3173
3174 LTbigf ... WARNING!!! lsof can't return file offsets
3175 for this dialect, so offset tests have
3176 been disabled.
3177
3178 LTbigf then performs the size test and skips the offset
3179 tests.
3180
3181 For more information see 00TEST and the "Why doesn't
3182 /proc-based lsof report file offsets (positions)?" Q&A of
3183 this file.
3184
31853.43.3 Why does the LTbasic test complain "ERROR!!! lsof this ..."
3186 and "ERROR!!! lsof that ..."?
3187
3188 The LTbasic test program uses lsof to examine a running
3189 lsof process. It looks for the lsof current working
3190 directory, executable (if possible), and kernel memory file
3191 (if applicable).
3192
3193 Failures to find those things result in the LTbasic error
3194 messages. More information on how LTbasic produces the error
3195 messages may be found in the LTbasic.c source file.
3196
3197 On HP-UX 11.11 and higher, for example, if the test's current
3198 working directory is on a loopback (LOFS) file system, LTbasic
3199 won't be able to find the current working directory of the lsof
3200 process because of a bug in the HP-UX kernel.
3201
3202 The solution for that HP-UX problem is to install an HP-UX
3203 patch. See the answer to the "Why doesn't PSTAT-based lsof
3204 report a CWD that is on a loopback (LOFS) file system?"
3205 question for more information on the patch.
3206
32073.43.4 NFS test issues
3208
32093.43.4.1 Why does the LTnfs test complain "couldn't find NFS file ..."?
3210
3211 The LTnfs test must work with an NFS test file. After it
3212 opens the file it asks lsof to find it on an NFS file system.
3213 If the file isn't on an NFS file system, lsof won't find it,
3214 and the NFS test script complains and fails.
3215
3216 The work-around is to use -p option to supply a path to a
3217 regular NFS file (not a directory) that is on an NFS file
3218 system that LTnfs can read. Presuming /share/bin/file is
3219 such a file and can be opened for reading by the LTnfs
3220 test, this sample shell command could be used to run the
3221 LTnfs test successfully:
3222
3223 $ ./LTnfs -p /share/bin/file
3224
3225 (If the NFS file system is enabled for large files, the
3226 NFS test will produce the error message described in the
3227 following Q&A.)
3228
32293.43.5 LTnlink test issues
3230
32313.43.5.1 Why does the LTnlink test complain that its test file is on
3232 an NFS file system?
3233
3234 The LTnlink test may complain:
3235
3236 LTnlink ... WARNING!!! test file <path> is NFS mounted.
3237
3238 and then issue an explanation and a hint about using the
3239 -p option.
3240
3241 The LTnlist test does this because of the way NFS file
3242 links are managed when an NFS file is unlinked and the
3243 unlinking process still has the file open. Unlike with
3244 files on a local file system, when an NFS file that is
3245 still open is unlinked, its link count is not reduced.
3246
3247 The file name is changed to a name of the form .nfsxxxx
3248 and the link count is left unchanged until the process
3249 holding the file open closes it. That's done by NFS so it
3250 can keep proper track of the file on NFS clients and servers.
3251
3252 Since the link count isn't reduced when the LTnlink test
3253 program closes the NFS test file it still has open, lsof
3254 won't find it for LTnlink with a link count of zero.
3255 Consequently, LTnlink disables that test section and issues
3256 its warning.
3257
3258 The warning suggests that the unlink test section can be
3259 run by giving LTnlink a path to a test file with the -p
3260 option. That path must name a file LTnlink can write and
3261 unlink. Presuming /scratch23/abe/nlinkfile is on a local
3262 file system and the LTnlink test can write to it and unlink
3263 it, this sample shell command can be used to run the complete
3264 LTnlink test successfully:
3265
3266 $ LTnlink -p /scratch23/abe/nlinkfile
3267
32683.43.5.2 Why does LTnlink delay and report "waiting for link count
3269 update: ..."?
3270
3271 On some UNIX dialects and file system combinations the
3272 updating of link count after a file has been unlinked can
3273 be delayed. Consequently, lsof won't be able to report
3274 the updated link count to LTnlink for a while.
3275
3276 When lsof doesn't report the proper link count to LTnlink,
3277 it sleeps and repeats the lsof call, using the "waiting
3278 for link count update: ..." message as a signal that it is
3279 waiting for the expected lsof response. The wait cycle
3280 duration is limited to approximately one minute.
3281
32823.43.5.3 Why does LTnlink fail because of an unlink error?
3283
3284 LTnlink may fail with an error similar to:
3285
3286 LTnlink ... ERROR!! unlink(<name>) failed: (Permission denied).
3287
3288 That message will be followed by a short explanation.
3289
3290 The error means that the kernel support for the file system on
3291 which the file <name> resides does not allow a process to
3292 unlink a file while it has the file open. (When LTnlink is run
3293 without the "-p path" option, it creates a <name> that begins
3294 with "./config.LTnlink" and ends with the LTnlink process ID
3295 number.)
3296
3297 An unlink failure of this type runs counter to original UNIX
3298 file system behavior, but it has been observed on some file
3299 system types, especially on the ZFS file system.
3300
3301 The work-around is to run LTnlink on a file system that allows
3302 a process to unlink a file it has open. Usually /tmp has that
3303 support. So, try running LTnlink this way:
3304
3305 $ ./LTnlink -p /tmp/<name>
3306
3307 where <name> is a unique name in /tmp of your choosing. To
3308 be safe, create a subdirectory in /tmp, named by your login:
3309
3310 $ rm -f /tmp/<login>
3311 $ mkdir /tmp/<login>
3312 $ ./LTnlink -p /tmp/<login>/<name>
3313
33143.43.6 LTdnlc test issues
3315
33163.43.6.1 Why won't the LTdnlc test run?
3317
3318 Lsof is unable to access the DNLC cache on AIX, because the
3319 kernel symbols for the DNLC aren't exported. Contact IBM
3320 to learn why that decision was made.
3321
3322 The LTdnlc test won't work on Apple Darwin because lsof
3323 can't obtain reliable DNLC information.
3324
3325 The LTdnlc test may fail on other dialects. Failure causes
3326 include: a busy system with a DNLC that is changing rapidly;
3327 path name components too large for the DNLC; a file system
3328 -- e.g., NFS, /tmp, loopback -- which doesn't fully
3329 participate in the DNLC; or DNLC limitations (Many DNLC
3330 implementations will only store path name components if
3331 they are 31 characters or less.)
3332
3333 If you suspect the file system doesn't fully participate
3334 in kernel DNLC processing, as a work-around rebuild and
3335 test lsof on one that does.
3336
33373.43.6.2 What does the LTdnlc test mean by "... <path> found: 100.00%"?
3338
3339 Even when it succeeds the LTdnlc test will report:
3340
3341 LTdnlc ... /export/home/abe/src/lsof4/tests found: 100.00%
3342
3343 This message means that the LTdnlc test asked lsof to find
3344 the file at the indicated path five times and lsof found
3345 the full path name in the indicated percentage of calls.
3346 The LTdnlc test considers it a failure if the percentage
3347 falls below 50.0%
3348
33493.43.6.3 Why does the DNLC test fail?
3350
3351 The DNLC test may fail when some component of the lsof
3352 tests/ sub-directory can't be cached by the kernel DNLC.
3353 Some kernels have a limit on the length of individual
3354 components (typically) 32.
3355
33563.43.7 Why hasn't the test suite been qualified for 64 bit HP-UX
3357 11 when lsof is compiled with gcc?
3358
3359 When I attempted to qualify lsof for HP-UX 11, compiled
3360 with gcc 3.0, the LTsock test failed. I traced the failure
3361 to a gcc compilation error. Because LTsock is an important
3362 test, I didn't feel that the test suite was qualified if
3363 it failed.
3364
3365 LTsock compiles and runs correctly on 64 bit HP-UX 11 when
3366 compiled with HP's ANSI-C.
3367
33683.43.8 LTszoff test issues
3369
33703.43.8.1 Why does LTszoff warn that lsof doesn't return file offsets?
3371
3372 On some dialects (e.g., Linux) lsof can't report file
3373 offsets, because the data access method underlying lsof
3374 doesn't provide them. If LTszoff knows that lsof can't
3375 report file offsets for the dialect, it issues this warning:
3376
3377 LTszoff ... WARNING!!! lsof can't return file offsets
3378 for this dialect, so offset tests have
3379 been disabled.
3380
3381 LTszoff then performs the size test and skips the offset
3382 tests.
3383
3384 For more information see 00TEST and the "Why doesn't
3385 /proc-based lsof report file offsets (positions)?" Q&A of
3386 this file.
3387
33883.43.9 LTlock test issues
3389
33903.44 File descriptor list (the ``-d'' option) problems
3391
33923.44.1 Why does lsof reject a ``-d'' FD list?
3393
3394 Lsof rejects ``-d'' FD lists that contain both exclusions
3395 and inclusions with messages like:
3396
3397 lsof: exclude in an include list: ^1
3398 lsof: include in an exclude list: 2
3399
3400 That's because ``-d'' FD lists are processed as ORed lists,
3401 so it makes no sense for them to contain both exclusions
3402 and inclusions.
3403
3404 I.e.,, if a ``-d'' FD list were to contain ``^cwd,1'', the
3405 ``^cwd'' member is useless, because the ``1'' member
3406 dominates by saying "include only FD 1". That effectively
3407 excludes ``cwd'' FD.
3408
3409 Note that lists may have multiple members of the same type,
3410 exclude or include. They are processed as an ORed set.
3411 If an FD isn't excluded by any member of an exclude list,
3412 it is selected. If an FD is included by any member of an
3413 include list, it is selected.
3414
34153.44.2 Why are file descriptors other than those in my FD list
3416 reported?
3417
3418 The FD list that follows ``-d'' excludes or includes file
3419 descriptors, but unless the ``-a'' (AND) option is specified,
3420 the FD list selections are ORed to the other selections.
3421
3422 For example, the following lsof command will cause all file
3423 descriptors to be listed for the lsof command, and all but
3424 the cwd descriptor for all other commands, probably not
3425 what was intended.
3426
3427 $ lsof -clsof -d^cwd
3428
3429 Hint: use ``-a'' -- e.g.,
3430
3431 $ lsof -clsof -a -d^cwd
3432
34333.45 How can I supply device numbers for inaccessible NFS file
3434 systems?
3435
3436 When lsof can't get device numbers for inaccessible NFS file
3437 systems via stat(2) or lstat(2), it attempts to get them from
3438 the mount table's dev=xxx options. Successes are reported with
3439 a warning message that indicates the source of the device
3440 number and that output might be incomplete as a consequence of
3441 the warnings.
3442
3443 Some system mount tables -- e.g., Linux /proc/mounts -- don't
3444 have a dev=xxx option. In that case, and provided lsof for the
3445 dialect supports them, you can use the +m option to create a
3446 mount table supplement file and the "+m m" option to use it.
3447
3448 First check the lsof -h (help) output to see if the +m and
3449 "+m m" options are supported. If they are, use +m to create a
3450 mount table supplement file when all mounted file systems are
3451 accessible. Use "+m m" later to make the supplement available
3452 when some mounted file systems might not be available.
3453
3454 Here's an example that creates a mount supplement file in
3455 $HOME/mnt-sup and later makes it available to lsof.
3456
3457 $ rm -f $HOME/mnt-sup
3458 $ lsof +m > $HOME/mnt-sup
3459 ...
3460 $ lsof +m $HOME/mnt-sup <other lsof options>
3461
3462 If lsof has to get the device number from the supplement, it
3463 will issue an informative warning message. The warning can be
3464 suppressed with lsof's -w option.
3465
3466 Caution! Since the mount table supplement file is static, it
3467 is its supplier's responsibility to update it as file system
3468 mounts change.
3469
3470 For more information, consult the lsof man page. The
3471 "ALTERNATE DEVICE NUMBERS" section has useful information on
3472 how lsof acquires device numbers when stat(2) or lstat(2)
3473 fail.
3474
34753.46 Why won't lsof find open files on over-mounted file systems?
3476
3477 When a file system, /xyz for example, is mounted on the same
3478 mount point as another file system, /abc for example, running
3479 lsof with an argument of the path of the first file system's
3480 mount point -- the over-mounted one, /abc -- probably will not
3481 reveal any files open on /abc.
3482
3483 That's because lsof looks for open files on a file system by
3484 looking for files with the file system's device number. The
3485 two file systems usually have different device numbers and lsof
3486 determines the device number search key from the supplied name
3487 of the second file system.
3488
3489 A general work-around exists only for Linux. On that UNIX
3490 dialect, when you know the over-mounted file system's mount
3491 point path, you can ask lsof to report on all open files and
3492 grep that output for the path of the over-mounted file system
3493 mount point.
3494
34953.47 What can be done when lsof reports no more space?
3496
3497 Many lsof methods cache information in memory, using the
3498 dialects malloc() library function. When malloc() can't
3499 allocate the requested amount of memory, lsof exits with
3500 warning messages similar to this AIX message:
3501
3502 lsof: no more dev-ch space at pid 2257750: 0x82a8e600
3503
3504 Lsof then exits immediately and produces no more output.
3505
3506 A possible work-around is to increase the memory foot print
3507 of the shell that runs lsof. That is often done with the
3508 ulimit(1) shell command.
3509
35103.48 What if the lsof build encounters ar and ld problems?
3511
3512 The lsof main and library Makefiles use the library archiver,
3513 ar, and the system loader, ld, applications. Improperly
3514 located, installed or configured versions of them may cause the
3515 lsof build to encounter errors with them.
3516
3517 The application producing the error should identify itself in
3518 its error messages.
3519
3520 The first thing to check the path of the application that is
3521 being used. Try `which ar` or `which ld` to see if perhaps the
3522 PATH used during the build might be causing the wrong archiver
3523 or loader to be used.
3524
3525 If the problem is with the use of the wrong archiver, and it's
3526 not possible to correct the PATH to it, try using the LSOF_AR
3527 environment variable to specify the path to and arguments for
3528 the correct archiver. See 00XCONFIG for more information and
3529 note that LSOF_AR must specify the path to the archive
3530 application and the arguments for it, less the terminating
3531 library and module name arguments.
3532
3533 If the problem is with the loader, there is no lsof work-
3534 around. That's because lsof calls the loader via the C
3535 compiler, so the problem must be fixed at the compiler (system)
3536 level.
3537
3538
35394.0 AIX Problems
3540
35414.1 What is the Stale Segment ID bug and why is -X needed?
3542
3543 Kevin Ruderman reports that he has been informed by IBM
3544 that processes using the AIX 3.2.x, 4.1[.12345]], 4.2[.1],
3545 and 4.3.x kernel's readx() function can cause other AIX
3546 processes to hang because of what appears to be file system
3547 corruption.
3548
3549 This failure, known as the Stale Segment ID bug, is caused
3550 by an error in the AIX kernel's journaled segment memory
3551 handler that causes the kernel's dir_search() function
3552 erroneously to believe directory entries contain zeroes.
3553 The process using the readx() call need not be doing anything
3554 wrong. Usually the system must be under such heavy load
3555 that the segment ID being used in the readx() call has been
3556 freed and then reallocated to another process since it was
3557 obtained from kernel memory.
3558
3559 Lsof uses the readx() function to access library entry
3560 structures, based on the segment ID it finds in the proc
3561 structure of a process. Since IBM probably will never fix
3562 the kernel bug, I've added an AIX-specific option to lsof
3563 that controls its use of the readx() function.
3564
3565 By default lsof readx() use is disabled; specifying the
3566 ``-X'' option enables readx() use.
3567
3568 If you want to change the default readx() behavior of AIX
3569 lsof, change the HASXOPT, HASXOPT_ROOT, and HASXOPT_VALUE
3570 definitions in dialects/aix/machine.h. You can also use
3571 these definitions to enable or disable readx() -- consult
3572 the comments in machine.h. You may want to disable readx()
3573 use permanently if you plan to make lsof publicly executable.
3574
3575 When HASXOPT_ROOT is defined, lsof will restrict use of
3576 the -X option to processes whose real UID is root; if
3577 HASXOPT_ROOT isn't defined, any user may specify the -X
3578 option. The Customize script offers the option to change
3579 HASXOPT_ROOT when HASXOPT is defined and HASXOPT_ROOT is
3580 named in any dialect's machine.h header file.
3581
3582 I have never seen lsof cause a problem with its use of
3583 readx(), but I believe there is some chance it could, given
3584 the right circumstances.
3585
35864.1.1 Stale Segment ID APAR
3587
3588 Here are the details of the Stale Segment ID bug and IBM's
3589 response, provided by Kevin Ruderman.
3590
3591 AIX V3
3592 APAR=ix49183
3593 user process hangs forever in kernel due to file
3594 system corruption
3595 STAT=closed prs TID=tx2527 ISEV=2 SEV=2
3596 (A "closed prs" is one closed with a Permanent
3597 ReStriction.)
3598 RCOMP=575603001 aix v3 for rs/6 RREL=r320
3599
3600 AIX V4 (internal defect, no apar #)
3601 prefix p
3602 name 175671
3603 abstract KERMP: loop for ever in dir_search()
3604
3605 Problem description:
3606
3607 1. Some user application -- e.g., lsof -- gets the segment
3608 ID (SID) for the process private segment of a target
3609 process from the process table.
3610
3611 2. The target process exits, deleting the process private
3612 segment.
3613
3614 3. The SID is reallocated for use as a persistent segment.
3615
3616 4. The user application runs again and tries to read the
3617 user area structure from /dev/mem, using the SID it read
3618 from the process table.
3619
3620 5. The loads done by the driver for /dev/mem cause faults
3621 in the directory; new blocks are allocated; the size
3622 changed; and zero pages created.
3623
3624 6. The next application that looks for a file in the affected
3625 directory hangs in the kernel's dir_search() function
3626 because of the zero pages. This occurs because the
3627 kernel's dir_search() function loops through the variable
3628 length entries one at a time, moving from one to the
3629 next by adding the length of the current entry to its
3630 address to get the address of the next entry. This
3631 process should end when the current pointer passes the
3632 end of the known directory length.
3633
3634 However, while the directory length has increased, the
3635 entry length data has not, so when dir_search() reaches
3636 the zero pages, it loops forever, adding a length of
3637 zero to the current pointer, never passing the end of
3638 the directory length. The application process is hung;
3639 it can't be killed or stopped.
3640
3641 IBM closed the problem with a PRS code (Permanent ReStriction)
3642 under AIX Version 3 and had targeted a fix for AIX 4.2. They
3643 have recently (I became aware of it September 10, 1996)
3644 cancelled the defect report altogether and have indicated they
3645 are not going to fix the defect.
3646
36474.2 Gcc Work-around for AIX 4.1x
3648
3649 When gcc is used to compile lsof for AIX 4.1x, it doesn't
3650 align one element of the user structure correctly. Xlc
3651 sees the U_irss element as a type "long long" and aligns
3652 it on an 8 byte boundary. That's because the default mode
3653 of xlc is -qlonglong; when -qlonglong is enabled, the
3654 _LONG_LONG symbol is also defined.
3655
3656 Gcc sees U_irss as a two element array of type long, because
3657 _LONG_LONG isn't defined. Hence gcc aligns the U_irss
3658 element array on a 4 byte boundary, rather than an 8 byte
3659 one, making the gcc incantation of the user structure 4
3660 bytes shorter than xlc's.
3661
3662 When the length of gcc's user structure is supplied as
3663 argument 4 to the undocumented getuser() function of the
3664 AIX kernel, getuser() rejects it as an incorrect size and
3665 returns EINVAL.
3666
3667 Lsof has a work-around for this problem. It involves a
3668 special test in the Configure script when the "aixgcc"
3669 Configure abbreviation is used -- e.g.,
3670
3671 $ Configure -n aixgcc
3672
3673 The test is to compile a small program with gcc and check
3674 the alignment of U_irss. If it's not aligned on an 8 byte
3675 boundary, the Configure script makes a special copy of
3676 <sys/user.h> in ./dialects/aix/aix<AIX_version> whose
3677 U_irss will align properly, and generates compile time
3678 options to use it.
3679
3680 While I have tested this work-around only with 4.1.4, it
3681 should work with earlier versions of AIX 4.1. It does not
3682 work for AIX 4.2; a different work-around is employed there.
3683 (See the next section.)
3684
3685 If you want to use this technique to compile other AIX
3686 4.1x programs with gcc for using getuser(), check the
3687 Configure script.
3688
3689 Stuart D. Gathman identified this gcc AIX alignment problem.
3690
36914.3 Gcc and AIX 4.2[.1]
3692
3693 Alignment problems with gcc and AIX 4.2[.1] inside the user
3694 structure are more severe, because there are some new 64
3695 bit types in AIX that gcc doesn't yet (as of 2.7.x) support.
3696 The <sys/user.h> U_irss element problem, discussed in 4.3
3697 above, doesn't exist in 4.2[.1].
3698
3699 The AIX lsof machine.h header file has a work-around,
3700 provided by Henry Grebler, that bypasses gcc alignment
3701 problems. Later versions of gcc (e.g., 2.8.x) will probably
3702 bypass the problems as well.
3703
37044.4 Why won't lsof's Configure allow the use of gcc for AIX
3705 below 4.1?
3706
3707 Gcc can't reliably be used to compile lsof for AIX versions
3708 below AIX 4.1 because of possible kernel structure element
3709 alignment differences between it and xlc.
3710
37114.5 What is an AIX SMT file type?
3712
3713 When you run AIX X clients with the DISPLAY environment
3714 variable set to ``:0.0'' they communicate with the AIX X
3715 server via files whose kernel file structure has an undefined
3716 type (f_type == 0xf) -- at least there's no definition for
3717 it in <sys/file.h>.
3718
3719 These are Shared Memory Transport (SMT) sockets, an artifact
3720 of AIXWindows, designed for more efficient data transfers
3721 between the X server and its clients.
3722
3723 Henry Grebler and David J. Wilson alerted me to the existence
3724 of these files. Mike Feldman and others helped me identify
3725 them as SMT sockets.
3726
3727 The curious reader can find more about SMT sockets in
3728 /usr/lpp/X11/README.SMT.
3729
37304.6 Why does AIX lsof start so slowly?
3731
3732 When AIX lsof starts it compares the running kernel's
3733 identity to the one for which it was built, using
3734 /usr/bin/oslevel. That comparison can sometimes take a
3735 long time to complete, depending on the system's maintenance
3736 level and how recently it was examined with oslevel.
3737
3738 AIX revisions 4.67 and above for AIX 5 and above don't use
3739 oslevel to determine the kernel identity. They use uname(2)
3740 instead, and it is much faster.
3741
3742 You can skip the oslevel test by suppressing warning messages
3743 with lsof's -w option. Doing that carries with it the risk
3744 of missing other warning messages, however.
3745
3746 You can also disable the kernel identity check by disabling
3747 the definition of the HASKERNIDCK symbol by editing AIX
3748 machine.h header file or by using the Customize script to
3749 disable it.
3750
3751 See the "Why does lsof warn "compiled for x ... y; this is
3752 z.?" section for more information.
3753
37544.7 Why does exec complain it can't find libc.a[shr.o]?
3755
3756 When you try to execute lsof you may get this complaint:
3757
3758 exec(): 0509-036 Cannot load program ./lsof because of
3759 the following errors:
3760 0509-022 Cannot load library libc.a[shr.o].
3761 0509-026 System error: A file or directory in
3762 the path name does not exist.
3763
3764 This is probably the result of making lsof when the LIBPATH
3765 environment variable contained a directory path that doesn't
3766 contain libc.a. You can see what LIBPATH contained when
3767 lsof was made by using the dump application on lsof. For
3768 example, if LIBPATH contained /foo/bar when lsof was made,
3769 you will see this (partial) dump output:
3770
3771 $ dump -H lsof
3772 ...
3773 ***Import File Strings***
3774 INDEX PATH BASE ...
3775 0 /foo/bar
3776
3777 To correct the problem, revisit the lsof source directory
3778 and remake lsof this way:
3779
3780 $ unset LIBPATH; make (sh or ksh)
3781 or
3782 % unsetenv LIBPATH; make (csh or tcsh)
3783
37844.8 What does lsof mean when it says, "no PCB, CANTSENDMORE,
3785 CANTRCVMORE" in a socket file's NAME column?
3786
3787 When an AIX application calls shutdown(2) on an open socket
3788 file, but hasn't called close(2) on the file, the file will
3789 remain visible to lsof as an open socket file without any
3790 extended protocol information.
3791
3792 Lsof reports that state in the NAME column by saying that
3793 there is "no PCB" (Protocol Control Block) for the protocol
3794 (e.g., TCP in the NODE column). If the open socket file
3795 has the state variables SO_CANTSENDMORE and SO_CANTRCVMORE
3796 set -- i.e., from the shutdown(2) call -- lsof reports them
3797 with the CANTSENDMORE and CANTRCVMORE notes in the NAME
3798 column.
3799
38004.9 When the -X option is used on AIX 4.3.3, why does lsof disable
3801 it, saying "WARNING: user struct mismatch; -X option disabled?"
3802
3803 The -X option causes lsof to read the loader information
3804 of the user structure from virtual memory via the readx()
3805 system call. It does that with the user structure definition
3806 from <sys/user.h> that was compiled into the lsof executable.
3807
3808 On AIX 4.3.3 there are two different user structure
3809 definitions in two separate <sys/user.h> header files,
3810 distributed at different times by IBM. If lsof was compiled
3811 with one and the kernel on which lsof is being run was
3812 compiled with the other, lsof normally won't get correct
3813 loader information when it calls readx().
3814
3815 In an attempt to compensate for that difference, lsof makes
3816 an independent check of the loader information by getting
3817 the user structure's open file count via readx() and
3818 comparing it to the open file count obtained independently
3819 via getprocs(). When the two counts don't match, lsof
3820 tries to read the count (and re-read the loader information)
3821 with two offsets, based on observed differences between
3822 the two user structures.
3823
3824 When one of the three attempts produces a correct open file
3825 count, lsof uses its corresponding offset on subsequent
3826 readings of the loader information.
3827
3828 When none of the three attempts produces a correct open
3829 file count, lsof issues the WARNING message and disables
3830 -X processing.
3831
3832 To eliminate this problem, obtain an lsof binary that
3833 matches the kernel of the AIX 4.3.3 system where you want
3834 to run lsof. Compiling lsof on the target system is the
3835 preferred way to get a matching binary.
3836
38374.10 Why doesn't the -X option work on my AIX 5L or 5.[123] system?
3838
3839 If your AIX 5L or 5.[123] system uses the ia64 architecture,
3840 lsof needs setuid-root permission to be able to do the
3841 processing that -X requires.
3842
3843 Check the output of `uname -a` to determine the architecture
3844 type.
3845
3846 The work-around is to give lsof setuid-root permission.
3847
38484.11 Why doesn't /usr/bin/oslevel report the correct AIX version?
3849
3850 The oslevel man page says, "The oslevel command reports
3851 the level of the operating system using a subset of all
3852 filesets installed on your system."
3853
3854 You can see which fileset is below the expected level with
3855 oslevel's -l option. For example, if you believe your
3856 system is at AIX level 4.3.3, but oslevel reports 4.3.2,
3857 use this oslevel command to find the filesets below 4.3.3:
3858
3859 $ /usr/bin/oslevel -l 4.3.3.0
3860
3861 If you don't know what level argument to supply to oslevel's
3862 -l option, use oslevel's -q option first.
3863
38644.11.1 Why doesn't /usr/bin/oslevel report the correct AIX version
3865 on AIX 5.1?
3866
3867 The subset list for oslevel on AIX 5.1 seems to include at
3868 least two filesets, xlsmp.msg.en_US.rte and xlsmp.rte, that
3869 do not install from AIX 5.1 media with a 5.1.0.0 level.
3870 Hence, oslevel reports 5.0.0.0 instead of the expected
3871 5.1.0.0.
3872
3873 If either xlsmp.msg.en_US.rte or xlsmp.rte is installed,
3874 lsof's Configure script and run-time tests will identify
3875 the AIX version incorrectly. The run-time test will
3876 issue a complaint message of this form:
3877
3878 lsof: WARNING: compiled for AIX version xxx; this is yyy.
3879
3880 You can correct the Configure test by pre-defining the
3881 oslevel value, setting the correct value in the LSOF_VSTR
3882 environment variable before running the Configure script
3883 -- e.g., to pre-define AIX 5.1 when using ksh, do this:
3884
3885 $ LSOF_VSTR=5.1.0.0 Configure -n aix
3886
3887 You can't affect oslevel output without uninstalling
3888 xlsmp.msg.en_US.rte and xlsmp.rte. If you can't do that,
3889 you'll have to put up with the run-time complaint.
3890
38914.12 Why does lsof for AIX 5.1 or above Power architecture
3892 complain about kernel bit size?
3893
3894 When you run an lsof binary on an AIX 5.1 or above Power
3895 system, it might complain:
3896
3897 lsof: FATAL: compiled for a 32 bit kernel.
3898 The bit size of this kernel is 64.
3899 or
3900 exec: 0509-036 Cannot load program ./lsof because of
3901 the following errors:
3902 0509-032 Cannot run a 64-bit program on a 32-bit
3903 machine.
3904
3905 Starting at lsof revision 4.61, lsof binaries for Power
3906 architecture systems running AIX 5.1 or above are closely
3907 tied to the kernel bit size. Lsof must do that so it can
3908 read and understand kernel structures.
3909
3910 Lsof's Configure script tunes the lsof configuration so
3911 that the binary built in the make(1) step is adjusted to
3912 the kernel bit size.
3913
3914 An lsof binary knows the bit size for which it was constructed,
3915 tests the bit size of the kernel under which it is running,
3916 and objects if the two sizes don't match. To see the bit
3917 size for which lsof was constructed, run it with its -v
3918 option and look for these lines in the output:
3919
3920 configuration info: 32 bit kernel
3921 or
3922 configuration info: 64 bit kernel
3923
3924 (Note: these lines will appear only in -v output for AIX
3925 5.1 and above lsof binaries, built for Power architecture.)
3926
3927 You can see the kernel bit size test method in the aix
3928 stanza of the lsof Configure script and in the get_kernel_access()
3929 function of the lsof .../dialects/aix/dproc.c source file.
3930
3931 There is more information on pre-defining the kernel bit
3932 size when building lsof in Configure, 00PORTING, and
3933 00XCONFIG.
3934
3935 The only work-around is to use an lsof binary built to
3936 match the running kernel bit size.
3937
39384.13 What can't gcc be used to compile lsof on the ia64 architecture
3939 for AIX 5 and above?
3940
3941 Gcc can't be used to compile lsof on the ia64 architecture
3942 for AIX 5 and above because I haven't had access to a system
3943 that has a working gcc compiler. The gcc compiler on my
3944 one and only ia64 AIX 5.1 test system, provided by IBM,
3945 didn't work at all.
3946
39474.14 Why does lsof get a segmentation fault when compiled with gcc
3948 for a 64 bit Power architecture AIX 5.1 kernel?
3949
3950 When lsof is configured with the lsof "aixgcc" Configure
3951 abbreviation, the resulting lsof executable may cause a
3952 segmentation violation when it is run. I've observed this
3953 with gcc version 2.9-aix43-010414-7.
3954
3955 As far as I have been able to tell, the segmentation fault
3956 is the result of a gcc compilation, loading, or library
3957 error. Watching lsof run with gcc's companion debugger,
3958 gdb, shows no error in the lsof source code that might
3959 explain the fault.
3960
3961 The only work-around I know is to use the IBM C compiler
3962 in place of gcc -- i.e., use the "aix" lsof Configure
3963 abbreviation.
3964
39654.15 Why does lsof ignore AFS on my AIX system?
3966
3967 The lsof Configure script quits on AIX when AFS is present,
3968 the AIX version is greater than 4.3.3.0 or the AFS version
3969 is greater than 3.5. That's because I have no test systems
3970 available for those AIX and AFS version combinations.
3971
3972 When the lsof Configure script detects an AIX and AFS
3973 version combination that is unsupported, it will report:
3974
3975 !!!FATAL: Lsof does not support AFS on this combination of
3976 AIX and AFS versions. To disable AFS, set the
3977 value of the AIX_HAS_AFS environment variable to
3978 "no".
3979
3980 The only work-around is to set the AIX_HAS_AFS environment
3981 variable as explained in the error message:
3982
3983 $ AIX_HAS_NSF=no; export AIX_HAS_NFS
3984 $ ./Configure -n aix
3985
39864.16 Why does lsof report "system paging space is low" and exit?
3987
3988 When AIX paging space runs low, the AIX kernel sends a SIGDANGER
3989 signal to processes, warning them that they should reduce their
3990 memory usage.
3991
3992 When lsof receives that signal, it issues the following fatal
3993 error message and exits:
3994
3995 lsof: FATAL: system paging space is low.
3996
3997 A possible work-around is to limit the amount of information
3998 lsof must cache in its process memory with the "-c", "-g", "-l"
3999 and "-p" options.
4000
4001 Also see the answer to the "What can be done when lsof reports
4002 no more space?" question.
4003
40044.17 Why does lsof have a compilation problem on AIX 5.3 above
4005 maintenance level 1?
4006
4007 On some AIX 5.3 systems with maintenance levels 2 and higher
4008 installed, lsof 4.77 and below may not compile properly. The
4009 compiler complains the snapshotObject structure definition,
4010 needed by <j2/j2_inode.h>, is missing.
4011
4012 That problem is fixed in the 4.78 revision.
4013
4014
40155.0 Apple Darwin Problems
4016
40175.1 What do /dev/kmem-based and libproc-based mean?
4018
4019 Lsof for Apple Darwin currently uses /dev/kmem to read kernel
4020 data structures from which it gathers and reports open file
4021 information. That version of lsof is called /dev/kmem-based
4022 lsof.
4023
4024 At an upcoming release lsof will use a library called libproc
4025 to obtain information about open files. That version of lsof
4026 wil be called libproc-based lsof.
4027
4028 The /dev/kmem-based lsof sources may be found in the kmem
4029 subdirectory of the dialects/darwin branch of the lsof source
4030 tree. When the supporting version of Apple Darwin is released,
4031 the libproc-based lsof sources will be found in
4032 .../dialects/darwin/libproc.
4033
40345.2 /dev/kmem-based Apple Darwin Questions
4035
40365.2.1 Why does Configure ask for a path to the Darwin XNU kernel
4037 header files?
4038
4039 When lsof was ported to Apple Darwin by Allan Nathanson at
4040 revision 4.53, some kernel header files needed by lsof
4041 weren't being exported by the developers. (That's still
4042 true at lsof revision 4.76.)
4043
4044 At first a shell script that Allan provided would get the
4045 missing header files by checking them out from the CVS
4046 root. Although the script was updated from time to time,
4047 eventually the re-organization of Darwin sources has made
4048 it impossible to update the script to do an automatic
4049 download of the missing header files.
4050
4051 At lsof revision 4.69 and above it is necessary for the Darwin
4052 lsof builder to download the Darwin XNU kernel headers before
4053 attempting to build lsof. The download my be done via a web
4054 browser, starting at this URL:
4055
4056 http://www.opensource.apple.com/darwinsource/index.html
4057
4058 Once there, select the link to the Mac OS X version that
4059 matches the one on the system where lsof is to be built.
4060
4061 Follow that link's "[ Source ]" link. Once there, select the
4062 tar.gz link of the xnu* entry near the bottom of the page.
4063 That entry should have a name that matches the xnu* name shown
4064 by `uname -a` -- e.g., if uname reports:
4065
4066 $ uname -a
4067 ... root:xnu/xnu-517.7.21 ...
4068
4069 Then the appropriate xnu* entry is xnu-517.7.21. Clicking
4070 its link should lead to an "Apple Open Source" page requesting
4071 an Apple ID and password.
4072
4073 Enter them if they're available. If an Apple ID and password
4074 are not available, get them by following the instructions on
4075 the page -- i.e., follow the signin.apple.com link.
4076
4077 Once a valid Apple ID and its password have been entered,
4078 the download will begin. Select the saving of the downloaded
4079 xnu*.tar.gz file in an appropriate place on the Mac OS X
4080 system.
4081
4082 Once the download completes, install it. Use gunzip to
4083 decompress the download and tar to extract the archive -- e.g.,
4084
4085 $ gunzip -c xnu-517.7.21.tar.gz | tar xf -
4086
4087 Remember the absolute path to the extracted archive. That is
4088 its installed place. E.g., if the xnu-517.7.21.tar archive was
4089 extracted to the lsof builder's home directory, its full
4090 installation path will be something like:
4091
4092 ~/xnu-517.7.21
4093
4094 Now run the lsof Configure script. When it asks for the path
4095 to the installed Darwin XNU kernel header files, supply the
4096 path to the gunzip'd and extracted xnu* archive -- e.g.,
4097 ~/xnu-517.7.21.
4098
4099 The path to the Darwin XNU kernel headers may also be
4100 supplied to the Configure script in the DARWIN_XNUDIR
4101 environment variable, eliminating the need to enter it
4102 interactively -- e.g.,
4103
4104 $ DARWIN_XNUDIR=~/xnu-344.49 ./Configure -n darwin
4105
41065.2.1.1 Why does Configure complain that Darwin XNU kernel header
4107 files are missing?
4108
4109 These are some reasons why the lsof Configure script might
4110 claim that Darwin XNU header files are missing:
4111
4112 * The wrong path to them was specified.
4113
4114 * The files and directories in the path are not readable
4115 and searchable -- i.e., check the modes and ownerships.
4116
4117 * The downloaded archive doesn't match the Mac OS X
4118 version of the system.
4119
4120 If in doubt, revisit the Darwin XNU kernel header file
4121 download instructions in the answer to the question "Why
4122 does Configure ask for a path to the Darwin XNU kernel
4123 header files?"
4124
4125 If Configure still can't find Darwin XNU kernel header
4126 files, contact me via e-mail at <abe@purdue.edu> for help.
4127 Make sure "lsof" appears in the "Subject:" line so my e-mail
4128 filter won't classify your letter as Spam.
4129
41305.2.2 Why doesn't Apple Darwin lsof report text file information?
4131
4132 At the first port of lsof to Apple Darwin, revision 4.53,
4133 insufficient information was available -- logic and header
4134 files -- to permit the installation of VM space scanning
4135 for text files. As of lsof 4.70 it is sill not available.
4136
4137 Text file support will be added to Apple Darwin lsof after
4138 the necessary information becomes available.
4139
41405.2.3 Why doesn't Apple Darwin lsof support IPv6?
4141
4142 At the first port of lsof to Apple Darwin, revision 4.53,
4143 Apple Darwin lacked IPv6 support. IPv6 became available
4144 in Apple Darwin version 1.5 and support for it was added
4145 to lsof then.
4146
41475.2.4 Why does lsof complain about a mismatch between the release
4148 for which lsof was compiled and the booted Mac OS X release?
4149
4150 When lsof is started on the "Gold Master" Darwin release
4151 (aka Mac OS X), it complains:
4152
4153 lsof: compiled for 1.0 release; this is 1.3.2.
4154
4155 This happens because the lsof binary released with Mac OS
4156 X was built on a system whose release number (1.0) doesn't
4157 match that of the released system -- usually 1.3.x Lsof
4158 makes this check because UNIX dialect OS changes are often
4159 accompanied by header file changes that affect lsof.
4160
4161 In this specific case, this error can be ignored. If you
4162 don't want to do that, get the lsof distribution and build
4163 lsof so its built-on and running-on Mac OS X release numbers
4164 match.
4165
41665.2.5 Why does lsof for Apple Darwin 8 and higher report
4167 "stat(...): ..." in the NAME column?
4168
4169 Lsof for Apple Darwin 8 may report messages like these in the
4170 NAME column:
4171
4172 stat(/private/var/run/asl_prune): No such file or directory
4173 or
4174 stat(/private/var/db/netinfo/local.nidb/Config): Permission denied
4175
4176 Those messages indicate that lsof was unable to collect open
4177 file information for the paths enclosed in "stat(...)" with the
4178 stat(2) function, because the function encountered the reported
4179 error.
4180
4181 A work-around for the "Permission denied" error is to run lsof
4182 with elevated privileges -- e.g., when logged on as the super
4183 user.
4184
4185 If the stat(2) error message is "No such file or directory",
4186 the file probably has been unlinked (removed) and there is no
4187 lsof work-around.
4188
41895.2.6 What are the limitations of Apple Darwin lsof link count
4190 reporting?
4191
4192 Lsof for Apple Darwin cannot report link count information
4193 reliably.
4194
4195 For Apple Darwin below 8 link count information is not always
4196 available in the kernel node structures available to lsof.
4197 When link count information is available, however, it includes
4198 link counts of zero. Thus, using lsof's +L1 option may result
4199 in the finding of some files whose link counts are zero.
4200
4201 Lsof can report only some link count information for Apple
4202 Darwin 8 and above. Link count information is only available
4203 for files where lsof can assemble the full file path and has
4204 permission to apply stat(2) to it. (See the answer to the "Why
4205 does lsof for Apple Darwin 8 and higher report "stat(...): ..."
4206 in the NAME column?" question for more information on stat(2)
4207 failures.)
4208
4209 Apple Darwin 8 and above files that have been unlinked and thus
4210 have a link count of zero cannot be found by stat(2) -- i.e.,
4211 stat(2) returns a "No such file or directory" error. As a
4212 result lsof never displays link counts of zero and the use of
4213 lsof's +L1 option to find them always fails.
4214
42155.3 Libproc-based Apple Darwin Questions
4216
4217
42186.0 BSD/OS BSDI Problems
4219
42206.0.5 Statement of deprecation
4221
4222 As of lsof revision 4.76 support for BSDI BSD/OS has been
4223 dropped. The 4.76 distribution of lsof for BSDI BSD/OS may be
4224 found on lsof.itap.purdue.edu in pub/tools/unix/lsof/OLD/src.
4225
4226
42277.0 DEC OSF/1, Digital UNIX, and Tru64 UNIX Problems
4228
42297.1 Why does lsof complain about non-existent /dev/fd entries?
4230
4231 When you run lsof for Digital UNIX 3.2, lsof may complain:
4232
4233 lsof: can't lstat /dev/fd/xxx: No such file or directory
4234 lsof: can't lstat /dev/fd/yyy: No such file or directory
4235
4236 (Or it may warn about other missing /dev/fd paths.) When
4237 you do an ``ls /dev/fd'' none of the missing paths are listed.
4238
4239 This is caused by a bug in the DEC library function
4240 getdirentries(). For some reason, when /dev/fd is a file
4241 system mount point, getdirentries() returns an incorrect
4242 size for it to readdir(). (Lsof calls readdir() in its
4243 ddev.c readdev() function.) Because of the incorrect size,
4244 readdir() goes past the end of the /dev/fd directory buffer,
4245 encounters random paths and returns them to lsof. Lsof
4246 then attempts to lstat(2) the random paths, gets error
4247 replies from lstat(2), and complains about the paths.
4248
4249 Duncan McEwan discovered this error and has reported it to
4250 DEC. Duncan also supplied an alternate readdir() function
4251 as a work-around. I've incorporated his readdir() in
4252 dialects/osf/ddev.c (as the static ReadDir() function) with
4253 some slight modifications, and enabled its use when the
4254 USELOCALREADDIR symbol is defined.
4255
4256 The Configure script defines USELOCALREADDIR for Digital
4257 UNIX version and 3.2. If you don't want to use Duncan's
4258 local readdir() function, edit the Makefile and remove
4259 -DUSELOCALREADDIR from the CFGF string. When DEC releases
4260 a corrected getdirentries() function, I'll modify the
4261 Configure script to stop defining USELOCALREADDIR.
4262
42637.2 Why does the Digital UNIX V3.2 ld complain about Ots* symbols?
4264
4265 When you compile lsof on your Digital UNIX V3.2 system, ld
4266 may complain:
4267
4268 ld:
4269 Unresolved:
4270 knlist
4271 _OtsRemainder32Unsigned
4272 _OtsDivide64Unsigned
4273 _OtsRemainder64Unsigned
4274 _OtsDivide32Unsigned
4275 _OtsMove
4276 _OtsDivide32
4277 _OtsRemainder32
4278 *** Exit 1
4279
4280 Chris Eleveld reports this happens on Digital UNIX V3.2
4281 systems after the Fortran compiler has been installed.
4282
4283 The best work-around seems to be to remove -lmld from the
4284 CFGL string in the Makefile produced by Configure -- i.e.,
4285 change:
4286
4287 CFGL= -lmld
4288 to
4289 CFGL=
4290
4291 According to the V3.2 man page for nlist(3), this shouldn't
4292 work, but my testing shows that it does. Although I haven't
4293 been able to test this second work-around, you might try
4294 adding -lots to CFGL, rather than removing -lmld -- i.e.,
4295 change:
4296
4297 CFGL= -lmld
4298 to
4299 CFGL= -lmld -lots
4300
4301 WARNING: my testing also shows that the V2.0 nlist(3) man
4302 page means what it says when it calls for -lmld -- lsof
4303 loaded without -mld under V2.0 can't locate the proc
4304 (process) table address.
4305
4306 DON'T REMOVE -lmld FROM THE DIGITAL UNIX V2.0 MAKEFILE.
4307
4308 If you run into this problem, please let me know what
4309 problem you encountered and how you solved it.
4310
43117.3 Why can't lsof locate named pipes (FIFOs) under V3.2?
4312
4313 While lsof for V3.2 can report on named pipes (FIFOs), it
4314 can't find them by name. That appears to happen because
4315 of the way the V3.2 kernel lstat(2) function reports named
4316 pipe device numbers.
4317
4318 The V3.2 kernel reports the device number as 0xfffffff,
4319 while the kernel structures for named pipes that lsof
4320 examines contain the device number of the file system on
4321 which the named pipe resides.
4322
4323 Consequently, lsof can't match the device and inode number
4324 pair it receives from applying lstat(2) to the named pipe
4325 with any device and inode number pair it finds when scanning
4326 kernel structures.
4327
4328 I don't have a work-around. You can, of course, ask for
4329 full lsof output and use a post-processing filer (e.g.,
4330 grep) to locate the named pipe of interest.
4331
4332 This problem doesn't exist under V2.0.
4333
43347.4 Why does lsof use the wrong configuration header files?
4335 For example, why can't the lsof compilation find cpus.h?
4336
4337 DEC OSF/1, Digital UNIX, and Tru64 UNIX configuration header
4338 files describe the hardware and software environment for
4339 which your kernel boot file was constructed. For example,
4340 /sys/<name>/cpus.h defines the number of CPUs in its NCPUS
4341 #define.
4342
4343 Lsof searches for the configuration header file subdirectory
4344 in /sys (/usr/sys for Digital UNIX version 4.0 and Tru64
4345 UNIX) by converting the first host name component to capital
4346 letters -- e.g., TOMIS is derived from tomis.bio.purdue.edu.
4347 If that subdirectory exists, lsof uses header files from
4348 it. (Configure reports what subdirectory is being used.)
4349
4350 If Configure doesn't find a host-name derived subdirectory,
4351 it prompts you for the entry of a subdirectory name. If
4352 you can't find one, quit Configure and run the kernel
4353 generation process to create a proper configuration sub-
4354 directory. If you don't identify a proper configuration
4355 subdirectory and you try to compile lsof, the compiler will
4356 complain about missing header files -- e.g., a missing
4357 cpus.h.
4358
4359 Once you have located or generated a proper configuration
4360 subdirectory, rerun Configure. If you have generated a
4361 configuration subdirectory whose name is derived from the
4362 host name, Configure will find and use it. If not, you
4363 will have to specify its name to Configure.
4364
43657.5 Why does lsof indicate incomplete paths with " -- " for Tru64
4366 UNIX 5.1 files?
4367
4368 When lsof can't find a component of a path in the kernel's
4369 name cache (aka DNLC), or can't determine that the left-most
4370 component has as its parent the file system root, it uses
4371 an "incomplete path" notation. That notation begins with
4372 the file system root name, followed by " -- ", followed by
4373 the consecutive path name components lsof was able to find
4374 in the DNLC -- e.g., "/ -- init".
4375
4376 Because the DNLC was significantly redesigned in Tru64 UNIX
4377 5.1, lsof's handling of the cache had to be completely
4378 redone. As part of the DNLC redesign a name cache entry
4379 parameter lsof formerly used to locate the file system root
4380 of a path was removed. With help from Chang Song I've been
4381 able to implement an alternate method for detecting the
4382 root of these file system types: AdvFS (MSFS), CDFS, DVDFS,
4383 FDFS, NFS, NFS3, and UFS.
4384
4385 When lsof doesn't know how to identify the root for a file
4386 system type, it will resort to the " -- " incomplete path
4387 notation.
4388
43897.6 Why doesn't lsof report link count, node number, and size
4390 for some Tru64 5.x CFS files?
4391
4392 Lsof reports link count, node number, and size for open
4393 CFS files as recorded in their kernel node structure's
4394 cached attributes. Sometimes not all attributes are cached
4395 on the system where lsof runs, so lsof cannot report them.
4396
43977.7 Why does lsof say it can't read the kernel name list or
4398 proc table on Digital UNIX 4.x or Tru64 UNIX?
4399
4400 By default on Digital UNIX 4 and Tru64 UNIX lsof reads the
4401 addresses for kernel symbols with the knlist(3) function.
4402 That function can fail, for example, when the kloadsrv
4403 daemon isn't running or is malfunctioning. When that
4404 happens, lsof may abort with one of these error messages:
4405
4406 lsof: can't read kernel name list from knlist(3): ...
4407 or
4408 lsof: can't read proc table info
4409
4410 The first message suggests a complete knlist(3) or kloadsrv
4411 failure; the second, a partial one.
4412
4413 If you know the name of the file from which the running
4414 system was booted, e.g., /vmunix, you can use lsof's -k
4415 option to direct it to read kernel symbol addresses from
4416 the name list of that file --
4417
4418 $ lsof -k /vmunix ...
4419
4420 If that works, then knlist(3) is malfunctioning and you
4421 need to fix it.
4422
4423
44248.0 FreeBSD Problems
4425
44268.1 Why doesn't lsof report on open kernfs files?
4427
4428 Lsof doesn't report on open FreeBSD kernfs files because
4429 the structures lsof needs aren't defined in the kernfs.h
4430 header file in /sys/misc/kernfs.
4431
44328.2 Why doesn't lsof work on my FreeBSD system?
4433
4434 If lsof doesn't work on your FreeBSD system, first make
4435 sure you have the latest lsof revision. See the answer to
4436 the "Where do I get lsof?" question for information on how
4437 to get the latest lsof revision.
4438
4439 Once you have gotten the latest lsof revision, Configure
4440 and make it. If Configure fails -- e.g., it complains
4441 about an unknown FreeBSD version -- then lsof probably
4442 hasn't been ported to your FreeBSD version yet, and there's
4443 no need to go any further. Follow the answer to the "How
4444 do I report an lsof bug" to report the Configure complaint
4445 to me.
4446
4447 If you are able to Configure and make lsof, run its test
4448 suite. (See the answer to the "Is there a test suite?"
4449 question for more information on how to use lsof's test
4450 suite.)
4451
4452 If lsof still fails, make sure your kernel sources, kernel
4453 header files, kernel boot file, standard header files and
4454 libraries are synchronized. They should all be built from the
4455 same CVS refresh. (Don't forget to do a "make buildworld"
4456 followed by a "make installworld".) If they aren't, then the
4457 KVM library or lsof may be using kernel structure definitions
4458 that don't match the booted kernel; or lsof may fail to compile
4459 properly because of header files in /usr/src/sys/sys and
4460 /usr/include/sys that don't match.
4461
4462 If you have synchronized your kernel, header files and
4463 libraries, and still can't get lsof to work, follow the
4464 steps in the answer to the "How do I report an lsof bug"
4465 question to report the problem to me.
4466
44678.3 Why doesn't lsof work on the RELEASE version of CURRENT?
4468
4469 Lsof tracks the CURRENT release of the current leading edge
4470 FreeBSD version, because my access to leading edge FreeBSD is
4471 limited to FreeBDSD.org reference systems, all running the
4472 CURRENT release.
4473
4474 Sometimes that tracking leads to changes in lsof that won't
4475 work on an earlier RELEASE version of the current leading edge
4476 version.
4477
4478 When that happens, please send e-mail to me <abe@purdue.edu>.
4479 Make sure "lsof" appears in the "Subject:" line so my e-mail
4480 filter won't classify your letter as Spam.
4481
44828.4 Why does kvm_open() complain it can't find some file?
4483
4484 If lsof issues this complaint:
4485
4486 lsof: kvm_open(execfile=/boot/kernel/kernel,
4487 corefile=/dev/mem: No such file or directory
4488
4489 Your FreeBSD system might not have a /dev/mem device. If
4490 not, create one -- e.g., as root do:
4491
4492 # mknod /dev/mem c <major> 0
4493 # chmod 440 /dev/mem
4494 # chgrp kmem /dev/mem
4495
4496 For <major> use /dev/kmem's major device number.
4497
4498 You may have to run kldload, too -- again as root do:
4499
4500 # kldload mem
4501
45028.5 FreeBSD ZFS Problems
4503
45048.5.1 Why does FreeBSD lsof report "WARNING: no ZFS support has been
4505 defined."?
4506
4507 Lsof issues that message when it detects a file on a ZFS file
4508 system, but has not been built with support for ZFS. Lsof's
4509 Configure script detects support can be added for ZFS when it
4510 finds this file:
4511
4512 /usr/src/sys/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
4513
4514 That header file and others in the OpenSolaris files in
4515 /usr/src enable lsof to extract information about ZFS files
4516 from the kernel structures associated with them.
4517
45188.6 Why can't Configure create lsof_owner.h for FreeBSD 6 and above?
4519
4520 Lsof may report:
4521
4522 Creating ./lockf_owner.h from /usr/src/sys/kern/kern_lockf.c
4523 FATAL ERROR: can't read /usr/src/sys/kern/kern_lockf.c
4524 FATAL ERROR: ./lockf_owner.h creation failed (see 00FAQ)
4525 or
4526 Creating ./lockf_owner.h from /usr/src/sys/kern/kern_lockf.c
4527 FATAL ERROR: ./lockf_owner.h creation failed (see 00FAQ)
4528
4529 Those messages mean that lsof's Configure script failed to
4530 create a local header file, ./lockf_owner.h, needed to use the
4531 new kernel file locking code of some versions of FreeBSD 6 and
4532 above.
4533
4534 The changes that implement that new locking code alter the
4535 lockf structure in <sys/lockf.h> and introduce a new structure,
4536 lockf_entry, to that header file. When Configure detects the
4537 presence of the lockf_entry definition in <sys/lockf.h>, it
4538 tries to construct the local header file, ./lockf_owner.h.
4539
4540 Configure has to do that because an unfortunate side effect of
4541 the new kernel file locking code is that <sys/lockf.h> doesn't
4542 contain the lockf_owner structure definition referenced in its
4543 own lockf structure. Lsof needs to access elements of that
4544 lockf_owner structure to determine if a lock belongs to the
4545 process that has a file open.
4546
4547 The missing lockf_owner structure definition is in the kernel
4548 source file, typically /usr/src/sys/kern/kern_lockf.c.
4549 Configure tries to extract the lockf_owner structure definition
4550 from kern_lockf.c into lsof's local header file, ./lockf_owner.h.
4551 If Configure can't do that, it reports:
4552
4553 FATAL ERROR: ./lockf_owner.h creation failed
4554
4555 If Configure can't even read kern_lockf.c, it first reports:
4556
4557 FATAL ERROR: can't read /usr/src/sys/kern/kern_lockf.c
4558
4559 The work-around for this problem is to update the FreeBSD
4560 kernel /usr/src tree (e.g., do a CVSup or csup) on the system
4561 where lsof is to be built and then do a "make buildworld"
4562 followed by a "make installworld".
4563
45648.6.1 Why are there lockf structure compiler errors for FreeBSD 6.0
4565 and higher lsof?
4566
4567 If, when compiling lsof, the compiler complains with error
4568 messages like:
4569
4570 dnode.c: In function 'get_lock_state':
4571 dnode.c:113: error: 'struct lockf' has no member named 'lf_flags'
4572 dnode.c:115: error: 'struct lockf' has no member named 'lf_id'
4573 ...
4574
4575 Then lsof is being built on a system that has new kernel file
4576 locking code and lsof's Configure script failed to build a
4577 local lockf_owner.h header file with a structure definition
4578 lsof needs.
4579
4580 See the "Why can't Configure create lsof_owner.h for FreeBSD 6
4581 and above?" section for more information and a work-around.
4582
45838.6.2 Why don't /usr/src/sys/sys/lockf.h and /usr/include/sys/lockf.h
4584 match?
4585
4586 This mismatch can cause the errors explained in the answer to
4587 the "Why are there lockf structure compiler errors for FreeBSD
4588 6.0 and higher lsof?" question.
4589
4590 If /usr/src/sys/sys/lockf.h has been updated with a CVSup or
4591 csup, the new lockf.h won't be propagated to /usr/include/sys
4592 until the "make buildworld" and "make installworld" steps have
4593 been completed.
4594
4595
45969.0 HP-UX Problems
4597
45989.1 What do /dev/kmem-based and PSTAT-based mean?
4599
4600 Lsof for HP-UX 11.0 and below uses /dev/kmem to read kernel
4601 data structures from which it gathers and reports open file
4602 information. That version of lsof is called /dev/kmem-based
4603 lsof.
4604
4605 Starting with HP-UX 10.10, finding definitions for the
4606 necessary kernel structures became more difficult as HP no
4607 longer distributed header files in /usr/include that defined
4608 all kernel structures. So I started "inventing" structure
4609 definitions by using Q4 to display them.
4610
4611 By HP-UX 11, the process of invention became extremely
4612 intensive to support. Following a patch to the ipc_s
4613 structure in early 1999, my invented definition of that
4614 structure became incorrect. Although I was able to devise
4615 a work-around test for the patch with Q4, it was clear that
4616 my inventions were bound to cause more problems.
4617
4618 Discussion with HP about the patch led to my proposing that
4619 an lsof API in the HP-UX kernel was the proper solution.
4620 Much to my surprise, HP agreed. I believe Carl Davidson
4621 was the prime mover behind that decision, but I know others
4622 participated, among them Louis Huemiller, Rich Rauenzahn,
4623 and Sailu Yallapragada. I am indebted to these folks and
4624 HP for their willingness to do this work.
4625
4626 The API was added to the PSTAT interface in a project named
4627 PEGL, Pstat Enhancements for Glance and Lsof. Louis and
4628 Sailu did the bulk of the design and implementation work
4629 and testing began in March, 2000
4630
4631 HP-UX 11.11 is the first version that provides PSTAT support
4632 for lsof. HP-UX versions in between 11.0 and 11.11 -- all
4633 Beta versions as far as I can determine -- have no lsof
4634 support.
4635
4636 See the "PSTAT-based HP-UX lsof Questions" section for
4637 questions and answers specific to PSTAT-based HP-UX lsof.
4638 The next section, "Why doesn't a /dev/kmem-based HP-UX lsof
4639 compilation use -O?" covers /dev/kmem-based HP-UX lsof.
4640
4641 The /dev/kmem-based lsof sources may be found in the kmem
4642 subdirectory of the dialects/hpux branch of the lsof source
4643 tree. The PSTAT-based lsof sources may be found in
4644 .../dialects/hpux/pstat.
4645
46469.2 /dev/kmem-based HP-UX lsof Questions
4647
4648 The sources for /dev/kmem-based lsof for HP-UX may be found
4649 in lsof_<revision>/dialects/hpux/kmem.
4650
4651 Lsof's Configure shell script decides to use these sources
4652 when it finds that the /usr/include/sys/pstat subdirectory
4653 doesn't exist.
4654
4655 Lsof can be forced to use the /dev/kmem sources by setting
4656 "/dev/kmem" in the HPUX_BASE environment variable. Consult
4657 the Configure shell script and 00XPORTING for more information.
4658
46599.2.1 Why doesn't a /dev/kmem-based HP-UX lsof compilation use -O?
4660
4661 If you only have the standard (bundled) HP-UX C compiler
4662 and haven't purchased and installed the optional one, then
4663 you can't use cc's -O option. The HP-UX cc(1) man page
4664 says this:
4665
4666 "Options
4667 Note that in the following list, the cc and c89 options
4668 -A , -G , -g , -O , -p , -v , -y , +z , and +Z are
4669 not supported by the C compiler provided as part of
4670 the standard HP-UX operating system. They are supported
4671 by the C compiler sold as an optional separate product."
4672
4673 Lsof's Configure script tries to detect what C compiler
4674 product you have installed by examining your compiler. If
4675 that examination reveals a standard (bundled) compiler,
4676 lsof avoids using -O.
4677
4678 If the Configure compiler test fails, the C compiler will
4679 complain that it doesn't support -O. You can suppress that
4680 complaint with this make invocation:
4681
4682 $ make DEBUG=""
4683
46849.2.2 Why doesn't the /dev/kmem-based CCITT support work under 10.x?
4685
4686 Pasi Kaara, who originally provided the HP-UX CCITT support,
4687 reports that it no longer works under HP-UX 10.x.
4688 Consequently, at lsof revision 4.02 it has been disabled.
4689
46909.2.3 Why can't /dev/kmem-based lsof be compiled with `cc -Aa` or
4691 `gcc -ansi` under HP-UX 10.x?
4692
4693 Some HP-UX 10.x header files, needed by lsof, can't be
4694 compiled properly in ANSI_C mode; structure element definition
4695 and alignment problems result. The f_offset member of the
4696 file structure, for example, is incorrect.
4697
4698 This ANSI-C obstacle extends to using the -Aa option of
4699 the HP C compiler and the -ansi option of gcc.
4700
47019.2.4 Why does /dev/kmem-based lsof complain about no C compiler?
4702
4703 Lsof's Configure script looks in /bin and /usr/ccs/bin for
4704 an HP C compiler, because it needs to know if the compiler
4705 is the standard (bundled) one or the optional separate
4706 product. If it finds no compiler in either place, Configure
4707 quits after complaining:
4708
4709 No executable cc in /bin or /usr/ccs/bin
4710
4711 If you don't have a C compiler in either of these standard
4712 places, you should consider installing it. If you have
4713 gcc installed, you can use it by declaring the ``hpuxgcc''
4714 abbreviation to lsof's Configure script.
4715
4716 If you have a C compiler in a non-standard location, you
4717 can use the HPUX_CCDIR[12] environment variables to name
4718 the path to it. Consult the 00XCONFIG file of the lsof
4719 distribution for more information.
4720
47219.2.5 Why does Configure complain about q4 for /dev/kmem-based lsof
4722 for HP-UX 11?
4723
4724 When you run Configure on an HP-UX 11 system, it may complain:
4725
4726 !!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!
4727 Configure can't use /usr/contrib/bin/q4 to examine the ipis_s
4728 structure. You must do that yourself, report the result in
4729 the HPUX_IPC_S_PATCH environment variable, then repeat the
4730 Configure step. Consult the Configure script's use of
4731 /usr/contrib/bin/q4 and the 00XCONFIG file for information
4732 on ipis_s testing and the setting of HPUX_IPC_S_PATCH.
4733 !!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!
4734
4735 This message states that Configure cannot use q4 from
4736 /usr/contrib/bin to examine the kernel's boot image for
4737 the ipis_s structure. Maybe q4 hasn't been installed, or
4738 perhaps Configure can't execute it.
4739
4740 Lsof needs to gather information about ipis_s to determine
4741 if the ipis_s structure is defined in the kernel boot image,
4742 if the ipis_s structure of the kernel boot image has an
4743 ipis_msgsqueued member, and if the ipc_s structure of the
4744 kernel boot image uses has an ipc_ipis member.
4745
4746 The ipis_s structure isn't described in any header file
4747 HP-UX releases with HP-UX 11. It appears in the private
4748 lsof header file .../dialects/hpux/kmem/hpux11/ipc_s.h.
4749 Lsof gets local and remote connection addresses (IP and
4750 port numbers) from ipc_s, so an incorrect ipc_s definition
4751 may cause incorrect reporting of TCP/IP connection addresses.
4752 It definitely will cause incorrect reporting on 32 bit
4753 kernels. In any case lsof should be compiled with a correct
4754 ipc_s definition no matter the kernel bit size, so the
4755 Configure script always tests for it when the HP-UX version
4756 is 11.
4757
4758 For lsof's Configure script to gather the necessary ipis_s
4759 information q4 needs to be installed in /usr/contrib/bin
4760 and the kernel boot image, /stand/vmunix, needs to have
4761 been processed with pxdb. If either is untrue, lsof issues
4762 the above error message, perhaps preceded by q4 messages.
4763 (Note: lsof's use of q4 may also fail if q4 can't execute
4764 nm -- e.g., it can't find /usr/bin/nm, or there is a
4765 conflicting, private version of nm earlier in the path.)
4766
4767 If /stand/vmunix hasn't been processed by pxdb, the q4
4768 messages will include:
4769
4770 q4: (error) vmunix not pxdb'd
4771 or
4772 q4: (warning) /stand/vmunix has not been processed by pxdb.
4773
4774 It's possible to make a suitable private copy of /stand/vmunix
4775 for configuring lsof. That requires /opt/langtools/bin/pxdb
4776 or the q4 version of pxdb from /usr/contrib/bin/q4pxdb.
4777 The path to the result is supplied to the lsof Configure
4778 script in the HPUX_BOOTFILE environment variable. Configure
4779 still requires /usr/contrib/bin/q4.
4780
4781 The following sample Bourne shell commands make a private
4782 copy of /stand/vmunix in /tmp, process it with pxdb or
4783 q4pxdb, and supply its path to lsof's Configure script in
4784 HPUX_BOOTFILE.
4785
4786 $ cp /stand/vmunix /tmp/vmunix.lsof
4787
4788 $ /opt/langtools/bin/pxdb /tmp/vmunix.lsof
4789 or
4790 $ /usr/contrib/bin/q4pxdb /tmp/vmunix.lsof
4791
4792 ... pxdb messages ...
4793 $ HPUX_BOOTFILE=/tmp/vmunix.lsof Configure -n hpux
4794
4795 It may also be necessary to use q4 outside the lsof Configure
4796 script. In that case q4 can be to determine the state of
4797 ipis_s and ipc_s with these q4 commands:
4798
4799 $ /usr/contrib/bin/q4 /stand/vmunix
4800 ...
4801 q4> fields -c struct ipc_s
4802 ...
4803 q4> fields -c struct ipis_s
4804
4805 Look in the q4 output for the ipc_ipis member of the ipc_s
4806 structure, and look in the q4 output for the ipis_s structure
4807 for the ipis_msgsqueued member. If ipc_s has ipc_ipis but
4808 ipis_s lacks ipis_msgsqueued, set HPUX_IPC_S_PATCH environment
4809 variable to "1". If ipc_s has ipc_ipis and ipis_s has
4810 ipis_msgsqueued, set HPUX_IPC_S_PATCH to "2" -- e.g.,
4811
4812 $ HPUX_IPC_S_PATCH=1 Configure -n hpux
4813 or
4814 $ HPUX_IPC_S_PATCH=2 Configure -n hpux
4815
4816 If ipc_s has no ipc_ipis member, set HPUX_IPC_S_PATCH to
4817 "N" -- e.g., use this Configure step:
4818
4819 $ HPUX_IPC_S_PATCH=N Configure -n hpux
4820
48219.2.6 When compiling /dev/kmem-based lsof for HP-UX 11 what do the
4822 "aCC runtime: ERROR..." messages mean?
4823
4824 When the lsof Makefile asks the HP-UX unbundled compiler
4825 to load lsof, it may complain:
4826
4827 /bin/cc -o lsof -DHPUXV=1100 -DHASVXFS -DHPUXKERNBITS=64 \
4828 -I/home/abe/src/lsof4/dialects/hpux/kmem/hpux11 +DD64 \
4829 -DHAS_IPC_S_PATCH=2 -I/home/abe/src/lsof4/dialects/hpux/kmem \
4830 -DLSOF_VSTR=\"B.11.00\" -g dfile.o dmnt.o dnode.o dnode1.o \
4831 dnode2.o dproc.o dsock.o dstore.o arg.o main.o misc.o \
4832 node.o print.o proc.o store.o usage.o -L./lib -llsof -lelf \
4833 -lnsl
4834 aCC runtime: ERROR: Unexpected use of shared libraries
4835 aCC runtime: ERROR: Read aCC manpage, +A option
4836 /usr/lib/nls/loc/locales.1//is_IS.iso88591
4837
4838 This is a bug in the HP-UX national language support.
4839 (Notice the last message with "locales" in it?) Complain
4840 to HP -- then use this work-around before executing make:
4841
4842 $ unset LANG
4843 $ make
4844
48459.2.7 Why doesn't /dev/kmem-based lsof for HP-UX 11 report VxFS file
4846 link counts, node numbers, and sizes correctly?
4847
4848 This is usually the result of running an lsof binary whose
4849 revision number is less than 4.57 on a system that has
4850 OnlineJFS support installed. It can also happen with lsof
4851 4.57 binaries when the OnlineJFS support with which they
4852 were built doesn't match the OnlineJFS status of the system
4853 on which they are run.
4854
4855 The OnlineJFS status of lsof 4.57 and higher binaries can
4856 be determined by running:
4857
4858 $ lsof -v 2>&1 | grep HASONLINEJFS
4859
4860 If that shell pipe produces output, lsof was compiled with
4861 OnlineJFS support enabled; no output, disabled.
4862
4863 If OnlineJFS is installed on an HP-UX 11 system the
4864 /sbin/fs/vxfs/subtype executable exists and outputs "vxfs3.3"
4865 when run.
4866
4867 The problem occurs because the optional OnlineJFS support
4868 installation doesn't update <sys/fs/vx_inode.h>. Consequently
4869 lsof can be compiled with an incorrect definition of the
4870 vx_inode structure and look for for link counts, node
4871 numbers, and sizes in the wrong places in the structure.
4872
4873 The current response I have gotten from HP is that no
4874 <sys/fs/vx_inode.h> update will be provided for OnlineJFS.
4875
4876 I've addressed this problem temporarily with a work-around
4877 (hack) in lsof revision 4.57.
4878
48799.2.8 Why can't /dev/kmem-based lsof be built with gcc for 64 bit
4880 HP-UX 11?
4881
4882 When Configure is given the "hpuxgcc" abbreviation, the
4883 HP-UX version is 11, and the kernel bit size is 64, the
4884 lsof Configure script may abort with the messages:
4885
4886 !!!!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!!!!
4887
4888 APPARENTLY GCC CANNOT BUILD 64 BIT EXECUTABLES.
4889 A COMPILER MUST BE USED THAT CAN. SEE 00FAQ
4890 FOR MORE INFORMATION.
4891
4892 (This is the "more information" in 00FAQ.)
4893
4894 This means the Configure script compiled a test program
4895 with gcc the result wasn't an ELF-64 binary. Lsof tries
4896 two gcc modes, one with no options and another with the
4897 -mlp64 option, before it concludes gcc can't be used.
4898
4899 See the "How can I acquire a gcc for building lsof for 64
4900 bit HP-UX 11?" answer for information on where you might
4901 be able to get a gcc for HP-UX 11 that can produce ELF-64
4902 executables.
4903
49049.2.8.1 How can I acquire a gcc for building lsof for 64 bit HP-UX 11?
4905
4906 Check this HP URL:
4907
4908 http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,547,00.html
4909
4910 (That's one very long link; be careful you cut 'n paste it
4911 all.)
4912
4913 In November 2001 that URL led to a web page whose title
4914 was "gcc for hp-ux 11." The page offered a link for
4915 downloading a 64 bit gcc 3.0 compiler for HP-UX 11.0 and
4916 11i. Rich Rauenzahn of HP installed that compiler on an
4917 HP test system he allows me to use and I successfully built
4918 a 64 bit lsof with it.
4919
4920 The HP package may install the 64 bit capable gcc in
4921 /usr/local/pa20_64/bin/gcc, so you may have to adjust your
4922 path or set the LSOF_CC environment variable to compensate.
4923
49249.2.9 Why does /dev/kmem-based lsof for HP-UX 11 report "unknown file
4925 system type" for some open files?
4926
4927 The lsof binary being used probably doesn't have support for
4928 the VxFS file system.
4929
4930 To confirm that, check `lsof -v` output for "-DHASVXFS". If
4931 it's not present, lsof doesn't have VxFS support.
4932
4933 You also need to establish that lsof really is complaining
4934 about VxFS files by checking the kernel boot file for the
4935 symbol associated with the hexadecimal address reported in the
4936 "unknown file system type" message -- e.g., "v_op: 0x8711c8."
4937 Use nm(1) to do that:
4938
4939 $ nm -x /stand/vmunix | grep 8711c8
4940
4941 If nm reports the symbol associated with the address is
4942 vx_vnodeops, then lsof is complaining about an open VxFS file.
4943
4944 The solution in that case is to build lsof yourself (The
4945 bundled C compiler will do it.), making sure that lsof's
4946 Configure script detects the presence of VxFS. Configure does
4947 that by finding these two header files:
4948
4949 /usr/include/sys/fs/vx_hpux.h
4950 /usr/include/sys/fs/vx_inode.h
4951
4952 If the system where you are building lsof doesn't have those
4953 header files, but does have VxFS, you might be able to install
4954 the header files by installing the HP JournalFS package from
4955 the CoreOS CD -- in particular the file set JournalFS.VXFS-PRG
4956 and its associated patch, PHKL_18543. (My thanks to Steve
4957 Bonds for that information.)
4958
4959 Finally, if you find that lsof isn't complaining about VxFS
4960 when it complains about an unknown file system type, send
4961 e-mail to me <abe@purdue.edu> for further assistance. Make
4962 sure "lsof" appears in the "Subject:" line so my e-mail filter
4963 won't classify your letter as Spam.
4964
49659.2.10 Why does the ANSI-C compiler complain about comments in HP-UX
4966 11 header files?
4967
4968 When compiling lsof on HP-UX 11, the HP ANSI-C compiler's
4969 pre-processor, cpp, may complain about comments in HP-UX header
4970 files -- e.g.,
4971
4972 cpp: "/usr/include/sys/cdfs.h", line 232: warning 2028:
4973 Found comment inside comment started on line 232.
4974 cpp: "/usr/include/sys/cdnode.h", line 196: warning 2028:
4975 Found comment inside comment started on line 196.
4976 cpp: "/usr/include/nfs/snode.h", line 30: warning 2028:
4977 Found comment inside comment started on line 30
4978
4979 This is not a problem with lsof. It is a problem with the
4980 HP-UX header files; they have non-compliant ANSI-C comment
4981 sequences in them -- e.g.,
4982
4983 <sys/cdfs.h>: 232
4984 /* struct cdfs *cdfs_link; /* linked list of file systems */
4985
4986 The initial "/*" is not terminated by an ending "*/" before the
4987 appearance of a second "/*".
4988
49899.2.11 Why does dnode1.c cause the HP-UX 11 compiler to complain that
4990 <sys/fs/vx_inode.h> is missing or incorrect?
4991
4992 If CFLAGS in the lsof Makefile for an HP-UX 11 compilation
4993 includes HASONLINEJFS, indicating the system has OnlineJFS
4994 support, lsof needs the <sys/fs/vx_inode.h> header file.
4995 Sometimes it is missing from /usr/include/sys/fs.
4996
4997 <sys/fs/vx_inode.h> is a header file that must be obtained from
4998 Veritas. If that proves impossible, please contact me via
4999 e-mail at <abe@purdue.edu>. Make sure "lsof" appears in the
5000 "Subject:" line so my e-mail filter won't classify your letter
5001 as Spam.
5002
5003
50049.3 PSTAT-based HP-UX lsof Questions
5005
5006 The sources for PSTAT-based lsof for HP-UX may be found in
5007 lsof_<revision>/dialects/hpux/pstat.
5008
5009 Lsof's Configure shell script decides to use these sources
5010 when it finds that the /usr/include/sys/pstat subdirectory
5011 exists.
5012
5013 Lsof can be forced to use the PSTAT-based sources by setting
5014 "pstat" in the HPUX_BASE environment variable. Consult
5015 the Configure shell script and 00XPORTING for more information.
5016
50179.3.1 Why does PSTAT-based lsof complain about pst_static and
5018 other PSTAT structures?
5019
5020 When lsof starts it may issue one of these fatal error
5021 messages:
5022
5023 lsof: FATAL: can't determine PSTAT static size
5024 lsof: FATAL: can't read <n> bytes of pst_static
5025 lsof: FATAL: pst_static doesn't contain <name>_size
5026 lsof: FATAL: <name>_size should be <n>
5027
5028 These messages indicate that lsof's tests for the proper
5029 level of PSTAT support have failed. The structure names,
5030 given in <name>, and sizes, given in <n>, identify the
5031 support deficiency more precisely.
5032
5033 You may need to upgrade the PSTAT support in your kernel
5034 to be able to use PSTAT-based lsof.
5035
50369.3.2 Why does PSTAT-based lsof complain it can't read pst_*
5037 structures?
5038
5039 Lsof may put messages like the following in the NAME
5040 column of its output.
5041
5042 can't read cwd pst_filedetails: Permission denied
5043 can't read mem pst_filedetails: Permission denied
5044 can't read rtd pst_filedetails: Permission denied
5045 can't read txt pst_filedetails: Permission denied
5046 can't read pst_filedetails: Permission denied
5047 can't read 3 stream structures: Permission denied
5048 can't read pst_socket: Permission denied
5049
5050 These messages indicate that the lsof binary lacks the
5051 authority to read the name structures for processes other
5052 than ones belonging to the UID under which lsof is running.
5053 Authority to read the structures of other processes is
5054 limited to root processes -- i.e., lsof must have setuid-root
5055 permission if it is to list open files for arbitrary
5056 processes.
5057
5058 If you want to eliminate these errors, you must run lsof
5059 as root or install it with setuid-root permission.
5060
50619.3.3 Why does PSTAT-based lsof rebuild the device cache file
5062 after each reboot?
5063
5064 After each HP-UX rebuild, the first time a user runs lsof it
5065 will report:
5066
5067 lsof: WARNING: device cache mismatch: /dev/tun...
5068 lsof: WARNING: created device cache file: /<user_path>
5069
5070 This happens because the device numbers on /dev/tun* device
5071 nodes are recalculated at each reboot. When lsof detects
5072 a change in the device number of a /dev/tun* file, it rebuilds
5073 its local device cache file.
5074
50759.3.4 Why doesn't PSTAT-based lsof report TCP addresses for
5076 telnetd's open socket files?
5077
5078 When lsof can't report TCP addresses for telnetd's open
5079 socket files it is because an unpatched PSTAT kernel
5080 interface doesn't report the addresses to lsof.
5081
5082 This has been addressed in PSTAT kernel patch PHKL_24047.
5083 It is available from the HP IT Resource Center at:
5084
5085 http://itrc.hp.com
5086
5087 In the page's "maintenance / support" box select the
5088 "individual patches" link. Once at its page, select the
5089 "hp-ux" link. On that page select the "Series 800" or
5090 "Series 700" radio button and select "11.11" from the
5091 pull-down list to the right of the button. Under "search
5092 or browse the path list" select "Search by Patch IDs" from
5093 the pull down list, enter PHKL_24047 in the following text
5094 box, and select search. That should lead to information
5095 about PHKL_24047 and a link for downloading it. (You may
5096 have to log in first and you may have to create a login
5097 identity by registering before you can log in.)
5098
5099 Some time in March 2006 the PHKL_24047 patch was "lost"
5100 by the HP-UX networking lab. It has been "found" again
5101 in August 2006 and will be re-released as a GRO patch
5102 "some time." I don't yet know when that will be. You
5103 must contact HP to learn about the availability of the
5104 GRO patch.
5105
51069.3.5 Why does PSTAT-based lsof cause an HP-UX 11.11 kernel panic?
5107
5108 When PSTAT-based lsof runs on some HP-UX 11.11 kernels,
5109 the kernel may panic. Symptoms include:
5110
5111 Console message:
5112 0xFBE000301100EF00 00000000 0000EF00 -
5113 type 31 = legacy PA HEX chassis-code
5114
5115 /var/adm/syslog:
5116 ... vmunix: Trap Type 15 (Data page fault)
5117 ... vmunix: Instruction Address (pcsq.pcoq) = 0x...
5118
5119 The panic is caused by a bug in the way PSTAT's pstat_getstream()
5120 function obtains module names from streams managed by the
5121 otsam stream driver (part of OSI Transport Services). Lsof
5122 calls pstat_getstream() when it encounters an open otsam
5123 stream file. An HP-UX 11.11 system uses otsam if otsam
5124 appears in /stand/system.
5125
5126 HP-UX 11.11 patch PHKL_24507 (available some time after
5127 July 15, 2001) fixes the pstat_getstream() bug. See the
5128 information in the answer to the "Why doesn't PSTAT-based
5129 lsof report TCP addresses for telnetd's open socket files?"
5130 question for information on how to obtain the patch.
5131
51329.3.6 Why doesn't PSTAT-based lsof report a CWD that is on a loopback
5133 (LOFS) file system?
5134
5135 When PSTAT-based lsof reports on processes whose current
5136 working directory (CWD) is on a loopback file system, lsof
5137 can't report the open CWD file. The reason is that the HP-UX
5138 11.11 and above kernel's loopback file system code is not
5139 passing the CWD file ID to the kernel's pstat(2) code. Hence
5140 lsof is given no information on the lofs CWD.
5141
5142 The problem was first reported to me by Ermin Borovac and an
5143 internal bug report was filed with the HP-UX file system group
5144 on October 26, 2004. That report has now been answered by the
5145 patch PHKL_33200 -- s700_800 11.11 lofs cumulative patch. The
5146 HP IT Resource Center (http://itrc.hp.com) is a source for the
5147 patch.
5148
51499.3.7 Why do some swinstall packages for PSTAT-based HP-UX 11.11
5150 packages complain about setgid and setuid bits?
5151
5152 First, let me explain that I do not provide lsof swinstall
5153 packages for lsof. Others provide them and they should be
5154 contacted about problems with their packages.
5155
5156 However, I have become aware of a problem with one package
5157 about which I have some information I can share. The problem
5158 shows up in these swinstall messages:
5159
5160 ERROR: Unknown owner and/or group for file
5161 "/usr/local/bin/lsof". SUID and/or SGID bit was
5162 not set.
5163 ERROR: Failed installing fileset "lsof.lsof-RUN,r=4.73".
5164 Check the above output for details.
5165
5166 The swpackage SUID/SGID functionality was restricted by changes
5167 for POSIX compliance, breaking backward compatibility. The
5168 patch PHCO_27671 allows SUID/SGID for uid/gid of 0 only, as a
5169 compromise between backward compatibility and POSIX conformance.
5170
5171 If the setuid bit is to be set on the executable, the UID and
5172 GID of the executable must be 0 (zero).
5173
51749.3.8 Why won't the bundled C compiler build PSTAT-based lsof for
5175 PA-RISC HP-UX 11.23?
5176
5177 A PA-RISC HP-UX 11.23 bundled C compiler dated May 2005 or
5178 later will not build PSTAT-based lsof. It will deliver error
5179 messages related to the system's <gssapi/gssapi.h> header
5180 file.
5181
5182 There is nothing wrong with that header file or lsof. The
5183 problem is that the bundled C compiler can't cope with the
5184 gssapi.h header file.
5185
5186 The work-around is to use the HP ANSI C compiler. Using gcc
5187 is not a satisfactory work-around. See the answer to the "Why
5188 won't gcc build PSTAT-based lsof for PA-RISC HP-UX 11.23?"
5189 question for more information.
5190
51919.3.9 Why won't gcc build PSTAT-based lsof for PA-RISC HP-UX 11.23?
5192
5193 Gcc will not even compile PSTAT-based lsof revisions below 4.77
5194 for PA-RISC HP-UX 11.23 dated May 2005 or later. It reports
5195 errors in lsof's print.c fill_portmap() function about missing
5196 members of the rpcent structure. That happens because gcc
5197 defines _XOPEN_SOURCE_EXTENDED which disables the definition of
5198 the rpcent structure in <netdb.h>.
5199
5200 Using the HP bundled C compiler is not a viable work-around.
5201 That is explained in the answer to the "Why won't the bundled C
5202 compiler build PSTAT-based lsof for PA-RISC HP-UX 11.23?"
5203
5204 While an lsof revision 4.77 or higher can be compiled with gcc,
5205 the results are unreliable. Lsof will compile, but it
5206 occasionally produces segment faults when it runs. I have not
5207 been able to reproduce the failure reliably or locate a
5208 debugger that will work with the gcc-compiled lsof.
5209
5210 The only reliable work-around is to use the HP ANSI C
5211 compiler.
5212
52139.3.10 Why does PSTAT-based lsof complain, "FATAL: pst_stream_size
5214 should be: 672; is 72" on HP-UX 11.11 and above?
5215
5216 This message indicates a mismatch between the PSTAT header
5217 files used to build lsof (<sys/pstat.h> and those in the
5218 /usr/include/sys/pstat subdirectory), and those that built the
5219 running kernel.
5220
5221 Unfortunately the June 2008 patch set for HP-UX 11.23 creates
5222 this inconsistency, because it does not contain all the patches
5223 needed to match the kernel with the PSTAT header files. Even
5224 more serious is that the missing patches update the kernel's
5225 PSTAT support to provide TCP/UDP endpoint information to lsof
5226 from TCP/TLI streams.
5227
5228 The patch inconsistency comes about because, while the following
5229 patch is installed,
5230
5231 PHKL_36577 1.0 PM-PSTAT section 2 manpage changes
5232
5233 other kernel patches are not.
5234
5235 The PHKL_36577 patch updates the PSTAT header files and manual
5236 pages to match kernel changes that other patches with the
5237 following numbers (or patches that contain or supersede them)
5238 contain:
5239
5240 PHNE_36575 1.0 Cumulative STREAMS Patch
5241 PHNE_37670 1.0 cumulative ARPA Transport patch
5242 PHNE_37851 1.0 NFS cumulative patch
5243
5244 Those patches implement the kernel changes that support the
5245 delivery of information promised in patch PHKL_36577.
5246
5247 The work-around is to install the missing patches.
5248
52499.4 Why won't the HP-UX depot install?
5250
5251 I don't distribute lsof depots, so I can't support them.
5252
5253 From time to time depots prepared by various sites -- e.g.,
5254 usually HP-UX software collection sites -- will contain errors
5255 that cause installation of the depot to fail.
5256
5257 Do not contact me when this happens. Instead, contact the
5258 administrator of the site that prepared the depot.
5259
5260 As should be clear from the bulk of the lsof documentation, I
5261 do not recommend you use pre-built lsof binaries in any form.
5262 Instead, I recommend you obtain the lsof source distribution
5263 and build lsof yourself.
5264
5265
526610.0 Linux
5267
526810.1 What do /dev/kmem-based and /proc-based lsof mean?
5269
5270 At approximately Linux 2.1.72 and exactly at lsof revision
5271 4.23 support for Linux forks. The first fork, containing
5272 the oldest lsof form is based on access to kernel memory
5273 structures, and is called /dev/kmem-based lsof. A
5274 /dev/kmem-based lsof is heavily intertwined with the Linux
5275 kernel version, its header files, and its system map file.
5276 Typically a /dev/kmem-based lsof needs only setgid permission
5277 to local all open file information.
5278
5279 After approximately Linux 2.1.72 and at revision 4.23 lsof
5280 obtains all its information from the /proc file system.
5281 That lsof is called the /proc-based lsof. A /proc-based
5282 lsof does not read kernel memory, needs neither kernel
5283 header files nor the system map file, and is less likely
5284 to be affected by Linux kernel changes. However, it does
5285 require setuid-root permission to list all open files, and
5286 it can't report file offsets (positions).
5287
5288 After revision 4.52 the /dev/kmem-based Linux sources for
5289 lsof are no longer distributed. Information about them
5290 may be found in the 00INDEX and README files at:
5291
5292 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/OLD/src
5293
529410.2 /proc-based Linux lsof Questions
5295
529610.2.1 Why doesn't /proc-based lsof report file offsets (positions)?
5297
5298 /proc-based lsof revisions 4.79 and above can only report file
5299 offsets (positions) for the files of Linux kernels 2.6.22 and
5300 above.
5301
5302 During its initialization /proc-based lsof tests to see if
5303 offset information can be obtained. If it cannot, lsof
5304 disables offset reporting. If the -o option was selected, lsof
5305 also issues this warning:
5306
5307 lsof: WARNING: can't report offset; disregarding -o.
5308
5309
531010.2.2 Why does /proc-based lsof report "can't identify protocol" for
5311 some socket files?
5312
5313 /proc-based lsof may report:
5314
5315 COMMAND PID ... TYPE ... NODE NAME
5316 pump 226 ... sock ... 309 can't identify protocol
5317
5318 This means that it can't identify the protocol (i.e., the
5319 AF_* designation) being used by the open socket file. Lsof
5320 identifies protocols by matching the node number associated
5321 with the /proc/<PID>/fd entry to the node numbers found in
5322 selected files of the /proc/net sub-directory. Currently
5323 /proc-based lsof examines these protocol files:
5324
5325 /proc/net/ax25 (untested)
5326 /proc/net/ipx (needs kernel patch)
5327 /proc/net/raw
5328 /proc/net/raw6
5329 /proc/net/tcp
5330 /proc/net/tcp6
5331 /proc/net/udp
5332 /proc/net/udp6
5333 /proc/net/unix
5334
5335 If /proc-based lsof says it can't identify the protocol
5336 for an open socket file, you may be able to identify the
5337 protocol yourself by using grep to look for the specific
5338 node number in the files of /proc/net -- e.g.,
5339
5340 $ grep <node_number> /proc/net/*
5341
5342 You may not be able to find the desired node number, because
5343 not all kernel protocol modules fully support /proc/net
5344 information.
5345
5346 If you find a matching node number in a /proc/net file that is
5347 not currently being processed by lsof, contact me via e-mail at
5348 <abe@purdue.edu>. I'll discuss adding support to /proc-based
5349 lsof for the protocol of the /proc/net file with you. Make
5350 sure "lsof" appears in the "Subject:" line so my e-mail filter
5351 won't classify your letter as Spam.
5352
5353 The code that matches node numbers of open IPX protocol
5354 socket files to those in /proc/net/ipx requires Jonathan
5355 Sergent's Linux 2.1.79 patch to /usr/src/linux/net/ipx/af_ipx.c.
5356 The patch, suitable for input to Larry Wall's patch program,
5357 may be found in the lsof distribution file:
5358
5359 .../dialects/linux/proc/patches/net_ipx_af_ipx.c.patch
5360
536110.2.3 Why does /proc-based lsof warn about unsupported formats?
5362
5363 Lsof may issue the following warning:
5364
5365 lsof: WARNING: unsupported format: /proc/net/<file>
5366
5367 if the header line of the indicated <file> in /proc/net --
5368 ax25, ipx, raw, tcp, udp, or unix -- doesn't match what
5369 lsof expects to find.
5370
5371 When the header line of a /proc/net file isn't what lsof
5372 expects, lsof probably can't parse the rest of the file
5373 correctly and doesn't try. As a result, lsof can't report
5374 any NAME column information (e.g., local and remote addresses)
5375 for socket files bound to the indicated network protocol.
5376
5377 If you get this warning, please send me e-mail at <abe@purdue.edu>.
5378 Include the contents of the file lsof claims has an unsupported
5379 format. Make sure "lsof" appears in the "Subject:" line so my
5380 e-mail filter won't classify your letter as Spam.
5381
538210.2.4 Why does /proc-based lsof report "(deleted)" after a path name?
5383
5384 The "(deleted)" notation following a path name in /proc-based
5385 lsof's NAME column comes from the /proc/<PID>/fd/<FD> entry
5386 for the open file. It's the Linux kernel's way of indicating
5387 the file is open but has been unlinked (rm'd).
5388
538910.2.5 Why doesn't /proc-based lsof report full open file information
5390 for all processes?
5391
5392 /proc-based lsof can only report on processes whose /proc
5393 files it has permission to read. /proc normally grants
5394 permission to read all its files only to root or to the
5395 owning user ID.
5396
5397 Without permission to read most /proc files, lsof can only
5398 report full information for processes belonging to the user
5399 who is running lsof. /proc-based lsof may be able to report
5400 some information for all processes, depending on the
5401 permissions of their associated /proc files, but usually
5402 /proc-based lsof won't be able to access the files in
5403 /proc/<PID>/fd/ that describe regular open files.
5404
5405 If you want /proc-based lsof to report on all processes, you
5406 must install it with setuid-root permission.
5407
540810.2.6 Why won't Customize offer to change HASDCACHE or WARNDEVACCESS
5409 for /proc-based lsof?
5410
5411 /proc-based lsof doesn't read device information from /dev
5412 or the device cache file, so it makes no sense to change
5413 the state of device cache processing or /dev node accessibility
5414 warnings.
5415
541610.2.7 /proc-based lsof Linux NFS questions
5417
541810.2.7.1 Why can't lsof find files on an accessible NFS file system?
5419
5420 On occasion lsof may be unable to identify that an open
5421 file is on an NFS file system. This is most likely the
5422 result of a bug in the way the Linux kernel supplies
5423 information to the reader of /proc/mounts (lsof) -- sometimes
5424 that pseudo-file is truncated by the kernel.
5425
5426 One way to see if this is the case is to search for the
5427 NFS file system in /proc/mounts -- e.g.,
5428
5429 $ grep <NFS_file_system_mount_point> /proc/mounts
5430
5431 If you get no output or the third word of the output isn't
5432 "nfs", then lsof won't consider the file system an NFS file
5433 system.
5434
5435 A second test is to look at the end of /proc/mounts --
5436 e.g.,
5437
5438 $ tail /proc/mounts
5439
5440 If tail reports "# truncated" then /proc/mounts is incomplete
5441 because of a Linux kernel bug. The bug is documented at:
5442
5443 http://www.xss.co.at/sysinfo/mounts.html
5444
5445 The bug is fixed in Linux kernel 2.4.18, and possibly in
5446 some earlier Linux kernel versions.
5447
544810.2.7.2 Why can't lsof find files on an inaccessible NFS file system?
5449
5450 If lsof issues this message about a Linux file system,
5451 mounted from an NFS server:
5452
5453 lsof: WARNING: can't stat() nfs file system /xxx/yyy
5454
5455 Then lsof won't be able to find any open files on the file
5456 system.
5457
5458 That's because of an inadequacy in the Linux /proc file
5459 system. Its /proc/mounts file doesn't give the device
5460 doublet (major and minor numbers) of the file system as do
5461 many UNIX systems (e.g., Solaris). The only way lsof can
5462 get the device doublet for a Linux file system is to call
5463 stat(2) on the file system path, which fails if the NFS
5464 server isn't accessible.
5465
5466 When lsof doesn't know the device doublet of a file system,
5467 it can't find open files on the inaccessible file system,
5468 because it can't match the doublets of open files to the
5469 doublet of the inaccessible file system.
5470
5471 This topic is covered extensively in lsof(8) it its ALTERNATE
5472 DEVICE NUMBERS and BLOCKS AND TIMEOUTS sections.
5473
547410.2.8 Why doesn't /proc-based Linux lsof report socket options and
5475 values, socket state flags, and TCP options and values?
5476
5477 The Linux /proc file system doesn't report socket options
5478 and values, socket states, and TCP options and values to
5479 lsof.
5480
548110.2.9 Does /proc-based Linux lsof use a device cache?
5482
5483 No. The Linux /proc/<PID>/fd/* entries provide device names to
5484 lsof via readlink(2). It is not necessary to enable device
5485 cache processing for /proc-based Linux lsof via the Customize
5486 script or modifications to the Linux machine.h header file.
5487
548810.2.10 Why doesn't /proc-based Linux lsof report any or all file structure
5489 values for its +fcfgGn option?
5490
5491 /proc-based lsof revisions 4.79 and above can only report some
5492 file structure values for Linux kernels below 2.6.22.
5493
5494 When running on Linux kernels at 2.6.22 and above lsof 4.79 can
5495 report some file flag values -- i.e., in response to the +fg or
5496 +fG options. The flag values are obtained from the
5497 /proc/<PID>/fdinfo/ files introduced at Linux kernel 2.6.22.
5498
5499 /proc-based Linux lsof tests its availability to obtain file
5500 flag values at initialization. If values are not available,
5501 lsof disables file flag reporting. If the flags were requested
5502 with +fg or +fG, lsof displays this warning:
5503
5504 lsof: WARNING: can't report file flags; disregarding +f.
5505
5506 As a special note, when Linux lsof can report flag bits, it
5507 will not report 'R' for a read-only file. There is no
5508 read-only flag bit O_* symbol in <fcntl.h> (or <bits/fcntl.h>)
5509 and lsof reports only bits that are set. The absence of O_RDWR
5510 and O_WRONLY flag bits implies the file is read-only.
5511
551210.3 Special Linux file types
5513
551410.3.1 Why is ``DEL'' reported as a Linux file type?
5515
5516 Lsof usually reports entries from the Linux /proc/<PID>/maps
5517 file with ``mem'' in the TYPE column. However, when lsof can't
5518 stat(2) a path in the process' ``maps'' file and the ``maps''
5519 file entry contains ``(deleted)'', indicating the file was
5520 deleted after it had been opened, lsof reports the file type as
5521 ``DEL''.
5522
552310.3.2 Why is ``unknown'' reported as a Linux file type?
5524
5525 Lsof may report a Linux file's type as ``unknown'' in the TYPE
5526 column when lsof can't obtain complete stat(2) results for the
5527 file.
5528
5529 Usually the NAME column will contain a ``(stat: xxx)'' error
5530 message, but that could have been suppressed with the lsof
5531 ``-w'' option.
5532
553310.4 Linux ``mem'' Entry Problems
5534
553510.4.1 What do ``path dev=xxx'' and ``path inode=yyy'' mean in the
5536 NAME column of Linux ``mem'' file types?
5537
5538 When the device or inode number in the process' ``maps'' file
5539 entry doesn't match the stat(2) results from the file path,
5540 lsof reports the inconsistent information from the stat(2) of
5541 the path parenthetically after the path in the NAME column
5542 in one of these forms:
5543
5544 (path dev=xxx) only the device number,
5545 ``xxx'', from a stat(2) of the
5546 ``maps'' file entry path
5547 differs from the ``maps'' file
5548 entry value reported in the
5549 DEVICE column.
5550
5551 (path inode=yyy) only the inode number,
5552 ``yyy'', from a stat(2) of the
5553 ``maps'' file entry path
5554 differs from the ``maps'' file
5555 entry value reported in the
5556 NODE column.
5557
5558 (path dev=xxx inode=yyy) Both device and inode numbers
5559 differ.
5560
5561 Lsof reports the ``maps'' file device number in the DEVICE
5562 column and the inode number in the NODE column.
5563
5564 When device and inode mismatches occur, lsof suppresses the
5565 reporting of link count and size. See the answer to the "Why
5566 is neither link count nor size reported for some Linux ``DEL''
5567 and ``mem'' file types?" question for more information.
5568
5569 Device and inode inconsistencies can occur when a file at a
5570 ``maps'' path is replaced after the process has started, or
5571 when a different file system with similar path names is mounted
5572 on top of the original file system.
5573
5574 The device inconsistency parenthetical messages can be
5575 suppressed with lsof's ``-w'' option.
5576
557710.4.2 Why is neither link count nor size reported for some Linux
5578 ``DEL'' and ``mem'' file types?
5579
5580 Link count and size are not reported for some entries from the
5581 process' ``maps'' file because a stat(2) of the entry file path
5582 failed or stat(2) delivered device or inode numbers that don't
5583 match the ones in the ``maps'' entry.
5584
5585 When the stat(2) device or inode numbers don't match those in
5586 the ``maps'' file entry, it is likely that the stat(2) results
5587 don't apply to the file that was originally mapped by the
5588 process and whose path appears in the ``maps'' file entry, so
5589 lsof tries to avoid reporting possibly incorrect information.
5590
5591 See the answer to the "What do ``path dev=xxx'' and ``path
5592 inode=yyy'' mean in the NAME column of Linux ``mem'' file
5593 types?" for more information on how mismatched stat(2) device
5594 and inode numbers are reported.
5595
559610.5 Special Linux NAME column messages
5597
559810.5.1 What does ``(stat: xxx)'' mean in the NAME column of Linux
5599 files?
5600
5601 When lsof tried to stat(2) the path in the NAME column, the
5602 stat(2) system call failed and produced an error message of
5603 ``xxx''.
5604
5605 This situation usually occurs if the lsof process lacks
5606 permission to stat(2) the path -- e.g., the lsof executable
5607 lacks root permission, or lsof is attempting to stat(2) a path
5608 on an NFS device mounted with the root_squash option.
5609
5610 The message can be suppressed with lsof's ``-w'' option.
5611
561210.5.2 What does ``(readlink: xxx)'' mean in the NAME column of
5613 Linux files?
5614
5615 When lsof tried to convert the /proc/<PID>/fd path, reported in
5616 the NAME column, to its full and more meaningful path, the
5617 readlink(2) system call used to do the conversion failed. The
5618 readlink(2) failure message is ``xxx''.
5619
5620 This situation usually occurs if the lsof process lacks
5621 permission to readlink(2) some part of the path -- e.g., the
5622 lsof executable lacks root permission, or lsof is attempting to
5623 stat(2) a path on an NFS device mounted with the root_squash
5624 option.
5625
5626 The message can be suppressed with lsof's ``-w'' option.
5627
562810.6 Why is ``NOFD'' reported as a Linux file type?
5629
5630 When lsof lacks permission to use opendir() on the fd/
5631 subdirectory of a process' /proc/<PID> directory, it reports a
5632 single file of the type ``NOFD'' (for no file descriptors).
5633
5634 Lsof reports the the /proc/<PID>/path in the NAME column,
5635 followed by "(opendir: xxx)", where ``xxx'' is the error
5636 message returned by opendir().
5637
5638 The ``NOFD'' entry can be suppressed with lsof's ``-w'' option.
5639
564010.7 Why does Linux lsof report a NAME column value that begins with
5641 ``/proc''?
5642
5643 When lsof has problems processing a ``/proc/<PID>'' entry --
5644 e.g., it can't convert the entry to a full and more meaningful
5645 path name, or it can't access the /proc/<PID>/fd subdirectory
5646 with opendir() -- it will report the /proc/<PID> path in the
5647 NAME column.
5648
564910.8 Linux /proc/net/tcp* and /proc/net/udp* issues
5650
565110.8.1 Why use the Linux -X option?
5652
5653 If you're not interested in TCP/IP socket information for a
5654 particular use of lsof, adding the -X option will make lsof run
5655 more quickly, because -X inhibits the reading of the
5656 /proc/net/tcp* and /proc/net/udp* files. For example, you may
5657 only be interested in knowing what process has a particular
5658 file open.
5659
5660 When the Linux system has a large number of open TCP/IP socket
5661 files, the time savings provided by -X can be significant.
5662
566310.8.2 Why does lsof say ``-i is useless when -X is specified''?
5664
5665 If -X is specified, lsof can't report much information on open
5666 TCP/IP socket files. However, lsof's -i option requests that
5667 information. Hence, the two options conflict and can't be used
5668 together.
5669
567010.8.3 Why does lsof say ``can't identify protocol (-X specified)''?
5671
5672 If the Linux lsof -X option is specified and an open socket
5673 file can't be identified without accessing the /proc/net/tcp*
5674 and /proc/net/udp* files, lsof will report that it can't
5675 identify the socket's protocol and that the failure may be
5676 caused by the -X specification
5677
5678
567911.0 NetBSD Problems
5680
568111.1 Why doesn't lsof report on open kernfs files?
5682
5683 Lsof doesn't report on open NetBSD kernfs files because the
5684 structures lsof needs aren't defined in the kernfs.h header
5685 file in /sys/misc/kernfs.
5686
568711.2 Why doesn't lsof report on open files on: file descriptor
5688 file systems; /proc file systems; 9660 (CD-ROM) file systems;
5689 MS-DOS (floppy disk) file systems; or kernel file systems?
5690
5691 Lsof is not able to report on open files on certain file
5692 system if /usr/src/sys/msdosfs didn't exist when the lsof
5693 Configure script ran and lsof was made. /usr/src/sys/msdosfs
5694 contains header files lsof needs for collecting data on
5695 certain file system files.
5696
5697 You can tell if an lsof executable above) lacks support
5698 for a file system if the following test of `lsof -v` produces
5699 nothing:
5700
5701 $ lsof -v 2>&1 | grep <support_enabled_definition>
5702
5703 The <support-enabled_definition> will be:
5704
5705 File System Type Definition Note
5706 ---------------- ---------- ----
5707 File descriptor HASFDESCFS
5708 /proc HASPROCFS
5709 9660 HAS9660FS
5710 MS-DOS HASMSDOSFS (lsof 4.61 and above)
5711 Kernel HASKERNFS
5712
5713 The work-around is to install /usr/src/sys, rerun the lsof
5714 Configure script, and remake lsof.
5715
571611.3 Why does lsof produce confusing results for nullfs file
5717 systems?
5718
5719 Consider this report from /sbin/mount:
5720
5721 /usr/home on /home type null (local)
5722
5723 (According to /sbin/mount /usr/home is the mounted-on device
5724 and /home is the mounted-on directory.)
5725
5726 When lsof is asked to report on open files on /home, it
5727 will report them as files on /usr/home instead. That's an
5728 artifact of the NetBSD kernel's dynamic name lookup cache
5729 (DNLC) and the way the kernel handles nullfs mounted-on
5730 directories.
5731
5732 While lsof will report all open files on /home when given
5733 /home as a file system directory argument, even though
5734 reporting them as located on /usr/home, lsof will not find
5735 the same files when asked to report on all open files on
5736 /usr/home when given /usr/home as a file system device
5737 argument. That's because from the mount perspective
5738 /usr/home is equivalent to a device, but from the device
5739 perspective it is still a directory.
5740
5741 So, what this lsof command reports:
5742
5743 $ lsof /home
5744 ... NAME
5745 ... /usr/home/...
5746
5747 Won't be duplicated by this lsof command:
5748
5749 $ lsof /usr/home
5750
5751 Another way to look at this confusing /home and /usr/home
5752 example is to consider what stat(2) reports. For /home
5753 stat(2) reports a device doublet that matches what lsof
5754 finds in open file node structures, while the device doublet
5755 stat(2) reports for /usr/home won't match what lsof finds.
5756 Nor does the mode reported by stat(2) indicate a block
5757 devices, as is the expected case.
5758
5759 There is no simple answer to this confusion, nor is there
5760 even a simple explanation. Simply be aware that when
5761 supplying file system arguments to lsof on NetBSD, use the
5762 mounted-on directory name for a nullfs as the lsof argument,
5763 and don't be surprised when the NAME column reports the
5764 mounted-on device name.
5765
576611.4 NetBSD header file problems
5767
576811.4.1 Why can't the compiler find some NetBSD header files?
5769
5770 If the compiler's pre-processor complains it can't find some
5771 header files when it compiles lsof source files, /usr/include
5772 and /usr/src may not have all the header files lsof needs.
5773
5774 As a work-around use the NETBSD_SYS environment variable
5775 to specify to lsof the location of the additional header
5776 files -- e.g.,
5777
5778 % setenv NETBSD_SYS /my_source
5779 % ./Configure -n netbsd
5780
5781 or
5782 $ NETBSD_SYS=/mys_source ./Configure -n netbsd
5783
5784 Caution: using this work-around may cause the lsof Configure
5785 script to activate or omit different features, depending
5786 on where it finds the header files that determine the state
5787 of the features.
5788
578911.4.2 Why does NetBSD lsof produce incorrect output?
5790
5791 If the NetBSD system's kernel was built from header files that
5792 don't match those in /usr/include -- e.g., //usr/src has the
5793 ones from which the kernel was built -- lsof may build, but
5794 won't produce correct output.
5795
5796 As a possible work-around, try directing the C compiler to
5797 select header files from /usr/src before it selects them from
5798 /usr/include. That can be done with the DEBUG make string --
5799 e.g.,
5800
5801 $ make DEBUG="-I/usr/src -I/usr/include"
5802
5803 If that work-around fails, try using the LSOF_INCLUDE and
5804 NETBSD_SYS environment variables to swap /usr/include and
5805 /usr/src when running the Configure script, then use the make
5806 DEBUG string when running make -- e.g.,
5807
5808 $ LSOF_INCLUDE=/usr/src; export LSOF_INCLUDE
5809 $ NETBSD_SYS=/usr/include; export NETBSD_SYS
5810 $ ./Configure -n netbsd
5811 $ make DEBUG="-I/usr/src -I/usr/include"
5812
581311.5 Why isn't lsof feature xxx enabled for NetBSD?
5814
5815 Lsof's Configure script enables NetBSD features by locating
5816 and examining header files associated with the features,
5817 and based on what it finds, setting compile-time definitions
5818 in Makefiles. (See 00PORTING for a list of the definitions.)
5819
5820 When Configure doesn't find header files or doesn't find
5821 appropriate values in header files, that may mean the header
5822 file tree lsof is searching is incomplete or out of date.
5823
5824 Lsof normally looks for NetBSD header files in /usr/include.
5825 It can also be directed to look in other directories --
5826 e.g., /sys -- if told to do so with the contents of the
5827 LSOF_INCLUDE and NETBSD_SYS environment variables.
5828
5829 To determine what header file enables a missing feature,
5830 check the NetBSD stanza in the Configure script. Then
5831 check the locations it checks for the indicated header
5832 files and contents.
5833
5834 See 00XCONFIG for more information on LSOF_INCLUDE and
5835 and NETBSD_SYS.
5836
5837
583812.0 NEXTSTEP and OPENSTEP Problems
5839
584012.1 Why can't lsof report on 3.1 lockf() or fcntl(F_SETLK)
5841 locks?
5842
5843 Lsof has code to test for locks defined with lockf() or
5844 fcntl(F_SETLK) under NEXTSTEP 3.1, but that code has never
5845 been tested. I couldn't test it, because my NEXTSTEP 3.1
5846 lockf() and fcntl(F_SETLK) functions return "Invalid
5847 argument" every way I have tried to invoke them.
5848
5849 If your NEXTSTEP 3.1 system does allow you to use lockf()
5850 and fcntl(F_SETLK) and lsof doesn't report locks set with
5851 them, then the code in .../dialects/next/dnode.c probably
5852 isn't correct. Please contact me via e-mail at <abe@purdue.edu>
5853 and tell me how you got your lockf() and fcntl(F_SETLK) system
5854 calls to work. Make sure "lsof" appears in the "Subject:" line
5855 so my e-mail filter won't classify your letter as Spam.
5856
585712.2 Why doesn't lsof compile for NEXTSTEP with AFS?
5858
5859 I no longer have a NEXTSTEP test system that has AFS.
5860 Changes to lsof since I once had a test system have caused
5861 me to change the AFS code in NEXTSTEP without being able
5862 to test the changes.
5863
5864 If you need AFS support for NEXTSTEP and can't get it to
5865 compile, please contact me. Perhaps we can jointly fix
5866 the problems.
5867
5868
586913.0 OpenBSD Problems
5870
587113.1 Why doesn't lsof support kernfs on my OpenBSD system?
5872
5873 Lsof supports the kernel file system on OpenBSD versions
5874 whose /sys/miscfs/kernfs/kernfs.h (or <miscfs/kernfs/kernfs.h>
5875 header file correctly defines the kern_target structure.
5876 The lsof Configure script's openbsd stanza checks for the
5877 presence of the structure's kt_name element and activates
5878 kernfs support for the CFLAGS -DHASKERNFS definition only
5879 when it finds kt_name.
5880
5881 The kernfs.h header file is scheduled to be updated in the
5882 OpenBSD 2.1 release, according to Kenneth Stailey, who
5883 authored its changes.
5884
588513.2 Will lsof work on OpenBSD on non-x86-based architectures?
5886
5887 I've not tested lsof on an OpenBSD system that uses a
5888 non-x86-based architecture, but I've had one report that
5889 lsof 4.33 compiles and works on OpenBSD for the pmax
5890 architecture (decstation 3100).
5891
589213.3 <sys/pipe.h> problems
5893
589413.3.1 Why does the compiler claim nbpg isn't defined?
5895
5896 When compiling lsof on some (older) OpenBSD SPARC versions,
5897 the compiler may complain:
5898
5899 In file included from ../dlsof.h:191,
5900 from ../lsof.h:166,
5901 from fino.c:52:
5902 /usr/include/sys/pipe.h:83: `nbpg' undeclared here
5903 (not in a function)
5904 /usr/include/sys/pipe.h:83: size of array `ms' has
5905 non-integer type
5906
5907 This happens because <sys/pipe.h> uses NBPG from
5908 <machine/param.h> to size the `ms' array, and some OpenBSD
5909 systems define NBPG in terms of a kernel integer variable,
5910 nbpg.
5911
5912 Lsof revisions 4.46 and above have a hack to dlsof.h,
5913 developed by Volker Borchert that avoids the compiler
5914 problem for SPARC OpenBSD 2.3. The hack might work for
5915 other OpenBSD SPARC versions, but hasn't been tested there.
5916
5917 If you want to enable the hack for your OpenBSD SPARC
5918 version, modify this code in .../dialects/n+obsd/dlsof.h:
5919
5920 # if defined(OPENBSDV)
5921 # if OPENBSDV==2030 && defined(__sparc__)
5922 # if defined(nbpg)
5923 #undef nbpg
5924 # endif /* defined(nbpg) */
5925 #define nbpg 4096 /* WARNING!!! ... */
5926 # endif /* OPENBSDV==2030 && defined(__sparc__) */
5927 #include <sys/pipe.h>
5928 #endif /* defined(OPENBSDV) */
5929
5930 You will probably want to change the second #if test to
5931 match your OpenBSD version. You may also want to change
5932 what value is assigned to nbpg. See the next section,
5933 "What value should I assign to nbpg?"
5934
593513.3.2 What value should I assign to nbpg?
5936
5937 If you need to enable the nbpg hack, described in "Why does
5938 the compiler claim nbpg isn't defined?", you may also need
5939 to assign a value other than 4096 to nbpg. 4096 works for
5940 the sun4c processor and should work for sun4m, but 8192
5941 may be needed for sun4.
5942
5943 Check <machine/param.h> and other OpenBSD documentation to
5944 determine the correct nbpg assignment.
5945
594613.4 Why doesn't lsof report on open MS-DOS file system (floppy
5947 disk) files?
5948
5949 Lsof is not able to report on open MS-DOS file system files
5950 if /usr/src/sys/msdosfs didn't exist when the lsof Configure
5951 script ran and lsof was made. /usr/src/sys/msdosfs contains
5952 header files lsof needs for collecting data on MS-DOS file
5953 system files.
5954
5955 You can tell if an lsof executable (revisions 4.61 and
5956 above) lacks MS-DOS file system support if the following
5957 command reports nothing:
5958
5959 $ lsof -v 2>&1 | grep HASMSDOSFS
5960
5961 The work-around is to install /usr/src/sys, rerun the lsof
5962 Configure script, and remake lsof.
5963
596413.5 Why isn't lsof feature xxx enabled for OpenBSD?
5965
5966 Lsof's Configure script enables OpenBSD features by locating
5967 and examining header files associated with the features,
5968 and based on what if finds, setting compile-time definitions
5969 in Makefiles. (See 00PORTING for a list of the definitions.)
5970
5971 When Configure doesn't find header files or doesn't find
5972 appropriate values in header files, that may mean the header
5973 file tree lsof is searching is incomplete or out of date.
5974
5975 Lsof normally looks for OpenBSD header files in /usr/include
5976 and /sys. It can also be directed to look in other
5977 directories if told to do so with the contents of the
5978 LSOF_INCLUDE and NETBSD_SYS environment variables.
5979
5980 To determine what header file enables a missing feature,
5981 check the OpenBSD stanza in the Configure script. Then
5982 check the locations it checks for the indicated header
5983 files and contents.
5984
5985 See 00XCONFIG for more information on LSOF_INCLUDE and
5986 and NETBSD_SYS.
5987
5988
598914.0 Output Problems
5990
599114.1 Why do the lsof column sizes change?
5992
5993 Lsof dynamically sizes its output columns each time it runs
5994 to make sure that each column takes the minimum space.
5995 Column parsing -- e.g., with awk -- is possible, because
5996 each column is guaranteed to be separated from the preceding
5997 one by at lease one space, and no column except the last
5998 (NAME) contains embedded spaces.
5999
600014.2 Why does the offset have ``0t' and ``0x'' prefixes?
6001
6002 The offset value that appears in the SIZE/OFF column has
6003 ``0t' and ``0x'' prefixes to distinguish it from size values
6004 that may appear in the same column.
6005
6006 Normally if the offset value is less than 100,000,000 (8
6007 digits), it appears in decimal with a ``0t' prefix; over
6008 99,999,999, in hexadecimal with a ``0x'' prefix.
6009
6010 A decimal offset is handy, for example, when tracking the
6011 progress of an outbound ftp transfer. When lsof reports
6012 on the ftp process, it will report the size of the file
6013 being sent with its open descriptor; it will report the
6014 progress of the transfer via the offset of the outbound
6015 open ftp data socket descriptor.
6016
6017 The ``-o [n]'' option may be used to specify the maximum
6018 number of decimal digits to be printed after ``0t'' before
6019 lsof switches to the hexadecimal digits after `0x''. As
6020 already noted, the default decimal digit count is 8.
6021
602214.3 What are the values printed in the FILE_FLAG column
6023 and why is 0x<value> sometimes included?
6024
6025 The two comma separated lists, separated by a semicolon,
6026 printed in the FILE-FLAG column (when the "+fg" option is
6027 specified), are short-hand names or hexadecimal values for
6028 the bits lsof finds in the f_flag or f_flags member of file
6029 structures for files (the first list, the one before the
6030 semicolon), and process open files flags found in various
6031 kernel structures, often named "pofile" (the second list,
6032 the one after the semicolon).
6033
6034 Lsof determines the short-hand names from symbols in the
6035 <fcntl.h>, <linux/fs.h>, <sys/fcntl.h>, <sys/fcntlcom.h>,
6036 o<sys/file.h>, and <sys/user.h> header files.
6037
6038 See the discussion of FILE-FLAG in the OUTPUT section of
6039 the lsof man page, and the FF_* and POF_* symbols in lsof.h
6040 for a list of the names.
6041
6042 Bits with no names defined for them are represented by an
6043 0x<value> member of the comma-separated list -- a hexadecimal
6044 integer. When "+fG" is specified (instead of "+fg"), lsof
6045 will list all flag values as two hexadecimal integers,
6046 separated by a semicolon.
6047
6048 When "-FG" is specified to get the flags in an output field,
6049 the format defaults to hexadecimal. You can get names
6050 instead by following "-FG" with "+fg" -- e.g.,
6051
6052 $ lsof -FG +fg ...
6053
6054 However, when you precede "-FG" with "+fg" -- e.g.,
6055
6056 $ lsof +fg -FG
6057
6058 the format will be hexadecimal; order is important.
6059
606014.3.1 Why doesn't lsof display FILE_FLAG values for my dialect?
6061
6062 All versions of lsof except the /proc-based Linux lsof
6063 report FILE-FLAG values. Lsof can't obtain FILE-FLAG
6064 information from the Linux /proc interface.
6065
606614.4 Network Addresses
6067
606814.4.1 Why does lsof's -n option cause IPv4 addresses, mapped to
6069 IPv6, to be displayed in IPv6 notation?
6070
6071 When you use the -n option to tell lsof to display numeric
6072 network addresses, and an IPv4 address has been mapped to
6073 IPv6, lsof displays the address in IPv6 format and puts
6074 "ipv4" in the TYPE column. That combination indicates the
6075 IPv4 address has been mapped to IPv6.
6076
6077 For example, the IPv4 address 1.2.3.4, when mapped to an
6078 IPv6 address, will be displayed by lsof as:
6079
6080 [::ffff:1.2.3.4]
6081
6082 The enclosing brackets are lsof's signal that this is an
6083 IPv6 address. Inside the brackets is a standard IPv6
6084 address, reported by inet_ntop(). The first two colons,
6085 signifying zeroes in the first 64 bits of the IPv6 address,
6086 and the hexadecimal ffff in the next 32 bits, indicate that
6087 the last 32 bits contains a mapped IPv4 address, which is
6088 then displayed in IPv4 dot notation.
6089
609014.5 Why does lsof output \x, ^x, or \xnn for characters
6091 sometimes?
6092
6093 Lsof displays only printable ASCII characters. Lsof
6094 considers a character printable if isprint(3) says it
6095 is. If isprint(3) says a character isn't printable,
6096 the lsof may page explains:
6097
6098 "... Non-printable characters are printed in one of
6099 three forms: the C ``\[bfrnt]'' form; the control
6100 character `^' form (e.g., ``^@''); or hexadecimal
6101 leading ``\x'' form (e.g., ``\xab''). Space is
6102 non-printable in the COMMAND column (``\x20'') and
6103 printable elsewhere."
6104
610514.5.1 Why is space considered a non-printable character in command
6106 names?
6107
6108 Space is considered an unprintable character in command
6109 names because it is sometimes possible to hide the full
6110 command name from scripts that parse ps(1) output by
6111 embedding a space in the name.
6112
611314.6 Why doesn't lsof print all the characters of a command name?
6114
6115 By default lsof prints the first nine characters of the
6116 names of commands associated with processes. If more
6117 characters are required, the "w" value of the "+c w" option
6118 may be used to specify a larger width.
6119
6120 If "w" is zero ('0') lsof will print all characters of all
6121 command names up to the limit of the number of characters
6122 supplied by the particular UNIX dialect. When reporting
6123 command names, lsof replaces non-printable characters as
6124 discussed in the answer to " Why does lsof output \x, ^x, or
6125 \xnn for characters sometimes?"
6126
6127 See the answer to the "Why is space considered a non-printable
6128 character in command names?" question for an explanation of why
6129 spaces are replaced by the ``\x20'' representation in command
6130 names.
6131
6132 The number of command name characters supplied to lsof by UNIX
6133 dialects in files and structures varies by dialect. For
6134 example, Linux 2.4.27 supplies lsof the first 15 characters of
6135 command names and Solaris 9 supplies 16. Thus, even if "w" is
6136 zero ('0'), lsof can't report more characters for command names
6137 on those two UNIX dialects than they provide lsof.
6138
613914.7 Why does lsof reject some -c command names, saying their lengths
6140 are "> what system provides (nn)"?
6141
6142 The command name length that a specific system provides varies
6143 from dialect to dialect. As noted in the answer to the "Why
6144 doesn't lsof print all the characters of a command name?"
6145 question, Linux and Solaris provide a limited number of command
6146 name characters.
6147
6148 When more characters are specified in the parameter to the -c
6149 option, lsof considers it an error and issues a fatal error
6150 message -- e.g.,
6151
6152 lsof: "-c xxxxyyyy" length (8) > what system provides (7)
6153
6154 The only work-around is to specify no more characters to -c
6155 that the system provides to lsof.
6156
615714.8 Why does lsof sometimes print TYPE numbers instead of names?
6158
6159 When lsof can't convert a type number to a name for printing in
6160 the TYPE column, it will report the number as four octets.
6161
616214.9 Marker line format problems
6163
616414.9.1 Why won't lsof accept a marker line format?
6165
6166 Lsof's Configure script must find the localtime(3) and
6167 strftime(3) functions in the dialect's C library in order to
6168 enable support for marker line formats.
6169
6170 Check the output of lsof's -v option for the presence of
6171 -DHAS_STRFTIME in the compiler flags. If it isn't there,
6172 Configure didn't find the necessary two C library functions.
6173
6174 If you think lsof should have found the functions, make a copy
6175 of the C test program in the Configure script that it uses to
6176 find the functions. Then use the copy, or a more informative
6177 modification of it, to learn why Configure can't find the
6178 functions. You can find that program by searching for
6179 strftime.
6180
618114.9.2 Why does lsof reject the NL (%n) marker line format?
6182
6183 When repeat mode and field output (with -F) have both been
6184 specified, lsof won't allow new line (NL) formats to be
6185 specified with ``%n''. That's because the marker line is
6186 always guaranteed to be a single line.
6187
6188 There is no work-around to this restriction.
6189
619014.10 How are protocol state name exclusion and inclusion used?
6191
6192 Protocol state name inclusion and exclusion with the ``-s p:s''
6193 option and its arguments have some issues to consider.
6194
6195 First, there is the problem of determining what state names, if
6196 any, the dialect produces. Try running this lsof command to
6197 find them:
6198
6199 $ lsof -i
6200
6201 Knowing the state names of interest, the next problem is to
6202 decide on the lsof options and their parameters that will
6203 produce the desired output. Here some examples are probably
6204 the most useful.
6205
6206 To list only TCP socket files in LISTEN and CLOSE_WAIT states,
6207 use:
6208
6209 $ lsof -itcp -stcp:listen,close_wait
6210 or
6211 $ lsof -iTCP -sTCP:LISTEN,CLOSE_WAIT
6212
6213 Case isn't important to lsof in protocol and state names.
6214
6215 To exclude TCP socket files in CLOSE_WAIT state, use:
6216
6217 $ lsof -itcp -stcp:^close_wait
6218
6219 Note the `^' preceding close_wait; it selects exclusion. You
6220 can mix included and excluded names in a comma separated list,
6221 but you may not include and exclude the same name for the same
6222 protocol.
6223
6224 To list TCP files in LISTEN state and UDP files in Idle state,
6225 use:
6226
6227 $ lsof -i -stcp:listen -sudp:idle
6228
6229 Note: if you don't accompany the ``-s p:s'' list option and
6230 argguments with the -i option, lsof will list all other regular
6231 files, while applying the specified inclusion and exclusion
6232 specifications to network files. Generally, then, you want to
6233 use -i with -s.
6234
623514.10.1 Why doesn't my dialect support state name exclusion and inclusion?
6236
6237 When state name inclusion and exclusion was added, I had access
6238 to test systems for AIX, Darwin, FreeBSD, Linux, PSTAT-based
6239 HP-UX and Solaris.
6240
6241 Therefore, I was unable to add and test the support to any other
6242 UNIX dialects.
6243
6244 If a dialect has the support, then the HASTCPUDPSTATE definition
6245 in its machine.h header file will be active; if not, it will be
6246 absent or commented out.
6247
6248 If your dialect doesn't have the support and you want it added,
6249 you will have to provide me Internet access to a test host, where
6250 I can compile lsof and have the credentials to test the changes
6251 the support requires. If that's possible for you, please contact
6252 me via e-mail at <abe@purdue.edu>. Make sure "lsof" appears in
6253 the "Subject:" line so my e-mail filter won't classify your letter
6254 as Spam.
6255
6256
625715.0 Pyramid Version Problems
6258
625915.0.5 Statement of deprecation
6260
6261 As of lsof revision 4.52 support for all Pyramid versions has
6262 been dropped. Contact me via e-mail at <abe@purdue.edu> if you
6263 are interested in obtaining the last lsof Pyramid distribution.
6264 Make sure "lsof" appears in the "Subject:" line so my e-mail
6265 filter won't classify your letter as Spam.
6266
6267
626816.0 SCO Problems
6269
627016.1 SCO OpenServer Problems
6271
627216.1.1 How can I avoid segmentation faults when compiling lsof?
6273
6274 If you have an older SCO OpenServer compiler, it may get
6275 a segmentation fault when compiling some lsof modules.
6276 That appears to happen because of the -Ox optimization
6277 action requested in the lsof Makefile.
6278
6279 Try changing -Ox to -O with this make invocation:
6280
6281 $ make DEBUG=-O
6282
6283 Bela Lubkin supplied this tip and Steve Williams verified
6284 it.
6285
628616.1.2 Where is libsocket.a?
6287
6288 If you compile lsof and the loader says it can't find the
6289 socket library, libsocket.a, called by the -lsocket option
6290 in the lsof compile flags, you probably are running an SCO
6291 OpenServer release earlier than 5.0 and don't have the
6292 TCP/IP Development System package installed.
6293
6294 You may have the necessary header files, because you have
6295 the TCP/IP run-time package installed, but if you don't
6296 have the TCP/IP Development System package installed, you
6297 won't have libsocket.a.
6298
6299 Your choices are to install the TCP/IP Development System
6300 package or upgrade to OpenServer Release 5.0. You will
6301 find libsocket.a in 5.0 -- you'll find all the libraries
6302 and header files there, in fact -- and you can use gcc to
6303 compile lsof if you don't want to install the 5.0 Development
6304 System package.
6305
630616.1.3 Why do I get "warning C4200" messages when I compile lsof?
6307
6308 When you compile lsof under OSR 3.2v4.2 (and perhaps under
6309 earlier versions as well), you may get many compiler warning
6310 messages of the form:
6311
6312 node.c(183) : warning C4200: previous declarator is not
6313 compatible with default argument promotion
6314
6315 In my opinion this is a bug in the OSR compiler. Because
6316 the compiler cannot handle full ANSI-C prototypes, it
6317 assumes default types for function parameters as it encounters
6318 untyped in a function prototype -- e.g., in this function
6319 declaration from node.c,
6320
6321 readrnode(ra, r)
6322 KA_T ra;
6323 struct rnode *r;
6324 {
6325 ...
6326
6327 the compiler assigns default int types to the ra and r
6328 arguments.
6329
6330 Then, when the compiler encounters the fully typed parameters
6331 after the function skeleton and sees parameters with types
6332 that don't match the assumptions it previously made, it
6333 whines about its own assumptions.
6334
6335 You can ignore these messages.
6336
633716.2 SCO|Caldera UnixWare Problems
6338
633916.2.1 Why doesn't lsof compile on my UnixWare 7.1.1 or above
6340 system?
6341
6342 When you Configure lsof with the "uw" abbreviation and try
6343 to compile it for UnixWare 7.1.1, you may get compiler
6344 error messages like this:
6345
6346 UX:acomp: ERROR: "dproc.c", line 98:
6347 undefined struct/union member: p_pgidp
6348
6349 This suggest that you probably have a non-stop cluster
6350 UnixWare 7.1.1 system. Its <sys/proc.h> header file differs
6351 from the one on the system where I did the lsof port to
6352 UnixWare 7.1.1. I currently don't have access to a non-stop
6353 cluster system to be able to develop changes to lsof that
6354 would make it compile and work there.
6355
6356 If you have a non-stop cluster UnixWare 7.1.1 system, want lsof
6357 for it, and can offer me a test account on the system, please
6358 contact me via e-mail at <abe@purdue.edu>. Make sure "lsof"
6359 appears in the "Subject:" line so my e-mail filter won't
6360 classify your letter as Spam.
6361
6362 If you have a system with nsc_cfs and can offer me a test
6363 account on it, please contact me via e-mail at <abe@purdue.edu>.
6364 Make sure "lsof" appears in the "Subject:" line so my e-mail
6365 filter won't classify your letter as Spam.
6366
636716.2.2 Why does lsof complain about node_self() on my UnixWare
6368 7.1.1 or above system?
6369
6370 If lsof exits immediately after issuing this message:
6371
6372 can't identify process NSC node; node_self(): <message>
6373
6374 It means that lsof has been built to run on a NonStop
6375 Cluster (NSC) UnixWare 7.1.1 or higher system and can't
6376 get the number of the node on which it is running. Lsof
6377 uses the node number to determine the path to the kernel
6378 boot file.
6379
6380 You can tell if lsof has been built for NSC by looking for
6381 "-DHAS_UW_NSC" in lsof's "-v" option output.
6382
6383 If the system on which you're trying to run lsof isn't
6384 running an NSC kernel, you will need to build a non-NSC
6385 lsof.
6386
638716.2.3 Why does UnixWare 7.1.1 or above complain about -lcluster,
6388 node_self(), or libcluster.so?
6389
6390 When you build, compile, and load lsof for UnixWare 7.1.1
6391 and above, ld may complain that it can't find the -lcluster
6392 library or that the node_self symbol is undefined. When
6393 you try to run an existing lsof binary it may complain that
6394 libcluster.so can't be found.
6395
6396 These messages mean the tests made by Configure on your
6397 system led it to believe your system is running a NonStop
6398 Cluster (NSC) kernel, or the lsof binary you're trying to
6399 use was built on a NonStop Cluster system. If an lsof
6400 binary was built for NSC, this shell command produces
6401 output:
6402
6403 $ strings <lsof_binary> | grep HAS_UW_NSC
6404
6405 If that's not the case, and you can rebuild lsof, set the
6406 UW_HAS_NSC environment variable to "N" and do this:
6407
6408 $ Configure -n clean
6409 $ UW_HAS_NSC=N
6410 $ export UW_HAS_NSC
6411 $ Configure -n uw
6412 $ make
6413
6414 You can also edit Makefile and lib/Makefile. Remove
6415 -DHAS_UW_NSC from the CFGF strings. Remove -lcluster from
6416 the CFGL strings. Then run make again.
6417
6418 If you have an existing NSC lsof binary and you want one
6419 for a non-NSC system, you will have to build lsof yourself
6420 on the system where you want to use it. (That's always a
6421 good idea anyway.)
6422
6423
642416.2.4 Why does UnixWare 7.1.1 or above lsof complain it can't
6425 read the kernel name list?
6426
6427 If lsof complains:
6428
6429 can't read kernel name list from <path>
6430
6431 It means that lsof can't find the booted kernel image file
6432 at <path>. On NonStop Cluster (NSC) UnixWare 7.1.1 or
6433 higher systems lsof determines the booted file path by
6434 examining this file:
6435
6436 /stand/`node_self`/boot
6437
6438 If examining that file doesn't lead to an NSC path, lsof
6439 uses:
6440
6441 /stand/1/unix
6442
6443 On non-NSC systems lsof expects the booted kernel image to
6444 be in /stand/unix.
6445
6446 If your booted kernel image is in a different place, use
6447 lsof's "-k <path>" option to specify its path.
6448
644916.2.5 Why doesn't lsof report link count, node number, and size
6450 for some UnixWare 7.1.1 or above CFS files?
6451
6452 Lsof reports link count, node number, and size for open
6453 CFS files as recorded in their kernel node structure's
6454 cached attributes. Sometimes not all attributes are cached
6455 on the node where lsof runs, so lsof cannot report them.
6456
645716.2.6 Why doesn't lsof report open files on all UnixWare 7.1.1
6458 NonStop Cluster (NSC) nodes?
6459
6460 Lsof can only report on files open on the node on which it
6461 runs, because the information lsof reports comes from the
6462 private kernel memory of the node. This may mean that
6463 asking lsof to find a specific open file, or use of a
6464 specific Internet address or port, may not report all open
6465 instances on nodes other than the one used to run lsof.
6466
6467 You can use the NSC onnode(1) command to run lsof on specific
6468 nodes, or the onall(1) command to run lsof on all nodes --
6469 e.g.,
6470
6471 $ onall lsof [options] 2>&1 | less
6472 or
6473 $ onnode node-number lsof [options] 2>&1 | less
6474
6475 Note that, when lsof is run all nodes, the path name
6476 component assembly results it reports in its NAME column
6477 may vary, because the dynamic name cache from which lsof
6478 gets the components is private to the kernel of each node.
6479
6480 Also note the use of shell redirection in the examples to
6481 merge the standard error file information from onnode and
6482 onall with lsof's standard output file output. That will
6483 put the onnode and onall node announcements in proper
6484 sequence with lsof's output.
6485
648616.2.7 Why doesn't lsof report the UnixWare 7.1.1 NonStop Cluster
6487 (NSC) node a process is using?
6488
6489 To induce lsof to report the node on which a process runs
6490 would be a significant, non-standard modification to lsof.
6491 It has much wider implications than merely the printing of
6492 a number in an output column. I'm not currently (April
6493 2001) prepared to undertake such a modification.
6494
6495 If you want node-specific NSC information about open files,
6496 run lsof under the control of onall(1) or onnode(1).
6497
6498 $ onall lsof [options] 2>&1 | less
6499 or
6500 $ onnode node-number lsof [options] 2>&1 | less
6501
650216.2.8 Why does the compiler complain about missing UnixWare 2.1[.x]
6503 header files?
6504
6505 SCO|Caldera didn't ship the following header files with
6506 UnixWare 2.1 through 2.1.3:
6507
6508 <fs/proc/prdata.h>
6509 <fs/procfs/prdata.h>
6510 <sys/fs/fifonode.h>
6511 <sys/fs/namenode.h>
6512
6513 Lsof needs those header files for its compilation. Contact
6514 SCO|Caldera to get copies of those header files.
6515
6516 If you can't get the header files from SCO|Caldera, please
6517 contact me via e-mail at <abe@purdue.edu>. Make sure "lsof"
6518 appears in the "Subject:" line so my e-mail filter won't
6519 classify your letter as Spam.
6520
6521
652217.0 Sun Problems
6523
652417.0.5 Statement of deprecation
6525
6526 Lsof support for SunOS 4.1.x was last tested at revision 4.51.
6527 Contact me via e-mail at <abe@purdue.edu> if you're interested in
6528 obtaining it. Make sure "lsof" appears in the "Subject:" line so
6529 my e-mail filter won't classify your letter as Spam.
6530
653117.1 My Sun gcc-compiled lsof doesn't work -- why?
6532
6533 Gcc can be used to build lsof successfully. However, an
6534 improperly installed Sun gcc compiler will usually not
6535 produce a working lsof.
6536
6537 If your Sun gcc-compiled lsof doesn't report anything, or
6538 reports ``can't read proc table,'' or gcc refuses to compile
6539 lsof without error, check that the gcc step that "fixes"
6540 Sun header files was run on the system where you're using
6541 gcc to compile lsof. As an alternative, if you have the
6542 SunPro C 5.0 compiler or later available, use it to compile
6543 lsof -- e.g., use the solariscc Configure abbreviations.
6544
654517.2 How can I make lsof compile with gcc under Solaris 2.[456],
6546 2.5.1, 7, 8 or 9?
6547
6548 Presuming your gcc-specific header files are wrong for
6549 Solaris, edit the lsof Configure-generated Makefile and
6550 lib/Makefile and make this change:
6551
6552 CFGF= -Dsolaris=20400 ...
6553 to
6554 CFGF= -Dsolaris=20400 -D__STDC__=0 -I/usr/include ...
6555
6556 or change:
6557
6558 CFGF= -Dsolaris=20500 ...
6559 to
6560 CFGF= -Dsolaris=20500 -D__STDC__=0 -I/usr/include ...
6561
6562 or change:
6563
6564 CFGF= -Dsolaris=20501 ...
6565 to
6566 CFGF= -Dsolaris=20501 -D__STDC__=0 -I/usr/include ...
6567
6568 This is only a temporary work-around. You really should
6569 instruct gcc to to update your gcc-specific header files
6570 or install a recent gcc (e.g., 3.2), which has no need for
6571 private copies of Solaris include files.
6572
657317.3 Why does Solaris Sun C complain about system header files?
6574
6575 You're probably trying to use /usr/ucb/cc if you get compiler
6576 complaints like:
6577
6578 cc -O -Dsun -Dsolaris=20300 ...
6579 "/usr/include/sys/machsig.h", line 81: macro BUS_OBJERR
6580 redefines previous macro at "/usr/ucbinclude/sys/signal.h",
6581 line 444
6582
6583 Note the reference to "/usr/ucbinclude/sys/signal.h". It
6584 reveals that the BSD Compatibility Package C compiler is
6585 in use. Lsof requires the ANSI C version of the Solaris
6586 C compiler, usually found in /usr/opt/bin/cc or
6587 /opt/SUNWspro/bin/cc.
6588
6589 Try adding a CC string to the lsof Makefile that points to
6590 the Sun ANSI C version of the Sun C compiler -- e.g.,
6591
6592 CC= /usr/opt/bin/cc
6593 or
6594 CC= /opt/SUNWspro/bin/cc.
6595
659617.4 Why doesn't lsof work under my Solaris 2.4 system?
6597
6598 If lsof doesn't work under your Solaris 2.4 system -- e.g.,
6599 it produces no output, little output, or the output is
6600 missing command names or file descriptors -- you may have
6601 a pair of conflicting Sun patches installed.
6602
6603 Solaris patch 101945-32 installs a kernel that was built
6604 with a <sys/auxv.h> header file whose NUM_*_VECTORS
6605 definitions don't match the ones in the <sys/auxv.h> updated
6606 by Solaris patch 102303-02.
6607
6608 NUM_*_VECTORS in the kernel of patch 101945-32 are smaller
6609 than the ones in the <sys/auxv.h> of patch 102303-02. The
6610 consequence is that when lsof is compiled with the <sys/auxv.h>
6611 whose NUM_*_VECTORS definitions are larger than the ones
6612 used to compile the patched kernel, lsof's user structure
6613 does not align with the one that the kernel employs.
6614
6615 If you have these two patches installed, contact Sun and
6616 complain about the mis-match.
6617
6618 You may be able to work around the problem by editing
6619 /usr/include/sys/auxv.h to have the following NUM_*_VECTORS
6620 definitions:
6621
6622 #define NUM_GEN_VECTORS 4
6623 #define NUM_SUN_VECTORS 8
6624
6625 The Configure script issues a prominent WARNING that you should
6626 try the work-around.
6627
6628 I thank Leif Hedstrom for identifying the offending patches.
6629
663017.5 Where are the Solaris header files?
6631
6632 If you try to compile lsof under Solaris and get a compiler
6633 complaint that it can't find system header files, perhaps
6634 you forgot to add the header file package, SUNWhea.
6635
663617.6 Where is the Solaris /usr/src/uts/<architecture>/sys/machparam.h?
6637
6638 When you try to Configure lsof for Solaris 2.[23456], 2.5.1,
6639 and 7 -- e.g., on a `uname -m` == sun4m system -- Configure
6640 complains:
6641
6642 grep: /usr/src/uts/sun4m/sys/machparam.h:
6643 No such file or directory
6644 grep: /usr/src/uts/sun4m/sys/machparam.h:
6645 No such file or directory
6646
6647 And when you try to compile the configured lsof, cc or gcc
6648 complains:
6649
6650 dproc.c:530: `KERNELBASE' undeclared (first use this function)
6651
6652 The explanation is that somehow your Solaris system doesn't
6653 have the header files in /usr/src/uts it should have. Perhaps
6654 someone removed the directory to save space. Perhaps you're
6655 using a gcc installation, copied from another system. In any
6656 event, you will have to load the header files from the SUNWhea
6657 package of your Solaris distribution.
6658
6659 KERNELBASE is an important symbol to lsof -- it keeps lsof
6660 from sending an illegal kernel value to kvm_read() where
6661 a segmentation violation might result (a bug in the kvm
6662 library). Lsof can get illegal kernel values because it
6663 reads kernel values slowly with kvm_read() calls that the
6664 kernel is changing rapidly.
6665
6666 Lsof doesn't need KERNELBASE at Solaris 2.5 and above,
6667 because it has a KERNELBASE value whose address lsof can
6668 find with /dev/ksyms and whose value it can read with
6669 kvm_read(). Under Solaris 2.5 /usr/src/uts has moved to
6670 /usr/platform.
6671
667217.7 Why does Solaris lsof say ``can't read proc table''?
6673
6674 When lsof collects data on processes, using the kvm_*()
6675 functions to scan the kernel's proc structure table, it
6676 checks to make sure it has identified a reasonable number
6677 of them -- a minimum of three. When lsof can't identify
6678 three processes during a scan, it repeats the scan.
6679
6680 When five scans fail to yield three processes, lsof issues
6681 the fatal message:
6682
6683 lsof: can't read proc table
6684
6685 and exits.
6686
6687 Usually lsof fails to identify three processes during a
6688 scan because its idea of the form of the proc structure
6689 differs from that being used by the kernel. Since the proc
6690 structure is defined in <sys/proc.h> and other /usr/include
6691 header files, the root cause of a proc structure discrepancy
6692 usually can be found in the composition of /usr/include.
6693
6694 One common way that /usr/include header files can be
6695 incorrect is that gcc was used to compile lsof, gcc used
6696 its special (i.e., "fixed") header files instead of the
6697 ones in /usr/include, and the special gcc header files
6698 weren't updated when Solaris was. Answers to these questions:
6699
6700 My Sun gcc-compiled lsof doesn't work -- why?
6701
6702 How can I make lsof compile with gcc under Solaris 2.[456],
6703 2.5.1, 7, 8 or 9?
6704
6705 Why does Solaris Sun C complain about system header files?
6706
6707 discuss the gcc header file problem and offer suggestions
6708 on how to fix it or work around it.
6709
6710 It may also be that you are trying to run a version of lsof
6711 that was compiled on an older version of Solaris. For
6712 example, an lsof executable, compiled for Solaris 2.4, will
6713 produce the ``can't read proc table'' message if you try
6714 to run it under Solaris 2.5. If you have compiled lsof
6715 under Solaris 2.5 and it still won't work, see if the header
6716 files in /usr/include have been updated to 2.5, or still
6717 represent a previous version of Solaris.
6718
6719 Another source of header file discrepancies to consider is
6720 the Solaris patch level and whether a binary kernel patch
6721 was not matched with a corresponding header file update.
6722 See the "Why doesn't lsof work under my Solaris 2.4 system?"
6723 question for an example of one in Solaris 2.4 -- there may
6724 be other such patch conflicts I don't know about.
6725
672617.8 Why does Solaris lsof complain about a bad cached clone device?
6727
6728 When lsof revisions below 4.04 have been run on a Solaris
6729 system and have been allowed to create a device cache file,
6730 the running of revisions 4.04 and above on the same systems
6731 may produce this complaint:
6732
6733 lsof: bad cached clone device: ...
6734 lsof: WARNING: created device cache file: ...
6735
6736 This is the result of a change in the device cache file
6737 that took place at lsof revision 4.04. The change introduced
6738 a node number into the clone device lines of the device
6739 cache file and was done in such a way that lsof could detect
6740 device cache files whose clone lines don't have node numbers
6741 (lines created by previous lsof revisions) and recognize
6742 the need to regenerate the device cache file.
6743
674417.9 Why doesn't Solaris make generate .o files?
6745
6746 Solaris /usr/ccs/bin/make won't generate .o files from .c
6747 files if /usr/share/lib/make/make.rules is missing. It
6748 may be found in and installed from the SUNWsport package.
6749
675017.10 Why does lsof report some Solaris 2.3 and 2.4 lock types as `N'?
6751
6752 For Solaris 2.3 with patch P101318 installed at level 45
6753 or above, and for all versions of Solaris 2.4, NFS locks
6754 are represented by a NFS-specific kernel lock structure
6755 that sometimes lacks a read or write lock type indicator.
6756 When lsof encounters such a lock structure, it reports the
6757 lock type as `N'.
6758
675917.11 Why does lsof Configure say "WARNING: no cc in ..."?
6760
6761 When lsof's Configure script is executed with the solariscc
6762 abbreviation it tries to make sure it's using the Sun C
6763 compiler and not the UCB substitute from /usr/ucb/cc.
6764 Thus, it looks for cc in the "standard" Sun compiler
6765 location, /opt/SUNWspro/bin.
6766
6767 If Configure can't find cc there, it issues the warning:
6768
6769 lsof: WARNING: no cc in /opt/SUNWspro/bin;
6770 using cc without path.
6771
6772 and uses cc for the compiler name, letting the shell find
6773 cc with its PATH environment variable.
6774
6775 You can tell Configure where to find your cc with the
6776 SOLARIS_CCDIR cross-configuration environment variable.
6777 (See 00XCONFIG for more information on SOLARIS_CCDIR).
6778 For example, use this Configure shell command:
6779
6780 SOLARIS_CCDIR=/usr/special/bin Configure -n solariscc
6781
6782 (SOLARIS_CCDIR should be the full path to the directory
6783 containing your cc.)
6784
678517.12 Solaris 7, 8 and 9 Problems
6786
678717.12.1 Why does lsof say the compiler isn't adequate for Solaris
6788 7, 8 or 9?
6789
6790 Solaris 7, 8 and 9 kernels come in two flavors, 32 and 64
6791 bit. 64 bit kernels run on machines that support the SPARC
6792 v9 instruction set architecture. Separate executables for
6793 some programs, -- e.g., ones using libkvm like lsof -- must
6794 be built for 32 and 64 bit kernels.
6795
6796 Previous Sun (e.g., SC4.0) and earlier gcc compilers will
6797 build lsof for 32 bit kernels, but they won't build it for
6798 64 bit kernels. Compilers that will build lsof for 64 bit
6799 Solaris 7, 8 and 9 kernels are the Sun WorkShop Compilers
6800 C 5.0 and above, and recent gcc versions, e.g., 3.2.
6801
6802 When given the ``-xarch=v9'' flag, the C 5.0 compiler and
6803 above, and associated loader and 64 bit libraries will
6804 build a 64 bit lsof executable; when given the "-m64" or
6805 "-mcpu=v9" (deprecated) flags, an appropriate gcc compiler
6806 will build a 64 bit lsof executable.
6807
6808 When the lsof Configure script detects a 64 bit kernel is
6809 in use (e.g., by executing `/bin/isainfo -kv`), and when
6810 it finds that the specified compiler is inappropriate,
6811 it complains with these messages:
6812
6813 For gcc:
6814
6815 "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
6816 "! !"
6817 "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT !"
6818 "! THIS GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT !"
6819 "! SOLARIS EXECUTABLES. LSOF WILL BE CONFIGURED FOR A !"
6820 "! 32 BIT echo KERNEL. !"
6821 "! !"
6822 "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
6823
6824 For Sun C:
6825
6826 !!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!
6827 ! !
6828 ! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT |
6829 ! THE VERSION OF SUN C AVAILABLE DOESN'T SUPPORT THE !
6830 ! -xarch=v9 FLAG. LSOF WILL BE CONFIGURED FOR A 32 BIT !
6831 ! KERNEL. !
6832 ! !
6833 !!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!
6834
683517.12.2 Why does Solaris 7, 8 or 9 lsof say "FATAL: lsof was compiled
6836 for..."?
6837
6838 Solaris 7, 8 or 9 lsof may say:
6839
6840 lsof: FATAL: lsof was compiled for a xx bit kernel,
6841 but this machine has booted a yy bit kernel.
6842
6843 Where: xx = 32 or 64
6844 yy = 64 or 32
6845
6846 (xx and yy won't match.)
6847
6848 This message indicates that lsof was compiled for one size
6849 kernel and is being asked to execute on a different size
6850 one. That's not possible for programs like lsof that use
6851 libkvm.
6852
6853 Depending on the instruction sets for which you need Solaris
6854 7, 8 or 9 lsof, you may need two or more versions of lsof,
6855 compiled for each kernel size, installed for use with
6856 /usr/lib/isaexec. See the "How do I install lsof for
6857 Solaris 7, 8 or 9?" section of this document for more
6858 information on that.
6859
686017.12.3 How do I build lsof for a 64 bit Solaris kernel under a 32
6861 bit Solaris kernel?
6862
6863 If your Solaris system has an appropriate compiler (e.g.,
6864 WorkShop Compilers C 5.0 and above, or a recent gcc like
6865 3.2) and the 64 bit libraries have been installed, you can
6866 force lsof's Configure script to build a 64 bit version of
6867 lsof with:
6868
6869 $ SOLARIS_KERNBITS=64 Configure -n solariscc
6870
6871 The SOLARIS_KERNBITS environment variable is part of the
6872 lsof cross-configuration support, described in the 00XCONFIG
6873 file of the lsof distribution.
6874
687517.12.4 How do I install lsof for Solaris 7, 8 or 9?
6876
6877 If you are installing lsof where it will be used only under
6878 the bit size kernel for which it was built, no special
6879 installation is required.
6880
6881 If, however, you are installing different versions of lsof
6882 for different bit sizes -- e.g., for use on a 64 bit NFS
6883 server and from its 32 bit clients -- you should read the
6884 man page for isaexec(3C) and install lsof according to its
6885 instructions.
6886
6887 The executable at the directory where lsof is to be found
6888 should be a hard link to /usr/lib/isaexec or a copy of it.
6889 In the directory there must be instruction architecture
6890 subdirectories -- e.g., .../sparc/ and .../sparcv9/. The
6891 lsof for 64 bit size kernels is installed in the .../sparcv9/
6892 subdirectory; the one for 32 bit size kernels, in .../sparc/.
6893
6894 For example, if you're installing 32 and 64 bit lsof
6895 executables in /usr/local/etc, you would:
6896
6897 # cd /usr/local/etc
6898 # ln /usr/lib/isaexec lsof
6899 # mkdir sparc sparcv9
6900 # install the 32 bit lsof as sparc/lsof
6901 # install the 64 bit lsof as sparcv9/lsof
6902 # chmod, chown, and chgrp sparc/lsof and
6903 sparcv9/lsof appropriately
6904
6905 Lsof permissions and ownerships are the same whether one
6906 or more lsof executables are being installed, with or
6907 without the /usr/lib/isaexec hard link.
6908
690917.12.5 Why does my Solaris 7, 8 or 9 system say it cannot execute
6910 lsof?
6911
6912 When you attempt to execute lsof, your Solaris 7, 8 or 9
6913 shell may complain:
6914
6915 ksh: ./lsof: cannot execute
6916
6917 If the lsof executable exists and has the proper execution
6918 permissions, this error may be the result of trying to
6919 execute an lsof, built for a 64 bit kernel, on a 32 bit
6920 kernel.
6921
6922 This will tell you about the lsof executable:
6923
6924 $ file lsof
6925 lsof: ELF 64-bit MSB executable SPARCV9 Version 1,
6926 dynamically linked, not stripped
6927
6928 The "64-bit" notation indicates the binary was built for
6929 a 64 bit kernel. To see the running kernel bit size, use
6930 this command:
6931
6932 $ isainfo -kv
6933 32-bit sparc kernel modules
6934
6935 The "32-bit" notation indicates a 32 bit kernel has been
6936 booted.
6937
6938 The only work-around is to obtain, or Configure and make,
6939 an lsof for the appropriate kernel bit size. If you
6940 Configure and make lsof on the kernel where you wish to
6941 run it the proper compiler, the lsof Configure step will
6942 generate Makefiles that can be used with make to build an
6943 appropriate lsof executable.
6944
6945 To compile a 64 bit lsof, you must have an appropriate
6946 compiler -- i.e., Sun WorkShop Compilers C 5.0 or higher
6947 or a recent gcc like 3.2.
6948
694917.12.6 What gcc will produce 64 bit Solaris 7, 8 and 9 executables?
6950 8 and 9 executables?
6951
6952 Properly built and installed recent gcc versions -- e.g.,
6953 3.2 -- will build lsof for 64 bit Solaris kernels.
6954
6955 If you update your gcc version to 3.2 or later, make sure
6956 the private gcc header files become current -- i.e., clear
6957 out any private header files from a previous gcc or Solaris
6958 installation before installing the new ones, or build to
6959 a new --prefix root and replace the old root with it after
6960 the build and installation are complete.
6961
696217.12.7 Why does lsof on my Solaris 7, 8 or 9 system say, "can't
6963 read namelist from /dev/ksyms?"
6964
6965 You're probably trying to use an lsof executable built for
6966 an earlier Solaris release on a 64 bit Solaris 7, 8 or 9
6967 kernel. The output from `lsof -v` will tell you the build
6968 environment of your lsof executable. You should also have
6969 gotten a warning message that lsof is compiled for a
6970 different Solaris version than the one under which it is
6971 running -- something like this:
6972
6973 lsof: WARNING: compiled for Solaris release X; this is Y
6974
6975 You need to build lsof on the system where you want to use
6976 it. For 64 bit Solaris 7, 8 and 9 you need a compiler that
6977 can generate 64 bit Solaris executables -- e.g., the Sun
6978 Workshop 5 C compiler or later, or a recent gcc version
6979 like 3.2. See the "Why does lsof say the compiler isn't
6980 adequate for Solaris 7, 8 or 9?" section and the ones
6981 following it for a discussion of building lsof for 64 bit
6982 Solaris 7, 8 or 9.
6983
698417.13 Solaris and COMMON
6985
698617.13.1 What does COMMON mean in the NAME column for a Solaris VCHR
6987 file?
6988
6989 When lsof puts COMMON or (COMMON) in the NAME column of a
6990 Solaris VCHR file, it means that the file is handled by
6991 the special file system functions of the kernel through a
6992 common vnode.
6993
699417.13.2 Why does a COMMON Solaris VCHR file sometimes seem to have an
6995 incorrect minor device number?
6996
6997 When lsof reports on an open file in a Solaris special file
6998 system that uses a COMMON vnode, and the file is a VCHR
6999 file, lsof tries to locate the associated device node by
7000 looking for matches on the major and minor device numbers
7001 first.
7002
7003 If no major and minor match results, lsof then looks for
7004 a match on pseudo and clone device files. (See /devices/pseudo.)
7005 Those device nodes are matched specially by either their
7006 major or minor device numbers, but not both. Hence, when
7007 lsof finds a match under those special conditions, it may
7008 report a value in its output DEVICE column that differs
7009 from one of the major and minor numbers of the device node.
7010
7011 Here's an example from a sun4m Solaris 7 system:
7012
7013 $ ls -li /devices/pseudo/pm@0:pm
7014 151261 crw-rw-rw- 1 root sys 117, 0 ...
7015 $ lsof /devices/pseudo/pm@0:pm
7016 COMMAND ... DEVICE ... NODE NAME
7017 powerd 117,1 ... 151261 /devices/pseudo/pm@0:pm (COMMON)
7018 Xsun ... 117,0 ... 151261 /devices/pseudo/pm@0:pm
7019
7020 Note that the DEVICE value for the file with (COMMON) in
7021 its name field has a different minor device number (1) from
7022 what ls reports (0), while the DEVICE value for the file
7023 without (COMMON) matches the ls output exactly. Both match
7024 on the major device number, 117. The minor device number
7025 mis-match is a result of the way the Solaris kernel handles
7026 special file system common vnodes, and it's the reason lsof
7027 puts (COMMON) after the name to signal that a mis-match is
7028 possible.
7029
703017.14 Why don't lsof and Solaris pfiles reports always match?
7031
7032 /usr/proc/bin/pfiles for Solaris 2.6, 7, 8, and 9 also
7033 reports information on open files for processes. Sometimes
7034 the information it reports differs from what lsof reports.
7035
7036 There are several reasons why this might be true. First,
7037 because pfiles is a Sun product, based on Sun kernel
7038 features, its developers have a better chance of knowing
7039 exactly how open file information is organized. I sometimes
7040 have to guess at how kernel file structure linkages are
7041 constructed by gleaning hints from header files.
7042
7043 Second, lsof is aimed at providing information, specifically
7044 device and node numbers, that can be used to identify named
7045 file system objects -- i.e., path names. Thus, lsof tries
7046 to make sure its device and node numbers match those reported
7047 by stat(2). Pfiles doesn't always report numbers that
7048 match stat(2) -- e.g., for files using clone and pseudo
7049 devices via common vnodes like the nlist() /dev/ksyms usage.
7050
7051 Here's the Solaris 7 COMMON VCHR example again with additional
7052 pfiles output:
7053
7054 $ ls -li /devices/pseudo/pm@0:pm
7055 151261 crw-rw-rw- 1 root sys 117, 0 ...
7056 $ lsof /devices/pseudo/pm@0:pm
7057 vic1: 10 = lsof /dev/pm
7058 COMMAND ... DEVICE ... NODE NAME
7059 powerd ... 117,1 ... 151261 /devices/pseudo/pm@0:pm (COMMON)
7060 Xsun ... 117,0 ... 151261 /devices/pseudo/pm@0:pm
7061 $ pfiles ...
7062 0: S_IFCHR ... dev:32,24 ino:61945 ... rdev:117,1
7063 ...
7064 14: S_IFCHR ... dev:32,24 ino:151261 ... rdev:117,0
7065
7066 Note that the NODE number, reported by lsof, matches what
7067 ls(1) and stat(2) report, while the ino value pfiles reports
7068 doesn't. Lsof also indicates with the (COMMON) notation
7069 that the DEVICE number is a pseudo one, derived from the
7070 character device's value. The lsof DEVICE value matches
7071 the pfiles rdev value, correct behavior for a character
7072 device, but pfiles gives no sign that it's not possible to
7073 find that character device number in /devices with ls(1)
7074 or stat(2).
7075
707617.15 Why does lsof say, "kvm_open(namelist=default, core=default):
7077 Permission denied?"
7078
7079 Lsof needs permission to read from the /dev/kmem and /dev/mem
7080 memory devices. Access to them is opened via a call to
7081 the kvm_open() library function and it reports the indicated
7082 message.
7083
7084 You must give lsof permission to read the memory devices.
7085 The super user can almost always do that, but other lsof
7086 users can do it if some group -- e.g., sys -- has permission
7087 to read the memory devices, and the lsof binary is installed
7088 with the group's ownership and with the setgid permission
7089 bit enabled.
7090
709117.16 Why is lsof slow on my busy Solaris UFS file system?
7092
7093 Lsof may be slow on a busy Solaris UFS file system when
7094 UFS logging has been enabled with the "logging" mount
7095 option. That option can significantly increase disk
7096 operations under certain conditions -- e.g., when a lot of
7097 files are accessed quickly.
7098
7099 When only the "logging" option is specified to mount, all
7100 file accesses (atime updates) are logged to the UFS logging
7101 queue. Each atime update requires two writes to the disk
7102 to complete it.
7103
7104 If you want to do UFS logging -- and there are reliability
7105 advantages to it -- consider using the "logging,noatime"
7106 mount options instead. That will shift atime updates from
7107 the logging queue to fewer and independent asynchronous
7108 operations, consequently making the UFS logging queue a
7109 smaller bottleneck.
7110
7111 Consult mount_ufs(1M) for more information on the logging
7112 and noatime options.
7113
7114 (My thanks to Casper Dik for this tip on improving the
7115 performance of UFS logging.)
7116
711717.17 Why is lsof so slow on my Solaris 8 or 9 system?
7118
7119 Solaris 8 has a post-release feature upgrade modifying
7120 kernel name cache (DNLC) handling that can slow lsof
7121 throughput dramatically. The feature, sometimes called
7122 negative DNLC caching, is standard in Solaris 9.
7123
7124 As best I can tell, when you install the Solaris 8 MU1
7125 package, you get negative DNLC caching. If this pipe
7126 produces any output, your system has negative DNLC caching.
7127
7128 $ nm /dev/ksyms | grep negative_cache_vnode
7129
7130 The reason negative DNLC caching perturbs lsof is that a
7131 single vnode address (found in the negative_cache_vnode
7132 kernel variable) is used to mark entries in the DNLC that
7133 are not (the negative part) found on disk.
7134
7135 Since a single vnode address (the DNLC key lsof uses) can
7136 represent many (I've seen upwards of 30,000.) DNLC entries,
7137 their presence overloads lsof's internal DNLC hashing
7138 function. An overloaded hash function is a slow hash
7139 function, and lsof's slows to a crawl when it encounters
7140 thousands of keys that produce the same value when the lsof
7141 DNLC hash function is applied to them.
7142
7143 The solution is simple -- ignore negative DNLC cache keys.
7144 They don't represent path name components lsof can use.
7145 Lsof revisions 4.50 and above have an addition that ignores
7146 them and the performance of those lsof revisions improves
7147 significantly when presented with negative DNLC cache keys.
7148
7149 If you don't have an lsof revision at 4.51 or later, there's
7150 a work-around. Use lsof's ``-C'' option. It disables
7151 lsof's DNLC caching. Of course, that also inhibits the
7152 reporting of any path name components from the kernel DNLC.
7153 When ``-c'' is used, lsof will continue to report file
7154 system and character device paths.
7155
715617.18 Solaris and VxFS
7157
715817.18.1 Why doesn't lsof support VxFS 3.4 on Solaris 2.6, and above?
7159
7160 Lsof will not support VxFS version 3.4 on Solaris 2.6 and above
7161 unless some files from VxFS Update 2 have been installed. VxFS
7162 3.4 FCS and VxFS 3.4 update 1 lack the header files lsof
7163 normally uses to obtain information from the VxFS 3.4 kernel
7164 node structure, vx_inode. VxFS 3.4 Update 2 provides a method
7165 whereby lsof can obtain the necessary vx_inode information from
7166 the vxfsu_get_ioffsets() function in Veritas utility
7167 libraries.
7168
7169 The utility libraries (32 bit and 64 bit versions) may be
7170 found in /opt/VRTSvxfs/lib. An ancillary header file may
7171 be found in /opt/VRTSvxfs/include/sys/fs/vx_libutil.h.
7172 Documentation of the vxfsu_get_ioffsets(3) function may be
7173 found in /opt/VRTS/man/man3/vxfsu_get_ioffsets.3.
7174
7175 Those files of VxFS 3.4 Update 2 may be downloaded from:
7176
7177 ftp://ftp.veritas.com/pub/support/vxfs_34.i64243.tar
7178
7179 The vxfs_34.i64243.tar archive will unpack into an i64243
7180 directory containing these files:
7181
7182 $ ls i64243
7183 README
7184 libvxfsutil.sol26.sums
7185 libvxfsutil.sol26.tar.Z
7186 libvxfsutil.sol27.sums
7187 libvxfsutil.sol27.tar.Z
7188 libvxfsutil.sol28.sums
7189 libvxfsutil.sol28.tar.Z
7190
7191 Read README. Select the *.tar.Z file appropriate for your
7192 Solaris version. Its contents will unpack into /opt/VRTS
7193 and /opt/VRTSvxfs, so you will need sufficient permission
7194 -- e.g., do it as root -- to unpack the uncompressed archive.
7195 Once you've done that, it's a good idea to compare the
7196 checksums of the archive you unpacked with the ones recorded
7197 in the appropriate *.sums file. Use `sum -r` to verify
7198 the checksums.
7199
7200 For example, if you want the Solaris 8 version, uncompress
7201 and unpack libvxfsutil.sol28.tar.Z -- e.g.,
7202
7203 $ su
7204 ...
7205 # cd i6423
7206 # zcat libvxfsutil.sol28.tar.Z | tar xf -
7207
7208 That should create these new files and subdirectories with
7209 the indicated checksums:
7210
7211 File or subdirectory sum -r
7212
7213 /opt/VRTSvxfs/include/vxfsutil.h 03938
7214 /opt/VRTSvxfs/lib/libvxfsutil.a 51794
7215 /opt/VRTSvxfs/lib/sparcv9/
7216 /opt/VRTSvxfs/lib/sparcv9/libvxfsutil.a 07420
7217 /opt/VRTS/man/man3/
7218 /opt/VRTS/man/man3/vxfsu_get_ioffsets.3 62480
7219
7220 Once these files are in place, run lsof's Configure script
7221 for the solaris or solariscc abbreviation. Configure will
7222 locate the appropriate VxFS 3.4 Update 2 files and set up
7223 for the making of an lsof that will properly display open
7224 VxFS 3.4 file information.
7225
722617.18.2 Why does lsof report "vx_inode: vxfsu_get_ioffsets error"
7227 for open Solaris 2.6 and above VxFS 3.4 and above files?
7228
7229 Even when lsof supports VxFS 3.4 and above on Solaris 2.6 and
7230 above, it may report "vx_inode: vxfsu_get_ioffsets error" in
7231 the NAME column for all VxFS files.
7232
7233 The usual cause is that lsof doesn't have permission to
7234 read the file at the end of the /dev/vxportal symbolic
7235 link. If, for example, lsof has been installed setgid(sys),
7236 then the /dev/vxportal symbolic link destination should be
7237 owned by the sys group and readable by it.
7238
7239 Update 2 for VxFS 3.4 sets the modes of the /dev/vxportal
7240 symbolic link destination to 0640 and the group ownership
7241 to sys. But I have had a report that the modes are wrong
7242 in a VxFS 4.0 installation.
7243
7244 Another cause may be that the system has more than one version
7245 of VxFS installed (Only one can be active.), and lsof's
7246 Configure script did not choose the header files and libraries
7247 for the active VxFS version. Configure opts for VxFS 4.0 and
7248 above header files and libraries (in /opt/VRTS) in preference
7249 to those for VxFS below 4.0 (in /opt/VRTSvxfs).
7250
7251 Look for the directories /opt/VRTS and /opt/VRTSvxfs. If you
7252 have /opt/VRTS, make sure its header and library symbolic links
7253 point to those of the active VxFS version.
7254
7255 If you have both directories, look at the CFLAGS that Configure
7256 constructed for making lsof and see which directory path
7257 follows a -I option. If that doesn't match the directory path
7258 of the active VxFS version, try pointing Configure at the
7259 correct directory with the SOLARIS_VXFSINCL environment
7260 variable -- e.g.,
7261
7262 $ SOLARIS_VXFSINCL=/opt/.../include ./Configure -n solaris
7263
726417.18.3 Why does Solaris Configure claim there is no VxFS library?
7265
7266 The lsof Configure script, when configuring for Solaris, may
7267 report:
7268
7269 FATAL: no VxFS .../libvxfsutil.a
7270
7271 That fatal error message indicates lsof has found the VxFS
7272 utility library's header files, but can't find the library
7273 itself in the expected location adjacent to the header files.
7274
7275 One possible cause is an incorrect symbolic link from
7276 /opt/VRTS/lib/sparcv9/libvxfsutil.a to the library's real
7277 location. (Some VxFS distributions declared the link
7278 incorrectly.) Use `ls -lL` on that path to see if it exists.
7279 If it doesn't exist, the link may be missing an additional
7280 leading "../" component.
7281
7282 If the problem is a missing "../" from the library's link, you
7283 can correct the link or check with Veritas/Symantec for the
7284 patch that corrects it.
7285
7286 If the problem is not a missing "../", and you know the
7287 libvxfsutil.a location, you can define its path in the
7288 SOLARIS_VXFSLIB environment variable before running the lsof
7289 Configure script. (See 00XCONFIG for information about using
7290 the SOLARIS_VXFSLIB environment variable.)
7291
7292 If you have no libvxfsutil.a, you must obtain it from
7293 Veritas/Symantec or find it in your VxFS installation package.
7294
729517.18.4 Why doesn't Solaris lsof report VxFS path name components?
7296
7297 Solaris lsof will report path name components for VxFS versions
7298 that use the common Solaris Dynamic Name Lookup Cache (DNLC) or
7299 on some file systems of VxFS versions that support the VxFS
7300 Reverse Name Lookup (RNL) facility.
7301
7302 VxFS versions 3.3 (approximately) and below use the common
7303 Solaris DNLC. (I haven't been able to determine exactly when
7304 VxFS stopped using the DNLC.) For versions above that boundary,
7305 but below 4.0, lsof can't report path name components.
7306
7307 At VxFS 4.0 and above, lsof can be compiled to use the VxFS RNL
7308 facility for reporting path names. If "-DHASVXFSRNL" appears
7309 in the compiler flags section of lsof "-v" option output, then
7310 the lsof Configure script detected the VxFS RNL facility and
7311 lsof has been compiled to use it.
7312
7313 Lsof's use of the RNL facility can fail when the VxFS file
7314 system disk layout version is below 6. In that case, lsof can
7315 report no path name components. For more information, see the
7316 vxfs_inotopath(3) manual page. any of the following commands
7317 will show the disk layout version for a VxFS file system, when
7318 supplied the block device or mount point on which the file
7319 system is mounted.
7320
7321 fstyp -v <block_device>
7322 or
7323 mkfs -m <block_device>
7324 or
7325 vxupgrade <mount_point>
7326
7327 You must have permission to read the block device -- e.g., be
7328 the root user.
7329
7330 You may also be able to upgrade an older disk layout to one
7331 that will work with the RNL. See the vxupgrade(1M) man page
7332 for more information on that.
7333
7334 When lsof can't report VxFS path name components, it reports
7335 the file system mount point and the path name of device on
7336 which it is mounted. The device path name is enclosed in
7337 parentheses.
7338
733917.18.5 Why does Solaris 10 lsof report scrambled VxFS paths?
7340
7341 Solaris 10 lsof may report a bogus, scrambled path for an open
7342 VxFS file, when lsof obtains the path from a vnode's cached
7343 path. Veritas/Symantec reports that their Solaris 10
7344 implementation has bugs in the way it handles the Solaris 10
7345 vnode cached path and those bugs will be fixed in an upcoming
7346 patch some time after August 15, 2005.
7347
7348 When Solaris 10 lsof reports a path for an open VxFs file
7349 obtained via the VxFS Reverse Name Lookup facility, the path
7350 will be correct.
7351
7352 Also see the answers to the questions "Why does Solaris 10 lsof
7353 sometimes report the wrong path name?" and "Why doesn't Solaris
7354 lsof report VxFS path name components?"
7355
735617.19 Large file problems
7357
735817.19.1 Why does lsof complain it can't stat(2) a Solaris 2.5.1
7359 large file?
7360
7361 When given an argument that is the path to a Solaris 2.5.1
7362 file, enable for large file operations with the O_LARGEFILE
7363 open(2) option, lsof complains that it can't stat(2) the
7364 file. That's because lsof isn't using a stat(2) call and
7365 associated structure enabled for large files.
7366
7367 This error has been fixed, starting at lsof revision 4.58
7368 for Solaris 2.6 and above. That fix won't work on Solaris
7369 2.5.1 and I no longer have access to a Solaris 2.5.1 test
7370 system to develop a separate fix.
7371
7372 The work-around is to avoid specifying a O_LARGEFILE path
7373 as an argument to lsof on Solaris 2.5.1. Instead use a
7374 combination of lsof and grep to achieve the same results,
7375 albeit more clumsily.
7376
737717.20 Why does lsof get a segmentation fault on 64 bit Solaris
7378 8 using NIS+?
7379
7380 I have received a report from Gary Craig that lsof produces
7381 a segmentation fault on his 64 bit Solaris 8 system using
7382 NIS+. Via an independent test program we have exonerated
7383 lsof and tracked the fault to the NIS+ __nis_server_name()
7384 function in the C name server library, -lnsl.
7385
7386 Lsof causes the __nis_server_name() NIS+ function to be
7387 called by calling getservent() to read entries of the port
7388 number to service name map.
7389
7390 The only Sun bug ID that appears to describe the problem
7391 is 4304244, although its text is unclear enough to leave
7392 room for doubt.
7393
7394 Until Sun eliminates the __nis_server_name() segmentation
7395 fault cause, a work-around for lsof is to use its "-P"
7396 option, causing lsof to avoid port to service name lookups.
7397
739817.21 Will lsof crash the Solaris kernel?
7399
7400 I've received and investigated one report that it has when
7401 the Sun hardware (a QME interface) was faulty. Today (May
7402 23, 2002) I've learned that Sun has reports of kernel
7403 crashes caused by adb, lsof, and mdb.
7404
7405 The Sun investigation pinpointed a problem in the /dev/kmem
7406 kernel driver and there is a Sun bug report, 4344513, about
7407 the problem. There is a fix in Solaris 9, and patches for
7408 Solaris 7 and 8 (SPARC and x86).
7409
7410 To see if your Solaris system is fixed, look for a
7411 /devices/pseudo/*allkmem node.
7412
7413 Extensive address filtering was added to lsof revision 4.50
7414 to forestall what I then (July 2001) believed to be only
7415 the possibility that lsof might crash Solaris. However,
7416 the filtering isn't perfect, since a filtered address might
7417 become invalid after lsof has filtered it but before lsof
7418 has delivered it to /dev/kmem. That filtering work is
7419 described in .../dialects/sun/solaris_kaddr_filters, also
7420 available at:
7421
7422 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/solaris_kaddr_filters
7423
7424 The best and safest work-around is to upgrade to Solaris
7425 9 or install an appropriate patch or its equivalent from
7426 this list:
7427
7428 Solaris SPARC x86
7429 Version Patch Patch
7430 ======= ===== =====
7431 7 106541-20 106542-20
7432 8 108528-14 108529-14
7433
743417.22 Why does lsof on Solaris 7, 8, or 9 report a kvm_open()
7435 failure?
7436
7437 When lsof is started on some Solaris 7, 8, and 9 systems
7438 it may report:
7439
7440 lsof: kvm_open(namelist=default, corefile=default): \
7441 No such file or directory
7442
7443 Lsof revisions 4.65 and later will first report:
7444
7445 lsof: cannot stat /dev/allkmem
7446
7447 The second message, not delivered in lsof revisions below
7448 4.65, explains the cause of the kvm_open() failure; it
7449 can't find /dev/allkmem.
7450
7451 /dev/allkmem is a device added to Solaris 7 and 8 in patches
7452 and in the Solaris 9 FCS. See the preceding "Will lsof
7453 crash the Solaris kernel?" section for more information on
7454 /dev/allkmem and the patches.
7455
7456 The kvm_open(3KVM) function in the KVM library of patched
7457 Solaris 7 and 8 systems and in Solaris 9 expects to find
7458 /dev/allkmem and exits on error when it does not.
7459
7460 If you have installed the patch that updated your KVM
7461 library to a version that expects /dev/allkmem to be present
7462 and it is not, you may need to reconfigure your system's
7463 devices with devfsadm(1M) or enter "boot -r" to the OpenBoot
7464 monitor's prompt (usually "ok").
7465
746617.23 Solaris and SAM-FS
7467
746817.23.1 Why does Solaris lsof report "(limited SAM-FS info)"?
7469
7470 Lsof 4.68 and above report "(limited SAM-FS info)" on
7471 Solaris in the NAME column after the path or file system
7472 name for all files it finds on SAM-FS file systems.
7473
7474 That's because no more information is known about the
7475 composition of the nodes that follow SAM-FS vnodes. If
7476 you can provide that information, please contact me via
7477 e-mail at <abe@purdue.edu>. Make sure "lsof" appears in the
7478 "Subject:" line so my e-mail filter won't classify your letter
7479 as Spam.
7480
748117.23.2 Why can't lsof locate named SAM-GS files?
7482
7483 Solaris lsof 4.68 and above can't locate files on SAM-FS
7484 file systems when the files are named as lsof arguments
7485 because lsof doesn't know how to locate open SAM-FS file
7486 device and node number information. (See also 'Why does
7487 Solaris lsof report "(limited SAM-FS info)?')
7488
748917.24 Lsof and Solaris 10 zones
7490
749117.24.1 How can I make lsof list the Solaris zone?
7492
7493 Use the lsof "-z [z]" option.
7494
749517.24.2 Why doesn't lsof work in a Solaris 10 zone?
7496
7497 When run from within a Solaris 10 zone, lsof will usually
7498 report:
7499
7500 lsof: can't stat(/devices): No such file or directory
7501
7502 That's because a Solaris zone usually has no /devices
7503 subdirectory, a restriction of the zone implementation intended
7504 to limit the ability of zone processes to control global system
7505 resources, including physical devices.
7506
7507 While a zone may have a /dev subdirectory, that subdirectory
7508 usually lacks the /dev/allkmem, /dev/mem and /dev/kmem devices
7509 lsof and the KVM library it uses require.
7510
7511 The work-around is to run lsof in the global zone. When it is
7512 run in a global zone lsof will be able to report on processes
7513 running in any zone, including the global zone.
7514
751517.24.3 Why does lsof complain it can't stat() Solaris 10 zone file
7516 systems?
7517
7518 When run from the global zone on Solaris 10 lsof may complain:
7519
7520 lsof: WARNING: can't stat() 15 zone file systems;
7521 using dev= options
7522
7523 The warning message means lsof found the reported number of
7524 file system entries in the mount table for which it didn't have
7525 permission to get stat(2) results, but which had "zone=" and
7526 "dev=" mount table options.
7527
7528 That is a normal restriction of Solaris 10 zones. Since the
7529 lsof warning message indicates it was able to find "dev="
7530 options for the file systems, lsof will probably work
7531 correctly.
7532
7533 One work-around is to relax the restrictions on zone mount
7534 points, so that lsof can stat() them. While that may be
7535 possible by changing directory modes or group ownerships, it is
7536 probably not a good idea, because it weakens the restrictions
7537 zones are intended to provide.
7538
7539 Another work-around is to suppress the warning message with
7540 lsof's "-w" option. The down side of that is that it causes
7541 the suppression of all warning messages, leading to the
7542 possibility that some non-stat() warning messages will be
7543 suppressed.
7544
754517.25 Solaris 10 problems
7546
754717.25.1 Why does Solaris 10 lsof sometimes report the wrong path name?
7548
7549 When a path name component is renamed -- e.g., with mv(1) --
7550 Solaris 10 lsof may report the old component for an open file
7551 that used the component in its path before the rename. That's
7552 because Solaris 10 lsof reports the path name cached in the
7553 open file's vnode and the Solaris 10 kernel doesn't update the
7554 open vnode's cached path name when a component of it is changed.
7555
7556 When an open file is deleted -- e.g., with rm(1) -- the path
7557 name by which it was opened remains cached in the vnode. Lsof
7558 can be instructed to display that path name with the -X option.
7559 The path name might be incorrect because of the rename problem
7560 described above. See the answer to the 'What does "(deleted)"
7561 mean in the NAME column of a Solaris 10 open file?' question
7562 for more information.
7563
7564 Lsof is sometimes able to detect that cached path name is
7565 incorrect. In that case lsof may report only the mounted-on
7566 directory and device of the file system or it may report that
7567 the path name is of questionable accuracy by appending a
7568 trailing "(?)" to it in the NAME column.
7569
7570 See the answer to the "Why does Solaris 10 lsof sometimes
7571 report only the mounted-on directory and device?" and 'What
7572 does "(?)" mean in the NAME column of a Solaris 10 open file?'
7573 questions for more information.
7574
757517.25.2 Why does Solaris 10 lsof sometimes report only the mounted-on
7576 directory and device?
7577
7578 For some regular open files lsof may report only the mounted-on
7579 directory and device of the file system on which the file
7580 resides. That's because lsof was able to determine that the
7581 path name cached in the open file's vnode is incorrect.
7582
7583 Lsof detects the cached path name is incorrect by applying
7584 stat(2) to it, provided that no error was detected when stat(2)
7585 was applied to the file system mounted-on directory during lsof
7586 setup. If a mounted-on directory stat(2) error was detected
7587 during setup, lsof does no cached path name analysis and simply
7588 reports it.
7589
7590 When the application of stat(2) to the cached path name returns
7591 a no-entry reply (the ENOENT error number), lsof concludes the
7592 path no longer exists (i.e., has been unlinked) and reports the
7593 mounted-on directory and device of the file system. That
7594 behavior can be modified with the -X option in lsof revisions
7595 4.77 and above. See the answer to the 'What does "(deleted)"
7596 mean in the NAME column of a Solaris 10 open file?' for more
7597 information.
7598
7599 When the application of stat(2) to the cached path name returns
7600 a permission error reply (the EACCES or EPERM error numbers),
7601 lsof reports the cached path name and adds a trailing "(?)" to
7602 indicate the reported path name is of questionable accuracy.
7603 See the answer to the question 'What does "(?)" mean in the
7604 NAME column of a Solaris 10 open file?' for more information.
7605
7606 If the application of stat(2) to the cached path name yields
7607 any other error reply, lsof reports the mounted-on directory
7608 and device of the file system.
7609
7610 When the application of stat(2) to the cached path name
7611 succeeds, lsof compares the reported device and node numbers to
7612 what it has obtained for the open file from kernel structures.
7613 If they match, lsof reports the cached path name. If they
7614 don't match, lsof instead reports the mounted-on directory and
7615 device of the file system.
7616
7617 A work-around that allows lsof to apply stat(2) successfully to
7618 cached path names is to give lsof sufficient permission to do
7619 it -- i.e., run lsof as the root user.
7620
762117.25.3 What does "(deleted)" mean in the NAME column of a Solaris 10
7622 open file?
7623
7624 When the -X option is specified to Solaris 10 lsof, it will
7625 report in its NAME column the path name cached for a deleted
7626 file in its vnode. The path name will be followed by
7627 "(deleted)".
7628
7629 Note that the path name cached in a file's vnode is the path
7630 name by which the file was opened. It is not updated by the
7631 Solaris kernel when any path name component is changed. Hence,
7632 it may not represent the final path name the open file had.
7633
7634 See the answer to the "Why does Solaris 10 lsof sometimes
7635 report the wrong path name?" question for more information on
7636 how changing a path name component affects the correctness of a
7637 what lsof reports.
7638
763917.25.4 What does "(?)" mean in the NAME column of a Solaris 10 open
7640 file?
7641
7642 When lsof encounters a path name cached in the open file's
7643 vnode that stat(2) reports lsof lacks permission to access,
7644 lsof adds "(?)" to the path name reported in the NAME column to
7645 indicate the path name is of questionable accuracy.
7646
7647 See the answers to the "Why does Solaris 10 lsof sometimes
7648 report the wrong path name?" and "Why does Solaris 10 lsof
7649 sometimes report only the mounted-on directory and device?"
7650 questions for more information on why lsof may report a path
7651 name of questionable accuracy.
7652
7653 A work-around that allows lsof to apply stat(2) successfully to
7654 cached path names is to give lsof sufficient permission to do
7655 it -- i.e., run lsof as the root user.
7656
765717.26 Solaris contract file problems
7658
765917.26.1 Why doesn't lsof report size, link count and node number for
7660 Solaris 10 contract files?
7661
7662 Lsof doesn't report size, link count or node number for Solaris
7663 10 contract files because I don't know how to obtain them from
7664 contract file kernel structures.
7665
766617.26.2 Why can't lsof locate a Solaris 10 contract file by path name?
7667
7668 Because lsof can't find the node number of Solaris contract
7669 files, it can't match the device and node numbers it gets from
7670 applying stat(2) to the contract file path name with what it
7671 finds in kernel data.
7672
767317.27 Solaris 10 ZFS probblems
7674
767517.27.1 Why does Configure ask for the location of ZFS header files?
7676
7677 To provide ZFS support when lsof is compiled it needs to have
7678 access to the definitions of ZFS structures used by the kernel.
7679 Those definitions are contained in header files that Sun does
7680 not distribute with Solaris 10.
7681
7682 When the Configure script detects the system might support ZFS
7683 by finding the <sys/fs/zfs.h> header file, it checks for the
7684 required ZFS kernel structure definition header files. When
7685 they are not found, it asks if ZFS support should be included
7686 and if so, with what definitions.
7687
7688 Two sources can be declared for definitions: 1) lsof's internal
7689 ones; or 2) the necessary header files at some location other
7690 than /usr/include/sys.
7691
7692 The necessary header files are:
7693
7694 dmu.h zfs_acl.h zfs_debug.h zfs_rlock.h zil.h
7695 spa.h zfs_context.h zfs_dir.h zfs_vfsops.h zio.h
7696 txg.h zfs_ctldir.h zfs_ioctl.h zfs_znode.h zio_impl.h
7697
7698 The necessary header files might have been obtained, for
7699 example, from the http://src.opensolaris.org Open Solaris
7700 source site. However, the Open Solaris header files might not
7701 be adequate -- see the answer to the "Why don't the Open
7702 Solaris ZFS header files provide correct ZFS kernel structure
7703 definitions?' question for information on why the Open Solaris
7704 ZFS header files might not provide correct ZFS kernel structure
7705 definitions.
7706
7707 The supplied header file path must point to a directory that
7708 contains a sys/ subdirectory where the matching header files
7709 are located -- e.g., if the supplied path is /tmp/zfs, then
7710 /tmp/zfs/sys must contain the necessary header files.
7711
7712 See the answer to the "Why do -h and -v output warn about
7713 possibly inaccurate ZFS kernel structure definitions?" question
7714 for information on the risks associated with using lsof's
7715 internal definitions.
7716
771717.27.2 Why do -h and -v output warn about possibly inaccurate ZFS
7718 kernel structure definitions?
7719
7720 When lsof is configured to use its internal ZFS kernel
7721 structure definitions, there is the chance that the definitions
7722 may be out of date. Hence, an lsof built with them may report
7723 incorrect device numbers, file sizes, node numbers and link
7724 counts.
7725
7726 Please contact me via e-mail at <abe@purdue.edu> for work-around
7727 suggestions. Make sure "lsof" appears in the "Subject:" line so
7728 my e-mail filter won't classify your letter as Spam.
7729
773017.27.3 Why don't the Open Solaris ZFS header files provide correct
7731 ZFS kernel structure definitions?
7732
7733 The Open Solaris ZFS header files may not provide correct ZFS
7734 kernel definitions. An lsof built with them may report
7735 incorrect device numbers, file sizes, node numbers and link
7736 counts.
7737
7738 The definitions may be incorrect because the Open Solaris
7739 header files are not synchronized with any particular Solaris
7740 10 release. Consequently they might contain modifications to
7741 the structures not in the structure definitions used to build
7742 the running kernel. It may be that only Sun has header files
7743 that match the kernel structures of the running Solaris 10
7744 kernel.
7745
7746 Please contact me via e-mail at <abe@purdue.edu> for work-around
7747 suggestions. Make sure "lsof" appears in the "Subject:" line so
7748 my e-mail filter won't classify your letter as Spam.
7749
7750
775117.28 Problems with Solaris 9 and above
7752
775317.28.1 Why does the compiler complain about lgrp_root on Solaris 9
7754 and above?
7755
7756 When compiling lsof on some older Solaris 9 and above systems,
7757 the compiler may report the following error:
7758
7759 /usr/include/sys/lgrp.h", line ...: identifier redeclared: lgrp_root
7760
7761 This error results from a conflict between usage of lgrp_root
7762 in both <sys/lgrp.h> and <sys/lgrp_user.h> when _KMEMUSER or
7763 _KERNEL is #define'd before <sys/lgrp.h> is #include'd.
7764
7765 Later versions of Solaris 9 and above don't have the conflict and
7766 I don't know a test that can be applied in the Configure script
7767 to determine when the conflict will occur.
7768
7769 There is a work-around in .../dialects/sun/machine.h. See the
7770 comments there about lgrp_root and enable the #include of
7771 <sys/lgrp.h> to activate the work-around.
7772
7773 The work-around is disabled because it causes other problems in
7774 Solaris 11, and because it is no longer needed in the versions
7775 of Solaris 9 and 10 to which I have access.
7776
7777
777818.0 Lsof Features
7779
778018.1 Why doesn't lsof doesn't report on /proc entries on my
7781 system?
7782
7783 /proc file system support is generally available only for
7784 BSD, SYSV R4 dialects, and Tru64 UNIX (Digital UNIX, DEC
7785 OSF/1). It's also available for Linux, and Pyramid DC/OSx
7786 and Reliant UNIX.
7787
7788 Even on some SYSV R4 dialects I encountered many problems
7789 while trying to incorporate /proc file system support.
7790 The chief problem is that some vendors don't distribute
7791 the header file that describes the /proc file system node
7792 -- usually called prdata.h.
7793
779418.2 How do I disable the device cache file feature or alter
7795 it's behavior?
7796
7797 To disable the device cache file feature for a dialect,
7798 remove the HASDCACHE definition from the machine.h file of
7799 the dialect's machine.h header file. You can also use
7800 HASDCACHE to change the default prefix (``.lsof'') of the
7801 device cache file.
7802
7803 Be sure you consider disabling the device cache file feature
7804 carefully. Having a device cache file significantly reduces
7805 lsof startup overhead by eliminating a full scan of /dev
7806 (or /devices) once the device cache file has been created.
7807 That full scan also overloads the kernel's name cache with
7808 the names of the /dev (or /devices) nodes, reducing the
7809 opportunity for lsof to find path name components of open
7810 files.
7811
7812 If you're worried about the presence of mode 0600 device
7813 cache files in the home directories of the real user IDs
7814 that execute lsof, consider these checks that lsof makes
7815 on the file before using it:
7816
7817 1. To read the device cache file, lsof must gain
7818 permission from access(2).
7819
7820 2. The device cache file's modes must be 0600 (0644
7821 if lsof is reading a system-wide device cache file)
7822 and its size non-zero.
7823
7824 3. There must be a correctly formatted section count
7825 line at the beginning of the file.
7826
7827 4. Each section must have a header line with a count
7828 that properly numbers the lines in the section.
7829 Legal sections are device, clone, pseudo-device,
7830 and CRC.
7831
7832 5. The lines of a section must have the proper format.
7833
7834 6. All lines are included in a 16 bit CRC, and it is
7835 recorded in a non-checksummed section line at the
7836 end of the file.
7837
7838 7. The checksum computed when the file is read must
7839 match the checksum recorded when the file was
7840 written.
7841
7842 8. The checksum section line must be followed by
7843 end-of-information.
7844
7845 9. Lsof must be able to get matching results from
7846 stat(2) on a randomly chosen entry of the device
7847 section.
7848
7849 For more information on the device cache file, read the
7850 00DCACHE file of the lsof distribution.
7851
785218.2.1 What's the risk with a perverted device cache file?
7853
7854 Even with the checks that lsof makes on the device cache
7855 file, it's conceivable that an intruder could modify it so
7856 it would pass lsof's tests.
7857
7858 The only serious consequence I know of this change is the
7859 removal of a file whose major device number identifies a
7860 socket from some user ID's device cache file. When such
7861 a device has been removed from the device cache file, and
7862 when lsof doesn't detect the removal, lsof may not be able
7863 to identify socket files when executed by the affected user
7864 ID. Only certain dialects are at risk to this attack --
7865 e.g., SCO OpenServer and Solaris 2.x, 7, 8, and 9.
7866
7867 If you're tracking a network intruder with lsof, that could
7868 be important to you. If you suspect that someone has
7869 corrupted the device cache file you're using, I recommend
7870 you use lsof's -Di option to tell it to ignore it and use
7871 the contents of /dev (or /devices) instead; or remove the
7872 device cache file (usually .lsof_hostname, where hostname
7873 is the first component of the host's name returned by
7874 gethostname(2)) from the user ID's home directory and let
7875 lsof create a new one for you.
7876
787718.2.2 How do I put the full host name in a personal device cache file
7878 path?
7879
7880 Lsof constructs the personal device cache file path name
7881 from a format specified in the HASPERSDC #define in the
7882 dialect's machine.h header file. As distributed HASPERSDC
7883 declares the path to be ``.lsof_'' plus the first component
7884 of the host name with the format ``.lsof_%L''.
7885
7886 If you want to change the way lsof constructs the personal
7887 device cache file path name, you can change the HASPERSDC
7888 #define and recompile lsof. If, for example, you #define
7889 HASPERSDC to be ``.lsof_%l'' (note the lower case `l'),
7890 Configure and remake lsof, then the personal device cache
7891 file path will be ``.lsof_'' plus the host name returned
7892 by gethostname(2).
7893
7894 See the 00DCACHE file of the lsof distribution for more
7895 information on the formation of the personal device cache
7896 file path and the use of the HASPERSDC #define.
7897
789818.2.3 How do I put the personal device cache file in /tmp?
7899
7900 Change the HASPERSDC definition in your dialect's machine.h
7901 header file.
7902
7903 When you redefine HASPERSDC, make sure you put at least
7904 one user identification conversion in it to keep separate
7905 the device cache files for each user of lsof. Also give
7906 some thought to including the ``%0'' conversion to define
7907 an alternate path for setuid-root and root processes.
7908
7909 Here's a definition that puts a personal device cache file
7910 in /tmp with the name ``.lsof_login_hostname_pers''.
7911
7912 #define HASPERSDC "/tmp/.lsof_%u_%l_pers"
7913
7914 Thus the /tmp personal device cache file path for login
7915 "abe" on host "lsof.itap.purdue.edu" would be:
7916
7917 /tmp/.lsof_abe_lsof.itap.purdue.edu_pers
7918
7919 You can add the User ID (UID) with the "%U" conversion and
7920 the first host name component with the ``%L'' conversion.
7921
7922 CAUTION: be careful using absolute paths like /tmp lest
7923 lsof processes that are setuid-root or whose real UID is
7924 root be used to exploit some security weakness via /tmp.
7925 Elect instead to add an alternate path for those processes
7926 with the ``%0'' conversion. Here's an extension of the
7927 previous HASPERSDC format for /tmp that declares an alternate
7928 path:
7929
7930 #define HASPERSDC "/tmp/.lsof_%u_%l_pers%0%h/.lsof_%L"
7931
7932 When the lsof process is setuid-root or its real UID is
7933 root, presuming root's home directory is `/' and the host's
7934 name is ``lsof.itap.purdue.edu'', the extended format yields:
7935
7936 /.lsof_vic
7937
793818.3 Why doesn't lsof know about AFS files on my favorite dialect?
7939
7940 Lsof currently supports AFS for these dialects:
7941
7942 AIX 4.1.4 (AFS 3.4a)
7943 Linux 1.2.13 (AFS 3.3)
7944 NEXTSTEP 3.2 (AFS 3.3)
7945 Solaris 2.[56] (AFS 3.4a)
7946
7947 It may recognize AFS files on other versions of these
7948 dialects, but I have no way to test that. Lsof may report
7949 correct information for AFS files on other dialects, but
7950 I can't test that either.
7951
7952 AFS support must be custom crafted for each UNIX dialect
7953 and then tested. If lsof supports your favorite dialect,
7954 but doesn't recognize its AFS files, probably I don't have
7955 access to a test system. If you want AFS support badly
7956 for your dialect, consider helping me do the development
7957 and testing.
7958
795918.3.1 Why doesn't lsof report node numbers for all AFS volume files,
7960 or how do I reveal dynamic module addresses to lsof?
7961
7962 When AFS is implemented via dynamic kernel modules -- e.g.,
7963 in NEXTSTEP -- lsof can't obtain the addresses of AFS
7964 variables in the kernel that it uses to identify AFS vnodes.
7965 It can guess that a vnode is assigned to an AFS file and
7966 it can obtain other information about AFS files, but it
7967 has trouble computing AFS volume node numbers.
7968
7969 To determine node numbers for AFS volumes other than the
7970 root volume, /afs, lsof needs access to a hashed volume
7971 structure pointer table. When it can't find the address
7972 of that table, because AFS support is implemented via
7973 dynamic kernel modules, lsof will return blanks in the
7974 INODE column for AFS volume files. Lsof can identify the
7975 root volume's node number (0), and can compute the node
7976 numbers for all other AFS files.
7977
7978 If you have a name list file that contains the addresses
7979 of the AFS dynamic modules -- e.g., you saved module symbols
7980 when you created a loadable module kernel with modload(8)
7981 by specifying -sym -- lsof may be able to find the kernel
7982 addresses it needs in that file.
7983
7984 Lsof looks up AFS dynamic kernel addresses for these dialects
7985 at these default paths:
7986
7987 NEXTSTEP 3.2 /usr/vice/etc/afs_loadable
7988
7989 A different path to a name list file with AFS dynamic kernel
7990 addresses may be specified with the -A option, when the -A
7991 option description appears in lsof's -h or -? (help) output.
7992
7993 If any addresses appear in the -A name list file that also
7994 appear in the regular kernel name list file -- e.g., /vmunix
7995 -- they must match, or lsof will silently ignore the -A
7996 addresses on the presumption that they are out of date.