AIXCompileLsof

How to compile lsof on AIX

Actually, compiling lsof on AIX is quite simple, but the procedure to be followed is different enough to merit its own little entry...

Please note that this valid for AIX 5.3, but the procedure for other AIX versions should be almost the same.

For absolute beginners, let me remind you that "lsof" is a very powerful utility that allows you to list all open files on a UNIX machines (list open files... get it?). This is a very powerful tool for sysadmins when you need to know who has opened what on a busy server. And since everything is a file under UNIX, listing all open files is to know a great deal, indeed.

You may say, why compile lsof? Simply because the lsof RPM package supplied on the AIX Linux/Freeware page does not work!

To compile, all that is needed is to follow the procedure detailed below, the only condition being to install gcc, gmake and gtar before starting this project:

  1. Download the latest version of lsof from its official site. In this example, the latest version was lsof 4.78.
  2. Unpack the archive with the command gtar xvzf lsof.tar.gz, if GNU tar has been installed on your machine.
  3. If GNU Tar is not installed, simply enter gunzip lsof.tar.gz Then, unpack the source code archive itself with the command tar lsof_4.78_src.tar, then change into the directory.
  4. Enter the command ./Configure aixgcc to configure the compilation. This "Configure" (please note the upper-case C) is slightly different from the "GNU configure" in that it is interactive. You can safely reply "yes" to the first question (Inventory) and "no" to the second one (Customizing).
  5. Once "Configure" is done, just enter make or gmake to start compiling. Once this is done, enter ./lsof -h to check the compilation has been performed correctly.
  6. A small quirk of lsof is that it does not have a make install procedure, but installing it is really simple:

Once all this is over, you can enter the command lsof -v and contemplate your success:

    root@galactus$ lsof -v
    lsof version information:
    revision: 4.78
    latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
    latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
    latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
    configuration info: 64 bit kernel
    constructed: mer 8 aoû 14:42:17 DFT 2007
    constructed by and on: root@galactus
    compiler: gcc
    compiler version: 4.0.0
    compiler flags: -DHASIPv6 -DHASSTAT64 -DHAS_JFS2 
                    -I/home/sysadmin/compilation/lsof_4.78/lsof_4.78_src/dialects/aix/aix5
                    -fms-extensions -maix64 -DAIX_KERNBITS=64 -DAIXA=1 -DAIXV=5300 -DLSOF_VSTR="5.3.0.0" -O
    loader flags: -L./lib -llsof
    system info: AIX galactus 3 5 000AE52CD600
    Anyone can list all files.
    /dev warnings are enabled.
    Kernel ID check is enabled.
    Device cache file read-only paths:
    Named via -D: none
    Named in environment variable LSOFDEVCACHE: none
    Personal path format (HASPERSDC): "%h/%p.lsof_%L"
    Modified personal path environment variable: LSOFPERSDCPATH
    LSOFPERSDCPATH value: none
    Personal path: /.lsof_galactus
    Device cache file write paths:
    Named via -D: none
    Named in environment variable LSOFDEVCACHE: none
    Personal path format (HASPERSDC): "%h/%p.lsof_%L"
    Modified personal path environment variable: LSOFPERSDCPATH
    LSOFPERSDCPATH value: none
    Personal path: /.lsof_galactus

I hope this will help someone out there!

What if the compilation fails?

Oh, noes!!

The compilation FAILS!

Usually with this kind of message:

#make

In file included from /usr/include/procinfo.h:49,
from ../dlsof.h:70,
from ../lsof.h:183,
from dvch.c:43:
/usr/include/sys/user.h:385: parse error before `uinfo_t'
/usr/include/sys/user.h:385: warning: no semicolon at end of struct or
union
/usr/include/sys/user.h:386: warning: data definition has no type or
storage class
/usr/include/sys/user.h:559: parse error before `}'
/usr/include/sys/user.h:640: field `ub_user' has incomplete type
/usr/include/sys/user.h:641: sizeof applied to an incomplete type
make: 1254-004 The error code from the last command is 1.


Stop.
make: 1254-004 The error code from the last command is 2.

What to do? What to do? As usual, Murphy's Law strikes when least expected, and, like me, you will probably encounter this problem as you are already under a lot of pressure...

Please note the file that creates the problem is irrelevant: the make error messages, on the other hand, will be the same pretty much every time.

The answer is really simple... update the following packages to their latest versions:

PLEASE NOTE The packages above may not be the latest version for your system, but they are on an AIX 5.3 machine. Please do check the version that apply to your machine, and don't just blindly update the packages listed above!

Once the packages are updated, just follow the procedure detailed above, and you should be all set!

See Also: