Page 1 of 1

Installing LSOF (List Open Files) 4.81

Posted: Sun Dec 14, 2008 6:06 pm
by cah
I was trying to find some ESTABLISHED connections' PIDs and LSOF is a great tool to do so.

I downloaded the latest software (4.81) and tried to configure and compile it.
It can be downloaded from Purdue University at ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/.
However, there are some road blocks.

First, it was saying my compiler (gcc 3.4.6) does not have 64-bit support.

Code: Select all

%Configure solaris
Testing prdata.h for PR_GWINDOWS, using gcc
Testing prdata.h for PR_LDT, using gcc
Testing gcc for 64 bit support

!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!
!                                                       !
! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT  !
! THIS GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT       !
! SOLARIS EXECUTABLES.  LSOF WILL BE CONFIGURED FOR A   !
! 32 BIT KERNEL.                                        !
!                                                       !
!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!
I could still compile it but it would not run after it compiles. It complains:

Code: Select all

%lsof
lsof: WARNING: compiled for Solaris release 5.10; this is .
lsof: FATAL: lsof was compiled for a 32 bit kernel,
      but this machine has booted a 64 bit kernel.
I then tried to get a LSOF package from sunfreeware.com. I checked GCC package first to see what version it has. I found some information from there:

sunfreeware.com
sunfreeware.com wrote: gcc-3.4.6-sol10-x86-local.gz. The GNU C compiler and related programs - installs in /usr/local. This package includes the GNU C, C++, and f77 suites and support files. These gcc packages require the installation of libiconv. It was compiled to use the SUN assembler and loader usually in /usr/ccs/bin if the SUNW developer packages are installed. If you need to do 64-bit compiles, you should use the gcc-3.4.3 that comes with Solaris 10 in /usr/sfw/bin. Please read the details on how this package was createound at Comd which can be fments on gcc 3.4.6 . The Details link below contains information on what is new in 3.4.6. Documentation is in /usr/local/doc/gcc, /usr/local/man, and /usr/local/info. The gcc package is quite large. Some users may have trouble downloading very large files via a browser. These users should try using command line anonymous ftp or perhaps the Sun Download Manager.
After changing the PATH order, I got it to compiled successfully.
This perhaps explains why I was unable to compile MySQL in 64-bit mode too.

Code: Select all

%file lsof
lsof:           ELF 64-bit LSB executable AMD64 Version 1, dynamically linked, not stripped, no debugging information available
When I tried to install it to the server for others to use, I got some other interesting message:

Code: Select all

%make install
(cd lib; make DEBUG="-O" CFGF="-Dsolaris=100000  -DHASPR_LDT -m64 -DHASIPv6 -DHASSOUXSOUA -DHAS_IPCLASSIFIER_H -DHAS_CRED_IMPL_H -DHAS_V_PATH -DHASZONES -DHAS_ZFS=1 -DHASUTMPX -DHAS_VSOCK -DHAS_STRFTIME -DLSOF_VSTR=\"5.10\"")
make[1]: Entering directory `/work/system_apps/lsof_4.81/lsof_4.81_src/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/system_apps/lsof_4.81/lsof_4.81_src/lib'
Constructing version.h
gcc  -Dsolaris=100000  -DHASPR_LDT -m64 -DHASIPv6 -DHASSOUXSOUA -DHAS_IPCLASSIFIER_H -DHAS_CRED_IMPL_H -DHAS_V_PATH -DHASZONES -DHAS_ZFS=1 -DHASUTMPX -DHAS_VSOCK -DHAS_STRFTIME -DLSOF_VSTR=\"5.10\"  -O   -c -o usage.o usage.c
gcc -o lsof  -Dsolaris=100000  -DHASPR_LDT -m64 -DHASIPv6 -DHASSOUXSOUA -DHAS_IPCLASSIFIER_H -DHAS_CRED_IMPL_H -DHAS_V_PATH -DHASZONES -DHAS_ZFS=1 -DHASUTMPX -DHAS_VSOCK -DHAS_STRFTIME -DLSOF_VSTR=\"5.10\"  -O ddev.o dfile.o dmnt.o dnode.o dnode1.o dnode2.o dproc.o dsock.o dstore.o arg.o main.o misc.o node.o print.o proc.o store.o usage.o util.o -L./lib -llsof  -lkvm -lelf -lsocket -lnsl

Please write your own install rule.  Lsof should be installed
setgid to the group that can can read /dev/kmem.  Normally
that is the kmem (SunOS) or sys (Solaris) group.  Your SunOS
install rule actions might look something like this:

  install <options> -m 2755 -g kmem lsof <bin_dest>
  install <options> -m 444 lsof.8 <man_dest>

Your Solaris install rule actions might look something like
this:

  install -[cf] <bin_dest> <options> -m 2755 -g sys lsof
  install -[cf] <man_dest> <options> -m 444 lsof.8

You may have to put additional values in <options>, as required
by the install application in your version of SunOS or Solaris.
You will have to set the appropriate destination for the lsof
executable in <bin_dest>; the appropriate destination for the
man page in <man_dest>.
I had to manually copy the files over and change the permissions.

Code: Select all

cd /usr/local/bin
cp -p /work/system_apps/lsof_4.81/lsof_4.81_src/lsof .
chmod 2755 lsof
chgrp sys lsof

cd /usr/local/man/man8
cp -p /work/system_apps/lsof_4.81/lsof_4.81_src/lsof.8 .
chmod 444 lsof.8
Then, all users can access lsof and its man page.