./lsof_4.42000755 023074 000012 00000000000 06705147616 013504 5ustar00varadhanstaff000000 000000 ./lsof_4.42/Configure000644 023074 000012 00000231441 06705147606 015433 0ustar00varadhanstaff000000 000000 #!/bin/sh # # Configure -- configure lsof # # See the LSOF_HLP here document for usage. # # See the lsof distribution file 00XCONFIG for information on setting # environment variables for cross-configuring lsof -- e.g., for configuring # for Linux 2.1.42 on a machine running 2.0.30. Marty Leisner # suggested this support and provided the Linux # Configure stanza modifications. # # When configuring for a particular dialect, , this script # requires that the subdirectory ./dialects/ contain a # shell script, named $LSOF_MK, that places its source modules in this # directory. # # $Id: Configure,v 1.71 99/03/29 15:06:40 abe Exp $ #LSOF_DISTRIBKVM may be introduced through the environment to specify the # Sun4 kernel virtual memory type of distrib.cf LSOF_F="ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c dstore.c kernelbase.h machine.h machine.h.old new_machine.h __lseek.s" LSOF_HLP_BASE=./cfghlp. LSOF_HLP=${LSOF_HLP_BASE}$$ #LSOF_LOCALSUFFIX may be introduced through the environment to select a local # version of a Makefile. It is used as a suffix to $LSOF_MKF. LSOF_MK=Mksrc #LSOF_MKC is the dialect's Mksrc create command -- default "ln -s". # LSOF_MKFC may be introduced though the environment to change the name # used for the created make file. if test "X$LSOF_MKFC" = "X" # { then LSOF_MKFC=Makefile fi # } LSOF_LIB=lib LSOF_MKF=Makefile LSOF_LIBMKF=Makefile LSOF_LIBMKFSKEL=Makefile.skel LSOF_VF=version # Make sure no other variable important to Makefile construction is # already set in the environment. # # $AFS_VICE locate of AFS VICE directory (default = /usr/vice) # $LSOF_AFS AFS temporary # $LSOF_AFSV AFS version # $LSOF_AR archive command for making the lsof library # $LSOF_ARCH Unix dialect architecture as a string -- may be # supplied externally # $LSOF_CC C compiler name (may be supplied extermally) # $LSOF_CCV C compiler version (may be supplied externally) # $LSOF_CDIR configuration directory # $LSOF_CFGD depend options # $LSOF_CFGDN depend file name # $LSOF_CFGF C flags -- e.g., -D's # $LSOF_CFGL last lsof library loader flags -- e.g., -l's # $LSOF_CINFO Configure information for LSOF_CINFO in version.h # $LSOF_DEBUG Makefile's DEBUG string # $LSOF_DINC include flags -- -I's # $LSOF_DOC special document (man page) directory path # $LSOF_ERR internal error flag # $LSOF_FCFGL first lsof library loader flags -- e.g., -l's # that must precede $LSOF_LIB # $LSOF_HOST host name (e.g., from uname -n) # $LSOF_INCLUDE directory where header files are found # (default = /usr/include) # $LSOF_LD loader name if not $LSOF_CC # $LSOF_LIB_NO if "N" don't configure the lsof library # $LSOF_LINUX_INCL temporary variable for holding path to Linux # include files # $LSOF_LOCALSUFFIX local suffix for Makefile -- e.g., PUCC for # Purdue University Computing Center's special # Makefile # $LSOF_PL patch level # $LSOF_RANLIB randomizing command for the lsof library # $LSOF_SCRIPT_CALL Customize and Inventory scripts call status # $LSOF_SPMKF Special Makefile name # $LSOF_TMP1 internal temporary # $LSOF_TMP2 internal temporary # $LSOF_TMPC_BASE base name for $LSOF_TMPC # $LSOF_TMPC temporary C source file base name # $LSOF_VERS Unix dialect version as a decimal number -- may # be supplied externally # $LSOF_VSTR Unix dialect version as a string -- may be supplied # externally if test "X$AFS_VICE" = "X" # { then AFS_VICE="/usr/vice" fi # } LSOF_AFS="" LSOF_AFSV="" LSOF_AR="ar cr \${LIB} \${OBJ}" if test "X$LSOF_ARCH" = "X" # { then LSOF_ARCH="" fi # } LSOF_CDIR="" LSOF_CFGD="" LSOF_CFGDN="" LSOF_CFGF="" LSOF_CFGL="" LSOF_CINFO="" LSOF_DEBUG="" LSOF_DOC="" LSOF_ERR="" LSOF_FCFGL="" LSOF_HOST="" if test "X$LSOF_INCLUDE" = "X" # { then LSOF_DINC="" LSOF_INCLUDE="/usr/include" else LSOF_DINC="-I$LSOF_INCLUDE" fi # } LSOF_LD="" LSOF_LIB_NO="" LSOF_LINUX_INCL="" LSOF_PL="" LSOF_RANLIB="ranlib \${LIB}" LSOF_SCRIPT_CALL="yes" LSOF_SPMKF="" LSOF_TMP1="" LSOF_TMP2="" LSOF_TMPC_BASE=./lsof_Configure_tmp_ LSOF_TMPC=${LSOF_TMPC_BASE}$$ if test "X$LSOF_VERS" = "X" # { then LSOF_VERS="" fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR="" fi # } # Make sure the help file is removed before an abnormal exit. trap 'rm -f $LSOF_HLP ${LSOF_TMPC_BASE}*; exit 1' 1 2 3 15 rm -f $LSOF_HLP cat > $LSOF_HLP << LSOF_HLP Usage: Configure : -clean : clean up previous configuration -d|-dialects : display a list of supported dialect versions -h|-help : display help information -n : avoid AFS, customization, and inventory checks (****USE -d TO GET TESTED DIALECT VERSION NUMBERS****): aix|aixgcc : IBM AIX xlc (aix) or gcc (aixgcc) bsdi : BSDI BSD/OS digital_unix|du|decosf : Digital UNIX (nee DEC OSF/1) freebsd : FreeBSD hpux|hpuxgcc : HP-UX cc (hpux) or gcc (hpuxgcc) linux : Linux netbsd : NetBSD nextstep|next|ns|nxt : NEXTSTEP openbsd : OpenBSD openstep|os : OpenStep osr|sco : SCO OpenServer pyramid|pyr : Pyramid DC/OSx and Reliant UNIX ptx : Sequent PTX solaris|solariscc : Solaris gcc (solaris) or cc (solariscc) sunos|sunoscc : SunOS gcc (sunos) or cc (sunoscc) ultrix : Ultrix unixware|uw : SCO UnixWare LSOF_HLP LSOF_TGT="no-target" args=$# while test $args -gt 0 # { do case $1 in # { -clean) if test -r $LSOF_MKFC # { then echo "make -f $LSOF_MKFC clean" make -f $LSOF_MKFC clean else if test -r ${LSOF_LIB}/${LSOF_LIBMKF} # { then echo "(cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF} clean)" (cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF} clean) else if test -r ${LSOF_LIB}/${LSOF_LIBMKF}.skel # { then echo "(cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF}.skel clean)" (cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF}.skel clean) fi # } fi # } fi # } rm -f $LSOF_F $LSOF_HLP $LSOF_MKFC ${LSOF_TMPC_BASE}* echo rm -f $LSOF_F $LSOF_HLP $LSOF_MKFC ${LSOF_TMPC_BASE}* rm -rf AFSHeaders AFSVersion version.h dialects/aix/aix41* echo rm -rf AFSHeaders AFSVersion version.h dialects/aix/aix41* rm -f ${LSOF_HLP_BASE}* cd9660_node.h dialects/uw/uw21/vm/swap.h echo "rm -rf dialects/n+obsd/uvm_include" rm -rf dialects/n+obsd/uvm_include echo "rm -f ${LSOF_HLP_BASE}* cd9660_node.h dialects/uw/uw21/vm/swap.h" rm -f dialects/uw/uw7/vm/swap.h dialects/hpux/hpux_mount.h echo "rm -f dialects/uw/uw7/vm/swap.h dialects/hpux/hpux_mount.h" rm -f dialects/du/du5_sys_malloc.h echo "rm -f dialects/du/du5_sys_malloc.h" rm -f ${LSOF_LIB}/${LSOF_LIBMKF} echo "rm -f ${LSOF_LIB}/${LSOF_LIBMKF}" exit 0 ;; -d|-dialects) if test -r ./00DIALECTS -a -r ./version # { then V=`sed '/VN/s/.ds VN \(.*\)/\1/' version` echo "lsof $V has been *tested* on these UNIX dialect versions:" cat 00DIALECTS echo Although "$V hasn't been tested on other versions of these dialects," echo "it may work. Try \`Configure \` and \`make\` to see." rm -f $LSOF_HLP exit 0 else echo "Can't display UNIX dialect version information:" if test ! -r ./00DIALECTS # { then echo " ./00DIALECTS is inaccessible." fi # } if test ! -r ./version # { then echo " ./version is inaccessible." fi # } rm -f $LSOF_HLP exit 1 fi # } ;; -h|-help) cat $LSOF_HLP rm -f $LSOF_HLP exit 0 ;; -n*) LSOF_SCRIPT_CALL="no" ;; *) if test $LSOF_TGT != no-target # { then echo "Only one dialect may be configured at a time." echo 'Both "$LSOF_TGT" and "$1" were specified.' cat $LSOF_HLP rm -f $LSOF_HLP exit 1 else LSOF_TGT=$1 fi # } ;; esac # } shift args=`expr $args - 1` done # } case $LSOF_TGT in # { no-target) echo "No target dialect was specified." cat $LSOF_HLP rm -f $LSOF_HLP exit 1 ;; # Configure for AIX xlc and AIX gcc. aix|aixgcc) LSOF_RANLIB="@echo \\\\\\\\c" # AIX make doesn't like a null ${RANLIB}. if test "X$LSOF_VSTR" = "X" # { then # If the AIX version isn't pre-defined, determine it. LSOF_TMP1=/usr/bin/oslevel if test -x $LSOF_TMP1 # { then echo "Determining AIX version with $LSOF_TMP1;" echo "this may take a while, depending on your maintenance level." LSOF_VSTR=`$LSOF_TMP1 | sed 's/[^0-9]*\([0-9\.]*\).*/\1/'` echo "$LSOF_TMP1 reports the version is $LSOF_VSTR." else LSOF_VSTR=`uname -rv | awk '{printf "%d.%d.0.0\n",\$2,\$1}'` echo "WARNING: can't execute $LSOF_TMP1; uname -rv reports" echo " the version is $LSOF_VSTR; edit CFGF in Makefile and" echo " lib/Makefile to refine AIXV and LSOF_VSTR." fi # } fi # } if test "X$LSOF_VERS" = "X" # { then LSOF_VERS=`echo $LSOF_VSTR | sed 's/\.//g'` fi # } if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xaixgcc" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` else LSOF_CC=cc fi # } fi # } LSOF_TGT="aix" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then # Prevent use of gcc for AIX below 4.1. if test $LSOF_VERS -lt 4100 # { then echo "********************************************************" echo "* Sorry, but gcc can't be used to compile lsof for AIX *" echo "* versions less than 4.1, because of possible kernel *" echo "* structure alignment differences between it and xlc. *" echo "********************************************************" exit 1 fi # } fi # } LSOF_CFGF="-DAIXV=$LSOF_VERS" # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } # Miscellaneous AIX tests if test -d ${LSOF_INCLUDE}/nfs # { then LSOF_CFGF="$LSOF_CFGF -DHAS_NFS" fi # } echo $LSOF_CC | grep cc | grep -v gcc > /dev/null if test $? -eq 0 -a $LSOF_VERS -ge 4140 # { then LSOF_CFGL="-bnolibpath" fi # } if test -r ${LSOF_INCLUDE}/sys/socket.h # { then grep AF_INET6 ${LSOF_INCLUDE}/sys/socket.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6" fi # } fi # } LSOF_DIALECT_DIR=aix echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then # Do gcc tests. if test $LSOF_VERS -ge 4100 -a $LSOF_VERS -lt 4200 # { then if test "X$AIX_USHACK" = "X" # { then # Compile and run a gcc test program to evaluate the user structure. rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){exit((offsetof(struct user, U_irss) & 0x7) ? 1 : 0);}" >>${LSOF_TMPC}.c echo "Testing user.h with $LSOF_CC" $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x if ! ${LSOF_TMPC}.x # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } rm -f ${LSOF_TMPC}.* else if test "$AIX_USHACK" = "Y" -o "$AIX_USHACK" = "y" # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } fi # } if test ${LSOF_TMP1} -eq 1 # { then echo "Applying gcc AIX 4.1+ user struct alignment hack" rm -rf ./dialects/aix/aix$LSOF_VERS mkdir ./dialects/aix/aix$LSOF_VERS mkdir ./dialects/aix/aix${LSOF_VERS}/sys sed 's/U_irss\[/dummy_for_alignment, U_irss\[/' < ${LSOF_INCLUDE}/sys/user.h > ./dialects/aix/aix${LSOF_VERS}/sys/user.h LSOF_CFGF="$LSOF_CFGF -U_LONG_LONG -I`pwd`/dialects/aix/aix$LSOF_VERS" fi # } fi # } else # Get xlc version number rm -f ${LSOF_TMPC}.* echo "main(){}" > ${LSOF_TMPC}.c echo "Getting version number of ${LSOF_CC};" $LSOF_CC -c ${LSOF_TMPC}.c -I${LSOF_INCLUDE} -o ${LSOF_TMPC}.o -qlist > /dev/null 2>&1 LSOF_CCV=`head -1 ${LSOF_TMPC}.lst | sed 's/\(.**\) ---.*/\1/'` rm ${LSOF_TMPC}.* echo "the version is \"${LSOF_CCV}\"." echo $LSOF_CCV | grep "Version 4" > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -qmaxmem=16384" fi # } fi # } ;; # Configure for BSDI BSD/OS. bsdi) if test "X$LSOF_CC" = "X" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } LSOF_LD="shlicc2" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the BSDI version isn't predefined, determine it. case $LSOF_VSTR in # { 2.0*) LSOF_VERS="20000" ;; 2.1*) LSOF_VERS="20100" ;; 3.0*) LSOF_VERS="30000" ;; 3.1*) LSOF_VERS="30100" ;; 4.0*) LSOF_VERS="40000" ;; *) echo Unknown BSDI release: `uname -r` echo Assuming BSDI 2.0 LSOF_VERS="20000" ;; esac # } fi # } # Test for a legal BSDI version. case $LSOF_VERS in # { 20000|20100|30000|30100|40000) ;; *) echo "Unsupported BSDI version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DBSDIV=$LSOF_VERS" if test -r ${LSOF_INCLUDE}/miscfs/fdesc/fdesc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } LSOF_CFGL="-lrpc -lkvm" LSOF_DIALECT_DIR=bsdi ;; # Configure for Digital UNIX. digital_unix|du|decosf) if test "X$LSOF_DINC" = "X" # { then LSOF_DINC="-I/usr/include" fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Digital UNIX version isn't predefined, determine it. case $LSOF_VSTR in # { V2.0) LSOF_VERS=20000 ;; V3.0) LSOF_VERS=30000 ;; V3.2) LSOF_VERS=30200 ;; ?4.0) LSOF_VERS=40000 ;; ?5.0) LSOF_VERS=50000 ;; *) echo "WARNING: unknown Digital UNIX version; assuming version is 2.0" LSOF_VERS=20000 ;; esac # } fi # } # Do Digital UNIX version specific stuff. case $LSOF_VERS in # { 20000) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" ;; 30000) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" LSOF_TMP2=-DUSELOCALREADDIR ;; 30200) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" LSOF_TMP2=-DUSELOCALREADDIR ;; 40000) LSOF_TMP1="/usr/sys" ;; 50000) LSOF_TMP1="/usr/sys" ;; *) echo "WARNING: unknown Digital UNIX version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } if test "X$DU_SYSDIR" = "X" # { then DU_SYSDIR=$LSOF_TMP1 fi # } LSOF_HOST=`uname -n` if test "X$DU_CDIR" = "X" # { then LSOF_CDIR=`expr $LSOF_HOST : '\([^\.]*\)\..*$'` if test "X$LSOF_CDIR" = "X" # { then LSOF_CDIR=$LSOF_HOST fi # } LSOF_CDIR=`echo $LSOF_CDIR | tr a-z A-Z` else LSOF_CDIR=$DU_CDIR fi # } LSOF_LOOP=1 while test $LSOF_LOOP = 1 # { do if test -d ${DU_SYSDIR}/$LSOF_CDIR # { then echo "Using header files in ${DU_SYSDIR}/$LSOF_CDIR" LSOF_LOOP=0 else cat << .CAT_MARK Please enter the name of the subdirectory in $DU_SYSDIR that contains the configuration files for this host. Usually its name would be $LSOF_CDIR, but that subdirectory doesn't seem to exist. The lsof compilation needs header files specific to this machine's configuration found in that directory. If you can't specify the appropriate configuration subdirectory, quit this Configure step now and generate a proper configuration subdirectory with the kernel generation process. .CAT_MARK echo "$DU_SYSDIR contains:" echo "" ls -CF $DU_SYSDIR echo "" echo -n "Configuration subdirectory name? " read LSOF_CDIR LSOF_EXCESS if test "X$LSOF_CDIR" = "X" -o ! -d ${DU_SYSDIR}/$LSOF_CDIR # { then echo "" echo Cannot access directory ${DU_SYSDIR}/$LSOF_CDIR. fi # } fi # } done # } # Determine the ADVFS file system version. if test "X$DU_ADVFSV" = "X" # { then echo "Determining the ADVFS version -- this will take a while." LSOF_ADVFSV=`/usr/sbin/setld -i | grep "^OSFADVFSBIN[0-9]" | sed 's/\([^ ]*\).*/\1/' | sort -u | tail -1 | sed 's/OSFADVFSBIN//'` else LSOF_ADVFSV=$DU_ADVFSV fi # } case $LSOF_ADVFSV in # { 1*) LSOF_ADVFSV=100 echo "The ADVFS version is 1." ;; 2*) LSOF_ADVFSV=200 echo "The ADVFS version is 2." ;; 3*) LSOF_ADVFSV=300 echo "The ADVFS version is 3." ;; 4*) LSOF_ADVFSV=400 echo "The ADVFS version is 4." ;; 5*) LSOF_ADVFSV=500 echo "The ADVFS version is 5." ;; *) echo "The ADVFS version is unknown; it will be assumed to be 1." LSOF_ADVFSV=100 ;; esac # } LSOF_CFGF="$LSOF_CFGF -DDUV=$LSOF_VERS -DADVFSV=$LSOF_ADVFSV $LSOF_TMP2" if test "X$DU_SYSINC" = "X" # { then DU_SYSINC="/usr/sys/include" fi # } LSOF_DINC="$LSOF_DINC -I${DU_SYSDIR}/$LSOF_CDIR -I$DU_SYSINC" LSOF_CFGL="-lmld" if test "X${DU_SHLIB}" = "X" # { then DU_SHLIB=/usr/shlib fi # } if test -r ${DU_SHLIB}/libmsfs.so # { then nm ${DU_SHLIB}/libmsfs.so | grep tag_to_path > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASTAGTOPATH" LSOF_CFGL="$LSOF_CFGL -lmsfs" fi # } fi # } grep "^struct spec_node {" ${DU_SYSDIR}/include/sys/specdev.h > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASSPECNODE" fi # } # Make du5_sys_malloc.h for DU 5.0 and above. Disable some compiler # warning messages to compensate for errors in DU 5 RPC and XDR # header files. Enable IPv6 handling. if test $LSOF_VERS -ge 50000 # { then LSOF_CFGF="$LSOF_CFGF -msg_disable funcredecl,ptrmismatch" LSOF_TMP1=${LSOF_INCLUDE}/sys/malloc.h if test -r $LSOF_TMP1 # { then LSOF_TMP2=dialects/du/du5_sys_malloc.h rm -f $LSOF_TMP2 echo "#if !defined(MANUFACTURED_DU5_SYS_MALLOC_H)" > $LSOF_TMP2 echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP2 echo "#define MANUFACTURED_DU5_SYS_MALLOC_H" >> $LSOF_TMP2 grep "^#define[ ]MALLOC_NUM_BUCKETS" $LSOF_TMP1 >> $LSOF_TMP2 echo "struct percpukmembuckets {" >> $LSOF_TMP2 sed '1,/^struct percpukmembuckets/d' $LSOF_TMP1 | sed -n '1,/^};/p' >> $LSOF_TMP2 echo "#endif" >> $LSOF_TMP2 LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/du" fi # } # Enable IPv6 for DU 5; check for gethostbyname2(). LSOF_CFGF="$LSOF_CFGF -DHASIPv6" if test -r ${LSOF_INCLUDE}/netdb.h # { then grep -q "gethostbyname2(" ${LSOF_INCLUDE}/netdb.h if test $? -ne 0 # { then grep -q "getipnodebyname" ${LSOF_INCLUDE}/netdb.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNOBYNAME2 -DHASIPNODEBYNAME" else LSOF_CFGF="$LSOF_CFGF -DHASNOBYNAME2" fi # } else LSOF_CFGF="$LSOF_CFGF -DHASBYNAME2" fi # } fi # } fi # } LSOF_DIALECT_DIR=du ;; # Configure for FreeBSD. freebsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the FreeBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.*) LSOF_VERS=100 ;; 2.0-*) LSOF_VERS=200 ;; 2.0.5-*) LSOF_VERS=205 ;; 2.1*) LSOF_VERS=210 ;; 2.2*) LSOF_VERS=220 ;; 3.0*) LSOF_VERS=300 ;; 3.1*) LSOF_VERS=310 ;; 4.0*) LSOF_VERS=400 ;; *) echo Unknown FreeBSD release: `uname -r` echo Assuming FreeBSD 2.x LSOF_CFGL="-lkvm" LSOF_VERS=200 LSOF_N_UNIXV=`/usr/sbin/sysctl -n kern.bootfile` if test "X$LSOF_N_UNIXV" = "X" # { then LSOF_N_UNIXV="/kernel" fi # } ;; esac # } fi # } # Get system CFLAGS from FREEBSD_MAKE_CONF (default=/etc/make.conf). if test "X$FREEBSD_MAKE_CONF" = "X" # { then FREEBSD_MAKE_CONF="/etc/make.conf" fi # } if test -r $FREEBSD_MAKE_CONF # { then LSOF_CFGF=`grep ^CFLAGS= /etc/make.conf | sed 's/CFLAGS=[ ]*\(.*\)/\1/'` LSOF_TMP=1 while test $LSOF_TMP -eq 1 # { do echo $LSOF_CFGF | grep -q -e '-O' if test $? -eq 0 # { then if test "X$LSOF_DEBUG" = "X" then # { LSOF_DEBUG=`echo $LSOF_CFGF | sed 's/.*\(-O[^ $]*\).*/\1/'` fi # } LSOF_CFGF=`echo $LSOF_CFGF | sed 's/\(.*\)-O[^ $]*\(.*\)/\1 \2/' | sed 's/^ *//g' | sed 's/ */ /g' | sed 's/ *$//` else LSOF_TMP=0 fi # } done # } fi # } # Do FreeBSD version-specific stuff. case $LSOF_VERS in # { 100) LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_CFGL="-lutil" LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/freebsd/include" if test "X$FREEBSD_KERNEL" = "X" # { then LSOF_N_UNIXV="/386bsd" else LSOF_N_UNIXV=$FREEBSD_KERNEL fi # } ;; 200|205|210) LSOF_CFGL="-lkvm" ;; 220) LSOF_CFGL="-lkvm" if test -r ${LSOF_INCLUDE}/vm/lock.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH" fi # } ;; 300|310) LSOF_CFGL="-lkvm" if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h # { then LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H" fi # } if test -r ${LSOF_INCLUDE}/vm/lock.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH" fi # } ;; 400) LSOF_CFGL="-lkvm" ;; *) echo "Unsupported FreeBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="$LSOF_CFGF -DFREEBSDV=$LSOF_VERS" if test $LSOF_VERS -lt 200 -a "X$FREEBSD_KERNEL" = "X" # { then if test ! -x $LSOF_N_UNIXV # { then echo "Hmmm -- $LSOF_N_UNIXV doesn't appear to be your kernel file." echo "Please enter the name of the file in / that contains" echo "the kernel for this host. It must be a regular file," echo "not a directory, and must be executable." LSOF_LOOP=1 while test $LSOF_LOOP = 1 # { do echo "" echo "/ contains:" echo "" ls -CF / echo "" echo -n "Kernel file name? " read LSOF_N_UNIXV LSOF_EXCESS LSOF_N_UNIXV="/$LSOF_N_UNIXV" if test ! -d $LSOF_N_UNIXV -a -x $LSOF_N_UNIXV # { then LSOF_LOOP=0 else echo "" echo $LSOF_N_UNIXV is not a regular executable file. fi # } done # } fi # } LSOF_N_UNIXV=`echo $LSOF_N_UNIXV | sed 's#^/*#/#'` LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=$LSOF_N_UNIXV" fi # } LSOF_TMP1=0 if test "X$FREEBSD_SYS" = "X" # { then if test -d /usr/src/sys # { then FREEBSD_SYS=/usr/src/sys else if test -d /sys # { then FREEBSD_SYS="/sys" fi # } fi # } fi # } if test -d ${FREEBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${FREEBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -r ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h # { then rm -f cd9660_node.h grep -q "^#ifdef KERNEL" ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h if test $? -eq 0 # { then ln -s ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h cd9660_node.h else sed -e '/^ \* Prototypes for ISOFS vnode operations/,$c\ \ The ISOFS prototypes were removed by Configure. */' \ < ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h > cd9660_node.h echo "" >> cd9660_node.h fi # } LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="$LSOF_DINC -I/usr/include -I$FREEBSD_SYS" fi # } if test -r ${LSOF_INCLUDE}/netinet/in.h # { then grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6" fi # } fi # } LSOF_DIALECT_DIR=freebsd ;; # Configure for HP-UX and HP-UX gcc. hpux|hpuxgcc) LSOF_CFGL="" LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the HP-UX version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%02d",\$2,\$3}'` fi # } if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xhpuxgcc" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` LSOF_CFGF="-DHAS_CONST" LSOF_DEBUG="-O" else if test "X$HPUX_CCDIR1" = "X" # { then HPUX_CCDIR1="/bin" fi # } if test "X$HPUX_CCDIR2" = "X" # { then HPUX_CCDIR2="/usr/ccs/bin" fi # } if test -x ${HPUX_CCDIR1}/cc # { then LSOF_CC=${HPUX_CCDIR1}/cc else if test -x ${HPUX_CCDIR2}/cc # { then LSOF_CC=${HPUX_CCDIR2}/cc else echo "No executable cc in $HPUX_CCDIR1 or $HPUX_CCDIR2" rm -f $LSOF_HLP exit 1 fi # } fi # } what $LSOF_CC | grep -q Bundled if test $? -eq 0 # { then if test "X$HPUX_LIBC1" = "X" # { then HPUX_LIBC1="/usr/lib" fi # } if test -r ${HPUX_LIBC1}/libc.sl # { then LSOF_FCFGL="-L$HPUX_LIBC -lc" else if test "X$HPUX_LIBC2" = "X" # { then HPUX_LIBC2="/usr/lib" fi # } if test -r ${HPUX_LIBC2}/libc.sl # { then LSOF_FCFGL="-L$HPUX_LIBC2 -lc" fi # } fi # } else LSOF_DEBUG="-O" fi # } fi # } fi # } LSOF_TGT="hpux" LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS" if test $LSOF_VERS -lt 1000 # { then if test "X$HPUX_X25DIR" = "X" # { then HPUX_X25DIR="/etc/conf" else HPUX_X25DIR=$HPUX_X25DIR fi # } if test -r ${HPUX_X25DIR}/x25/x25addrstr.h # { then LSOF_CFGF="$LSOF_CFGF -DHPUX_CCITT" LSOF_DINC="$LSOF_DINC -I$HPUX_X25DIR" fi # } fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_hpux.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } if test $LSOF_VERS -ge 1030 # { then if test "X$HPUX_KERNBITS" = "X" # { then HPUX_KERNBITS=`getconf _SC_KERNEL_BITS` fi # } LSOF_CFGF="$LSOF_CFGF -DHPUXKERNBITS=${HPUX_KERNBITS} -I`pwd`/dialects/hpux/hpux11" if test $HPUX_KERNBITS -eq 64 # { then echo "" echo "*****************************************" echo "* *" echo "* NOTICE! Configuring for 64 bit HP-UX *" echo "* *" echo "*****************************************" echo "" LSOF_CFGF="$LSOF_CFGF +DD64" LSOF_CFGL="$LSOF_CFGL -lelf" LSOF_CINFO="64 bit HP-UX" else LSOF_CINFO="32 bit HP-UX" fi # } LSOF_CFGL="$LSOF_CFGL -lnsl" fi # } # Test for the ipc_ipis member in the ipc_s structure. If it is present, # set HAS_IPC_S_PATCH. if test $LSOF_VERS -eq 1100 # { then if test "X$HPUX_IPC_S_PATCH" = "X" # { then LSOF_TMP=/usr/contrib/bin/q4 if test -x $LSOF_TMP # { then rm -f ${LSOF_TMPC}.out echo "Looking for ipc_ipis with $LSOF_TMP ... \c" echo "fields -c struct ipc_s" | $LSOF_TMP /stand/vmunix > ${LSOF_TMPC}.out 2>&1 if test $? -ne 0 # { then echo "" echo "" echo "!!!ERROR!!! $LSOF_TMP failed and produced the following output." echo "" cat ${LSOF_TMPC}.out HPUX_IPC_S_PATCH=fail else grep ipc_ipis ${LSOF_TMPC}.out > /dev/null 2>&1 if test $? -eq 0 # { then HPUX_IPC_S_PATCH="Y" echo "ipc_s has it." else echo "ipc_s doesn't have it." fi # } fi # } else echo "Can't locate or execute $LSOF_TMP" echo "ls says: \c" ls -ld $LSOF_TMP HPUX_IPC_S_PATCH=fail fi # } if test "X$HPUX_IPC_S_PATCH" = "Xfail" # { then echo "" echo "!!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!" echo "Configure can't use $LSOF_TMP to test the ipc_s" echo "structure for an ipc_ipis member. You must determine that" echo "yourself, report the result as Y or N in the HPUX_IPC_S_PATCH" echo "environment variable, and repeat the Configure step. Consult" echo "the Configure script's use of $LSOF_TMP and the" echo "00XPORTING file for more information on testing for ipc_ipis." echo "!!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!" echo "" exit 1 fi # } fi # } if test "X$HPUX_IPC_S_PATCH" = "XY" -o "X$HPUX_IPC_S_PATCH" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_IPC_S_PATCH" fi # } fi #} # Manufacture an hpux_mount.h header file with a mount struct in it, as # required. if test -r ${LSOF_INCLUDE}/sys/mount.h # { then LSOF_TMP1=dialects/hpux/hpux_mount.h rm -f $LSOF_TMP1 echo "#if !defined(MANUFACTURED_HPUX_SYS_MOUNT_H)" > $LSOF_TMP1 echo "#define MANUFACTURED_HPUX_SYS_MOUNT_H" >> $LSOF_TMP1 echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP1 echo "struct mount" >> $LSOF_TMP1 sed '1,/struct mount/d' ${LSOF_INCLUDE}/sys/mount.h | sed -n '1,/m_dev/p' >> $LSOF_TMP1 echo "};" >> $LSOF_TMP1 echo "#endif" >> $LSOF_TMP1 LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/hpux" fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } LSOF_DIALECT_DIR=hpux ;; # Configure for Linux. linux) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } LSOF_DIALECT_DIR="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Linux version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\./ /g' | awk '{printf "%d%d%03d",\$1,\$2,\$3}'` fi # } LSOF_CFGF="-DLINUXV=$LSOF_VERS" # Test the extent of Linux /proc support. if test "X$LINUX_BASE" = "X" # { then LINUX_BASE="/dev/kmem" if test -d /proc/self/fd # { then ls -l /proc/self/fd | grep "/proc/[0-9][0-9]*/fd" > /dev/null if test $? -eq 0 # { then LINUX_BASE="/proc" fi # } fi # } fi # } # Check for a legal LINUX_BASE value. if test "X$LINUX_BASE" != "X/dev/kmem" -a "X$LINUX_BASE" != "X/proc" # { then echo "Unknown LINUX_BASE value: $LINUX_BASE" exit 1 fi # } if test "$LINUX_BASE" = "/proc" # { then # Configure /proc-based Linux lsof. LSOF_DIALECT_DIR="linux/proc" echo "Configuring /proc-based Linux lsof" LSOF_CINFO="/proc-based" if test $LSOF_VERS -lt 2172 # { then echo "" echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!" echo "! !" echo "! THE /PROC-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON !" echo "! LINUX KERNELS BELOW 2.1.72, AND MAY NOT WORK ON THIS !" echo "! KERNEL. IT SHOULD USE A /DEV/KMEM-BASED LSOF. IF YOU !" echo "! ARE UNCERTAIN ABOUT THE STATUS OF YOUR /PROC, CONTACT !" echo "! ME FOR ADVICE. !" echo "! !" echo "! Vic Abell !" echo "! !" echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!" echo "" fi # } fi # } if test "$LINUX_BASE" = "/dev/kmem" # { then # Configure /dev/kmem-based Linux lsof. LSOF_DIALECT_DIR=linux/kmem LSOF_CINFO="/dev/kmem-based" echo "Configuring /dev/kmem-based Linux lsof" if test $LSOF_VERS -ge 21072 # { then echo "" echo "!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!" echo "! !" echo "! THE /DEV/KMEM-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON !" echo "! LINUX KERNELS ABOVE 2.1.72, AND MAY NOT WORK ON THIS !" echo "! KERNEL. THIS KERNEL SHOULD USE A /PROC-BASED LSOF. !" echo "! IF FILES IN /PROC/FD/... DON'T HAVE NAMES, BUT A NUMBER !" echo "! FOLLOWING ''-> ['', THE /PROC FILE SYSTEM OF THIS KERNEL !" echo "! MAY BE MISCONFIGURED. CONTACT ME FOR ASSISTANCE. !" echo "! !" echo "! Vic Abell !" echo "! !" echo "!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!" echo "" fi # } # If the Linux kernel directory isn't pre-defined, set its default. # If the Linux kernel include directory isn't pre-defined, set its # default. if test "X$LINUX_KERNEL" = "X" # { then LINUX_KERNEL="/usr/src/linux" fi # } LSOF_LINUX_INCL=${LINUX_KERNEL}/include/linux # If the Linux C library type isn't predefined, determine it. if test "X$LINUX_CLIB" = "X" # { then echo -n "Testing C library type with $LSOF_CC ... " rm -f ${LSOF_TMPC}.* echo "#include " > $LSOF_TMPC.c echo "main(){" >> $LSOF_TMPC.c echo "#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)" >> $LSOF_TMPC.c echo "printf(\"-DGLIBCV=%d\\n\",__GLIBC__*100+__GLIBC_MINOR__);" >> $LSOF_TMPC.c echo "#elif defined(__GLIBC__)" >> $LSOF_TMPC.c echo "printf(\"-DGLIBCV=%d00\\n\",__GLIBC__);" >> $LSOF_TMPC.c echo "#else" >> $LSOF_TMPC.c echo "printf(\"\\n\");" >> $LSOF_TMPC.c echo "#endif" >> $LSOF_TMPC.c echo "return(0); }" >> $LSOF_TMPC.c $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 if test -x ${LSOF_TMPC}.x # { then LINUX_CLIB=`${LSOF_TMPC}.x` LSOF_TMP=$? else LINUX_CLIB="" LSOF_TMP=1 fi # } rm -f ${LSOF_TMPC}.* echo "done" if test $LSOF_TMP -ne 0 # { then echo "Cannot determine C library type; assuming it is not glibc." LINUX_CLIB="" else if test "X$LINUX_CLIB" = "X" # { then echo "The C library type is not glibc." else echo "The C library type is glibc, version \"$LINUX_CLIB\"." fi # } fi # } fi # } if test "X$LINUX_CLIB" != "X" # { then LSOF_CFGF="$LSOF_CFGF $LINUX_CLIB" fi # } # Test Linux socket support. if test -r ${LINUX_KERNEL}/net/inet/sock.h # { then LSOF_TMP1="net/inet/sock.h" else if test -r ${LINUX_KERNEL}/include/net/sock.h # { then LSOF_TMP1="include/net/sock.h" LSOF_DINC="$LSOF_DINC -I${LINUX_KERNEL}/include" else echo "WARNING: cannot find ${LINUX_KERNEL}/net/inet/sock.c or" echo " ${LINUX_KERNEL}/include/net/sock.c. Lsof may fail to" echo " compile, or it it compiles, it may fail to identify" echo " socket files correctly. Does this machine have the" echo " Linux kernel source and header files in ${LINUX_KERNEL}?" echo " If it does not, you probably cannot build lsof." LSOF_TMP1="" fi # } fi # } if test "X$LSOF_TMP1" != "X" # { then grep protinfo ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then grep unix_address ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASUNMINSOCK=1" else LSOF_CFGF="$LSOF_CFGF -DHASUNMINSOCK=0" fi # } fi # } grep "ax25_cb[ ]*\*ax25;" ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASAX25CBPTR" fi # } fi # } grep '*sk;' ${LSOF_LINUX_INCL}/net.h > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_SOCKET_SK" fi # } if test -r ${LSOF_LINUX_INCL}/netdevice.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNETDEVICE_H" fi # } # Test the Linux kernel loader format. if test -r ${LSOF_LINUX_INCL}/autoconf.h # { then egrep "^#define[ ]*CONFIG_KERNEL_ELF" ${LSOF_LINUX_INCL}/autoconf.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DKERN_LD_ELF" fi # } fi # } # Test Linux lock support. if test -r ${LSOF_LINUX_INCL}/fs.h # { then grep fl_fd ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_FD" fi # } grep fl_file ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_FILE" fi # } grep fl_whence ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_WHENCE" fi # } fi # } # Test for Linux atomic lock support. if test -r ${LINUX_KERNEL}/include/asm/atomic.h # { then grep "typedef struct .* atomic_t;" ${LINUX_KERNEL}/include/asm/atomic.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_ATOMIC_T" fi # } fi # } # Test for Linux query_module() support. if test -r ${LINUX_KERNEL}/include/asm/unistd.h # { then grep __NR_query_module ${LINUX_KERNEL}/include/asm/unistd.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_QUERY_MODULE" fi # } fi # } # Test Linux kernel lseek() support. if test $LSOF_VERS -ge 21000 # { then if test "X$LINUX_LSEEK" = "X" # { then echo "Testing lseek() with $LSOF_CC" rm -f ${LSOF_TMPC}.* echo '#include ' > ${LSOF_TMPC}.c echo '#include ' >> ${LSOF_TMPC}.c echo '#include ' >> ${LSOF_TMPC}.c echo 'main() { int f;' >> ${LSOF_TMPC}.c echo 'if((f=open("/dev/kmem",O_RDONLY,0600))<0)exit(1);' >> ${LSOF_TMPC}.c echo 'if(lseek(f,(off_t)-4097,SEEK_CUR)==-1)exit(2);' >> ${LSOF_TMPC}.c echo 'exit(0);}' >> ${LSOF_TMPC}.c $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x ${LSOF_TMPC}.x LSOF_TMP=$? case $LSOF_TMP in # { 0) echo "Lseek() is OK." ;; 1) echo "Configure for Linux 2.[12].x needs read permission to" echo "/dev/kmem in order to test lseek() on it." rm -f ${LSOF_TMPC}.* $LSOF_HLP exit 1 ;; 2) echo "Lseek() is suspect; using private __lseek.s." LSOF_SPMKF="Makefile.lseek" ;; *) echo "Unexpected return of $LSOF_TMP from lseek() test program, ${LSOF_TMPC}.c" rm -f $LSOF_HLP exit 1 ;; esac # } rm -f ${LSOF_TMPC}.* else if test "X$LINUX_LSEEK" = "XY" -o "X$LINUX_LSEEK" = "Xy" # { then LSOF_SPMKF="Makefile.lseek" fi # } fi # } fi # } # Test for Linux PID hashing support. grep pidhash_next ${LSOF_LINUX_INCL}/sched.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASHASHPID" fi # } # Test for Linux dcache structure. if test -r ${LSOF_LINUX_INCL}/dcache.h # { then grep "^struct dentry {" ${LSOF_LINUX_INCL}/dcache.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASDENTRY" fi # } fi # } # Test for Linux __kernel_key_t type. grep __kernel_key_t ${LSOF_INCLUDE}/linux/types.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNELKEYT" fi # } # Test for the presence of (for Alpha). if test -r ${LSOF_INCLUDE}/asm/termiobits.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_ASM_TERMIOBITS" fi # } fi # } ;; # Configure for NetBSD. netbsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the NetBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.0*) LSOF_VERS="1000" ;; 1.1*) LSOF_VERS="1010" ;; 1.2*) LSOF_VERS="1020" ;; 1.3*) LSOF_VERS="1030" ;; *) echo Unknown NetBSD release: `uname -r` echo Assuming NetBSD 1.0 LSOF_VERS="1000" ;; esac # } fi # } # Test for legal NetBSD version. case $LSOF_VERS in # { 1000|1010|1020|1030) ;; *) echo "Unsupported NetBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DNETBSDV=$LSOF_VERS" if test -r ${LSOF_INCLUDE}/nfs/nfsproto.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO" fi # } LSOF_TMP1=0 if test "X$NETBSD_SYS" = "X" # { then NETBSD_SYS="/sys" fi # } if test -d ${NETBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${NETBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -d ${NETBSD_SYS}/isofs/cd9660 # { then LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" LSOF_TMP1=1 fi # } if test -r ${NETBSD_SYS}/miscfs/kernfs/kernfs.h # { then grep -q "kt_name;" ${NETBSD_SYS}/miscfs/kernfs/kernfs.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNFS" LSOF_TMP1=1 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="-I$LSOF_INCLUDE -I$NETBSD_SYS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } grep -q i_ffs_size ${LSOF_INCLUDE}/ufs/ufs/inode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASI_FFS" fi # } grep -q VT_EXT2FS ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS" grep -q i_e2fs_size ${LSOF_INCLUDE}/ufs/ufs/inode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASI_E2FS" fi # } fi # } if test -r ${LSOF_INCLUDE}/nfs/nfsnode.h # { then grep -q "*n_vattr" ${LSOF_INCLUDE}/nfs/nfsnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSVATTRP" fi # } fi # } if test "X$NETBSD_UVM" = "X" # { then if test -r /etc/mk.conf # { then grep -q "^UVM[ ]*=" /etc/mk.conf if test $? -eq 0 # { then NETBSD_UVM="Y" fi # } fi # } if test "X$NETBSD_UVM" = "X" # { then if test -r ${LSOF_INCLUDE}/sys/vnode.h # { then grep -q UVM ${LSOF_INCLUDE}/sys/vnode.h if test $? -ne 0 # { then grep -q "v_uvm;" ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then NETBSD_UVM="Y" fi # } fi # } fi # } fi # } fi # } rm -rf dialects/n+obsd/uvm_include if test "X$NETBSD_UVM" = "XY" -o "X$NETBSD_UVM" = "Xy" # { then mkdir dialects/n+obsd/uvm_include touch dialects/n+obsd/uvm_include/opt_uvmhist.h touch dialects/n+obsd/uvm_include/opt_lockdebug.h LSOF_CFGF="$LSOF_CFGF -DUVM -I`pwd`/dialects/n+obsd/uvm_include" fi # } if test -r ${LSOF_INCLUDE}/netinet/in.h # { then grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6" fi # } fi # } LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=/netbsd" LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=n+obsd ;; # Configure for NeXTSTEP or OpenStep. nextstep|next|ns|nxt|openstep|os) LSOF_AR="rm -f \${LIB}; $LSOF_AR" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'` fi # } if test "X$LSOF_VERS" = "X" # { then # If the NeXSTEP version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed -n 's/\([0-9]*\)\.\([0-9]*\)/\1\2/p'` fi # } if test "X$LSOF_CC" = "X" # { then if test -x /usr/local/bin/gcc # { then LSOF_CC=/usr/local/bin/gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` else LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } fi # } echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then LSOF_CFGL="-w" else LSOF_CFGL="" fi # } LSOF_CFGF="-DSTEPV=$LSOF_VERS" LSOF_DIALECT_DIR=n+os # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } ;; # Configure for OpenBSD. (OpenBSD uses NetBSD dialect sources and version # numbering. openbsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the OpenBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.2*) LSOF_VERS=1020 ;; 2.0*) LSOF_VERS=2000 ;; 2.1*) LSOF_VERS=2010 ;; 2.2*) LSOF_VERS=2020 ;; 2.3*) LSOF_VERS=2030 ;; 2.4*) LSOF_VERS=2040 ;; 2.5*) LSOF_VERS=2050 ;; *) echo Unknown OpenBSD release: `uname -r` echo Assuming OpenBSD 1.2 LSOF_VERS=1020 ;; esac # } fi # } # Test for legal OpenBSD version. case $LSOF_VERS in # { 1020|2000|2010|2020|2030|2040|2050) ;; *) echo "Unsupported OpenBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DOPENBSDV=$LSOF_VERS -DN_UNIXV=/bsd" if test -r ${LSOF_INCLUDE}/nfs/nfsproto.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO" fi # } LSOF_TMP1=0 if test "X$OPENBSD_SYS" = "X" # { then OPENBSD_SYS="/sys" fi # } if test -d ${OPENBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${OPENBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -d ${OPENBSD_SYS}/isofs/cd9660 # { then LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" LSOF_TMP1=1 fi # } if test -r ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h # { then grep -q "kt_name;" ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNFS" LSOF_TMP1=1 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="-I$LSOF_INCLUDE -I$OPENBSD_SYS" fi # } grep -q VT_EXT2FS ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=n+obsd ;; # Configure for Pyramid DC/OSx and Reliant UNIX. pyramid|pyr) # Establish C compiler, its version, and its options. if /bin/test "X$LSOF_CC" = "X" # { then LSOF_CC=/usr/ccs/bin/cc LSOF_CCV="`$LSOF_CC -V 2>&1 | head -1`" fi # } LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if /bin/test ! -x dialects/pyramid/MkKernOpts # { then /bin/echo "Can't execute dialects/pyramid/MkKernOpts" rm -f $LSOF_HLP exit 1 fi # } LSOF_CFGF="`LSOF_CCV=$LSOF_CCV dialects/pyramid/MkKernOpts`" /bin/echo $LSOF_CFGF | /usr/bin/egrep -e -Klp64 > /dev/null if /bin/test $? -eq 0 # { then # Compile a test program to see if -Klp64 is supported. rm -f ${LSOF_TMPC}.* echo "main(){}" > ${LSOF_TMPC}.c echo "Testing $LSOF_CC for -Klp64 support" $LSOF_CC -Klp64 ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x if /bin/test $? -ne 0 # { then rm -f ${LSOF_TMPC}.* echo "$LSOF_CC doesn't support -Klp64. Consult 00FAQ." exit 1 fi # } rm -f ${LSOF_TMPC}.* echo "$LSOF_CC supports -Klp64." fi # } # Do miscellaneous feature tests, based on their supporting header files. if /bin/test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/fs/tfs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASTFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/fs/objfs/obj_fs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASOBJFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/mipc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASMIPCH" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/dnlc.h # { then /bin/grep "name;" ${LSOF_INCLUDE}/sys/dnlc.h > /dev/null if /bin/test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASDNLCPTR" fi # } fi # } LSOF_CFGL="-lsocket -lnsl -lelf" LSOF_DIALECT_DIR=pyramid ;; # Configure for Sequent PTX. ptx) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -v` fi # } if test "X$LSOF_VERS" = "X" # { then # If the PTX version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%d%d",substr($1,2), $2, $3}'` fi # } if test $LSOF_VERS -ge 400 # { then # PTX 4.x tests if test "X$PTX_CONF" = "X" # { then PTX_CONF="/usr/conf/uts" fi # } if test $LSOF_VERS -lt 410 # { then LSOF_CFGL="-lrpc -lelf -linet -lnsl -lseq" else if test $LSOF_VERS -lt 423 # { then LSOF_CFGL="-lrpc -lelf -lnsl -lseq -lsocket" else LSOF_CFGL="-lelf -lnsl -lseq -lsocket" fi # } fi # } if test -r ${PTX_CONF}/nfs/rnode.h # { then LSOF_CFGF="-DHAS_NFS" fi # } # PTX 4.x TCP version tests. if test "X$PTX_TCPV" = "X" # { then if test "X$PTX_TCP_NAME" = "X" # { then PTX_TCP_NAME="/usr/options/tcp/tcp.name" fi # } if test -r $PTX_TCP_NAME # { then PTX_TCPV=`cat ${PTX_TCP_NAME} | awk '{print $2}' | awk -F. '{printf "%d%d%d",substr($1,2), $2, $3}'` fi # } fi # } else # PTX 2.x tests if test -r ${LSOF_INCLUDE}/nfs/rnode.h # { then LSOF_CFGF="-DHAS_NFS" fi # } LSOF_CFGL="-lrpc -linet -lnsl -lseq" fi # } # Guarantee a TCP version, even if it's zero. Add the PTX and TCP # versions to the Makefile's configuration flags. if test "X$PTX_TCPV" = "X" # { then PTX_TCPV="0" fi # } LSOF_CFGF="-DPTXV=$LSOF_VERS -DTCPV=$PTX_TCPV $LSOF_CFGF" # Check for PTX CDROM node header file. if test -r ${LSOF_INCLUDE}/sys/cdfsinode.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_CDFS" fi # } # Check for PTX inp_addr structure. if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h # { then grep "inp_laddr;" ${LSOF_INCLUDE}/netinet/in_pcb.h | grep struct > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASINADDRSTR" fi # } fi # } # Test PTX VxFS status. if test -r ${LSOF_INCLUDE}/sys/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" if test -r ${LSOF_INCLUDE}/sys/vx_dnlc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFSDNLC" fi # } fi # } LSOF_DIALECT_DIR=ptx ;; # Configure for SCO OpenServer. osr|sco) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR="`LANG=C_C.C uname -X 2>/dev/null | grep Release | sed 's/Release = \(.*\)/\1/'`" fi # } if test "X$LSOF_VERS" = "X" # { then # If the SCO OpenServer release version isn't predefined, determine it. case $LSOF_VSTR in # { 3.2v2.0) LSOF_VERS="20" ;; 3.2v2.1) LSOF_VERS="21" ;; 3.2v4.0) LSOF_VERS="40" ;; 3.2v4.1) LSOF_VERS="41" ;; 3.2v4.2) LSOF_VERS="42" ;; 3.2v5.0.*) LSOF_VERS="`echo $LSOF_VSTR | sed 's/3\.2v//; s/\.//g'`" ;; *) echo Unknown SCO OpenServer release: `uname -X | grep Release` echo Assuming 3.2.0 or 3.2.1 LSOF_VERS="0" ;; esac # } fi # } # Do SCO OpenServer specific stuff. case $LSOF_VERS in # { 0) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 20) LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 21) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 40) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 41) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 42) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 5*) LSOF_CFGF="-belf" LSOF_CFGL="-lsocket" LSOF_DEBUG="-O3 -Kspace" ;; *) echo "Unsupported SCO OpenServer release: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DOSRV=$LSOF_VERS $LSOF_CFGF" if test "X$OSR_STATLSTAT" = "X" # { then echo "Testing libc.a for statlstat" /bin/nm /lib/libc.a | grep statlstat > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT" fi # } else if test "X$OSR_STATLSTAT" = "XY" -o "X$OSR_STATLSTAT" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT" fi # } fi # } if test -r ${LSOF_INCLUDE}/sys/fs/nfs/rnode.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_NFS" fi # } if test ! -r ${LSOF_INCLUDE}/netdb.h # { then LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/osr/include" fi # } LSOF_DIALECT_DIR=osr ;; # Configure for Sun Solaris, SunPro C and gcc. solaris|solariscc) LSOF_RANLIB="" if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xsolariscc" # { then if test "X$SOLARIS_CCDIR" = "X" # { then SOLARIS_CCDIR="/opt/SUNWspro/bin" fi # } if test -x ${SOLARIS_CCDIR}/cc # { then LSOF_CC=${SOLARIS_CCDIR}/cc else echo "WARNING: no cc in ${SOLARIS_CCDIR}; using cc without path." LSOF_CC=cc fi # } LSOF_CCV=`$LSOF_CC -V 2>&1 | sed -n 's/^cc: \(.*\)/\1/p'` else LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } fi # } LSOF_TGT="solaris" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Solaris version isn't predefined, determine it. case $LSOF_VSTR in # { 5.[0-2]) LSOF_VERS="20300" ;; 5.3) LSOF_VERS="20300" ;; 5.4) LSOF_VERS="20400" ;; 5.5) LSOF_VERS="20500" ;; 5.5.1) LSOF_VERS="20501" ;; 5.6*) LSOF_VERS="20600" ;; 5.7*) LSOF_VERS="70000" ;; *) echo Unknown Solaris version: $LSOF_VSTR rm -f $LSOF_HLP exit 1 esac # } fi # } # Do Solaris version-specific stuff. case $LSOF_VERS in # { 20300) # Solaris patch 101318-32 creates a longer kernel tcp_s structure, # and 101318-45 changes the way the vnode's v_filocks member is # handled. The following code creates a symbol definition for # patch 101318 whose value is the patch level. No symbol is defined # if the patch level is not greater than zero. if test "X$SOLARIS_23P101318" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=101318 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_23P101318 fi # } if test $LSOF_PL -gt 0 # { then LSOF_CFGF="-DP101318=$LSOF_PL" fi # } ;; 20400) if test "X$SOLARIS_24P101945" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=101945 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_24P101945 fi # } if test $LSOF_PL -ge 32 # { then if test "X$SOLARIS_24P102303" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=102303 /var/sadm/pkg/SUNWhea*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_24P102303 fi # } if test $LSOF_PL -ge 2 # { then echo "WARNING: your Solaris 2.4 system appears to have patches 101945-32 and 102303-2" echo " installed. This probably means the NUM_*_VECTORS definitions in" echo " don't match the ones used to build your kernel. Consult" echo " the Sun Problems section of the 00FAQ file of the lsof distribution" echo " for an explanation of the work-around being supplied by including" echo " the header file ./dialects/sun/include/sys/auxv.h." LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/sun/include" fi # } fi # } ;; 20500|20501) ;; 20600|70000) if test "X$SOLARIS_26PR_GWINDOWS" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#define _KMEMUSER" > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum prnodetype p=PR_GWINDOWS;}" >> ${LSOF_TMPC}.c echo "Testing prdata.h for PR_GWINDOWS, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS" fi # } else if test "X$SOLARIS_26PR_GWINDOWS" = "XY" -o "X$SOLARIS_26PR_GWINDOWS" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS" fi # } fi # } if test "X$SOLARIS_26PR_LDT" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#define _KMEMUSER" > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum prnodetype p=PR_LDT;}" >> ${LSOF_TMPC}.c echo "Testing prdata.h for PR_LDT, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SOLARIS_26PR_LDT" = "XY" -o "X$SOLARIS_26PR_LDT" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT" fi # } fi # } if test $LSOF_VERS -eq 70000 # { then if test "X$SOLARIS_27KERNBITS" = "X" # { then SOLARIS_27KERNBITS=`/bin/isainfo -kv` fi # } echo $SOLARIS_27KERNBITS | grep 64 > /dev/null if test $? -eq 0 # { then echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then echo "" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "! !" echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT |" echo "! GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT SOLARIS 2.7 !" echo "! EXECUTABLES. LSOF WILL BE CONFIGURED FOR A 32 BIT !" echo "! KERNEL. !" echo "! !" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "" else LSOF_TMP1=`echo $LSOF_CCV | sed -n 's/[^0-9]*\([0-9]\)\..*/\1/p'` if test "X$LSOF_TMP1" = "X" # { then LSOF_TMP1="0" fi # } if test $LSOF_TMP1 -ge 5 # { then LSOF_CFGF="$LSOF_CFGF -xarch=v9" echo "" echo "*********************************" echo "* Configuring for 64 bit kernel *" echo "*********************************" echo "" LSOF_CINFO="64 bit kernel" else echo "" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "! !" echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT |" echo "! THE VERSION OF SUN C AVAILABLE DOESN'T SUPPORT THE !" echo "! -xarch=v9 FLAG. LSOF WILL BE CONFIGURED FOR A 32 BIT !" echo "! KERNEL. !" echo "! !" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "" fi # } fi # } else echo "" echo "*********************************" echo "* Configuring for 32 bit kernel *" echo "*********************************" echo "" LSOF_CINFO="32 bit kernel" fi # } fi # } ;; *) echo "Unsupported Solaris version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-Dsolaris=$LSOF_VERS $LSOF_CFGF" # Test for VSOCK. if test "X$SOLARIS_VSOCK" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c echo "Testing vnode.h for VSOCK, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SOLARIS_VSOCK" = "XY" -o "X$SOLARIS_VSOCK" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then if test "X$SUN_AFSAPATHDEF" = "X" # { then ls /usr/vice/etc/modload/libafs > /dev/null 2>&1 if test $? -ne 0 # { then LSOF_TMP1=`ls /usr/vice/etc/modload/libafs* 2>/dev/null | wc -l` if test $LSOF_TMP1 -ne 0 # { then SUN_AFSAPATHDEF=`ls /usr/vice/etc/modload/libafs*` fi # } fi # } fi # } if test "X$SUN_AFSAPATHDEF" != "X" # { then LSOF_CFGF="$LSOF_CFGF -DAFSAPATHDEF=\\\"$SUN_AFSAPATHDEF\\\"" fi # } LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } # Test for VxFS. if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" if test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_FS_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_sol.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOL_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_machdep.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_MACHDEP_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_solaris.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOLARIS_H" grep "off32_t;" ${LSOF_INCLUDE}/sys/fs/vx_machdep.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF32_T" fi # } grep "off64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF64_T" fi # } grep "vx_u64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_U64_T" fi # } fi # } egrep "struct[ ]vx_inode[ ]\{" ${LSOF_INCLUDE}/sys/fs/vx_inode.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_VX_INODE" fi # } fi # } # Set libraries and dialect subdirectory. LSOF_CFGL="-lkvm -lelf -lsocket -lnsl" LSOF_DIALECT_DIR=sun # Set PUCC-specific stuff. if test "X$LSOF_LOCALSUFFIX" = "XPUCC" # { then LSOF_DOC="\${DESTDIR}/usr/local/man" fi # } ;; # Configure for SunOS 4.1.x, Sun C and gcc. sunos|sunoscc) if test "X$LSOF_CC" = "X" # { then # See if a compiler is impled by the target name. If a Sun C compiler # is implied, find it. if test "X$LSOF_TGT" = "Xsunos" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` LSOF_CFGF="-ansi" else if test "X$SUNOS_ACC" = "X" # { then SUNOS_ACC="/usr/lang" fi # } if test -x ${SUNOS_ACC}/acc # { then LSOF_CC=${SUNOS_ACC}/acc else LSOF_CC=cc fi # } fi # } fi # } LSOF_TGT="sunos" echo $LSOF_CC | grep gcc > /dev/null if test $? -ne 0 # { then # See if the Sun C compiler supports the const keyword. if test "X$SUNOS_NOCONST" = "X" # { then rm -f ${LSOF_TMPC}.* echo "main() { const x; }" > ${LSOF_TMPC}.c echo "Testing $LSOF_CC for const support" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC -c ${LSOF_TMPC}.c -o ${LSOF_TMPC}.o > /dev/null 2>&1 else $LSOF_CC -c ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.o > /dev/null 2>&1 fi # } if test $? -ne 0 # { then LSOF_CFGF="-DNOCONST" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SUNOS_NOCONST" = "XY" -o "X$SUNOS_NOCONST" = "Xy" # { then LSOF_CFGF="-DNOCONST" fi # } fi # } fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_ARCH" = "X" # { then LSOF_ARCH=`uname -m` fi # } if test "X$LSOF_VERS" = "X" # { then # If SunOS version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/' | awk -F. '{printf "%d%02d%02d", $1, $2, $3}'` fi # } LSOF_CFGF="$LSOF_CFGF -DSUNOSV=$LSOF_VERS" LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=sun if test "X$LSOF_LOCALSUFFIX" = "XPUCC" # { then LSOF_DOC="\${DESTDIR}/usr/man" fi # } # Test for VSOCK. if test "X$SUNOS_VSOCK" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c echo "Testing vnode.h for VSOCK, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SUNOS_VSOCK" = "XY" -o "X$SUNOS_VSOCK" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } ;; # Configure for DEC Ultrix. ultrix) LSOF_CFGF="-Olimit 1024" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Ultrix version isn't pre-defined, determine it. case $LSOF_VSTR in # { 4.2) LSOF_VERS="40200" ;; 4.3) LSOF_VERS="40300" ;; 4.4) LSOF_VERS="40400" ;; 4.5) LSOF_VERS="40500" ;; *) echo Unknown Ultrix release: `uname -r` rm -f $LSOF_HLP exit 1 ;; esac # } fi # } # Test for a legal Ultrix version. case $LSOF_VERS in # { 40200|40300|40400|40500) ;; *) echo "Unsupported Ultrix version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DULTRIXV=$LSOF_VERS $LSOF_CFGF" if test "X$ULTRIX_HWNM" = "X" # { then ULTRIX_HWNM=`uname -m` fi # } case $ULTRIX_HWNM in # { RISC) ;; VAX) LSOF_CFGF="$LSOF_CFGF -DVAXULTRIX" ;; *) echo Unknown machine hardware name: `uname -m` rm -f $LSOF_HLP exit 1 ;; esac # } # Test for DECnet if test "X$ULTRIX_DECNET" = "X" # { then if test "X$ULTRIX_USRLIB" = "X" # { then ULTRIX_USRLIB="/usr/lib" fi # } if test -r ${ULTRIX_USRLIB}/libdnet.a -a -r ${LSOF_INCLUDE}netdnet/dn.h # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } else if test "X$ULTRIX_DECNET" = "XY" -o "X$ULTRIX_DECNET" = "Xy" # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_CFGL="-ldnet" LSOF_CFGF="$LSOF_CFGF -DDECnet" else LSOF_CFGL="" fi # } LSOF_DIALECT_DIR=ultrix ;; # Configure for SCO UnixWare. unixware|uw) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -v` fi # } if test "X$LSOF_VERS" = "X" # { then # If the UnixWare version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/; s/\./ /g' | awk '{printf "%d%02d%02d\n", $1, $2, $3;}'` fi # } LSOF_CFGF="-DUNIXWAREV=$LSOF_VERS" # Do UnixWare version-specific stuff. case $LSOF_VERS in # { 20100|20101|20102|20103) LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw21" if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h # { then (cd ./dialects/uw/uw21/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h) fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } LSOF_CFGL="-lsocket -lnsl -lelf -lgen" ;; 70000|70001) LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw7" if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h # { then (cd ./dialects/uw/uw7/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h) fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_gemini.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } LSOF_CFGL="-lsocket -lnsl -lelf -lgen" /bin/pkginfo | grep -i patch | grep -i ptf7038 > /dev/null if test -r ${LSOF_INCLUDE}/sys/file.h # { then grep f_open ${LSOF_INCLUDE}/sys/file.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_F_OPEN" fi # } fi # } ;; *) echo Unsupported UnixWare version: `uname -v` rm -f $LSOF_HLP exit 1 ;; esac # } if test -r ${LSOF_INCLUDE}/sys/fs/xnamnode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASXNAMNODE" fi # } LSOF_DIALECT_DIR=uw ;; # Handle unknown abbreviation. *) echo "Can't configure for $LSOF_TGT." cat $LSOF_HLP rm -f $LSOF_HLP exit 1 ;; # End of LSOF_TGT cases esac # } # Do an inventory of the distribution, as required. if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverInv # { then if test ! -f ./Inventory # Want -x, but Ultrix doesn't grok it. # { then echo "Can't find Inventory script." rm -f $LSOF_HLP exit 1 fi # } ./Inventory fi # } # Make sure target directory exists. if test ! -d ./dialects/$LSOF_DIALECT_DIR # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_MK exists in the target directory. if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_MKF, $LSOF_SPMKF, or $LSOF_MKF.$LSOF_LOCALSUFFIX) exists # in the target directory. if test "X$LSOF_SPMKF" != "X" # { then LSOF_TMP1=$LSOF_SPMKF else LSOF_TMP1=$LSOF_MKF fi # } if test "X$LSOF_LOCALSUFFIX" != "X" # { then LSOF_REST=$LSOF_TMP1.$LSOF_LOCALSUFFIX else LSOF_REST=$LSOF_TMP1 fi # } if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_VF exists. Extract the version number from it. if test ! -r $LSOF_VF # { then echo "Version number file, ./$LSOF_VF, doesn't exist." rm -f $LSOF_HLP exit 1 else LSOF_VN=`sed "s/.ds VN \(.*\)/\1/" < version` fi # } # Clean up in advance. rm -f $LSOF_F $LSOF_MKFC echo rm -f $LSOF_F $LSOF_MKFC # Make the dialect sources. if test "X$LSOF_MKC" = "X" # { then LSOF_MKC="ln -s" fi # } LSOF_MKC=$LSOF_MKC ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK $LSOF_TGT $LSOF_VERS # Make $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF. echo "# $LSOF_TGT Makefile for lsof version $LSOF_VN" > $LSOF_MKFC echo "" >> $LSOF_MKFC if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc fi # } echo "CC= $LSOF_CC" >> $LSOF_MKFC if test "X$LSOF_CCV" != "X" # { then echo "CCV= $LSOF_CCV" >> $LSOF_MKFC fi # } if test "X$LSOF_LIB_NO" = "X" # { then echo "LIB= ${LSOF_LIB}/liblsof.a" >> $LSOF_MKFC fi # } echo "" >> $LSOF_MKFC if test "X$LSOF_LD" != "X" # { then echo "LD= $LSOF_LD" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_CINFO" != "X" # { then echo "CINFO= $LSOF_CINFO" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_CFGD" != "X" # { then echo "CFGD= $LSOF_CFGD" >> $LSOF_MKFC fi # } if test "X$LSOF_CFGDN" != "X" # { then echo "CFGDN= $LSOF_CFGDN" >> $LSOF_MKFC fi # } if test "X$LSOF_ARCH" != "X" # { then LSOF_CFGF="$LSOF_CFGF -DLSOF_ARCH=\\\"$LSOF_ARCH\\\"" fi # } if test "X$LSOF_VSTR" != "X" # { then LSOF_TMP=`echo $LSOF_VSTR | sed 's/(/\\\\(/g' | sed 's/)/\\\\)/g'` LSOF_CFGF="$LSOF_CFGF -DLSOF_VSTR=\\\"$LSOF_TMP\\\"" fi # } echo "CFGF= $LSOF_CFGF" >> $LSOF_MKFC if test "X$LSOF_LIB_NO" = "X" # { then echo "CFGL= $LSOF_FCFGL -L./$LSOF_LIB -llsof $LSOF_CFGL" >> $LSOF_MKFC fi # } if test "X$LSOF_DEBUG" = "X" # { then LSOF_DEBUG="-O" fi # } echo "" >> $LSOF_MKFC echo "DEBUG= $LSOF_DEBUG" >> $LSOF_MKFC echo "" >> $LSOF_MKFC if test "X$LSOF_DINC" != "X" # { then echo "DINC= $LSOF_DINC" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_DOC" != "X" # { then echo "DOC=$LSOF_DOC" >> $LSOF_MKFC fi # } echo "" >> $LSOF_MKFC if test "X$LSOF_DISTRIBKVM" != "X" -a "X$LSOF_DISTRIBKVM" != "XKVM" # { then echo "KVM= $LSOF_DISTRIBKVM" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } rm -f ${LSOF_LIB}/$LSOF_LIBMKF if test "X$LSOF_LIB_NO" = "X" # { then cp $LSOF_MKFC ${LSOF_LIB}/$LSOF_LIBMKF fi # } cat ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST >> $LSOF_MKFC if test "X$LSOF_LIB_NO" = "X" # { then # Put optional archiver and randomizing strings in ${LSOF_LIB}/$LSOF_LIBMKF. # Add its skeleton section. echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF if test "X$LSOF_AR" != "X" # { then echo "AR= $LSOF_AR" >> ${LSOF_LIB}/$LSOF_LIBMKF fi # } if test "X$LSOF_RANLIB" != "X" # { then echo "RANLIB= $LSOF_RANLIB" >> ${LSOF_LIB}/$LSOF_LIBMKF fi # } echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF cat ${LSOF_LIB}/$LSOF_LIBMKFSKEL >> ${LSOF_LIB}/$LSOF_LIBMKF echo $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF created. else echo $LSOF_MKFC created. fi # } rm -f $LSOF_HLP # Call Customize, as required. if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverCust # { then if test ! -f ./Customize # { Want -x, but Ultrix doesn't grok it. then echo "Can't find Customize script." exit 1 fi # } ./Customize $LSOF_DIALECT_DIR fi # } exit 0 ./lsof_4.42/Configure.orig000644 023074 000012 00000231114 06705147611 016363 0ustar00varadhanstaff000000 000000 #!/bin/sh # # Configure -- configure lsof # # See the LSOF_HLP here document for usage. # # See the lsof distribution file 00XCONFIG for information on setting # environment variables for cross-configuring lsof -- e.g., for configuring # for Linux 2.1.42 on a machine running 2.0.30. Marty Leisner # suggested this support and provided the Linux # Configure stanza modifications. # # When configuring for a particular dialect, , this script # requires that the subdirectory ./dialects/ contain a # shell script, named $LSOF_MK, that places its source modules in this # directory. # # $Id: Configure,v 1.71 99/03/29 15:06:40 abe Exp $ #LSOF_DISTRIBKVM may be introduced through the environment to specify the # Sun4 kernel virtual memory type of distrib.cf LSOF_F="ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c dstore.c kernelbase.h machine.h machine.h.old new_machine.h __lseek.s" LSOF_HLP_BASE=./cfghlp. LSOF_HLP=${LSOF_HLP_BASE}$$ #LSOF_LOCALSUFFIX may be introduced through the environment to select a local # version of a Makefile. It is used as a suffix to $LSOF_MKF. LSOF_MK=Mksrc #LSOF_MKC is the dialect's Mksrc create command -- default "ln -s". # LSOF_MKFC may be introduced though the environment to change the name # used for the created make file. if test "X$LSOF_MKFC" = "X" # { then LSOF_MKFC=Makefile fi # } LSOF_LIB=lib LSOF_MKF=Makefile LSOF_LIBMKF=Makefile LSOF_LIBMKFSKEL=Makefile.skel LSOF_VF=version # Make sure no other variable important to Makefile construction is # already set in the environment. # # $AFS_VICE locate of AFS VICE directory (default = /usr/vice) # $LSOF_AFS AFS temporary # $LSOF_AFSV AFS version # $LSOF_AR archive command for making the lsof library # $LSOF_ARCH Unix dialect architecture as a string -- may be # supplied externally # $LSOF_CC C compiler name (may be supplied extermally) # $LSOF_CCV C compiler version (may be supplied externally) # $LSOF_CDIR configuration directory # $LSOF_CFGD depend options # $LSOF_CFGDN depend file name # $LSOF_CFGF C flags -- e.g., -D's # $LSOF_CFGL last lsof library loader flags -- e.g., -l's # $LSOF_CINFO Configure information for LSOF_CINFO in version.h # $LSOF_DEBUG Makefile's DEBUG string # $LSOF_DINC include flags -- -I's # $LSOF_DOC special document (man page) directory path # $LSOF_ERR internal error flag # $LSOF_FCFGL first lsof library loader flags -- e.g., -l's # that must precede $LSOF_LIB # $LSOF_HOST host name (e.g., from uname -n) # $LSOF_INCLUDE directory where header files are found # (default = /usr/include) # $LSOF_LD loader name if not $LSOF_CC # $LSOF_LIB_NO if "N" don't configure the lsof library # $LSOF_LINUX_INCL temporary variable for holding path to Linux # include files # $LSOF_LOCALSUFFIX local suffix for Makefile -- e.g., PUCC for # Purdue University Computing Center's special # Makefile # $LSOF_PL patch level # $LSOF_RANLIB randomizing command for the lsof library # $LSOF_SCRIPT_CALL Customize and Inventory scripts call status # $LSOF_SPMKF Special Makefile name # $LSOF_TMP1 internal temporary # $LSOF_TMP2 internal temporary # $LSOF_TMPC_BASE base name for $LSOF_TMPC # $LSOF_TMPC temporary C source file base name # $LSOF_VERS Unix dialect version as a decimal number -- may # be supplied externally # $LSOF_VSTR Unix dialect version as a string -- may be supplied # externally if test "X$AFS_VICE" = "X" # { then AFS_VICE="/usr/vice" fi # } LSOF_AFS="" LSOF_AFSV="" LSOF_AR="ar cr \${LIB} \${OBJ}" if test "X$LSOF_ARCH" = "X" # { then LSOF_ARCH="" fi # } LSOF_CDIR="" LSOF_CFGD="" LSOF_CFGDN="" LSOF_CFGF="" LSOF_CFGL="" LSOF_CINFO="" LSOF_DEBUG="" LSOF_DOC="" LSOF_ERR="" LSOF_FCFGL="" LSOF_HOST="" if test "X$LSOF_INCLUDE" = "X" # { then LSOF_DINC="" LSOF_INCLUDE="/usr/include" else LSOF_DINC="-I$LSOF_INCLUDE" fi # } LSOF_LD="" LSOF_LIB_NO="" LSOF_LINUX_INCL="" LSOF_PL="" LSOF_RANLIB="ranlib \${LIB}" LSOF_SCRIPT_CALL="yes" LSOF_SPMKF="" LSOF_TMP1="" LSOF_TMP2="" LSOF_TMPC_BASE=./lsof_Configure_tmp_ LSOF_TMPC=${LSOF_TMPC_BASE}$$ if test "X$LSOF_VERS" = "X" # { then LSOF_VERS="" fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR="" fi # } # Make sure the help file is removed before an abnormal exit. trap 'rm -f $LSOF_HLP ${LSOF_TMPC_BASE}*; exit 1' 1 2 3 15 rm -f $LSOF_HLP cat > $LSOF_HLP << LSOF_HLP Usage: Configure : -clean : clean up previous configuration -d|-dialects : display a list of supported dialect versions -h|-help : display help information -n : avoid AFS, customization, and inventory checks (****USE -d TO GET TESTED DIALECT VERSION NUMBERS****): aix|aixgcc : IBM AIX xlc (aix) or gcc (aixgcc) bsdi : BSDI BSD/OS digital_unix|du|decosf : Digital UNIX (nee DEC OSF/1) freebsd : FreeBSD hpux|hpuxgcc : HP-UX cc (hpux) or gcc (hpuxgcc) linux : Linux netbsd : NetBSD nextstep|next|ns|nxt : NEXTSTEP openbsd : OpenBSD openstep|os : OpenStep osr|sco : SCO OpenServer pyramid|pyr : Pyramid DC/OSx and Reliant UNIX ptx : Sequent PTX solaris|solariscc : Solaris gcc (solaris) or cc (solariscc) sunos|sunoscc : SunOS gcc (sunos) or cc (sunoscc) ultrix : Ultrix unixware|uw : SCO UnixWare LSOF_HLP LSOF_TGT="no-target" args=$# while test $args -gt 0 # { do case $1 in # { -clean) if test -r $LSOF_MKFC # { then echo "make -f $LSOF_MKFC clean" make -f $LSOF_MKFC clean else if test -r ${LSOF_LIB}/${LSOF_LIBMKF} # { then echo "(cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF} clean)" (cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF} clean) else if test -r ${LSOF_LIB}/${LSOF_LIBMKF}.skel # { then echo "(cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF}.skel clean)" (cd ${LSOF_LIB}; make -f ${LSOF_LIBMKF}.skel clean) fi # } fi # } fi # } rm -f $LSOF_F $LSOF_HLP $LSOF_MKFC ${LSOF_TMPC_BASE}* echo rm -f $LSOF_F $LSOF_HLP $LSOF_MKFC ${LSOF_TMPC_BASE}* rm -rf AFSHeaders AFSVersion version.h dialects/aix/aix41* echo rm -rf AFSHeaders AFSVersion version.h dialects/aix/aix41* rm -f ${LSOF_HLP_BASE}* cd9660_node.h dialects/uw/uw21/vm/swap.h echo "rm -rf dialects/n+obsd/uvm_include" rm -rf dialects/n+obsd/uvm_include echo "rm -f ${LSOF_HLP_BASE}* cd9660_node.h dialects/uw/uw21/vm/swap.h" rm -f dialects/uw/uw7/vm/swap.h dialects/hpux/hpux_mount.h echo "rm -f dialects/uw/uw7/vm/swap.h dialects/hpux/hpux_mount.h" rm -f dialects/du/du5_sys_malloc.h echo "rm -f dialects/du/du5_sys_malloc.h" rm -f ${LSOF_LIB}/${LSOF_LIBMKF} echo "rm -f ${LSOF_LIB}/${LSOF_LIBMKF}" exit 0 ;; -d|-dialects) if test -r ./00DIALECTS -a -r ./version # { then V=`sed '/VN/s/.ds VN \(.*\)/\1/' version` echo "lsof $V has been *tested* on these UNIX dialect versions:" cat 00DIALECTS echo Although "$V hasn't been tested on other versions of these dialects," echo "it may work. Try \`Configure \` and \`make\` to see." rm -f $LSOF_HLP exit 0 else echo "Can't display UNIX dialect version information:" if test ! -r ./00DIALECTS # { then echo " ./00DIALECTS is inaccessible." fi # } if test ! -r ./version # { then echo " ./version is inaccessible." fi # } rm -f $LSOF_HLP exit 1 fi # } ;; -h|-help) cat $LSOF_HLP rm -f $LSOF_HLP exit 0 ;; -n*) LSOF_SCRIPT_CALL="no" ;; *) if test $LSOF_TGT != no-target # { then echo "Only one dialect may be configured at a time." echo 'Both "$LSOF_TGT" and "$1" were specified.' cat $LSOF_HLP rm -f $LSOF_HLP exit 1 else LSOF_TGT=$1 fi # } ;; esac # } shift args=`expr $args - 1` done # } case $LSOF_TGT in # { no-target) echo "No target dialect was specified." cat $LSOF_HLP rm -f $LSOF_HLP exit 1 ;; # Configure for AIX xlc and AIX gcc. aix|aixgcc) LSOF_RANLIB="@echo \\\\\\\\c" # AIX make doesn't like a null ${RANLIB}. if test "X$LSOF_VSTR" = "X" # { then # If the AIX version isn't pre-defined, determine it. LSOF_TMP1=/usr/bin/oslevel if test -x $LSOF_TMP1 # { then echo "Determining AIX version with $LSOF_TMP1;" echo "this may take a while, depending on your maintenance level." LSOF_VSTR=`$LSOF_TMP1 | sed 's/[^0-9]*\([0-9\.]*\).*/\1/'` echo "$LSOF_TMP1 reports the version is $LSOF_VSTR." else LSOF_VSTR=`uname -rv | awk '{printf "%d.%d.0.0\n",\$2,\$1}'` echo "WARNING: can't execute $LSOF_TMP1; uname -rv reports" echo " the version is $LSOF_VSTR; edit CFGF in Makefile and" echo " lib/Makefile to refine AIXV and LSOF_VSTR." fi # } fi # } if test "X$LSOF_VERS" = "X" # { then LSOF_VERS=`echo $LSOF_VSTR | sed 's/\.//g'` fi # } if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xaixgcc" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` else LSOF_CC=cc fi # } fi # } LSOF_TGT="aix" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then # Prevent use of gcc for AIX below 4.1. if test $LSOF_VERS -lt 4100 # { then echo "********************************************************" echo "* Sorry, but gcc can't be used to compile lsof for AIX *" echo "* versions less than 4.1, because of possible kernel *" echo "* structure alignment differences between it and xlc. *" echo "********************************************************" exit 1 fi # } fi # } LSOF_CFGF="-DAIXV=$LSOF_VERS" # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } # Miscellaneous AIX tests if test -d ${LSOF_INCLUDE}/nfs # { then LSOF_CFGF="$LSOF_CFGF -DHAS_NFS" fi # } echo $LSOF_CC | grep cc | grep -v gcc > /dev/null if test $? -eq 0 -a $LSOF_VERS -ge 4140 # { then LSOF_CFGL="-bnolibpath" fi # } if test -r ${LSOF_INCLUDE}/sys/socket.h # { then grep AF_INET6 ${LSOF_INCLUDE}/sys/socket.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6" fi # } fi # } LSOF_DIALECT_DIR=aix echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then # Do gcc tests. if test $LSOF_VERS -ge 4100 -a $LSOF_VERS -lt 4200 # { then if test "X$AIX_USHACK" = "X" # { then # Compile and run a gcc test program to evaluate the user structure. rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){exit((offsetof(struct user, U_irss) & 0x7) ? 1 : 0);}" >>${LSOF_TMPC}.c echo "Testing user.h with $LSOF_CC" $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x if ! ${LSOF_TMPC}.x # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } rm -f ${LSOF_TMPC}.* else if test "$AIX_USHACK" = "Y" -o "$AIX_USHACK" = "y" # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } fi # } if test ${LSOF_TMP1} -eq 1 # { then echo "Applying gcc AIX 4.1+ user struct alignment hack" rm -rf ./dialects/aix/aix$LSOF_VERS mkdir ./dialects/aix/aix$LSOF_VERS mkdir ./dialects/aix/aix${LSOF_VERS}/sys sed 's/U_irss\[/dummy_for_alignment, U_irss\[/' < ${LSOF_INCLUDE}/sys/user.h > ./dialects/aix/aix${LSOF_VERS}/sys/user.h LSOF_CFGF="$LSOF_CFGF -U_LONG_LONG -I`pwd`/dialects/aix/aix$LSOF_VERS" fi # } fi # } else # Get xlc version number rm -f ${LSOF_TMPC}.* echo "main(){}" > ${LSOF_TMPC}.c echo "Getting version number of ${LSOF_CC};" $LSOF_CC -c ${LSOF_TMPC}.c -I${LSOF_INCLUDE} -o ${LSOF_TMPC}.o -qlist > /dev/null 2>&1 LSOF_CCV=`head -1 ${LSOF_TMPC}.lst | sed 's/\(.**\) ---.*/\1/'` rm ${LSOF_TMPC}.* echo "the version is \"${LSOF_CCV}\"." echo $LSOF_CCV | grep "Version 4" > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -qmaxmem=16384" fi # } fi # } ;; # Configure for BSDI BSD/OS. bsdi) if test "X$LSOF_CC" = "X" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } LSOF_LD="shlicc2" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the BSDI version isn't predefined, determine it. case $LSOF_VSTR in # { 2.0*) LSOF_VERS="20000" ;; 2.1*) LSOF_VERS="20100" ;; 3.0*) LSOF_VERS="30000" ;; 3.1*) LSOF_VERS="30100" ;; 4.0*) LSOF_VERS="40000" ;; *) echo Unknown BSDI release: `uname -r` echo Assuming BSDI 2.0 LSOF_VERS="20000" ;; esac # } fi # } # Test for a legal BSDI version. case $LSOF_VERS in # { 20000|20100|30000|30100|40000) ;; *) echo "Unsupported BSDI version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DBSDIV=$LSOF_VERS" if test -r ${LSOF_INCLUDE}/miscfs/fdesc/fdesc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } LSOF_CFGL="-lrpc -lkvm" LSOF_DIALECT_DIR=bsdi ;; # Configure for Digital UNIX. digital_unix|du|decosf) if test "X$LSOF_DINC" = "X" # { then LSOF_DINC="-I/usr/include" fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Digital UNIX version isn't predefined, determine it. case $LSOF_VSTR in # { V2.0) LSOF_VERS=20000 ;; V3.0) LSOF_VERS=30000 ;; V3.2) LSOF_VERS=30200 ;; ?4.0) LSOF_VERS=40000 ;; ?5.0) LSOF_VERS=50000 ;; *) echo "WARNING: unknown Digital UNIX version; assuming version is 2.0" LSOF_VERS=20000 ;; esac # } fi # } # Do Digital UNIX version specific stuff. case $LSOF_VERS in # { 20000) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" ;; 30000) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" LSOF_TMP2=-DUSELOCALREADDIR ;; 30200) LSOF_CFGF="-Olimit 1024" LSOF_TMP1="/sys" LSOF_TMP2=-DUSELOCALREADDIR ;; 40000) LSOF_TMP1="/usr/sys" ;; 50000) LSOF_TMP1="/usr/sys" ;; *) echo "WARNING: unknown Digital UNIX version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } if test "X$DU_SYSDIR" = "X" # { then DU_SYSDIR=$LSOF_TMP1 fi # } LSOF_HOST=`uname -n` if test "X$DU_CDIR" = "X" # { then LSOF_CDIR=`expr $LSOF_HOST : '\([^\.]*\)\..*$'` if test "X$LSOF_CDIR" = "X" # { then LSOF_CDIR=$LSOF_HOST fi # } LSOF_CDIR=`echo $LSOF_CDIR | tr a-z A-Z` else LSOF_CDIR=$DU_CDIR fi # } LSOF_LOOP=1 while test $LSOF_LOOP = 1 # { do if test -d ${DU_SYSDIR}/$LSOF_CDIR # { then echo "Using header files in ${DU_SYSDIR}/$LSOF_CDIR" LSOF_LOOP=0 else cat << .CAT_MARK Please enter the name of the subdirectory in $DU_SYSDIR that contains the configuration files for this host. Usually its name would be $LSOF_CDIR, but that subdirectory doesn't seem to exist. The lsof compilation needs header files specific to this machine's configuration found in that directory. If you can't specify the appropriate configuration subdirectory, quit this Configure step now and generate a proper configuration subdirectory with the kernel generation process. .CAT_MARK echo "$DU_SYSDIR contains:" echo "" ls -CF $DU_SYSDIR echo "" echo -n "Configuration subdirectory name? " read LSOF_CDIR LSOF_EXCESS if test "X$LSOF_CDIR" = "X" -o ! -d ${DU_SYSDIR}/$LSOF_CDIR # { then echo "" echo Cannot access directory ${DU_SYSDIR}/$LSOF_CDIR. fi # } fi # } done # } # Determine the ADVFS file system version. if test "X$DU_ADVFSV" = "X" # { then echo "Determining the ADVFS version -- this will take a while." LSOF_ADVFSV=`/usr/sbin/setld -i | grep "^OSFADVFSBIN[0-9]" | sed 's/\([^ ]*\).*/\1/' | sort -u | tail -1 | sed 's/OSFADVFSBIN//'` else LSOF_ADVFSV=$DU_ADVFSV fi # } case $LSOF_ADVFSV in # { 1*) LSOF_ADVFSV=100 echo "The ADVFS version is 1." ;; 2*) LSOF_ADVFSV=200 echo "The ADVFS version is 2." ;; 3*) LSOF_ADVFSV=300 echo "The ADVFS version is 3." ;; 4*) LSOF_ADVFSV=400 echo "The ADVFS version is 4." ;; 5*) LSOF_ADVFSV=500 echo "The ADVFS version is 5." ;; *) echo "The ADVFS version is unknown; it will be assumed to be 1." LSOF_ADVFSV=100 ;; esac # } LSOF_CFGF="$LSOF_CFGF -DDUV=$LSOF_VERS -DADVFSV=$LSOF_ADVFSV $LSOF_TMP2" if test "X$DU_SYSINC" = "X" # { then DU_SYSINC="/usr/sys/include" fi # } LSOF_DINC="$LSOF_DINC -I${DU_SYSDIR}/$LSOF_CDIR -I$DU_SYSINC" LSOF_CFGL="-lmld" if test "X${DU_SHLIB}" = "X" # { then DU_SHLIB=/usr/shlib fi # } if test -r ${DU_SHLIB}/libmsfs.so # { then nm ${DU_SHLIB}/libmsfs.so | grep tag_to_path > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASTAGTOPATH" LSOF_CFGL="$LSOF_CFGL -lmsfs" fi # } fi # } grep "^struct spec_node {" ${DU_SYSDIR}/include/sys/specdev.h > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASSPECNODE" fi # } # Make du5_sys_malloc.h for DU 5.0 and above. Disable some compiler # warning messages to compensate for errors in DU 5 RPC and XDR # header files. Enable IPv6 handling. if test $LSOF_VERS -ge 50000 # { then LSOF_CFGF="$LSOF_CFGF -msg_disable funcredecl,ptrmismatch" LSOF_TMP1=${LSOF_INCLUDE}/sys/malloc.h if test -r $LSOF_TMP1 # { then LSOF_TMP2=dialects/du/du5_sys_malloc.h rm -f $LSOF_TMP2 echo "#if !defined(MANUFACTURED_DU5_SYS_MALLOC_H)" > $LSOF_TMP2 echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP2 echo "#define MANUFACTURED_DU5_SYS_MALLOC_H" >> $LSOF_TMP2 grep "^#define[ ]MALLOC_NUM_BUCKETS" $LSOF_TMP1 >> $LSOF_TMP2 echo "struct percpukmembuckets {" >> $LSOF_TMP2 sed '1,/^struct percpukmembuckets/d' $LSOF_TMP1 | sed -n '1,/^};/p' >> $LSOF_TMP2 echo "#endif" >> $LSOF_TMP2 LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/du" fi # } # Enable IPv6 for DU 5; check for gethostbyname2(). LSOF_CFGF="$LSOF_CFGF -DHASIPv6" if test -r ${LSOF_INCLUDE}/netdb.h # { then grep -q "gethostbyname2(" ${LSOF_INCLUDE}/netdb.h if test $? -ne 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNOBYNAME2" fi # } fi # } fi # } LSOF_DIALECT_DIR=du ;; # Configure for FreeBSD. freebsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the FreeBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.*) LSOF_VERS=100 ;; 2.0-*) LSOF_VERS=200 ;; 2.0.5-*) LSOF_VERS=205 ;; 2.1*) LSOF_VERS=210 ;; 2.2*) LSOF_VERS=220 ;; 3.0*) LSOF_VERS=300 ;; 3.1*) LSOF_VERS=310 ;; 4.0*) LSOF_VERS=400 ;; *) echo Unknown FreeBSD release: `uname -r` echo Assuming FreeBSD 2.x LSOF_CFGL="-lkvm" LSOF_VERS=200 LSOF_N_UNIXV=`/usr/sbin/sysctl -n kern.bootfile` if test "X$LSOF_N_UNIXV" = "X" # { then LSOF_N_UNIXV="/kernel" fi # } ;; esac # } fi # } # Get system CFLAGS from FREEBSD_MAKE_CONF (default=/etc/make.conf). if test "X$FREEBSD_MAKE_CONF" = "X" # { then FREEBSD_MAKE_CONF="/etc/make.conf" fi # } if test -r $FREEBSD_MAKE_CONF # { then LSOF_CFGF=`grep ^CFLAGS= /etc/make.conf | sed 's/CFLAGS=[ ]*\(.*\)/\1/'` LSOF_TMP=1 while test $LSOF_TMP -eq 1 # { do echo $LSOF_CFGF | grep -q -e '-O' if test $? -eq 0 # { then if test "X$LSOF_DEBUG" = "X" then # { LSOF_DEBUG=`echo $LSOF_CFGF | sed 's/.*\(-O[^ $]*\).*/\1/'` fi # } LSOF_CFGF=`echo $LSOF_CFGF | sed 's/\(.*\)-O[^ $]*\(.*\)/\1 \2/' | sed 's/^ *//g' | sed 's/ */ /g' | sed 's/ *$//` else LSOF_TMP=0 fi # } done # } fi # } # Do FreeBSD version-specific stuff. case $LSOF_VERS in # { 100) LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_CFGL="-lutil" LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/freebsd/include" if test "X$FREEBSD_KERNEL" = "X" # { then LSOF_N_UNIXV="/386bsd" else LSOF_N_UNIXV=$FREEBSD_KERNEL fi # } ;; 200|205|210) LSOF_CFGL="-lkvm" ;; 220) LSOF_CFGL="-lkvm" if test -r ${LSOF_INCLUDE}/vm/lock.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH" fi # } ;; 300|310) LSOF_CFGL="-lkvm" if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h # { then LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H" fi # } if test -r ${LSOF_INCLUDE}/vm/lock.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH" fi # } ;; 400) LSOF_CFGL="-lkvm" ;; *) echo "Unsupported FreeBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="$LSOF_CFGF -DFREEBSDV=$LSOF_VERS" if test $LSOF_VERS -lt 200 -a "X$FREEBSD_KERNEL" = "X" # { then if test ! -x $LSOF_N_UNIXV # { then echo "Hmmm -- $LSOF_N_UNIXV doesn't appear to be your kernel file." echo "Please enter the name of the file in / that contains" echo "the kernel for this host. It must be a regular file," echo "not a directory, and must be executable." LSOF_LOOP=1 while test $LSOF_LOOP = 1 # { do echo "" echo "/ contains:" echo "" ls -CF / echo "" echo -n "Kernel file name? " read LSOF_N_UNIXV LSOF_EXCESS LSOF_N_UNIXV="/$LSOF_N_UNIXV" if test ! -d $LSOF_N_UNIXV -a -x $LSOF_N_UNIXV # { then LSOF_LOOP=0 else echo "" echo $LSOF_N_UNIXV is not a regular executable file. fi # } done # } fi # } LSOF_N_UNIXV=`echo $LSOF_N_UNIXV | sed 's#^/*#/#'` LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=$LSOF_N_UNIXV" fi # } LSOF_TMP1=0 if test "X$FREEBSD_SYS" = "X" # { then if test -d /usr/src/sys # { then FREEBSD_SYS=/usr/src/sys else if test -d /sys # { then FREEBSD_SYS="/sys" fi # } fi # } fi # } if test -d ${FREEBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${FREEBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -r ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h # { then rm -f cd9660_node.h grep -q "^#ifdef KERNEL" ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h if test $? -eq 0 # { then ln -s ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h cd9660_node.h else sed -e '/^ \* Prototypes for ISOFS vnode operations/,$c\ \ The ISOFS prototypes were removed by Configure. */' \ < ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h > cd9660_node.h echo "" >> cd9660_node.h fi # } LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="$LSOF_DINC -I/usr/include -I$FREEBSD_SYS" fi # } if test -r ${LSOF_INCLUDE}/netinet/in.h # { then grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6" fi # } fi # } LSOF_DIALECT_DIR=freebsd ;; # Configure for HP-UX and HP-UX gcc. hpux|hpuxgcc) LSOF_CFGL="" LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the HP-UX version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%02d",\$2,\$3}'` fi # } if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xhpuxgcc" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` LSOF_CFGF="-DHAS_CONST" LSOF_DEBUG="-O" else if test "X$HPUX_CCDIR1" = "X" # { then HPUX_CCDIR1="/bin" fi # } if test "X$HPUX_CCDIR2" = "X" # { then HPUX_CCDIR2="/usr/ccs/bin" fi # } if test -x ${HPUX_CCDIR1}/cc # { then LSOF_CC=${HPUX_CCDIR1}/cc else if test -x ${HPUX_CCDIR2}/cc # { then LSOF_CC=${HPUX_CCDIR2}/cc else echo "No executable cc in $HPUX_CCDIR1 or $HPUX_CCDIR2" rm -f $LSOF_HLP exit 1 fi # } fi # } what $LSOF_CC | grep -q Bundled if test $? -eq 0 # { then if test "X$HPUX_LIBC1" = "X" # { then HPUX_LIBC1="/usr/lib" fi # } if test -r ${HPUX_LIBC1}/libc.sl # { then LSOF_FCFGL="-L$HPUX_LIBC -lc" else if test "X$HPUX_LIBC2" = "X" # { then HPUX_LIBC2="/usr/lib" fi # } if test -r ${HPUX_LIBC2}/libc.sl # { then LSOF_FCFGL="-L$HPUX_LIBC2 -lc" fi # } fi # } else LSOF_DEBUG="-O" fi # } fi # } fi # } LSOF_TGT="hpux" LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS" if test $LSOF_VERS -lt 1000 # { then if test "X$HPUX_X25DIR" = "X" # { then HPUX_X25DIR="/etc/conf" else HPUX_X25DIR=$HPUX_X25DIR fi # } if test -r ${HPUX_X25DIR}/x25/x25addrstr.h # { then LSOF_CFGF="$LSOF_CFGF -DHPUX_CCITT" LSOF_DINC="$LSOF_DINC -I$HPUX_X25DIR" fi # } fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_hpux.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } if test $LSOF_VERS -ge 1030 # { then if test "X$HPUX_KERNBITS" = "X" # { then HPUX_KERNBITS=`getconf _SC_KERNEL_BITS` fi # } LSOF_CFGF="$LSOF_CFGF -DHPUXKERNBITS=${HPUX_KERNBITS} -I`pwd`/dialects/hpux/hpux11" if test $HPUX_KERNBITS -eq 64 # { then echo "" echo "*****************************************" echo "* *" echo "* NOTICE! Configuring for 64 bit HP-UX *" echo "* *" echo "*****************************************" echo "" LSOF_CFGF="$LSOF_CFGF +DD64" LSOF_CFGL="$LSOF_CFGL -lelf" LSOF_CINFO="64 bit HP-UX" else LSOF_CINFO="32 bit HP-UX" fi # } LSOF_CFGL="$LSOF_CFGL -lnsl" fi # } # Test for the ipc_ipis member in the ipc_s structure. If it is present, # set HAS_IPC_S_PATCH. if test $LSOF_VERS -eq 1100 # { then if test "X$HPUX_IPC_S_PATCH" = "X" # { then LSOF_TMP=/usr/contrib/bin/q4 if test -x $LSOF_TMP # { then rm -f ${LSOF_TMPC}.out echo "Looking for ipc_ipis with $LSOF_TMP ... \c" echo "fields -c struct ipc_s" | $LSOF_TMP /stand/vmunix > ${LSOF_TMPC}.out 2>&1 if test $? -ne 0 # { then echo "" echo "" echo "!!!ERROR!!! $LSOF_TMP failed and produced the following output." echo "" cat ${LSOF_TMPC}.out HPUX_IPC_S_PATCH=fail else grep ipc_ipis ${LSOF_TMPC}.out > /dev/null 2>&1 if test $? -eq 0 # { then HPUX_IPC_S_PATCH="Y" echo "ipc_s has it." else echo "ipc_s doesn't have it." fi # } fi # } else echo "Can't locate or execute $LSOF_TMP" echo "ls says: \c" ls -ld $LSOF_TMP HPUX_IPC_S_PATCH=fail fi # } if test "X$HPUX_IPC_S_PATCH" = "Xfail" # { then echo "" echo "!!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!" echo "Configure can't use $LSOF_TMP to test the ipc_s" echo "structure for an ipc_ipis member. You must determine that" echo "yourself, report the result as Y or N in the HPUX_IPC_S_PATCH" echo "environment variable, and repeat the Configure step. Consult" echo "the Configure script's use of $LSOF_TMP and the" echo "00XPORTING file for more information on testing for ipc_ipis." echo "!!!ERROR!!! !!!ERROR!!! !!!ERROR!!! !!!ERROR!!!" echo "" exit 1 fi # } fi # } if test "X$HPUX_IPC_S_PATCH" = "XY" -o "X$HPUX_IPC_S_PATCH" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_IPC_S_PATCH" fi # } fi #} # Manufacture an hpux_mount.h header file with a mount struct in it, as # required. if test -r ${LSOF_INCLUDE}/sys/mount.h # { then LSOF_TMP1=dialects/hpux/hpux_mount.h rm -f $LSOF_TMP1 echo "#if !defined(MANUFACTURED_HPUX_SYS_MOUNT_H)" > $LSOF_TMP1 echo "#define MANUFACTURED_HPUX_SYS_MOUNT_H" >> $LSOF_TMP1 echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP1 echo "struct mount" >> $LSOF_TMP1 sed '1,/struct mount/d' ${LSOF_INCLUDE}/sys/mount.h | sed -n '1,/m_dev/p' >> $LSOF_TMP1 echo "};" >> $LSOF_TMP1 echo "#endif" >> $LSOF_TMP1 LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/hpux" fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } LSOF_DIALECT_DIR=hpux ;; # Configure for Linux. linux) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } LSOF_DIALECT_DIR="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Linux version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\./ /g' | awk '{printf "%d%d%03d",\$1,\$2,\$3}'` fi # } LSOF_CFGF="-DLINUXV=$LSOF_VERS" # Test the extent of Linux /proc support. if test "X$LINUX_BASE" = "X" # { then LINUX_BASE="/dev/kmem" if test -d /proc/self/fd # { then ls -l /proc/self/fd | grep "/proc/[0-9][0-9]*/fd" > /dev/null if test $? -eq 0 # { then LINUX_BASE="/proc" fi # } fi # } fi # } # Check for a legal LINUX_BASE value. if test "X$LINUX_BASE" != "X/dev/kmem" -a "X$LINUX_BASE" != "X/proc" # { then echo "Unknown LINUX_BASE value: $LINUX_BASE" exit 1 fi # } if test "$LINUX_BASE" = "/proc" # { then # Configure /proc-based Linux lsof. LSOF_DIALECT_DIR="linux/proc" echo "Configuring /proc-based Linux lsof" LSOF_CINFO="/proc-based" if test $LSOF_VERS -lt 2172 # { then echo "" echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!" echo "! !" echo "! THE /PROC-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON !" echo "! LINUX KERNELS BELOW 2.1.72, AND MAY NOT WORK ON THIS !" echo "! KERNEL. IT SHOULD USE A /DEV/KMEM-BASED LSOF. IF YOU !" echo "! ARE UNCERTAIN ABOUT THE STATUS OF YOUR /PROC, CONTACT !" echo "! ME FOR ADVICE. !" echo "! !" echo "! Vic Abell !" echo "! !" echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!" echo "" fi # } fi # } if test "$LINUX_BASE" = "/dev/kmem" # { then # Configure /dev/kmem-based Linux lsof. LSOF_DIALECT_DIR=linux/kmem LSOF_CINFO="/dev/kmem-based" echo "Configuring /dev/kmem-based Linux lsof" if test $LSOF_VERS -ge 21072 # { then echo "" echo "!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!" echo "! !" echo "! THE /DEV/KMEM-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON !" echo "! LINUX KERNELS ABOVE 2.1.72, AND MAY NOT WORK ON THIS !" echo "! KERNEL. THIS KERNEL SHOULD USE A /PROC-BASED LSOF. !" echo "! IF FILES IN /PROC/FD/... DON'T HAVE NAMES, BUT A NUMBER !" echo "! FOLLOWING ''-> ['', THE /PROC FILE SYSTEM OF THIS KERNEL !" echo "! MAY BE MISCONFIGURED. CONTACT ME FOR ASSISTANCE. !" echo "! !" echo "! Vic Abell !" echo "! !" echo "!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!===!!!WARNING!!!" echo "" fi # } # If the Linux kernel directory isn't pre-defined, set its default. # If the Linux kernel include directory isn't pre-defined, set its # default. if test "X$LINUX_KERNEL" = "X" # { then LINUX_KERNEL="/usr/src/linux" fi # } LSOF_LINUX_INCL=${LINUX_KERNEL}/include/linux # If the Linux C library type isn't predefined, determine it. if test "X$LINUX_CLIB" = "X" # { then echo -n "Testing C library type with $LSOF_CC ... " rm -f ${LSOF_TMPC}.* echo "#include " > $LSOF_TMPC.c echo "main(){" >> $LSOF_TMPC.c echo "#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)" >> $LSOF_TMPC.c echo "printf(\"-DGLIBCV=%d\\n\",__GLIBC__*100+__GLIBC_MINOR__);" >> $LSOF_TMPC.c echo "#elif defined(__GLIBC__)" >> $LSOF_TMPC.c echo "printf(\"-DGLIBCV=%d00\\n\",__GLIBC__);" >> $LSOF_TMPC.c echo "#else" >> $LSOF_TMPC.c echo "printf(\"\\n\");" >> $LSOF_TMPC.c echo "#endif" >> $LSOF_TMPC.c echo "return(0); }" >> $LSOF_TMPC.c $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 if test -x ${LSOF_TMPC}.x # { then LINUX_CLIB=`${LSOF_TMPC}.x` LSOF_TMP=$? else LINUX_CLIB="" LSOF_TMP=1 fi # } rm -f ${LSOF_TMPC}.* echo "done" if test $LSOF_TMP -ne 0 # { then echo "Cannot determine C library type; assuming it is not glibc." LINUX_CLIB="" else if test "X$LINUX_CLIB" = "X" # { then echo "The C library type is not glibc." else echo "The C library type is glibc, version \"$LINUX_CLIB\"." fi # } fi # } fi # } if test "X$LINUX_CLIB" != "X" # { then LSOF_CFGF="$LSOF_CFGF $LINUX_CLIB" fi # } # Test Linux socket support. if test -r ${LINUX_KERNEL}/net/inet/sock.h # { then LSOF_TMP1="net/inet/sock.h" else if test -r ${LINUX_KERNEL}/include/net/sock.h # { then LSOF_TMP1="include/net/sock.h" LSOF_DINC="$LSOF_DINC -I${LINUX_KERNEL}/include" else echo "WARNING: cannot find ${LINUX_KERNEL}/net/inet/sock.c or" echo " ${LINUX_KERNEL}/include/net/sock.c. Lsof may fail to" echo " compile, or it it compiles, it may fail to identify" echo " socket files correctly. Does this machine have the" echo " Linux kernel source and header files in ${LINUX_KERNEL}?" echo " If it does not, you probably cannot build lsof." LSOF_TMP1="" fi # } fi # } if test "X$LSOF_TMP1" != "X" # { then grep protinfo ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then grep unix_address ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASUNMINSOCK=1" else LSOF_CFGF="$LSOF_CFGF -DHASUNMINSOCK=0" fi # } fi # } grep "ax25_cb[ ]*\*ax25;" ${LINUX_KERNEL}/$LSOF_TMP1 > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASAX25CBPTR" fi # } fi # } grep '*sk;' ${LSOF_LINUX_INCL}/net.h > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_SOCKET_SK" fi # } if test -r ${LSOF_LINUX_INCL}/netdevice.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNETDEVICE_H" fi # } # Test the Linux kernel loader format. if test -r ${LSOF_LINUX_INCL}/autoconf.h # { then egrep "^#define[ ]*CONFIG_KERNEL_ELF" ${LSOF_LINUX_INCL}/autoconf.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DKERN_LD_ELF" fi # } fi # } # Test Linux lock support. if test -r ${LSOF_LINUX_INCL}/fs.h # { then grep fl_fd ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_FD" fi # } grep fl_file ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_FILE" fi # } grep fl_whence ${LSOF_LINUX_INCL}/fs.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_FL_WHENCE" fi # } fi # } # Test for Linux atomic lock support. if test -r ${LINUX_KERNEL}/include/asm/atomic.h # { then grep "typedef struct .* atomic_t;" ${LINUX_KERNEL}/include/asm/atomic.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_ATOMIC_T" fi # } fi # } # Test for Linux query_module() support. if test -r ${LINUX_KERNEL}/include/asm/unistd.h # { then grep __NR_query_module ${LINUX_KERNEL}/include/asm/unistd.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_QUERY_MODULE" fi # } fi # } # Test Linux kernel lseek() support. if test $LSOF_VERS -ge 21000 # { then if test "X$LINUX_LSEEK" = "X" # { then echo "Testing lseek() with $LSOF_CC" rm -f ${LSOF_TMPC}.* echo '#include ' > ${LSOF_TMPC}.c echo '#include ' >> ${LSOF_TMPC}.c echo '#include ' >> ${LSOF_TMPC}.c echo 'main() { int f;' >> ${LSOF_TMPC}.c echo 'if((f=open("/dev/kmem",O_RDONLY,0600))<0)exit(1);' >> ${LSOF_TMPC}.c echo 'if(lseek(f,(off_t)-4097,SEEK_CUR)==-1)exit(2);' >> ${LSOF_TMPC}.c echo 'exit(0);}' >> ${LSOF_TMPC}.c $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x ${LSOF_TMPC}.x LSOF_TMP=$? case $LSOF_TMP in # { 0) echo "Lseek() is OK." ;; 1) echo "Configure for Linux 2.[12].x needs read permission to" echo "/dev/kmem in order to test lseek() on it." rm -f ${LSOF_TMPC}.* $LSOF_HLP exit 1 ;; 2) echo "Lseek() is suspect; using private __lseek.s." LSOF_SPMKF="Makefile.lseek" ;; *) echo "Unexpected return of $LSOF_TMP from lseek() test program, ${LSOF_TMPC}.c" rm -f $LSOF_HLP exit 1 ;; esac # } rm -f ${LSOF_TMPC}.* else if test "X$LINUX_LSEEK" = "XY" -o "X$LINUX_LSEEK" = "Xy" # { then LSOF_SPMKF="Makefile.lseek" fi # } fi # } fi # } # Test for Linux PID hashing support. grep pidhash_next ${LSOF_LINUX_INCL}/sched.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASHASHPID" fi # } # Test for Linux dcache structure. if test -r ${LSOF_LINUX_INCL}/dcache.h # { then grep "^struct dentry {" ${LSOF_LINUX_INCL}/dcache.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASDENTRY" fi # } fi # } # Test for Linux __kernel_key_t type. grep __kernel_key_t ${LSOF_INCLUDE}/linux/types.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNELKEYT" fi # } # Test for the presence of (for Alpha). if test -r ${LSOF_INCLUDE}/asm/termiobits.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_ASM_TERMIOBITS" fi # } fi # } ;; # Configure for NetBSD. netbsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the NetBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.0*) LSOF_VERS="1000" ;; 1.1*) LSOF_VERS="1010" ;; 1.2*) LSOF_VERS="1020" ;; 1.3*) LSOF_VERS="1030" ;; *) echo Unknown NetBSD release: `uname -r` echo Assuming NetBSD 1.0 LSOF_VERS="1000" ;; esac # } fi # } # Test for legal NetBSD version. case $LSOF_VERS in # { 1000|1010|1020|1030) ;; *) echo "Unsupported NetBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DNETBSDV=$LSOF_VERS" if test -r ${LSOF_INCLUDE}/nfs/nfsproto.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO" fi # } LSOF_TMP1=0 if test "X$NETBSD_SYS" = "X" # { then NETBSD_SYS="/sys" fi # } if test -d ${NETBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${NETBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -d ${NETBSD_SYS}/isofs/cd9660 # { then LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" LSOF_TMP1=1 fi # } if test -r ${NETBSD_SYS}/miscfs/kernfs/kernfs.h # { then grep -q "kt_name;" ${NETBSD_SYS}/miscfs/kernfs/kernfs.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNFS" LSOF_TMP1=1 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="-I$LSOF_INCLUDE -I$NETBSD_SYS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } grep -q i_ffs_size ${LSOF_INCLUDE}/ufs/ufs/inode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASI_FFS" fi # } grep -q VT_EXT2FS ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS" grep -q i_e2fs_size ${LSOF_INCLUDE}/ufs/ufs/inode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASI_E2FS" fi # } fi # } if test -r ${LSOF_INCLUDE}/nfs/nfsnode.h # { then grep -q "*n_vattr" ${LSOF_INCLUDE}/nfs/nfsnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSVATTRP" fi # } fi # } if test "X$NETBSD_UVM" = "X" # { then if test -r /etc/mk.conf # { then grep -q "^UVM[ ]*=" /etc/mk.conf if test $? -eq 0 # { then NETBSD_UVM="Y" fi # } fi # } if test "X$NETBSD_UVM" = "X" # { then if test -r ${LSOF_INCLUDE}/sys/vnode.h # { then grep -q UVM ${LSOF_INCLUDE}/sys/vnode.h if test $? -ne 0 # { then grep -q "v_uvm;" ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then NETBSD_UVM="Y" fi # } fi # } fi # } fi # } fi # } rm -rf dialects/n+obsd/uvm_include if test "X$NETBSD_UVM" = "XY" -o "X$NETBSD_UVM" = "Xy" # { then mkdir dialects/n+obsd/uvm_include touch dialects/n+obsd/uvm_include/opt_uvmhist.h touch dialects/n+obsd/uvm_include/opt_lockdebug.h LSOF_CFGF="$LSOF_CFGF -DUVM -I`pwd`/dialects/n+obsd/uvm_include" fi # } if test -r ${LSOF_INCLUDE}/netinet/in.h # { then grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6" fi # } fi # } LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=/netbsd" LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=n+obsd ;; # Configure for NeXTSTEP or OpenStep. nextstep|next|ns|nxt|openstep|os) LSOF_AR="rm -f \${LIB}; $LSOF_AR" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'` fi # } if test "X$LSOF_VERS" = "X" # { then # If the NeXSTEP version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed -n 's/\([0-9]*\)\.\([0-9]*\)/\1\2/p'` fi # } if test "X$LSOF_CC" = "X" # { then if test -x /usr/local/bin/gcc # { then LSOF_CC=/usr/local/bin/gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` else LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } fi # } echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then LSOF_CFGL="-w" else LSOF_CFGL="" fi # } LSOF_CFGF="-DSTEPV=$LSOF_VERS" LSOF_DIALECT_DIR=n+os # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } ;; # Configure for OpenBSD. (OpenBSD uses NetBSD dialect sources and version # numbering. openbsd) if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the OpenBSD version isn't pre-defined, determine it. case $LSOF_VSTR in # { 1.2*) LSOF_VERS=1020 ;; 2.0*) LSOF_VERS=2000 ;; 2.1*) LSOF_VERS=2010 ;; 2.2*) LSOF_VERS=2020 ;; 2.3*) LSOF_VERS=2030 ;; 2.4*) LSOF_VERS=2040 ;; 2.5*) LSOF_VERS=2050 ;; *) echo Unknown OpenBSD release: `uname -r` echo Assuming OpenBSD 1.2 LSOF_VERS=1020 ;; esac # } fi # } # Test for legal OpenBSD version. case $LSOF_VERS in # { 1020|2000|2010|2020|2030|2040|2050) ;; *) echo "Unsupported OpenBSD version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DOPENBSDV=$LSOF_VERS -DN_UNIXV=/bsd" if test -r ${LSOF_INCLUDE}/nfs/nfsproto.h # { then LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO" fi # } LSOF_TMP1=0 if test "X$OPENBSD_SYS" = "X" # { then OPENBSD_SYS="/sys" fi # } if test -d ${OPENBSD_SYS}/miscfs/fdesc # { then LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS" LSOF_TMP1=1 fi # } if test -d ${OPENBSD_SYS}/miscfs/procfs # { then LSOF_CFGF="$LSOF_CFGF -DHASPROCFS" LSOF_TMP1=1 fi # } if test -d ${OPENBSD_SYS}/isofs/cd9660 # { then LSOF_CFGF="$LSOF_CFGF -DHAS9660FS" LSOF_TMP1=1 fi # } if test -r ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h # { then grep -q "kt_name;" ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASKERNFS" LSOF_TMP1=1 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_DINC="-I$LSOF_INCLUDE -I$OPENBSD_SYS" fi # } grep -q VT_EXT2FS ${LSOF_INCLUDE}/sys/vnode.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS" fi # } grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASNCVPID" fi # } LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=n+obsd ;; # Configure for Pyramid DC/OSx and Reliant UNIX. pyramid|pyr) # Establish C compiler, its version, and its options. if /bin/test "X$LSOF_CC" = "X" # { then LSOF_CC=/usr/ccs/bin/cc LSOF_CCV="`$LSOF_CC -V 2>&1 | head -1`" fi # } LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if /bin/test ! -x dialects/pyramid/MkKernOpts # { then /bin/echo "Can't execute dialects/pyramid/MkKernOpts" rm -f $LSOF_HLP exit 1 fi # } LSOF_CFGF="`LSOF_CCV=$LSOF_CCV dialects/pyramid/MkKernOpts`" /bin/echo $LSOF_CFGF | /usr/bin/egrep -e -Klp64 > /dev/null if /bin/test $? -eq 0 # { then # Compile a test program to see if -Klp64 is supported. rm -f ${LSOF_TMPC}.* echo "main(){}" > ${LSOF_TMPC}.c echo "Testing $LSOF_CC for -Klp64 support" $LSOF_CC -Klp64 ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x if /bin/test $? -ne 0 # { then rm -f ${LSOF_TMPC}.* echo "$LSOF_CC doesn't support -Klp64. Consult 00FAQ." exit 1 fi # } rm -f ${LSOF_TMPC}.* echo "$LSOF_CC supports -Klp64." fi # } # Do miscellaneous feature tests, based on their supporting header files. if /bin/test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/fs/tfs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASTFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/fs/objfs/obj_fs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASOBJFS" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/mipc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASMIPCH" fi # } if /bin/test -r ${LSOF_INCLUDE}/sys/dnlc.h # { then /bin/grep "name;" ${LSOF_INCLUDE}/sys/dnlc.h > /dev/null if /bin/test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASDNLCPTR" fi # } fi # } LSOF_CFGL="-lsocket -lnsl -lelf" LSOF_DIALECT_DIR=pyramid ;; # Configure for Sequent PTX. ptx) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -v` fi # } if test "X$LSOF_VERS" = "X" # { then # If the PTX version isn't predefined, determine it. LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%d%d",substr($1,2), $2, $3}'` fi # } if test $LSOF_VERS -ge 400 # { then # PTX 4.x tests if test "X$PTX_CONF" = "X" # { then PTX_CONF="/usr/conf/uts" fi # } if test $LSOF_VERS -lt 410 # { then LSOF_CFGL="-lrpc -lelf -linet -lnsl -lseq" else if test $LSOF_VERS -lt 423 # { then LSOF_CFGL="-lrpc -lelf -lnsl -lseq -lsocket" else LSOF_CFGL="-lelf -lnsl -lseq -lsocket" fi # } fi # } if test -r ${PTX_CONF}/nfs/rnode.h # { then LSOF_CFGF="-DHAS_NFS" fi # } # PTX 4.x TCP version tests. if test "X$PTX_TCPV" = "X" # { then if test "X$PTX_TCP_NAME" = "X" # { then PTX_TCP_NAME="/usr/options/tcp/tcp.name" fi # } if test -r $PTX_TCP_NAME # { then PTX_TCPV=`cat ${PTX_TCP_NAME} | awk '{print $2}' | awk -F. '{printf "%d%d%d",substr($1,2), $2, $3}'` fi # } fi # } else # PTX 2.x tests if test -r ${LSOF_INCLUDE}/nfs/rnode.h # { then LSOF_CFGF="-DHAS_NFS" fi # } LSOF_CFGL="-lrpc -linet -lnsl -lseq" fi # } # Guarantee a TCP version, even if it's zero. Add the PTX and TCP # versions to the Makefile's configuration flags. if test "X$PTX_TCPV" = "X" # { then PTX_TCPV="0" fi # } LSOF_CFGF="-DPTXV=$LSOF_VERS -DTCPV=$PTX_TCPV $LSOF_CFGF" # Check for PTX CDROM node header file. if test -r ${LSOF_INCLUDE}/sys/cdfsinode.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_CDFS" fi # } # Check for PTX inp_addr structure. if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h # { then grep "inp_laddr;" ${LSOF_INCLUDE}/netinet/in_pcb.h | grep struct > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASINADDRSTR" fi # } fi # } # Test PTX VxFS status. if test -r ${LSOF_INCLUDE}/sys/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" if test -r ${LSOF_INCLUDE}/sys/vx_dnlc.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFSDNLC" fi # } fi # } LSOF_DIALECT_DIR=ptx ;; # Configure for SCO OpenServer. osr|sco) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR="`LANG=C_C.C uname -X 2>/dev/null | grep Release | sed 's/Release = \(.*\)/\1/'`" fi # } if test "X$LSOF_VERS" = "X" # { then # If the SCO OpenServer release version isn't predefined, determine it. case $LSOF_VSTR in # { 3.2v2.0) LSOF_VERS="20" ;; 3.2v2.1) LSOF_VERS="21" ;; 3.2v4.0) LSOF_VERS="40" ;; 3.2v4.1) LSOF_VERS="41" ;; 3.2v4.2) LSOF_VERS="42" ;; 3.2v5.0.*) LSOF_VERS="`echo $LSOF_VSTR | sed 's/3\.2v//; s/\.//g'`" ;; *) echo Unknown SCO OpenServer release: `uname -X | grep Release` echo Assuming 3.2.0 or 3.2.1 LSOF_VERS="0" ;; esac # } fi # } # Do SCO OpenServer specific stuff. case $LSOF_VERS in # { 0) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 20) LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 21) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" LSOF_MKC="cp" ;; 40) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 41) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 42) LSOF_CFGF="-nointl" LSOF_CFGL="-lrpc -lsocket -lc_s" LSOF_DEBUG="-Ox" ;; 5*) LSOF_CFGF="-belf" LSOF_CFGL="-lsocket" LSOF_DEBUG="-O3 -Kspace" ;; *) echo "Unsupported SCO OpenServer release: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DOSRV=$LSOF_VERS $LSOF_CFGF" if test "X$OSR_STATLSTAT" = "X" # { then echo "Testing libc.a for statlstat" /bin/nm /lib/libc.a | grep statlstat > /dev/null 2>&1 if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT" fi # } else if test "X$OSR_STATLSTAT" = "XY" -o "X$OSR_STATLSTAT" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT" fi # } fi # } if test -r ${LSOF_INCLUDE}/sys/fs/nfs/rnode.h # { then LSOF_CFGF="$LSOF_CFGF -DHAS_NFS" fi # } if test ! -r ${LSOF_INCLUDE}/netdb.h # { then LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/osr/include" fi # } LSOF_DIALECT_DIR=osr ;; # Configure for Sun Solaris, SunPro C and gcc. solaris|solariscc) LSOF_RANLIB="" if test "X$LSOF_CC" = "X" # { then if test "X$LSOF_TGT" = "Xsolariscc" # { then if test "X$SOLARIS_CCDIR" = "X" # { then SOLARIS_CCDIR="/opt/SUNWspro/bin" fi # } if test -x ${SOLARIS_CCDIR}/cc # { then LSOF_CC=${SOLARIS_CCDIR}/cc else echo "WARNING: no cc in ${SOLARIS_CCDIR}; using cc without path." LSOF_CC=cc fi # } LSOF_CCV=`$LSOF_CC -V 2>&1 | sed -n 's/^cc: \(.*\)/\1/p'` else LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` fi # } fi # } LSOF_TGT="solaris" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Solaris version isn't predefined, determine it. case $LSOF_VSTR in # { 5.[0-2]) LSOF_VERS="20300" ;; 5.3) LSOF_VERS="20300" ;; 5.4) LSOF_VERS="20400" ;; 5.5) LSOF_VERS="20500" ;; 5.5.1) LSOF_VERS="20501" ;; 5.6*) LSOF_VERS="20600" ;; 5.7*) LSOF_VERS="70000" ;; *) echo Unknown Solaris version: $LSOF_VSTR rm -f $LSOF_HLP exit 1 esac # } fi # } # Do Solaris version-specific stuff. case $LSOF_VERS in # { 20300) # Solaris patch 101318-32 creates a longer kernel tcp_s structure, # and 101318-45 changes the way the vnode's v_filocks member is # handled. The following code creates a symbol definition for # patch 101318 whose value is the patch level. No symbol is defined # if the patch level is not greater than zero. if test "X$SOLARIS_23P101318" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=101318 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_23P101318 fi # } if test $LSOF_PL -gt 0 # { then LSOF_CFGF="-DP101318=$LSOF_PL" fi # } ;; 20400) if test "X$SOLARIS_24P101945" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=101945 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_24P101945 fi # } if test $LSOF_PL -ge 32 # { then if test "X$SOLARIS_24P102303" = "X" # { then LSOF_PL=`grep -h SUNW_PATCHID=102303 /var/sadm/pkg/SUNWhea*/pkginfo | sed 's/.*-//' | sort -u | tail -1` if test "X$LSOF_PL" = "X" # { then LSOF_PL=0 fi # } else LSOF_PL=$SOLARIS_24P102303 fi # } if test $LSOF_PL -ge 2 # { then echo "WARNING: your Solaris 2.4 system appears to have patches 101945-32 and 102303-2" echo " installed. This probably means the NUM_*_VECTORS definitions in" echo " don't match the ones used to build your kernel. Consult" echo " the Sun Problems section of the 00FAQ file of the lsof distribution" echo " for an explanation of the work-around being supplied by including" echo " the header file ./dialects/sun/include/sys/auxv.h." LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/sun/include" fi # } fi # } ;; 20500|20501) ;; 20600|70000) if test "X$SOLARIS_26PR_GWINDOWS" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#define _KMEMUSER" > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum prnodetype p=PR_GWINDOWS;}" >> ${LSOF_TMPC}.c echo "Testing prdata.h for PR_GWINDOWS, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS" fi # } else if test "X$SOLARIS_26PR_GWINDOWS" = "XY" -o "X$SOLARIS_26PR_GWINDOWS" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS" fi # } fi # } if test "X$SOLARIS_26PR_LDT" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#define _KMEMUSER" > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum prnodetype p=PR_LDT;}" >> ${LSOF_TMPC}.c echo "Testing prdata.h for PR_LDT, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SOLARIS_26PR_LDT" = "XY" -o "X$SOLARIS_26PR_LDT" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT" fi # } fi # } if test $LSOF_VERS -eq 70000 # { then if test "X$SOLARIS_27KERNBITS" = "X" # { then SOLARIS_27KERNBITS=`/bin/isainfo -kv` fi # } echo $SOLARIS_27KERNBITS | grep 64 > /dev/null if test $? -eq 0 # { then echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then echo "" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "! !" echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT |" echo "! GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT SOLARIS 2.7 !" echo "! EXECUTABLES. LSOF WILL BE CONFIGURED FOR A 32 BIT !" echo "! KERNEL. !" echo "! !" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "" else LSOF_TMP1=`echo $LSOF_CCV | sed -n 's/[^0-9]*\([0-9]\)\..*/\1/p'` if test "X$LSOF_TMP1" = "X" # { then LSOF_TMP1="0" fi # } if test $LSOF_TMP1 -ge 5 # { then LSOF_CFGF="$LSOF_CFGF -xarch=v9" echo "" echo "*********************************" echo "* Configuring for 64 bit kernel *" echo "*********************************" echo "" LSOF_CINFO="64 bit kernel" else echo "" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "! !" echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT |" echo "! THE VERSION OF SUN C AVAILABLE DOESN'T SUPPORT THE !" echo "! -xarch=v9 FLAG. LSOF WILL BE CONFIGURED FOR A 32 BIT !" echo "! KERNEL. !" echo "! !" echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!" echo "" fi # } fi # } else echo "" echo "*********************************" echo "* Configuring for 32 bit kernel *" echo "*********************************" echo "" LSOF_CINFO="32 bit kernel" fi # } fi # } ;; *) echo "Unsupported Solaris version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-Dsolaris=$LSOF_VERS $LSOF_CFGF" # Test for VSOCK. if test "X$SOLARIS_VSOCK" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c echo "Testing vnode.h for VSOCK, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SOLARIS_VSOCK" = "XY" -o "X$SOLARIS_VSOCK" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then if test "X$SUN_AFSAPATHDEF" = "X" # { then ls /usr/vice/etc/modload/libafs > /dev/null 2>&1 if test $? -ne 0 # { then LSOF_TMP1=`ls /usr/vice/etc/modload/libafs* 2>/dev/null | wc -l` if test $LSOF_TMP1 -ne 0 # { then SUN_AFSAPATHDEF=`ls /usr/vice/etc/modload/libafs*` fi # } fi # } fi # } if test "X$SUN_AFSAPATHDEF" != "X" # { then LSOF_CFGF="$LSOF_CFGF -DAFSAPATHDEF=\\\"$SUN_AFSAPATHDEF\\\"" fi # } LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } # Test for VxFS. if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" if test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_FS_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_sol.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOL_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_machdep.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_MACHDEP_H" fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_solaris.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOLARIS_H" grep "off32_t;" ${LSOF_INCLUDE}/sys/fs/vx_machdep.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF32_T" fi # } grep "off64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF64_T" fi # } grep "vx_u64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_U64_T" fi # } fi # } egrep "struct[ ]vx_inode[ ]\{" ${LSOF_INCLUDE}/sys/fs/vx_inode.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS_VX_INODE" fi # } fi # } # Set libraries and dialect subdirectory. LSOF_CFGL="-lkvm -lelf -lsocket -lnsl" LSOF_DIALECT_DIR=sun # Set PUCC-specific stuff. if test "X$LSOF_LOCALSUFFIX" = "XPUCC" # { then LSOF_DOC="\${DESTDIR}/usr/local/man" fi # } ;; # Configure for SunOS 4.1.x, Sun C and gcc. sunos|sunoscc) if test "X$LSOF_CC" = "X" # { then # See if a compiler is impled by the target name. If a Sun C compiler # is implied, find it. if test "X$LSOF_TGT" = "Xsunos" # { then LSOF_CC=gcc LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'` LSOF_CFGF="-ansi" else if test "X$SUNOS_ACC" = "X" # { then SUNOS_ACC="/usr/lang" fi # } if test -x ${SUNOS_ACC}/acc # { then LSOF_CC=${SUNOS_ACC}/acc else LSOF_CC=cc fi # } fi # } fi # } LSOF_TGT="sunos" echo $LSOF_CC | grep gcc > /dev/null if test $? -ne 0 # { then # See if the Sun C compiler supports the const keyword. if test "X$SUNOS_NOCONST" = "X" # { then rm -f ${LSOF_TMPC}.* echo "main() { const x; }" > ${LSOF_TMPC}.c echo "Testing $LSOF_CC for const support" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC -c ${LSOF_TMPC}.c -o ${LSOF_TMPC}.o > /dev/null 2>&1 else $LSOF_CC -c ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.o > /dev/null 2>&1 fi # } if test $? -ne 0 # { then LSOF_CFGF="-DNOCONST" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SUNOS_NOCONST" = "XY" -o "X$SUNOS_NOCONST" = "Xy" # { then LSOF_CFGF="-DNOCONST" fi # } fi # } fi # } if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_ARCH" = "X" # { then LSOF_ARCH=`uname -m` fi # } if test "X$LSOF_VERS" = "X" # { then # If SunOS version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/' | awk -F. '{printf "%d%02d%02d", $1, $2, $3}'` fi # } LSOF_CFGF="$LSOF_CFGF -DSUNOSV=$LSOF_VERS" LSOF_CFGL="-lkvm" LSOF_DIALECT_DIR=sun if test "X$LSOF_LOCALSUFFIX" = "XPUCC" # { then LSOF_DOC="\${DESTDIR}/usr/man" fi # } # Test for VSOCK. if test "X$SUNOS_VSOCK" = "X" # { then rm -f ${LSOF_TMPC}.* echo "#include " > ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "#include " >> ${LSOF_TMPC}.c echo "main(){" >> ${LSOF_TMPC}.c echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c echo "Testing vnode.h for VSOCK, using $LSOF_CC" echo $LSOF_CC | grep gcc > /dev/null if test $? -eq 0 # { then $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1 else $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1 fi # } if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } rm -f ${LSOF_TMPC}.* else if test "X$SUNOS_VSOCK" = "XY" -o "X$SUNOS_VSOCK" = "Xy" # { then LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK" fi # } fi # } # Test for AFS. if test -r ${AFS_VICE}/etc/ThisCell # { then if test "X$LSOF_SCRIPT_CALL" = "Xno" # { then if test -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } else if test ! -x ./AFSConfig # { then echo "Can't find or execute the AFSConfig script" rm -f $LSOF_HLP exit 1 fi # } ./AFSConfig if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion # { then LSOF_AFS="yes" fi # } fi # } if test "X$LSOF_AFS" = "Xyes" # { then LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'` LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV" LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`" fi # } fi # } ;; # Configure for DEC Ultrix. ultrix) LSOF_CFGF="-Olimit 1024" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -r` fi # } if test "X$LSOF_VERS" = "X" # { then # If the Ultrix version isn't pre-defined, determine it. case $LSOF_VSTR in # { 4.2) LSOF_VERS="40200" ;; 4.3) LSOF_VERS="40300" ;; 4.4) LSOF_VERS="40400" ;; 4.5) LSOF_VERS="40500" ;; *) echo Unknown Ultrix release: `uname -r` rm -f $LSOF_HLP exit 1 ;; esac # } fi # } # Test for a legal Ultrix version. case $LSOF_VERS in # { 40200|40300|40400|40500) ;; *) echo "Unsupported Ultrix version: $LSOF_VERS" rm -f $LSOF_HLP exit 1 ;; esac # } LSOF_CFGF="-DULTRIXV=$LSOF_VERS $LSOF_CFGF" if test "X$ULTRIX_HWNM" = "X" # { then ULTRIX_HWNM=`uname -m` fi # } case $ULTRIX_HWNM in # { RISC) ;; VAX) LSOF_CFGF="$LSOF_CFGF -DVAXULTRIX" ;; *) echo Unknown machine hardware name: `uname -m` rm -f $LSOF_HLP exit 1 ;; esac # } # Test for DECnet if test "X$ULTRIX_DECNET" = "X" # { then if test "X$ULTRIX_USRLIB" = "X" # { then ULTRIX_USRLIB="/usr/lib" fi # } if test -r ${ULTRIX_USRLIB}/libdnet.a -a -r ${LSOF_INCLUDE}netdnet/dn.h # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } else if test "X$ULTRIX_DECNET" = "XY" -o "X$ULTRIX_DECNET" = "Xy" # { then LSOF_TMP1=1 else LSOF_TMP1=0 fi # } fi # } if test $LSOF_TMP1 -eq 1 # { then LSOF_CFGL="-ldnet" LSOF_CFGF="$LSOF_CFGF -DDECnet" else LSOF_CFGL="" fi # } LSOF_DIALECT_DIR=ultrix ;; # Configure for SCO UnixWare. unixware|uw) LSOF_RANLIB="" if test "X$LSOF_VSTR" = "X" # { then LSOF_VSTR=`uname -v` fi # } if test "X$LSOF_VERS" = "X" # { then # If the UnixWare version isn't pre-defined, determine it. LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/; s/\./ /g' | awk '{printf "%d%02d%02d\n", $1, $2, $3;}'` fi # } LSOF_CFGF="-DUNIXWAREV=$LSOF_VERS" # Do UnixWare version-specific stuff. case $LSOF_VERS in # { 20100|20101|20102|20103) LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw21" if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h # { then (cd ./dialects/uw/uw21/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h) fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } LSOF_CFGL="-lsocket -lnsl -lelf -lgen" ;; 70000|70001) LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw7" if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h # { then (cd ./dialects/uw/uw7/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h) fi # } if test -r ${LSOF_INCLUDE}/sys/fs/vx_gemini.h # { then LSOF_CFGF="$LSOF_CFGF -DHASVXFS" fi # } LSOF_CFGL="-lsocket -lnsl -lelf -lgen" /bin/pkginfo | grep -i patch | grep -i ptf7038 > /dev/null if test -r ${LSOF_INCLUDE}/sys/file.h # { then grep f_open ${LSOF_INCLUDE}/sys/file.h > /dev/null if test $? -eq 0 # { then LSOF_CFGF="$LSOF_CFGF -DHAS_F_OPEN" fi # } fi # } ;; *) echo Unsupported UnixWare version: `uname -v` rm -f $LSOF_HLP exit 1 ;; esac # } if test -r ${LSOF_INCLUDE}/sys/fs/xnamnode.h # { then LSOF_CFGF="$LSOF_CFGF -DHASXNAMNODE" fi # } LSOF_DIALECT_DIR=uw ;; # Handle unknown abbreviation. *) echo "Can't configure for $LSOF_TGT." cat $LSOF_HLP rm -f $LSOF_HLP exit 1 ;; # End of LSOF_TGT cases esac # } # Do an inventory of the distribution, as required. if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverInv # { then if test ! -f ./Inventory # Want -x, but Ultrix doesn't grok it. # { then echo "Can't find Inventory script." rm -f $LSOF_HLP exit 1 fi # } ./Inventory fi # } # Make sure target directory exists. if test ! -d ./dialects/$LSOF_DIALECT_DIR # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_MK exists in the target directory. if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_MKF, $LSOF_SPMKF, or $LSOF_MKF.$LSOF_LOCALSUFFIX) exists # in the target directory. if test "X$LSOF_SPMKF" != "X" # { then LSOF_TMP1=$LSOF_SPMKF else LSOF_TMP1=$LSOF_MKF fi # } if test "X$LSOF_LOCALSUFFIX" != "X" # { then LSOF_REST=$LSOF_TMP1.$LSOF_LOCALSUFFIX else LSOF_REST=$LSOF_TMP1 fi # } if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST # { then echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST doesn't exist." rm -f $LSOF_HLP exit 1 fi # } # Make sure $LSOF_VF exists. Extract the version number from it. if test ! -r $LSOF_VF # { then echo "Version number file, ./$LSOF_VF, doesn't exist." rm -f $LSOF_HLP exit 1 else LSOF_VN=`sed "s/.ds VN \(.*\)/\1/" < version` fi # } # Clean up in advance. rm -f $LSOF_F $LSOF_MKFC echo rm -f $LSOF_F $LSOF_MKFC # Make the dialect sources. if test "X$LSOF_MKC" = "X" # { then LSOF_MKC="ln -s" fi # } LSOF_MKC=$LSOF_MKC ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK $LSOF_TGT $LSOF_VERS # Make $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF. echo "# $LSOF_TGT Makefile for lsof version $LSOF_VN" > $LSOF_MKFC echo "" >> $LSOF_MKFC if test "X$LSOF_CC" = "X" # { then LSOF_CC=cc fi # } echo "CC= $LSOF_CC" >> $LSOF_MKFC if test "X$LSOF_CCV" != "X" # { then echo "CCV= $LSOF_CCV" >> $LSOF_MKFC fi # } if test "X$LSOF_LIB_NO" = "X" # { then echo "LIB= ${LSOF_LIB}/liblsof.a" >> $LSOF_MKFC fi # } echo "" >> $LSOF_MKFC if test "X$LSOF_LD" != "X" # { then echo "LD= $LSOF_LD" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_CINFO" != "X" # { then echo "CINFO= $LSOF_CINFO" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_CFGD" != "X" # { then echo "CFGD= $LSOF_CFGD" >> $LSOF_MKFC fi # } if test "X$LSOF_CFGDN" != "X" # { then echo "CFGDN= $LSOF_CFGDN" >> $LSOF_MKFC fi # } if test "X$LSOF_ARCH" != "X" # { then LSOF_CFGF="$LSOF_CFGF -DLSOF_ARCH=\\\"$LSOF_ARCH\\\"" fi # } if test "X$LSOF_VSTR" != "X" # { then LSOF_TMP=`echo $LSOF_VSTR | sed 's/(/\\\\(/g' | sed 's/)/\\\\)/g'` LSOF_CFGF="$LSOF_CFGF -DLSOF_VSTR=\\\"$LSOF_TMP\\\"" fi # } echo "CFGF= $LSOF_CFGF" >> $LSOF_MKFC if test "X$LSOF_LIB_NO" = "X" # { then echo "CFGL= $LSOF_FCFGL -L./$LSOF_LIB -llsof $LSOF_CFGL" >> $LSOF_MKFC fi # } if test "X$LSOF_DEBUG" = "X" # { then LSOF_DEBUG="-O" fi # } echo "" >> $LSOF_MKFC echo "DEBUG= $LSOF_DEBUG" >> $LSOF_MKFC echo "" >> $LSOF_MKFC if test "X$LSOF_DINC" != "X" # { then echo "DINC= $LSOF_DINC" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } if test "X$LSOF_DOC" != "X" # { then echo "DOC=$LSOF_DOC" >> $LSOF_MKFC fi # } echo "" >> $LSOF_MKFC if test "X$LSOF_DISTRIBKVM" != "X" -a "X$LSOF_DISTRIBKVM" != "XKVM" # { then echo "KVM= $LSOF_DISTRIBKVM" >> $LSOF_MKFC echo "" >> $LSOF_MKFC fi # } rm -f ${LSOF_LIB}/$LSOF_LIBMKF if test "X$LSOF_LIB_NO" = "X" # { then cp $LSOF_MKFC ${LSOF_LIB}/$LSOF_LIBMKF fi # } cat ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST >> $LSOF_MKFC if test "X$LSOF_LIB_NO" = "X" # { then # Put optional archiver and randomizing strings in ${LSOF_LIB}/$LSOF_LIBMKF. # Add its skeleton section. echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF if test "X$LSOF_AR" != "X" # { then echo "AR= $LSOF_AR" >> ${LSOF_LIB}/$LSOF_LIBMKF fi # } if test "X$LSOF_RANLIB" != "X" # { then echo "RANLIB= $LSOF_RANLIB" >> ${LSOF_LIB}/$LSOF_LIBMKF fi # } echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF cat ${LSOF_LIB}/$LSOF_LIBMKFSKEL >> ${LSOF_LIB}/$LSOF_LIBMKF echo $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF created. else echo $LSOF_MKFC created. fi # } rm -f $LSOF_HLP # Call Customize, as required. if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverCust # { then if test ! -f ./Customize # { Want -x, but Ultrix doesn't grok it. then echo "Can't find Customize script." exit 1 fi # } ./Customize $LSOF_DIALECT_DIR fi # } exit 0 ./lsof_4.42/arg.c000644 023074 000012 00000111421 06705147614 014476 0ustar00varadhanstaff000000 000000 /* * arg.c - common argument processing support functions for lsof */ /* * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * * Written by Victor A. Abell * * This software is not subject to any license of the American Telephone * and Telegraph Company or the Regents of the University of California. * * Permission is granted to anyone to use this software for any purpose on * any computer system, and to alter it and redistribute it freely, subject * to the following restrictions: * * 1. Neither the authors nor Purdue University are responsible for any * consequences of the use of this software. * * 2. The origin of this software must not be misrepresented, either by * explicit claim or by omission. Credit to the authors and Purdue * University must appear in documentation and sources. * * 3. Altered versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 4. This notice may not be removed or altered. */ #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: arg.c,v 1.25 99/03/29 07:08:16 abe Exp $"; #endif #include "lsof.h" _PROTOTYPE(static int ckfd_range,(char *first, char *dash, char *last, int *lo, int *hi)); _PROTOTYPE(static void enter_fd_lst,(char *nm, int lo, int hi)); _PROTOTYPE(static int enter_nwad,(struct nwad *n, int sp, int ep, char *s, struct hostent *he)); /* * ckfd_range() - check fd range */ static int ckfd_range(first, dash, last, lo, hi) char *first; /* starting character */ char *dash; /* '-' location */ char *last; /* '\0' location */ int *lo; /* returned low value */ int *hi; /* returned high value */ { char *cp; /* * See if the range character pointers make sense. */ if (first >= dash || dash >= last) { (void) fprintf(stderr, "%s: illegal FD range for -d: ", Pn); safestrprt(first, stderr, 1); return(1); } /* * Assemble and check the high and low values. */ for (cp = first, *lo = 0; *cp && cp < dash; cp++) { if (!isdigit((unsigned char)*cp)) { FD_range_nondigit: (void) fprintf(stderr, "%s: non-digit in -d FD range: ", Pn); safestrprt(first, stderr, 1); return(1); } *lo = (*lo * 10) + (int)(*cp - '0'); } for (cp = dash+1, *hi = 0; *cp && cp < last; cp++) { if (!isdigit((unsigned char)*cp)) goto FD_range_nondigit; *hi = (*hi * 10) + (int)(*cp - '0'); } if (*lo >= *hi) { (void) fprintf(stderr, "%s: -d FD range's low >= its high: ", Pn); safestrprt(first, stderr, 1); return(1); } return(0); } /* * ck_file_arg() - check file arguments */ int ck_file_arg(i, ac, av, fv, rs, sbp) int i; /* first file argument index */ int ac; /* argument count */ char *av[]; /* argument vector */ int fv; /* Ffilesys value (real or temporary) */ int rs; /* Readlink() status if argument count == 1: * 0 = undone; 1 = done */ struct stat *sbp; /* if non-NULL, pointer to stat(2) buffer * when argument count == 1 */ { unsigned char ad, an; short err = 0; char *fnm, *fsnm, *path; int fsm, ftype, j; MALLOC_S l; struct mounts *mp; static struct mounts **mmp = (struct mounts **)NULL; int mx, nm; static int nma = 0; struct stat sb; struct sfile *sfp; short ss = 0; #if defined(CKFA_EXPDEV) dev_t dev, rdev; #endif /* defined(CKFA_EXPDEV) */ #if defined(HASPROCFS) int pfsnl = -1; pid_t pid; struct procfsid *pfi; #endif /* defined(HASPROCFS) */ /* * Loop through arguments. */ for (; i < ac; i++) { if (rs && (ac == 1) && (i == 0)) path = av[i]; else { if (!(path = Readlink(av[i]))) { ErrStat = 1; continue; } } /* * Remove a terminating `/' from Readlink()-expanded path, but never * from an argument-specified path. Don't remove `/' from a single * character path name, either. * * Check for file system argument. */ if (path != av[i] && (j = strlen(path)) > 1 && path[j-1] == '/') path[j-1] = '\0'; for (ftype = 1, mp = readmnt(), nm = 0; (fv != 1) && mp; mp = mp->next) { fsm = 0; if (strcmp(mp->dir, path) == 0) fsm++; else if (fv == 2 || (mp->fs_mode & S_IFMT) == S_IFBLK) { if (mp->fsnmres && strcmp(mp->fsnmres, path) == 0) fsm++; } if (!fsm) continue; ftype = 0; /* * Skip duplicates. */ for (mx = 0; mx < nm; mx++) { if (strcmp(mp->dir, mmp[mx]->dir) == 0 && mp->dev == mmp[mx]->dev && mp->inode == mmp[mx]->inode) break; } if (mx < nm) continue; /* * Allocate space for and save another mount point match and * the type of match -- directory name (mounted) or file system * name (mounted-on). */ if (nm >= nma) { nma += 5; l = (MALLOC_S)(nma * sizeof(struct mounts *)); if (mmp) mmp = (struct mounts **)realloc((MALLOC_P *)mmp, l); else mmp = (struct mounts **)malloc(l); if (!mmp) { (void) fprintf(stderr, "%s: no space for mount pointers\n", Pn); Exit(1); } } mmp[nm++] = mp; } if (fv == 2 && nm == 0) { (void) fprintf(stderr, "%s: not a file system: ", Pn); safestrprt(av[i], stderr, 1); ErrStat = 1; continue; } /* * Loop through the file system matches. If there were none, make one * pass through the loop, using simply the path name. */ mx = 0; do { /* * Allocate an sfile structure and fill in the type and link. */ if (!(sfp = (struct sfile *)malloc(sizeof(struct sfile)))) { (void) fprintf(stderr, "%s: no space for files\n", Pn); Exit(1); } sfp->next = Sfile; Sfile = sfp; sfp->f = 0; if ((sfp->type = ftype)) { /* * For a non-file system path, use the path as the file name * and set a NULL file system name. */ fnm = path; fsnm = (char *)NULL; /* * Stat the path to obtain its characteristics. */ if (sbp && (ac == 1)) sb = *sbp; else { if (statsafely(fnm, &sb) != 0) { int en = errno; (void) fprintf(stderr, "%s: status error on ", Pn); safestrprt(fnm, stderr, 0); (void) fprintf(stderr, ": %s\n", strerror(en)); Sfile = sfp->next; (void) free((FREE_P *)sfp); ErrStat = 1; continue; } } sfp->i = sb.st_ino; sfp->mode = sb.st_mode & S_IFMT; #if defined(CKFA_EXPDEV) /* * Expand device numbers before saving, so that they match the * already-expanded local mount info table device numbers. * (This is an EP/IX 2.1.1 and above artifact.) */ dev = expdev(sb.st_dev); rdev = expdev(sb.st_rdev); #endif /* defined(CKFA_EXPDEV) */ if (sfp->mode == S_IFBLK || sfp->mode == S_IFCHR #if defined(CKFA_XDEVTST) || CKFA_XDEVTST #endif /* defined(CKFA_XDEVTST) */ ) #if defined(CKFA_EXPDEV) sfp->dev = rdev; else sfp->dev = dev; #else /* !defined(CKFA_EXPDEV) */ sfp->dev = sb.st_rdev; else sfp->dev = sb.st_dev; #endif /* defined(CKFA_EXPDEV) */ #if defined(CKFA_MPXCHAN) /* * Save a (possible) multiplexed channel number. (This is an * AIX artifact.) */ sfp->ch = getchan(path); #endif /* defined(CKFA_MPXCHAN) */ } else { mp = mmp[mx++]; ss++; #if defined(HASPROCFS) /* * If this is a /proc file system, set the search flag and * abandon the sfile entry. */ if (mp == Mtprocfs) { Sfile = sfp->next; (void) free((FREE_P *)sfp); Procsrch = 1; continue; } #endif /* defined(HASPROCFS) */ /* * Derive file name and file system name for a mount point. * * Save the device number, inode number, and modes. */ fnm = mp->dir; fsnm = mp->fsname; sfp->dev = mp->dev; sfp->i = mp->inode; sfp->mode = mp->mode & S_IFMT; } ss = 1; /* indicate a "safe" stat() */ /* * Store the file name and file system name pointers in the sfile * structure, allocating space as necessary. */ if (!fnm || fnm == path) { sfp->name = fnm; an = 0; } else { if (!(sfp->name = mkstrcpy(fnm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for file name: ", Pn); safestrprt(fnm, stderr, 1); Exit(1); } an = 1; } if (!fsnm || fsnm == path) { sfp->devnm = fsnm; ad = 0; } else { if (!(sfp->devnm = mkstrcpy(fsnm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for file system name: ", Pn); safestrprt(fsnm, stderr, 1); Exit(1); } ad = 1; } if (!(sfp->aname = mkstrcpy(av[i], (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for argument file name: ", Pn); safestrprt(av[i], stderr, 1); Exit(1); } #if defined(HASPROCFS) /* * See if this is an individual member of a proc file system. */ if (!Mtprocfs || Procsrch) continue; # if defined(HASFSTYPE) if (strcmp(sb.st_fstype, HASPROCFS) != 0) continue; # endif /* defined(HASFSTYPE) */ if (pfsnl == -1) pfsnl = strlen(Mtprocfs->dir); if (!pfsnl) continue; if (strncmp(Mtprocfs->dir, path, pfsnl) != 0) continue; if (path[pfsnl] != '/') # if defined(HASPINODEN) pid = 0; # else /* !defined(HASPINODEN) */ continue; # endif /* defined(HASPINODEN) */ else { for (j = pfsnl+1; path[j]; j++) { if (!isdigit((unsigned char)path[j])) break; } if (path[j] || (j - pfsnl - 1) < 1 || (sfp->mode & S_IFMT) != S_IFREG) # if defined(HASPINODEN) pid = 0; # else /* !defined(HASPINODEN) */ continue; # endif /* defined(HASPINODEN) */ else pid = atoi(&path[pfsnl+1]); } if (!(pfi = (struct procfsid *)malloc((MALLOC_S) sizeof(struct procfsid)))) { (void) fprintf(stderr, "%s: no space for %s ID: ", Pn, Mtprocfs->dir); safestrprt(path, stderr, 1); Exit(1); } pfi->pid = pid; pfi->f = 0; pfi->nm = sfp->aname; pfi->next = Procfsid; Procfsid = pfi; # if defined(HASPINODEN) pfi->inode = (unsigned long)sfp->i; # endif /* defined(HASPINODEN) */ /* * Abandon the Sfile entry, lest it be used in is_file_named(). */ Sfile = sfp->next; if (ad) (void) free((FREE_P *)sfp->devnm); if (an) (void) free((FREE_P *)sfp->name); (void) free((FREE_P *)sfp); #endif /* defined(HASPROCFS) */ } while (mx < nm); } if (!ss) err = 1; return((int)err); } #if defined(HASDCACHE) /* * ctrl_dcache() - enter device cache control */ int ctrl_dcache(c) char *c; /* control string */ { int rc = 0; if (!c) { (void) fprintf(stderr, "%s: no device cache option control string\n", Pn); return(1); } /* * Decode argument function character. */ switch (*c) { case '?': if (*(c+1) != '\0') { (void) fprintf(stderr, "%s: nothing should follow -D?\n", Pn); return(1); } DChelp = 1; return(0); case 'b': case 'B': if (Setuidroot #if !defined(WILLDROPGID) || Myuid #endif /* !defined(WILLDROPGID) */ ) rc = 1; else DCstate = 1; break; case 'r': case 'R': if (Setuidroot && *(c+1)) rc = 1; else DCstate = 2; break; case 'u': case 'U': if (Setuidroot #if !defined(WILLDROPGID) || Myuid #endif /* !defined(WILLDROPGID) */ ) rc = 1; else DCstate = 3; break; case 'i': case 'I': if (*(c+1) == '\0') { DCstate = 0; return(0); } /* fall through */ default: (void) fprintf(stderr, "%s: unknown -D option: ", Pn); safestrprt(c, stderr, 1); return(1); } if (rc) { (void) fprintf(stderr, "%s: -D option restricted to root: ", Pn); safestrprt(c, stderr, 1); return(1); } /* * Skip to optional path name and save it. */ for (c++; *c && (*c == ' ' || *c == '\t'); c++) ; if (strlen(c)) { if (!(DCpathArg = mkstrcpy(c, (MALLOC_S)NULL))) { (void) fprintf(stderr, "%s: no space for -D path: ", Pn); safestrprt(c, stderr, 1); Exit(1); } } return(0); } #endif /* defined(HASDCACHE) */ /* * enter_fd() - enter file descriptor list for searching */ int enter_fd(f) char *f; /* file descriptor list pointer */ { char buf[32], c, *cp1, *cp2, *dash; int err, hi, lo; char *fc; /* * Check for non-empty list and make a copy. */ if (!f || (strlen(f) + 1) < 2) { (void) fprintf(stderr, "%s: no file descriptor specified\n", Pn); return(1); } if (!(fc = mkstrcpy(f, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for fd string: ", Pn); safestrprt(f, stderr, 1); Exit(1); } /* * Isolate each file descriptor in the comma-separated list, then enter it * in the file descriptor string list. If a descriptor has the form: * * [0-9]+-[0-9]+ * * treat it as an ascending range of file descriptor numbers. */ for (cp1 = fc, err = 0; *cp1;) { for (cp2 = cp1, dash = (char *)NULL; *cp2 && *cp2 != ','; cp2++) { if (*cp2 == '-') dash = cp2; } if ((c = *cp2) != '\0') *cp2 = '\0'; if (cp2 > cp1) { if (dash) { if (ckfd_range(cp1, dash, cp2, &lo, &hi)) err = 1; else (void) enter_fd_lst((char *)NULL, lo, hi); } else (void) enter_fd_lst(cp1, 0, 0); } if (c == '\0') break; cp1 = cp2 + 1; } (void) free((FREE_P *)fc); return(err); } /* * enter_fd_lst() - make an entry in the FD list, Fdl */ static void enter_fd_lst(nm, lo, hi) char *nm; /* FD name (none if NULL) */ int lo; /* FD low boundary (if nm NULL) */ int hi; /* FD high boundary (if nm NULL) */ { char *cp; struct fd_lst *f; int n; /* * Allocate an fd_lst entry. */ if (!(f = (struct fd_lst *)malloc((MALLOC_S)sizeof(struct fd_lst)))) { (void) fprintf(stderr, "%s: no space for FD list entry\n", Pn); Exit(1); } if (nm) { /* * Process an FD name. First see if it contains only digits; if it * does, convert them to an integer and set the low and high * boundaries to the result. * * If the name has a non-digit, store it as a string, and set the * boundaries to impossible values (i.e., low > high). */ for (cp = nm, n = 0; *cp; cp++) { if (!isdigit((unsigned char)*cp)) break; n = (n * 10) + (int)(*cp - '0'); } if (*cp) { if (!(f->nm = mkstrcpy(nm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for copy of: %s\n", Pn, nm); Exit(1); } lo = 1; hi = 0; } else { f->nm = (char *)NULL; lo = hi = n; } } else f->nm = (char *)NULL; f->hi = hi; f->lo = lo; f->next = Fdl; Fdl = f; } /* * enter_dir() - enter the files of a directory for searching */ #define EDDEFFNL 128 /* default file name length */ int enter_dir(d, descend) char *d; /* directory path name pointer */ int descend; /* subdirectory descend flag: * 0 = don't descend * 1 = descend */ { char *av[2]; dev_t ddev; DIR *dfp; char *dn = (char *)NULL; MALLOC_S dnl, dnamlen; struct DIRTYPE *dp; int en, err, sl; int fct = 0; char *fp = (char *)NULL; MALLOC_S fpl = (MALLOC_S)0; MALLOC_S fpli = (MALLOC_S)0; struct stat sb; /* * Check the directory path; reduce symbolic links; stat(2) it; make sure it's * really a directory. */ if (!d || !*d || *d == '+' || *d == '-') { if (!Fwarn) (void) fprintf(stderr, "%s: +d not followed by a directory path\n", Pn); return(1); } if (!(dn = Readlink(d))) return(1); if (statsafely(dn, &sb)) { if (!Fwarn) { en = errno; (void) fprintf(stderr, "%s: WARNING: can't stat(", Pn); safestrprt(dn, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } return(1); } if ((sb.st_mode & S_IFMT) != S_IFDIR) { if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: not a directory: ", Pn); safestrprt(dn, stderr, 1); } if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } return(1); } ddev = sb.st_dev; /* * Stack the directory and record it in Sfile for searching. */ Dstkn = Dstkx = 0; Dstk = (char **)NULL; (void) stkdir(dn); av[0] = (dn == d) ? mkstrcpy(dn, (MALLOC_S)NULL) : dn; av[1] = (char *)NULL; dn = (char *)NULL; if (!ck_file_arg(0, 1, av, 1, 1, &sb)) { av[0] = (char *)NULL; fct++; } /* * Unstack the next directory and examine it. */ while (--Dstkx >= 0) { if (!(dn = Dstk[Dstkx])) continue; Dstk[Dstkx] = (char *)NULL; /* * Open the directory path and prepare its name for use with the * files in the directory. */ if (!(dfp = OpenDir(dn))) { if (!Fwarn) { if ((en = errno) != ENOENT) { (void) fprintf(stderr, "%s: WARNING: can't opendir(", Pn); safestrprt(dn, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } } (void) free((FREE_P *)dn); dn = (char *)NULL; continue; } dnl = strlen(dn); sl = ((dnl > 0) && (*(dn + dnl - 1) == '/')) ? 0 : 1; /* * Define space for possible addition to the directory path. */ fpli = (MALLOC_S)(dnl + sl + EDDEFFNL + 1); if ((int)fpli > (int)fpl) { fpl = fpli; if (!fp) fp = (char *)malloc(fpl); else fp = (char *)realloc(fp, fpl); if (!fp) { (void) fprintf(stderr, "%s: no space for path to entries in directory: %s\n", Pn, dn); Exit(1); } } (void) sprintf(fp, "%s%s", dn, sl ? "/" : ""); (void) free((FREE_P *)dn); dn = (char *)NULL; /* * Read the contents of the directory. */ for (dp = ReadDir(dfp); dp; dp = ReadDir(dfp)) { /* * Skip: entries with no inode number; * entries with a zero length name; * "."; * and "..". */ if (!dp->d_ino) continue; #if defined(HASDNAMLEN) dnamlen = (MALLOC_S)dp->d_namlen; #else /* !defined(HASDNAMLEN) */ dnamlen = (MALLOC_S)strlen(dp->d_name); #endif /* defined(HASDNAMLEN) */ if (!dnamlen) continue; if (dnamlen <= 2 && dp->d_name[0] == '.') { if (dnamlen == 1) continue; if (dp->d_name[1] == '.') continue; } /* * Form the entry's path name. */ fpli = (MALLOC_S)(dnamlen - (fpl - dnl - sl - 1)); if ((int)fpli > 0) { fpl += fpli; if (!(fp = (char *)realloc(fp, fpl))) { (void) fprintf(stderr, "%s: no space for: ", Pn); safestrprt(dn, stderr, 0); putc('/', stderr); safestrprtn(dp->d_name, dnamlen, stderr, 1); Exit(1); } } (void) strncpy(fp + dnl + sl, dp->d_name, dnamlen); fp[dnl + sl + dnamlen] = '\0'; /* * Lstatsafely() the entry; complain if that fails. * * Ignore symbolic links and files not not the directory's device. * * Stack entries that represent subdirectories. */ if (lstatsafely(fp, &sb)) { if ((en = errno) != ENOENT) { if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: can't lstat(", Pn); safestrprt(fp, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } } continue; } if ((sb.st_mode & S_IFMT) == S_IFLNK || sb.st_dev != ddev) continue; if (av[0]) { (void) free((FREE_P *)av[0]); av[0] = (char *)NULL; } av[0] = mkstrcpy(fp, (MALLOC_S *)NULL); if ((sb.st_mode & S_IFMT) == S_IFDIR && descend) /* * Stack a subdirectory according to the descend argument. */ stkdir(av[0]); /* * Use ck_file_arg() to record the entry for searching. Force it * to consider the entry a file, not a file system. */ if (!ck_file_arg(0, 1, av, 1, 1, &sb)) { av[0] = (char *)NULL; fct++; } } (void) CloseDir(dfp); if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } } /* * Free malloc()'d space. */ if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } if (av[0] && av[0] != fp) { (void) free((FREE_P *)av[0]); av[0] = (char *)NULL; } if (fp) { (void) free((FREE_P *)fp); fp = (char *)NULL; } if (Dstk) { (void) free((FREE_P *)Dstk); Dstk = (char **)NULL; } if (!fct) { /* * Warn if no files were recorded for searching. */ if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: no files found in directory: ", Pn); safestrprt(d, stderr, 1); } return(1); } return(0); } /* * enter_id() - enter PGRP or PID for searching */ int enter_id(ty, p) enum IDType ty; /* type: PGRP or PID */ char *p; /* process group ID string pointer */ { char *cp; int i, id, mx, n; struct int_lst *s; if (!p) { (void) fprintf(stderr, "%s: no process%s ID specified\n", Pn, (ty == PGRP) ? " group" : ""); return(1); } /* * Set up variables for the type of ID. */ switch (ty) { case PGRP: mx = Mxpgrp; n = Npgrp; s = Spgrp; break; case PID: mx = Mxpid; n = Npid; s = Spid; break; default: (void) fprintf(stderr, "%s: enter_id \"", Pn); safestrprt(p, stderr, 0); (void) fprintf(stderr, "\", invalid type: %d\n", ty); Exit(1); } /* * Convert and store the ID. */ for (cp = p; *cp;) { /* * Assemble ID. */ for (id = 0; *cp && *cp != ','; cp++) { #if defined(__STDC__) if (!isdigit((unsigned char)*cp)) #else if (!isascii(*cp) || ! isdigit((unsigned char)*cp)) #endif /* __STDC__ */ { (void) fprintf(stderr, "%s: illegal process%s ID: ", Pn, (ty == PGRP) ? " group" : ""); safestrprt(p, stderr, 1); return(1); } id = (id * 10) + *cp - '0'; } if (*cp) cp++; /* * Avoid entering duplicates. */ for (i = 0; i < n; i++) { if (id == s[i].i) break; } if (i < n) continue; /* * Allocate table table space. */ if (n >= mx) { mx += IDINCR; if (!s) s = (struct int_lst *)malloc( (MALLOC_S)(sizeof(struct int_lst) * mx)); else s = (struct int_lst *)realloc((MALLOC_P *)s, (MALLOC_S)(sizeof(struct int_lst) * mx)); if (!s) { (void) fprintf(stderr, "%s: no space for %d process%s IDs", Pn, mx, (ty == PGRP) ? " group" : ""); Exit(1); } } s[n].f = 0; s[n++].i = id; } /* * Save variables for the type of ID. */ if (ty == PGRP) { Mxpgrp = mx; Npgrp = n; Spgrp = s; } else { Mxpid = mx; Npid = Npuns = n; Spid = s; } return(0); } /* * enter_network_address() - enter Internet address for searching */ int enter_network_address(na) char *na; /* Internet address string pointer */ { int ae, ep, i, pr, sp; unsigned char *ap; char *cp, *p, *wa; struct hostent *he = (struct hostent *)NULL; char *hn = (char *)NULL; MALLOC_S l; struct nwad n; int pt = 0; int pu = 0; struct servent *se, *se1; char *sn = (char *)NULL; MALLOC_S snl = 0; int err, must_free_hostent = 0; if (!na) { (void) fprintf(stderr, "%s: no network address specified\n", Pn); return(1); } /* * Initialize network address structure. */ n.proto = (char *)NULL; n.af = 0; for (i = 0; i < MAX_AF_ADDR; i++) { n.a[i] = 0; } /* * Process protocol name, optionally followed by a '@' and a host name or * Internet address, or a ':' and a service name or port number. */ wa = na; if (*wa && *wa != '@' && *wa != ':') { for (p = wa; *wa && *wa != '@' && *wa != ':'; wa++) ; if ((l = wa - p)) { if (!(n.proto = mkstrcat(p, l, (char *)NULL, -1, (char *)NULL, -1, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for protocol name from ", Pn); safestrprt(na, stderr, 1); nwad_exit: if (n.proto) (void) free((FREE_P *)n.proto); if (hn) (void) free((FREE_P *)hn); if (sn) (void) free((FREE_P *)sn); if (must_free_hostent) (void) freehostent(he); return(1); } /* * The protocol name should be "tcp" or "udp". */ if (strcasecmp(n.proto, "tcp") != 0 && strcasecmp(n.proto, "udp") != 0) { (void) fprintf(stderr, "%s: unknown protocol name (%s) in ", Pn, n.proto); safestrprt(na, stderr, 1); goto nwad_exit; } /* * Convert protocol name to lower case. */ for (p = n.proto; *p; p++) { if (*p >= 'A' && *p <= 'Z') *p = *p - 'A' + 'a'; } } } /* * Process an IPv4 address (1.2.3.4), IPv6 address ([1:2:3:4:5:6:7:8]), * or host name, preceded by a '@' and optionally followed by a colon * and a service name or port number. */ if (*wa == '@') { wa++; if (!*wa || *wa == ':') { unacc_address: (void) fprintf(stderr, "%s: unacceptable Internet address in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } if (*wa < '0' || *wa > '9' && *wa != '[') { /* * Assemble host name. */ for (p = wa; *p && *p != ':'; p++) ; if ((l = p - wa)) { if (!(hn = mkstrcat(wa, l, (char *)NULL, -1, (char *)NULL, -1, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for host name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } #if defined(HASIPv6) && (defined(HASBYNAME2) || defined(HASIPNODEBYNAME)) #if defined(HASBYNAME2) if (!(he = gethostbyname2(hn, AF_INET)) #else if (!(he = getipnodebyname(hn, AF_INET, AI_DEFAULT, &err)) #endif /* HASBYNAME2 */ || he->h_addrtype != AF_INET) { #if defined(HASBYNAME2) if (!(he = gethostbyname2(hn, AF_INET6)) #else if (!(he = getipnodebyname(hn, AF_INET6, 0, &err)) #endif || he->h_addrtype != AF_INET6) { #if defined(HASIPNODEBYNAME) (void)freehostent(he); #endif he = (struct hostent *)NULL; } } if (!he) #else /* !defined(HASIPv6) || !defined(HASBYNAME2) */ if (!(he = gethostbyname(hn))) #endif /* defined(HASIPv6) && !defined(HASBYNAME2) */ { fprintf(stderr, "%s: unknown host name (%s) in ", Pn, hn); safestrprt(na, stderr, 1); goto nwad_exit; } #if defined(HASIPNODEBYNAME) must_free_hostent = 1; #endif ap = (unsigned char *)he->h_addr; n.af = he->h_addrtype; #if defined(HASIPv6) for (i = 0; i < (he->h_length - 1) && i < (MAX_AF_ADDR - 1); i++) { n.a[i] = *ap++; } n.a[i] = *ap; #else /* !defined(HASIPv6) */ n.a[0] = *ap++; n.a[1] = *ap++; n.a[2] = *ap++; n.a[3] = *ap; #endif /* defined(HASIPv6) */ } wa = p; } else if (*wa == '[') { #if defined(HASIPv6) /* * Assemble IPv6 address. */ if (!(cp = strrchr(++wa, ']'))) goto unacc_address; *cp = '\0'; i = inet_pton(AF_INET6, wa, (void *)&n.a); *cp = ']'; if (i != 1) goto unacc_address; for (ae = i = 0; i < MAX_AF_ADDR; i++) { if ((ae |= n.a[i])) break; } if (!ae) goto unacc_address; n.af = AF_INET6; wa = cp + 1; #else /* !defined(HASIPv6) */ (void) fprintf(stderr, "%s: unsupported IPv6 address in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; #endif } else { /* * Assemble IPv4 address. */ for (i = 0; *wa; wa++) { if (*wa == ':') break; if (*wa == '.') { i++; if (i >= MIN_AF_ADDR) break; continue; } if (*wa < '0' || *wa > '9') goto unacc_address; ae = (10 * n.a[i]) + *wa - '0'; if (ae > 255) goto unacc_address; n.a[i] = ae; } if (i != (MIN_AF_ADDR - 1) || (!n.a[0] && !n.a[1] && !n.a[2] && !n.a[3])) goto unacc_address; n.af = AF_INET; } } /* * If there is no port number, enter the address. */ if (!*wa) { if (enter_nwad(&n, -1, -1, na, he)) goto nwad_exit; if (sn) (void) free((FREE_P *)sn); return(0); } /* * Process a service name or port number list, preceded by a colon. * * Entries of the list are separated with commas; elements of a numeric range * are specified with a separating minus sign (`-'); all service names must * belong to the same protocol; embedded spaces are not allowed. An embedded * minus sign in a name is taken to be part of the name, the starting entry * of a range can't be a service name. */ if (*wa != ':' || *(wa + 1) == '\0') { unacc_port: (void) fprintf(stderr, "%s: unacceptable port specification in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } for (++wa; wa && *wa; wa++) { for (ep = pr = sp = 0; *wa; wa++) { if (*wa < '0' || *wa > '9') { /* * Convert service name to port number, using already-specified * protocol name. A '-' is taken to be part of the name; hence * the staring entry of a range can't be a service name. */ for (p = wa; *wa && *wa != ','; wa++) ; if (!(l = wa - p)) { (void) fprintf(stderr, "%s: invalid service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } if (sn) { if (l > snl) { sn = (char *)realloc((MALLOC_P *)sn, l + 1); snl = l; } } else { sn = (char *)malloc(l + 1); snl = l; } if (!sn) { (void) fprintf(stderr, "%s: no space for service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } (void) strncpy(sn, p, l); *(sn + l) = '\0'; if (n.proto) { /* * If the protocol has been specified, look up the port * number for the service name for the specified protocol. */ if (!(se = getservbyname(sn, n.proto))) { (void) fprintf(stderr, "%s: unknown service %s for %s in ", Pn, sn, n.proto); safestrprt(na, stderr, 1); goto nwad_exit; } pt = (int)ntohs(se->s_port); } else { /* * If no protocol has been specified, look up the port * numbers for the service name for both TCP and UDP. */ if((se = getservbyname(sn, "tcp"))) pt = (int)ntohs(se->s_port); if ((se1 = getservbyname(sn, "udp"))) pu = (int)ntohs(se1->s_port); if (!se && !se1) { (void) fprintf(stderr, "%s: unknown service %s in ", Pn, sn); safestrprt(na, stderr, 1); goto nwad_exit; } if (se && se1 && pt != pu) { (void) fprintf(stderr, "%s: TCP=%d and UDP=%d %s ports conflict;\n", Pn, pt, pu, sn); (void) fprintf(stderr, " specify \"tcp:%s\" or \"udp:%s\".\n", sn, sn); goto nwad_exit; } if (!se && se1) pt = pu; } if (pr) ep = pt; else { sp = pt; if (*wa == '-') pr++; } } else { /* * Assemble port number. */ for (; *wa && *wa != ','; wa++) { if (*wa == '-') { if (pr) goto unacc_port; pr++; break; } if (*wa < '0' || *wa > '9') goto unacc_port; if (pr) ep = (ep * 10) + *wa - '0'; else sp = (sp * 10) + *wa - '0'; } } if (!*wa || *wa == ',') break; if (pr) continue; goto unacc_port; } if (!pr) ep = sp; if (ep < sp) goto unacc_port; /* * Enter completed port or port range specification. */ if (enter_nwad(&n, sp, ep, na, he)) goto nwad_exit; if (!*wa) break; } if (must_free_hostent) (void) freehostent(he); if (sn) (void) free((FREE_P *)sn); return(0); } /* * enter_nwad() - enter nwad structure */ static int enter_nwad(n, sp, ep, s, he) struct nwad *n; /* pointer to partially completed * nwad (less port) */ int sp; /* starting port number */ int ep; /* ending port number */ char *s; /* string that states the address */ struct hostent *he; /* pointer to hostent struct from which * network address came */ { int ac; unsigned char *ap; static int na = 0; struct nwad nc; struct nwad *np; /* * Allocate space for the argument specification. */ if (strlen(s)) { if (!(n->arg = mkstrcpy(s, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for Internet argument: ", Pn); safestrprt(s, stderr, 1); Exit(1); } } else n->arg = (char *)NULL; /* * Loop through all hostent addresses. */ for (ac = 1, nc = *n;;) { /* * Test address specification -- it must contain at least one of: * protocol, Internet address or port. If correct, link into search * list. */ if (!nc.proto && !nc.a[0] && !nc.a[1] && !nc.a[2] && !nc.a[3] #if defined(HASIPv6) && (nc.af != AF_INET6 || (!nc.a[4] && !nc.a[5] && !nc.a[6] && !nc.a[7] && !nc.a[8] && !nc.a[9] && !nc.a[10] && !nc.a[11] && !nc.a[12] && !nc.a[13] && !nc.a[14] && !nc.a[15])) #endif /* defined(HASIPv6) */ && sp == -1) { (void) fprintf(stderr, "%s: incomplete Internet address specification: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Limit the network address chain length to MAXNWAD for reasons of * search efficiency. */ if (na >= MAXNWAD) { (void) fprintf(stderr, "%s: network address limit (%d) exceeded: ", Pn, MAXNWAD); safestrprt(s, stderr, 1); return(1); } /* * Allocate space for the address specification. */ if ((np = (struct nwad *)malloc(sizeof(struct nwad))) == NULL) { (void) fprintf(stderr, "%s: no space for network address from: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Construct and link the address specification. */ *np = nc; np->sport = sp; np->eport = ep; np->f = 0; np->next = Nwad; Nwad = np; na++; /* * If the network address came from gethostbyname(), advance to * the next address; otherwise quit. */ if (!he) break; if (!(ap = (unsigned char *)he->h_addr_list[ac++])) break; #if defined(HASIPv6) { int i; for (i = 0; (i < (he->h_length - 1)) && (i < (MAX_AF_ADDR - 1)); i++) { nc.a[i] = *ap++; } nc.a[i] = *ap; } #else /* !defined(HASIPv6) */ nc.a[0] = *ap++; nc.a[1] = *ap++; nc.a[2] = *ap++; nc.a[3] = *ap; #endif /* defined(HASIPv6) */ } return(0); } /* * enter_str_lst() - enter a string on a list */ int enter_str_lst(opt, s, lp) char *opt; /* option name */ char *s; /* string to enter */ struct str_lst **lp; /* string's list */ { char *cp; MALLOC_S len; struct str_lst *lpt; if (!s || *s == '-' || *s == '+') { (void) fprintf(stderr, "%s: missing %s option value\n", Pn, opt); return(1); } if (!(cp = mkstrcpy(s, &len))) { (void) fprintf(stderr, "%s: no string copy space: ", Pn); safestrprt(s, stderr, 1); return(1); } if ((lpt = (struct str_lst *)malloc(sizeof(struct str_lst))) == NULL) { (void) fprintf(stderr, "%s: no list space: ", Pn); safestrprt(s, stderr, 1); (void) free((FREE_P *)cp); return(1); } lpt->f = 0; lpt->str = cp; lpt->len = (int)len; lpt->next = *lp; *lp = lpt; return(0); } /* * enter_uid() - enter User Identifier for searching */ int enter_uid(u) char *u; /* User IDentifier string pointer */ { int err, excl, i, j, lnml, nn; MALLOC_S len; char lnm[LOGINML+1], *lp; struct passwd *pw; char *s, *st; uid_t uid; if (!u) { (void) fprintf(stderr, "%s: no UIDs specified\n", Pn); return(1); } for (err = 0, s = u; *s;) { /* * Assemble next User IDentifier. */ for (excl = i = j = lnml = nn = uid = 0, st = s; *s && *s != ','; i++, s++) { if (lnml >= LOGINML) { while (*s && *s != ',') { s++; lnml++; } (void) fprintf(stderr, "%s: -u login name > %d characters: ", Pn, LOGINML); safestrprtn(st, lnml, stderr, 1); err = j = 1; break; } if (i == 0 && *s == '^') { excl = 1; continue; } lnm[lnml++] = *s; if (nn) continue; #if defined(__STDC__) if (isdigit((unsigned char)*s)) #else /* !defined(__STDC__) */ if (isascii(*s) && isdigit((unsigned char)*s)) #endif /* defined(__STDC__) */ uid = (uid * 10) + *s - '0'; else nn++; } if (*s) s++; if (j) continue; if (nn) { lnm[lnml++] = '\0'; if ((pw = getpwnam(lnm)) == NULL) { (void) fprintf(stderr, "%s: can't get UID for ", Pn); safestrprt(lnm, stderr, 1); err = 1; continue; } else uid = pw->pw_uid; } #if defined(HASSECURITY) /* * If the security mode is enabled, only the root user may list files * belonging to user IDs other than the real user ID of this lsof * process. */ if (Myuid && uid != Myuid) { (void) fprintf(stderr, "%s: ID %d request rejected because of security mode.\n", Pn, uid); err = 1; continue; } #endif /* HASSECURITY */ /* * Avoid entering duplicates. */ for (i = j = 0; i < Nuid; i++) { if (uid != Suid[i].uid) continue; if (Suid[i].excl == excl) { j = 1; continue; } (void) fprintf(stderr, "%s: UID %d has been included and excluded\n", Pn, (int)uid); err = j = 1; break; } if (j) continue; /* * Allocate space for User IDentifier. */ if (Nuid >= Mxuid) { Mxuid += UIDINCR; len = (MALLOC_S)(Mxuid * sizeof(struct seluid)); if (!Suid) Suid = (struct seluid *)malloc(len); else Suid = (struct seluid *)realloc((MALLOC_P *)Suid, len); if (!Suid) { (void) fprintf(stderr, "%s: no space for UIDs", Pn); Exit(1); } } if (nn) { if (!(lp = mkstrcpy(lnm, (MALLOC_S)NULL))) { (void) fprintf(stderr, "%s: no space for login: ", Pn); safestrprt(lnm, stderr, 1); Exit(1); } Suid[Nuid].lnm = lp; } else Suid[Nuid].lnm = (char *)NULL; Suid[Nuid].uid = uid; Suid[Nuid++].excl = excl; if (excl) Nuidexcl++; else Nuidincl++; } return(err); } ./lsof_4.42/arg.c.orig000644 023074 000012 00000110365 06705147616 015445 0ustar00varadhanstaff000000 000000 /* * arg.c - common argument processing support functions for lsof */ /* * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * * Written by Victor A. Abell * * This software is not subject to any license of the American Telephone * and Telegraph Company or the Regents of the University of California. * * Permission is granted to anyone to use this software for any purpose on * any computer system, and to alter it and redistribute it freely, subject * to the following restrictions: * * 1. Neither the authors nor Purdue University are responsible for any * consequences of the use of this software. * * 2. The origin of this software must not be misrepresented, either by * explicit claim or by omission. Credit to the authors and Purdue * University must appear in documentation and sources. * * 3. Altered versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 4. This notice may not be removed or altered. */ #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: arg.c,v 1.25 99/03/29 07:08:16 abe Exp $"; #endif #include "lsof.h" _PROTOTYPE(static int ckfd_range,(char *first, char *dash, char *last, int *lo, int *hi)); _PROTOTYPE(static void enter_fd_lst,(char *nm, int lo, int hi)); _PROTOTYPE(static int enter_nwad,(struct nwad *n, int sp, int ep, char *s, struct hostent *he)); /* * ckfd_range() - check fd range */ static int ckfd_range(first, dash, last, lo, hi) char *first; /* starting character */ char *dash; /* '-' location */ char *last; /* '\0' location */ int *lo; /* returned low value */ int *hi; /* returned high value */ { char *cp; /* * See if the range character pointers make sense. */ if (first >= dash || dash >= last) { (void) fprintf(stderr, "%s: illegal FD range for -d: ", Pn); safestrprt(first, stderr, 1); return(1); } /* * Assemble and check the high and low values. */ for (cp = first, *lo = 0; *cp && cp < dash; cp++) { if (!isdigit((unsigned char)*cp)) { FD_range_nondigit: (void) fprintf(stderr, "%s: non-digit in -d FD range: ", Pn); safestrprt(first, stderr, 1); return(1); } *lo = (*lo * 10) + (int)(*cp - '0'); } for (cp = dash+1, *hi = 0; *cp && cp < last; cp++) { if (!isdigit((unsigned char)*cp)) goto FD_range_nondigit; *hi = (*hi * 10) + (int)(*cp - '0'); } if (*lo >= *hi) { (void) fprintf(stderr, "%s: -d FD range's low >= its high: ", Pn); safestrprt(first, stderr, 1); return(1); } return(0); } /* * ck_file_arg() - check file arguments */ int ck_file_arg(i, ac, av, fv, rs, sbp) int i; /* first file argument index */ int ac; /* argument count */ char *av[]; /* argument vector */ int fv; /* Ffilesys value (real or temporary) */ int rs; /* Readlink() status if argument count == 1: * 0 = undone; 1 = done */ struct stat *sbp; /* if non-NULL, pointer to stat(2) buffer * when argument count == 1 */ { unsigned char ad, an; short err = 0; char *fnm, *fsnm, *path; int fsm, ftype, j; MALLOC_S l; struct mounts *mp; static struct mounts **mmp = (struct mounts **)NULL; int mx, nm; static int nma = 0; struct stat sb; struct sfile *sfp; short ss = 0; #if defined(CKFA_EXPDEV) dev_t dev, rdev; #endif /* defined(CKFA_EXPDEV) */ #if defined(HASPROCFS) int pfsnl = -1; pid_t pid; struct procfsid *pfi; #endif /* defined(HASPROCFS) */ /* * Loop through arguments. */ for (; i < ac; i++) { if (rs && (ac == 1) && (i == 0)) path = av[i]; else { if (!(path = Readlink(av[i]))) { ErrStat = 1; continue; } } /* * Remove a terminating `/' from Readlink()-expanded path, but never * from an argument-specified path. Don't remove `/' from a single * character path name, either. * * Check for file system argument. */ if (path != av[i] && (j = strlen(path)) > 1 && path[j-1] == '/') path[j-1] = '\0'; for (ftype = 1, mp = readmnt(), nm = 0; (fv != 1) && mp; mp = mp->next) { fsm = 0; if (strcmp(mp->dir, path) == 0) fsm++; else if (fv == 2 || (mp->fs_mode & S_IFMT) == S_IFBLK) { if (mp->fsnmres && strcmp(mp->fsnmres, path) == 0) fsm++; } if (!fsm) continue; ftype = 0; /* * Skip duplicates. */ for (mx = 0; mx < nm; mx++) { if (strcmp(mp->dir, mmp[mx]->dir) == 0 && mp->dev == mmp[mx]->dev && mp->inode == mmp[mx]->inode) break; } if (mx < nm) continue; /* * Allocate space for and save another mount point match and * the type of match -- directory name (mounted) or file system * name (mounted-on). */ if (nm >= nma) { nma += 5; l = (MALLOC_S)(nma * sizeof(struct mounts *)); if (mmp) mmp = (struct mounts **)realloc((MALLOC_P *)mmp, l); else mmp = (struct mounts **)malloc(l); if (!mmp) { (void) fprintf(stderr, "%s: no space for mount pointers\n", Pn); Exit(1); } } mmp[nm++] = mp; } if (fv == 2 && nm == 0) { (void) fprintf(stderr, "%s: not a file system: ", Pn); safestrprt(av[i], stderr, 1); ErrStat = 1; continue; } /* * Loop through the file system matches. If there were none, make one * pass through the loop, using simply the path name. */ mx = 0; do { /* * Allocate an sfile structure and fill in the type and link. */ if (!(sfp = (struct sfile *)malloc(sizeof(struct sfile)))) { (void) fprintf(stderr, "%s: no space for files\n", Pn); Exit(1); } sfp->next = Sfile; Sfile = sfp; sfp->f = 0; if ((sfp->type = ftype)) { /* * For a non-file system path, use the path as the file name * and set a NULL file system name. */ fnm = path; fsnm = (char *)NULL; /* * Stat the path to obtain its characteristics. */ if (sbp && (ac == 1)) sb = *sbp; else { if (statsafely(fnm, &sb) != 0) { int en = errno; (void) fprintf(stderr, "%s: status error on ", Pn); safestrprt(fnm, stderr, 0); (void) fprintf(stderr, ": %s\n", strerror(en)); Sfile = sfp->next; (void) free((FREE_P *)sfp); ErrStat = 1; continue; } } sfp->i = sb.st_ino; sfp->mode = sb.st_mode & S_IFMT; #if defined(CKFA_EXPDEV) /* * Expand device numbers before saving, so that they match the * already-expanded local mount info table device numbers. * (This is an EP/IX 2.1.1 and above artifact.) */ dev = expdev(sb.st_dev); rdev = expdev(sb.st_rdev); #endif /* defined(CKFA_EXPDEV) */ if (sfp->mode == S_IFBLK || sfp->mode == S_IFCHR #if defined(CKFA_XDEVTST) || CKFA_XDEVTST #endif /* defined(CKFA_XDEVTST) */ ) #if defined(CKFA_EXPDEV) sfp->dev = rdev; else sfp->dev = dev; #else /* !defined(CKFA_EXPDEV) */ sfp->dev = sb.st_rdev; else sfp->dev = sb.st_dev; #endif /* defined(CKFA_EXPDEV) */ #if defined(CKFA_MPXCHAN) /* * Save a (possible) multiplexed channel number. (This is an * AIX artifact.) */ sfp->ch = getchan(path); #endif /* defined(CKFA_MPXCHAN) */ } else { mp = mmp[mx++]; ss++; #if defined(HASPROCFS) /* * If this is a /proc file system, set the search flag and * abandon the sfile entry. */ if (mp == Mtprocfs) { Sfile = sfp->next; (void) free((FREE_P *)sfp); Procsrch = 1; continue; } #endif /* defined(HASPROCFS) */ /* * Derive file name and file system name for a mount point. * * Save the device number, inode number, and modes. */ fnm = mp->dir; fsnm = mp->fsname; sfp->dev = mp->dev; sfp->i = mp->inode; sfp->mode = mp->mode & S_IFMT; } ss = 1; /* indicate a "safe" stat() */ /* * Store the file name and file system name pointers in the sfile * structure, allocating space as necessary. */ if (!fnm || fnm == path) { sfp->name = fnm; an = 0; } else { if (!(sfp->name = mkstrcpy(fnm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for file name: ", Pn); safestrprt(fnm, stderr, 1); Exit(1); } an = 1; } if (!fsnm || fsnm == path) { sfp->devnm = fsnm; ad = 0; } else { if (!(sfp->devnm = mkstrcpy(fsnm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for file system name: ", Pn); safestrprt(fsnm, stderr, 1); Exit(1); } ad = 1; } if (!(sfp->aname = mkstrcpy(av[i], (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for argument file name: ", Pn); safestrprt(av[i], stderr, 1); Exit(1); } #if defined(HASPROCFS) /* * See if this is an individual member of a proc file system. */ if (!Mtprocfs || Procsrch) continue; # if defined(HASFSTYPE) if (strcmp(sb.st_fstype, HASPROCFS) != 0) continue; # endif /* defined(HASFSTYPE) */ if (pfsnl == -1) pfsnl = strlen(Mtprocfs->dir); if (!pfsnl) continue; if (strncmp(Mtprocfs->dir, path, pfsnl) != 0) continue; if (path[pfsnl] != '/') # if defined(HASPINODEN) pid = 0; # else /* !defined(HASPINODEN) */ continue; # endif /* defined(HASPINODEN) */ else { for (j = pfsnl+1; path[j]; j++) { if (!isdigit((unsigned char)path[j])) break; } if (path[j] || (j - pfsnl - 1) < 1 || (sfp->mode & S_IFMT) != S_IFREG) # if defined(HASPINODEN) pid = 0; # else /* !defined(HASPINODEN) */ continue; # endif /* defined(HASPINODEN) */ else pid = atoi(&path[pfsnl+1]); } if (!(pfi = (struct procfsid *)malloc((MALLOC_S) sizeof(struct procfsid)))) { (void) fprintf(stderr, "%s: no space for %s ID: ", Pn, Mtprocfs->dir); safestrprt(path, stderr, 1); Exit(1); } pfi->pid = pid; pfi->f = 0; pfi->nm = sfp->aname; pfi->next = Procfsid; Procfsid = pfi; # if defined(HASPINODEN) pfi->inode = (unsigned long)sfp->i; # endif /* defined(HASPINODEN) */ /* * Abandon the Sfile entry, lest it be used in is_file_named(). */ Sfile = sfp->next; if (ad) (void) free((FREE_P *)sfp->devnm); if (an) (void) free((FREE_P *)sfp->name); (void) free((FREE_P *)sfp); #endif /* defined(HASPROCFS) */ } while (mx < nm); } if (!ss) err = 1; return((int)err); } #if defined(HASDCACHE) /* * ctrl_dcache() - enter device cache control */ int ctrl_dcache(c) char *c; /* control string */ { int rc = 0; if (!c) { (void) fprintf(stderr, "%s: no device cache option control string\n", Pn); return(1); } /* * Decode argument function character. */ switch (*c) { case '?': if (*(c+1) != '\0') { (void) fprintf(stderr, "%s: nothing should follow -D?\n", Pn); return(1); } DChelp = 1; return(0); case 'b': case 'B': if (Setuidroot #if !defined(WILLDROPGID) || Myuid #endif /* !defined(WILLDROPGID) */ ) rc = 1; else DCstate = 1; break; case 'r': case 'R': if (Setuidroot && *(c+1)) rc = 1; else DCstate = 2; break; case 'u': case 'U': if (Setuidroot #if !defined(WILLDROPGID) || Myuid #endif /* !defined(WILLDROPGID) */ ) rc = 1; else DCstate = 3; break; case 'i': case 'I': if (*(c+1) == '\0') { DCstate = 0; return(0); } /* fall through */ default: (void) fprintf(stderr, "%s: unknown -D option: ", Pn); safestrprt(c, stderr, 1); return(1); } if (rc) { (void) fprintf(stderr, "%s: -D option restricted to root: ", Pn); safestrprt(c, stderr, 1); return(1); } /* * Skip to optional path name and save it. */ for (c++; *c && (*c == ' ' || *c == '\t'); c++) ; if (strlen(c)) { if (!(DCpathArg = mkstrcpy(c, (MALLOC_S)NULL))) { (void) fprintf(stderr, "%s: no space for -D path: ", Pn); safestrprt(c, stderr, 1); Exit(1); } } return(0); } #endif /* defined(HASDCACHE) */ /* * enter_fd() - enter file descriptor list for searching */ int enter_fd(f) char *f; /* file descriptor list pointer */ { char buf[32], c, *cp1, *cp2, *dash; int err, hi, lo; char *fc; /* * Check for non-empty list and make a copy. */ if (!f || (strlen(f) + 1) < 2) { (void) fprintf(stderr, "%s: no file descriptor specified\n", Pn); return(1); } if (!(fc = mkstrcpy(f, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for fd string: ", Pn); safestrprt(f, stderr, 1); Exit(1); } /* * Isolate each file descriptor in the comma-separated list, then enter it * in the file descriptor string list. If a descriptor has the form: * * [0-9]+-[0-9]+ * * treat it as an ascending range of file descriptor numbers. */ for (cp1 = fc, err = 0; *cp1;) { for (cp2 = cp1, dash = (char *)NULL; *cp2 && *cp2 != ','; cp2++) { if (*cp2 == '-') dash = cp2; } if ((c = *cp2) != '\0') *cp2 = '\0'; if (cp2 > cp1) { if (dash) { if (ckfd_range(cp1, dash, cp2, &lo, &hi)) err = 1; else (void) enter_fd_lst((char *)NULL, lo, hi); } else (void) enter_fd_lst(cp1, 0, 0); } if (c == '\0') break; cp1 = cp2 + 1; } (void) free((FREE_P *)fc); return(err); } /* * enter_fd_lst() - make an entry in the FD list, Fdl */ static void enter_fd_lst(nm, lo, hi) char *nm; /* FD name (none if NULL) */ int lo; /* FD low boundary (if nm NULL) */ int hi; /* FD high boundary (if nm NULL) */ { char *cp; struct fd_lst *f; int n; /* * Allocate an fd_lst entry. */ if (!(f = (struct fd_lst *)malloc((MALLOC_S)sizeof(struct fd_lst)))) { (void) fprintf(stderr, "%s: no space for FD list entry\n", Pn); Exit(1); } if (nm) { /* * Process an FD name. First see if it contains only digits; if it * does, convert them to an integer and set the low and high * boundaries to the result. * * If the name has a non-digit, store it as a string, and set the * boundaries to impossible values (i.e., low > high). */ for (cp = nm, n = 0; *cp; cp++) { if (!isdigit((unsigned char)*cp)) break; n = (n * 10) + (int)(*cp - '0'); } if (*cp) { if (!(f->nm = mkstrcpy(nm, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for copy of: %s\n", Pn, nm); Exit(1); } lo = 1; hi = 0; } else { f->nm = (char *)NULL; lo = hi = n; } } else f->nm = (char *)NULL; f->hi = hi; f->lo = lo; f->next = Fdl; Fdl = f; } /* * enter_dir() - enter the files of a directory for searching */ #define EDDEFFNL 128 /* default file name length */ int enter_dir(d, descend) char *d; /* directory path name pointer */ int descend; /* subdirectory descend flag: * 0 = don't descend * 1 = descend */ { char *av[2]; dev_t ddev; DIR *dfp; char *dn = (char *)NULL; MALLOC_S dnl, dnamlen; struct DIRTYPE *dp; int en, err, sl; int fct = 0; char *fp = (char *)NULL; MALLOC_S fpl = (MALLOC_S)0; MALLOC_S fpli = (MALLOC_S)0; struct stat sb; /* * Check the directory path; reduce symbolic links; stat(2) it; make sure it's * really a directory. */ if (!d || !*d || *d == '+' || *d == '-') { if (!Fwarn) (void) fprintf(stderr, "%s: +d not followed by a directory path\n", Pn); return(1); } if (!(dn = Readlink(d))) return(1); if (statsafely(dn, &sb)) { if (!Fwarn) { en = errno; (void) fprintf(stderr, "%s: WARNING: can't stat(", Pn); safestrprt(dn, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } return(1); } if ((sb.st_mode & S_IFMT) != S_IFDIR) { if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: not a directory: ", Pn); safestrprt(dn, stderr, 1); } if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } return(1); } ddev = sb.st_dev; /* * Stack the directory and record it in Sfile for searching. */ Dstkn = Dstkx = 0; Dstk = (char **)NULL; (void) stkdir(dn); av[0] = (dn == d) ? mkstrcpy(dn, (MALLOC_S)NULL) : dn; av[1] = (char *)NULL; dn = (char *)NULL; if (!ck_file_arg(0, 1, av, 1, 1, &sb)) { av[0] = (char *)NULL; fct++; } /* * Unstack the next directory and examine it. */ while (--Dstkx >= 0) { if (!(dn = Dstk[Dstkx])) continue; Dstk[Dstkx] = (char *)NULL; /* * Open the directory path and prepare its name for use with the * files in the directory. */ if (!(dfp = OpenDir(dn))) { if (!Fwarn) { if ((en = errno) != ENOENT) { (void) fprintf(stderr, "%s: WARNING: can't opendir(", Pn); safestrprt(dn, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } } (void) free((FREE_P *)dn); dn = (char *)NULL; continue; } dnl = strlen(dn); sl = ((dnl > 0) && (*(dn + dnl - 1) == '/')) ? 0 : 1; /* * Define space for possible addition to the directory path. */ fpli = (MALLOC_S)(dnl + sl + EDDEFFNL + 1); if ((int)fpli > (int)fpl) { fpl = fpli; if (!fp) fp = (char *)malloc(fpl); else fp = (char *)realloc(fp, fpl); if (!fp) { (void) fprintf(stderr, "%s: no space for path to entries in directory: %s\n", Pn, dn); Exit(1); } } (void) sprintf(fp, "%s%s", dn, sl ? "/" : ""); (void) free((FREE_P *)dn); dn = (char *)NULL; /* * Read the contents of the directory. */ for (dp = ReadDir(dfp); dp; dp = ReadDir(dfp)) { /* * Skip: entries with no inode number; * entries with a zero length name; * "."; * and "..". */ if (!dp->d_ino) continue; #if defined(HASDNAMLEN) dnamlen = (MALLOC_S)dp->d_namlen; #else /* !defined(HASDNAMLEN) */ dnamlen = (MALLOC_S)strlen(dp->d_name); #endif /* defined(HASDNAMLEN) */ if (!dnamlen) continue; if (dnamlen <= 2 && dp->d_name[0] == '.') { if (dnamlen == 1) continue; if (dp->d_name[1] == '.') continue; } /* * Form the entry's path name. */ fpli = (MALLOC_S)(dnamlen - (fpl - dnl - sl - 1)); if ((int)fpli > 0) { fpl += fpli; if (!(fp = (char *)realloc(fp, fpl))) { (void) fprintf(stderr, "%s: no space for: ", Pn); safestrprt(dn, stderr, 0); putc('/', stderr); safestrprtn(dp->d_name, dnamlen, stderr, 1); Exit(1); } } (void) strncpy(fp + dnl + sl, dp->d_name, dnamlen); fp[dnl + sl + dnamlen] = '\0'; /* * Lstatsafely() the entry; complain if that fails. * * Ignore symbolic links and files not not the directory's device. * * Stack entries that represent subdirectories. */ if (lstatsafely(fp, &sb)) { if ((en = errno) != ENOENT) { if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: can't lstat(", Pn); safestrprt(fp, stderr, 0); (void) fprintf(stderr, "): %s\n", strerror(en)); } } continue; } if ((sb.st_mode & S_IFMT) == S_IFLNK || sb.st_dev != ddev) continue; if (av[0]) { (void) free((FREE_P *)av[0]); av[0] = (char *)NULL; } av[0] = mkstrcpy(fp, (MALLOC_S *)NULL); if ((sb.st_mode & S_IFMT) == S_IFDIR && descend) /* * Stack a subdirectory according to the descend argument. */ stkdir(av[0]); /* * Use ck_file_arg() to record the entry for searching. Force it * to consider the entry a file, not a file system. */ if (!ck_file_arg(0, 1, av, 1, 1, &sb)) { av[0] = (char *)NULL; fct++; } } (void) CloseDir(dfp); if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } } /* * Free malloc()'d space. */ if (dn && dn != d) { (void) free((FREE_P *)dn); dn = (char *)NULL; } if (av[0] && av[0] != fp) { (void) free((FREE_P *)av[0]); av[0] = (char *)NULL; } if (fp) { (void) free((FREE_P *)fp); fp = (char *)NULL; } if (Dstk) { (void) free((FREE_P *)Dstk); Dstk = (char **)NULL; } if (!fct) { /* * Warn if no files were recorded for searching. */ if (!Fwarn) { (void) fprintf(stderr, "%s: WARNING: no files found in directory: ", Pn); safestrprt(d, stderr, 1); } return(1); } return(0); } /* * enter_id() - enter PGRP or PID for searching */ int enter_id(ty, p) enum IDType ty; /* type: PGRP or PID */ char *p; /* process group ID string pointer */ { char *cp; int i, id, mx, n; struct int_lst *s; if (!p) { (void) fprintf(stderr, "%s: no process%s ID specified\n", Pn, (ty == PGRP) ? " group" : ""); return(1); } /* * Set up variables for the type of ID. */ switch (ty) { case PGRP: mx = Mxpgrp; n = Npgrp; s = Spgrp; break; case PID: mx = Mxpid; n = Npid; s = Spid; break; default: (void) fprintf(stderr, "%s: enter_id \"", Pn); safestrprt(p, stderr, 0); (void) fprintf(stderr, "\", invalid type: %d\n", ty); Exit(1); } /* * Convert and store the ID. */ for (cp = p; *cp;) { /* * Assemble ID. */ for (id = 0; *cp && *cp != ','; cp++) { #if defined(__STDC__) if (!isdigit((unsigned char)*cp)) #else if (!isascii(*cp) || ! isdigit((unsigned char)*cp)) #endif /* __STDC__ */ { (void) fprintf(stderr, "%s: illegal process%s ID: ", Pn, (ty == PGRP) ? " group" : ""); safestrprt(p, stderr, 1); return(1); } id = (id * 10) + *cp - '0'; } if (*cp) cp++; /* * Avoid entering duplicates. */ for (i = 0; i < n; i++) { if (id == s[i].i) break; } if (i < n) continue; /* * Allocate table table space. */ if (n >= mx) { mx += IDINCR; if (!s) s = (struct int_lst *)malloc( (MALLOC_S)(sizeof(struct int_lst) * mx)); else s = (struct int_lst *)realloc((MALLOC_P *)s, (MALLOC_S)(sizeof(struct int_lst) * mx)); if (!s) { (void) fprintf(stderr, "%s: no space for %d process%s IDs", Pn, mx, (ty == PGRP) ? " group" : ""); Exit(1); } } s[n].f = 0; s[n++].i = id; } /* * Save variables for the type of ID. */ if (ty == PGRP) { Mxpgrp = mx; Npgrp = n; Spgrp = s; } else { Mxpid = mx; Npid = Npuns = n; Spid = s; } return(0); } /* * enter_network_address() - enter Internet address for searching */ int enter_network_address(na) char *na; /* Internet address string pointer */ { int ae, ep, i, pr, sp; unsigned char *ap; char *cp, *p, *wa; struct hostent *he = (struct hostent *)NULL; char *hn = (char *)NULL; MALLOC_S l; struct nwad n; int pt = 0; int pu = 0; struct servent *se, *se1; char *sn = (char *)NULL; MALLOC_S snl = 0; if (!na) { (void) fprintf(stderr, "%s: no network address specified\n", Pn); return(1); } /* * Initialize network address structure. */ n.proto = (char *)NULL; n.af = 0; for (i = 0; i < MAX_AF_ADDR; i++) { n.a[i] = 0; } /* * Process protocol name, optionally followed by a '@' and a host name or * Internet address, or a ':' and a service name or port number. */ wa = na; if (*wa && *wa != '@' && *wa != ':') { for (p = wa; *wa && *wa != '@' && *wa != ':'; wa++) ; if ((l = wa - p)) { if (!(n.proto = mkstrcat(p, l, (char *)NULL, -1, (char *)NULL, -1, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for protocol name from ", Pn); safestrprt(na, stderr, 1); nwad_exit: if (n.proto) (void) free((FREE_P *)n.proto); if (hn) (void) free((FREE_P *)hn); if (sn) (void) free((FREE_P *)sn); return(1); } /* * The protocol name should be "tcp" or "udp". */ if (strcasecmp(n.proto, "tcp") != 0 && strcasecmp(n.proto, "udp") != 0) { (void) fprintf(stderr, "%s: unknown protocol name (%s) in ", Pn, n.proto); safestrprt(na, stderr, 1); goto nwad_exit; } /* * Convert protocol name to lower case. */ for (p = n.proto; *p; p++) { if (*p >= 'A' && *p <= 'Z') *p = *p - 'A' + 'a'; } } } /* * Process an IPv4 address (1.2.3.4), IPv6 address ([1:2:3:4:5:6:7:8]), * or host name, preceded by a '@' and optionally followed by a colon * and a service name or port number. */ if (*wa == '@') { wa++; if (!*wa || *wa == ':') { unacc_address: (void) fprintf(stderr, "%s: unacceptable Internet address in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } if (*wa < '0' || *wa > '9' && *wa != '[') { /* * Assemble host name. */ for (p = wa; *p && *p != ':'; p++) ; if ((l = p - wa)) { if (!(hn = mkstrcat(wa, l, (char *)NULL, -1, (char *)NULL, -1, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for host name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } #if defined(HASIPv6) && !defined(HASNOBYNAME2) if (!(he = gethostbyname2(hn, AF_INET)) || he->h_addrtype != AF_INET) { if (!(he = gethostbyname2(hn, AF_INET6)) || he->h_addrtype != AF_INET6) he = (struct hostent *)NULL; } if (!he) #else /* !defined(HASIPv6) || defined(HASBYNAME2) */ if (!(he = gethostbyname(hn))) #endif /* defined(HASIPv6) && !defined(HASBYNAME2) */ { fprintf(stderr, "%s: unknown host name (%s) in ", Pn, hn); safestrprt(na, stderr, 1); goto nwad_exit; } ap = (unsigned char *)he->h_addr; n.af = he->h_addrtype; #if defined(HASIPv6) for (i = 0; i < (he->h_length - 1) && i < (MAX_AF_ADDR - 1); i++) { n.a[i] = *ap++; } n.a[i] = *ap; #else /* !defined(HASIPv6) */ n.a[0] = *ap++; n.a[1] = *ap++; n.a[2] = *ap++; n.a[3] = *ap; #endif /* defined(HASIPv6) */ } wa = p; } else if (*wa == '[') { #if defined(HASIPv6) /* * Assemble IPv6 address. */ if (!(cp = strrchr(++wa, ']'))) goto unacc_address; *cp = '\0'; i = inet_pton(AF_INET6, wa, (void *)&n.a); *cp = ']'; if (i != 1) goto unacc_address; for (ae = i = 0; i < MAX_AF_ADDR; i++) { if ((ae |= n.a[i])) break; } if (!ae) goto unacc_address; n.af = AF_INET6; wa = cp + 1; #else /* !defined(HASIPv6) */ (void) fprintf(stderr, "%s: unsupported IPv6 address in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; #endif } else { /* * Assemble IPv4 address. */ for (i = 0; *wa; wa++) { if (*wa == ':') break; if (*wa == '.') { i++; if (i >= MIN_AF_ADDR) break; continue; } if (*wa < '0' || *wa > '9') goto unacc_address; ae = (10 * n.a[i]) + *wa - '0'; if (ae > 255) goto unacc_address; n.a[i] = ae; } if (i != (MIN_AF_ADDR - 1) || (!n.a[0] && !n.a[1] && !n.a[2] && !n.a[3])) goto unacc_address; n.af = AF_INET; } } /* * If there is no port number, enter the address. */ if (!*wa) { if (enter_nwad(&n, -1, -1, na, he)) goto nwad_exit; if (sn) (void) free((FREE_P *)sn); return(0); } /* * Process a service name or port number list, preceded by a colon. * * Entries of the list are separated with commas; elements of a numeric range * are specified with a separating minus sign (`-'); all service names must * belong to the same protocol; embedded spaces are not allowed. An embedded * minus sign in a name is taken to be part of the name, the starting entry * of a range can't be a service name. */ if (*wa != ':' || *(wa + 1) == '\0') { unacc_port: (void) fprintf(stderr, "%s: unacceptable port specification in ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } for (++wa; wa && *wa; wa++) { for (ep = pr = sp = 0; *wa; wa++) { if (*wa < '0' || *wa > '9') { /* * Convert service name to port number, using already-specified * protocol name. A '-' is taken to be part of the name; hence * the staring entry of a range can't be a service name. */ for (p = wa; *wa && *wa != ','; wa++) ; if (!(l = wa - p)) { (void) fprintf(stderr, "%s: invalid service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } if (sn) { if (l > snl) { sn = (char *)realloc((MALLOC_P *)sn, l + 1); snl = l; } } else { sn = (char *)malloc(l + 1); snl = l; } if (!sn) { (void) fprintf(stderr, "%s: no space for service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } (void) strncpy(sn, p, l); *(sn + l) = '\0'; if (n.proto) { /* * If the protocol has been specified, look up the port * number for the service name for the specified protocol. */ if (!(se = getservbyname(sn, n.proto))) { (void) fprintf(stderr, "%s: unknown service %s for %s in ", Pn, sn, n.proto); safestrprt(na, stderr, 1); goto nwad_exit; } pt = (int)ntohs(se->s_port); } else { /* * If no protocol has been specified, look up the port * numbers for the service name for both TCP and UDP. */ if((se = getservbyname(sn, "tcp"))) pt = (int)ntohs(se->s_port); if ((se1 = getservbyname(sn, "udp"))) pu = (int)ntohs(se1->s_port); if (!se && !se1) { (void) fprintf(stderr, "%s: unknown service %s in ", Pn, sn); safestrprt(na, stderr, 1); goto nwad_exit; } if (se && se1 && pt != pu) { (void) fprintf(stderr, "%s: TCP=%d and UDP=%d %s ports conflict;\n", Pn, pt, pu, sn); (void) fprintf(stderr, " specify \"tcp:%s\" or \"udp:%s\".\n", sn, sn); goto nwad_exit; } if (!se && se1) pt = pu; } if (pr) ep = pt; else { sp = pt; if (*wa == '-') pr++; } } else { /* * Assemble port number. */ for (; *wa && *wa != ','; wa++) { if (*wa == '-') { if (pr) goto unacc_port; pr++; break; } if (*wa < '0' || *wa > '9') goto unacc_port; if (pr) ep = (ep * 10) + *wa - '0'; else sp = (sp * 10) + *wa - '0'; } } if (!*wa || *wa == ',') break; if (pr) continue; goto unacc_port; } if (!pr) ep = sp; if (ep < sp) goto unacc_port; /* * Enter completed port or port range specification. */ if (enter_nwad(&n, sp, ep, na, he)) goto nwad_exit; if (!*wa) break; } if (sn) (void) free((FREE_P *)sn); return(0); } /* * enter_nwad() - enter nwad structure */ static int enter_nwad(n, sp, ep, s, he) struct nwad *n; /* pointer to partially completed * nwad (less port) */ int sp; /* starting port number */ int ep; /* ending port number */ char *s; /* string that states the address */ struct hostent *he; /* pointer to hostent struct from which * network address came */ { int ac; unsigned char *ap; static int na = 0; struct nwad nc; struct nwad *np; /* * Allocate space for the argument specification. */ if (strlen(s)) { if (!(n->arg = mkstrcpy(s, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for Internet argument: ", Pn); safestrprt(s, stderr, 1); Exit(1); } } else n->arg = (char *)NULL; /* * Loop through all hostent addresses. */ for (ac = 1, nc = *n;;) { /* * Test address specification -- it must contain at least one of: * protocol, Internet address or port. If correct, link into search * list. */ if (!nc.proto && !nc.a[0] && !nc.a[1] && !nc.a[2] && !nc.a[3] #if defined(HASIPv6) && (nc.af != AF_INET6 || (!nc.a[4] && !nc.a[5] && !nc.a[6] && !nc.a[7] && !nc.a[8] && !nc.a[9] && !nc.a[10] && !nc.a[11] && !nc.a[12] && !nc.a[13] && !nc.a[14] && !nc.a[15])) #endif /* defined(HASIPv6) */ && sp == -1) { (void) fprintf(stderr, "%s: incomplete Internet address specification: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Limit the network address chain length to MAXNWAD for reasons of * search efficiency. */ if (na >= MAXNWAD) { (void) fprintf(stderr, "%s: network address limit (%d) exceeded: ", Pn, MAXNWAD); safestrprt(s, stderr, 1); return(1); } /* * Allocate space for the address specification. */ if ((np = (struct nwad *)malloc(sizeof(struct nwad))) == NULL) { (void) fprintf(stderr, "%s: no space for network address from: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Construct and link the address specification. */ *np = nc; np->sport = sp; np->eport = ep; np->f = 0; np->next = Nwad; Nwad = np; na++; /* * If the network address came from gethostbyname(), advance to * the next address; otherwise quit. */ if (!he) break; if (!(ap = (unsigned char *)he->h_addr_list[ac++])) break; #if defined(HASIPv6) { int i; for (i = 0; (i < (he->h_length - 1)) && (i < (MAX_AF_ADDR - 1)); i++) { nc.a[i] = *ap++; } nc.a[i] = *ap; } #else /* !defined(HASIPv6) */ nc.a[0] = *ap++; nc.a[1] = *ap++; nc.a[2] = *ap++; nc.a[3] = *ap; #endif /* defined(HASIPv6) */ } return(0); } /* * enter_str_lst() - enter a string on a list */ int enter_str_lst(opt, s, lp) char *opt; /* option name */ char *s; /* string to enter */ struct str_lst **lp; /* string's list */ { char *cp; MALLOC_S len; struct str_lst *lpt; if (!s || *s == '-' || *s == '+') { (void) fprintf(stderr, "%s: missing %s option value\n", Pn, opt); return(1); } if (!(cp = mkstrcpy(s, &len))) { (void) fprintf(stderr, "%s: no string copy space: ", Pn); safestrprt(s, stderr, 1); return(1); } if ((lpt = (struct str_lst *)malloc(sizeof(struct str_lst))) == NULL) { (void) fprintf(stderr, "%s: no list space: ", Pn); safestrprt(s, stderr, 1); (void) free((FREE_P *)cp); return(1); } lpt->f = 0; lpt->str = cp; lpt->len = (int)len; lpt->next = *lp; *lp = lpt; return(0); } /* * enter_uid() - enter User Identifier for searching */ int enter_uid(u) char *u; /* User IDentifier string pointer */ { int err, excl, i, j, lnml, nn; MALLOC_S len; char lnm[LOGINML+1], *lp; struct passwd *pw; char *s, *st; uid_t uid; if (!u) { (void) fprintf(stderr, "%s: no UIDs specified\n", Pn); return(1); } for (err = 0, s = u; *s;) { /* * Assemble next User IDentifier. */ for (excl = i = j = lnml = nn = uid = 0, st = s; *s && *s != ','; i++, s++) { if (lnml >= LOGINML) { while (*s && *s != ',') { s++; lnml++; } (void) fprintf(stderr, "%s: -u login name > %d characters: ", Pn, LOGINML); safestrprtn(st, lnml, stderr, 1); err = j = 1; break; } if (i == 0 && *s == '^') { excl = 1; continue; } lnm[lnml++] = *s; if (nn) continue; #if defined(__STDC__) if (isdigit((unsigned char)*s)) #else /* !defined(__STDC__) */ if (isascii(*s) && isdigit((unsigned char)*s)) #endif /* defined(__STDC__) */ uid = (uid * 10) + *s - '0'; else nn++; } if (*s) s++; if (j) continue; if (nn) { lnm[lnml++] = '\0'; if ((pw = getpwnam(lnm)) == NULL) { (void) fprintf(stderr, "%s: can't get UID for ", Pn); safestrprt(lnm, stderr, 1); err = 1; continue; } else uid = pw->pw_uid; } #if defined(HASSECURITY) /* * If the security mode is enabled, only the root user may list files * belonging to user IDs other than the real user ID of this lsof * process. */ if (Myuid && uid != Myuid) { (void) fprintf(stderr, "%s: ID %d request rejected because of security mode.\n", Pn, uid); err = 1; continue; } #endif /* HASSECURITY */ /* * Avoid entering duplicates. */ for (i = j = 0; i < Nuid; i++) { if (uid != Suid[i].uid) continue; if (Suid[i].excl == excl) { j = 1; continue; } (void) fprintf(stderr, "%s: UID %d has been included and excluded\n", Pn, (int)uid); err = j = 1; break; } if (j) continue; /* * Allocate space for User IDentifier. */ if (Nuid >= Mxuid) { Mxuid += UIDINCR; len = (MALLOC_S)(Mxuid * sizeof(struct seluid)); if (!Suid) Suid = (struct seluid *)malloc(len); else Suid = (struct seluid *)realloc((MALLOC_P *)Suid, len); if (!Suid) { (void) fprintf(stderr, "%s: no space for UIDs", Pn); Exit(1); } } if (nn) { if (!(lp = mkstrcpy(lnm, (MALLOC_S)NULL))) { (void) fprintf(stderr, "%s: no space for login: ", Pn); safestrprt(lnm, stderr, 1); Exit(1); } Suid[Nuid].lnm = lp; } else Suid[Nuid].lnm = (char *)NULL; Suid[Nuid].uid = uid; Suid[Nuid++].excl = excl; if (excl) Nuidexcl++; else Nuidincl++; } return(err); } ice name. */ for (p = wa; *wa && *wa != ','; wa++) ; if (!(l = wa - p)) { (void) fprintf(stderr, "%s: invalid service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } if (sn) { if (l > snl) { sn = (char *)realloc((MALLOC_P *)sn, l + 1); snl = l; } } else { sn = (char *)malloc(l + 1); snl = l; } if (!sn) { (void) fprintf(stderr, "%s: no space for service name: ", Pn); safestrprt(na, stderr, 1); goto nwad_exit; } (void) strncpy(sn, p, l); *(sn + l) = '\0'; if (n.proto) { /* * If the protocol has been specified, look up the port * number for the service name for the specified protocol. */ if (!(se = getservbyname(sn, n.proto))) { (void) fprintf(stderr, "%s: unknown service %s for %s in ", Pn, sn, n.proto); safestrprt(na, stderr, 1); goto nwad_exit; } pt = (int)ntohs(se->s_port); } else { /* * If no protocol has been specified, look up the port * numbers for the service name for both TCP and UDP. */ if((se = getservbyname(sn, "tcp"))) pt = (int)ntohs(se->s_port); if ((se1 = getservbyname(sn, "udp"))) pu = (int)ntohs(se1->s_port); if (!se && !se1) { (void) fprintf(stderr, "%s: unknown service %s in ", Pn, sn); safestrprt(na, stderr, 1); goto nwad_exit; } if (se && se1 && pt != pu) { (void) fprintf(stderr, "%s: TCP=%d and UDP=%d %s ports conflict;\n", Pn, pt, pu, sn); (void) fprintf(stderr, " specify \"tcp:%s\" or \"udp:%s\".\n", sn, sn); goto nwad_exit; } if (!se && se1) pt = pu; } if (pr) ep = pt; else { sp = pt; if (*wa == '-') pr++; } } else { /* * Assemble port number. */ for (; *wa && *wa != ','; wa++) { if (*wa == '-') { if (pr) goto unacc_port; pr++; break; } if (*wa < '0' || *wa > '9') goto unacc_port; if (pr) ep = (ep * 10) + *wa - '0'; else sp = (sp * 10) + *wa - '0'; } } if (!*wa || *wa == ',') break; if (pr) continue; goto unacc_port; } if (!pr) ep = sp; if (ep < sp) goto unacc_port; /* * Enter completed port or port range specification. */ if (enter_nwad(&n, sp, ep, na, he)) goto nwad_exit; if (!*wa) break; } if (sn) (void) free((FREE_P *)sn); return(0); } /* * enter_nwad() - enter nwad structure */ static int enter_nwad(n, sp, ep, s, he) struct nwad *n; /* pointer to partially completed * nwad (less port) */ int sp; /* starting port number */ int ep; /* ending port number */ char *s; /* string that states the address */ struct hostent *he; /* pointer to hostent struct from which * network address came */ { int ac; unsigned char *ap; static int na = 0; struct nwad nc; struct nwad *np; /* * Allocate space for the argument specification. */ if (strlen(s)) { if (!(n->arg = mkstrcpy(s, (MALLOC_S *)NULL))) { (void) fprintf(stderr, "%s: no space for Internet argument: ", Pn); safestrprt(s, stderr, 1); Exit(1); } } else n->arg = (char *)NULL; /* * Loop through all hostent addresses. */ for (ac = 1, nc = *n;;) { /* * Test address specification -- it must contain at least one of: * protocol, Internet address or port. If correct, link into search * list. */ if (!nc.proto && !nc.a[0] && !nc.a[1] && !nc.a[2] && !nc.a[3] #if defined(HASIPv6) && (nc.af != AF_INET6 || (!nc.a[4] && !nc.a[5] && !nc.a[6] && !nc.a[7] && !nc.a[8] && !nc.a[9] && !nc.a[10] && !nc.a[11] && !nc.a[12] && !nc.a[13] && !nc.a[14] && !nc.a[15])) #endif /* defined(HASIPv6) */ && sp == -1) { (void) fprintf(stderr, "%s: incomplete Internet address specification: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Limit the network address chain length to MAXNWAD for reasons of * search efficiency. */ if (na >= MAXNWAD) { (void) fprintf(stderr, "%s: network address limit (%d) exceeded: ", Pn, MAXNWAD); safestrprt(s, stderr, 1); return(1); } /* * Allocate space for the address specification. */ if ((np = (struct nwad *)malloc(sizeof(struct nwad))) == NULL) { (void) fprintf(stderr, "%s: no space for network address from: ", Pn); safestrprt(s, stderr, 1); return(1); } /* * Construct and link the address specification. */ *np = nc; np->sport = sp; np->eport = ep; np->f = 0; np->next = Nwad; Nwad = np; na++; /* * If the network address came from gethostbyname(), advance to * the next address; otherwise quit. */ if (!he) break; if (!(ap = (unsigned char *)he->h_addr_list[ac++])) break; #if defined(HASIPv6) { int i; for (i = 0; (i < (he->h_length - 1)) && (i < (MAX_AF_ADDR - 1)); i++) { nc.a[i] = *ap++; } nc.a[i] = *ap; } #else /* !defined(HASIPv6) */ nc.a[0] = *ap++; nc.a[1] = *ap++; nc.a[2] = *ap++; nc.a[3] = *ap; #endif /* defined(HASIPv6) */ } return(0); } /* * enter_str_lst() - enter a string on a list */ int enter_str_lst(opt, s, lp) char *opt; /* option name */ char *s; /* string to enter */ struct str_lst **lp; /* string's list */ { char *cp; MALLOC_S len; struct str_lst *lpt; if (!s || *s == '-' || *s == '+') { (void) fprintf(stderr, "%s: missing %s option value\n", Pn, opt); return(1); } if (!(cp = mkstrcpy(s, &len))) { (void) fprintf(stderr, "%s: no string copy space: ", Pn); safestrprt(s, stderr, 1); return(1); } if ((lpt = (struct str_lst *)malloc(sizeof(struct str_lst))) == NULL) { (void) fprintf(stderr, "%s: no list space: ", Pn); safestrprt(s, stderr, 1); (void) free((FREE_P *)cp); return(1); } lpt->f = 0; lpt->str = cp; lpt->len = (int)len; lpt->next = *lp; *lp = lpt; return(0); } /* * enter_uid() - enter User Identifier for searching */ int enter_uid(u) char *u; /* User IDentifier string pointer */ { int err, excl, i, j, lnml, nn; MALLOC_S len; char lnm[LOGINML+1], *lp; struct passwd *pw; char *s, *st; uid_t uid; if (!u) { (void) fprintf(stderr, "%s: no UIDs specified\n", Pn); return(1); } for (err = 0, s = u; *s;) { /* * Assemble next User IDentifier. */ for (excl = i = j = lnml = nn = uid = 0, st = s; *s && *s != ','; i++, s++) { if (lnml >= LOGINML) { while (*s && *s != ',') { s++; lnml++; } (void) fprintf(stderr, "%s: -u login name > %d characters: ", Pn, LOGINML); safestrprtn(st, lnml, stderr, 1); err = j = 1; break; } if (i == 0 && *s == '^') { excl = 1; continue; } lnm[lnml++] = *s; if (nn) continue; #if defined(__STDC__) if (isdigit((unsigned char)*s)) #else /* !defined(__STDC__) */ if (isascii(*s) && isdigit((unsigned char)*s)) #endif /* defined(__STDC__) */ uid = (uid * 10) + *s - '0'; else nn++; } if (*s) s++; if (j) continue; if (nn) { lnm[lnml++] = '\0'; if ((pw = getpwnam(lnm)) == NULL) { (void) fprintf(stderr, "%s: can't get UID for ", Pn); safestrprt(lnm, stderr, 1); err = 1; continue; } else uid = pw->pw_uid; } #if defined(HASSECURITY) /* * If the security mode is enabled, only the root user may list files * belonging to user IDs other than the real user ID of this lsof * process. */ if (Myuid && uid != Myuid) { (void) fprintf(stderr, "%s: ID %d request rejected because of security mode.\n", Pn, uid); err = 1; continue; } #endif /* HASSECURITY */ /* * Avoid entering duplicates. */ for (i = j = 0; i < Nuid; i++) { if (uid != Suid[i].uid) continue; if (Suid[i].excl == excl) { j = 1; continue; } (void) fprintf(stderr, "%s: UID %d has been included and excluded\n", Pn, (int)uid); err = j = 1; break; } if (j) continue; /* * Allocate space for User IDentifier. */ if (Nuid >= Mxuid) { Mxuid += UIDINCR; len = (MALLOC_S)(Mxuid * sizeof(struct seluid)); if (!Suid) Suid = (struct seluid *)malloc(len); else Suid = (struct seluid *)realloc((MALLOC_P *)Suid, len); if (!Suid) { (void) fprintf(stderr, "%s: no space for UIDs", Pn); Exit(1); } } if (nn) { if (!(lp = mkstrcpy(lnm, (MALLOC_S)NULL))) { (void) fprintf(stderr, "%s: no space for login: ", Pn); safestrprt(lnm, stderr, 1); Exit(1); } Suid[Nuid].lnm = lp; } else Suid[Nuid].lnm = (char *)NULL; Suid[Nuid].uid = uid; Suid[Nuid++].excl = excl; if (excl) Nuidexcl++; else Nuidincl++; } return(err); }