This file contains a port of lsof 3.24 to RT/PC BSD 4.3. The contributor is: R. Bernstein Contact him if you have questions. Vic Abell April 15, 1995 ============================================================================== Here are my notes in compiling lsof on AIX. In version 3.24 (and 3.16). I needed to modify the install target in the created Makefile. This is what was in the Makefile--- install: all dirs FRC install -f ${BIN} -S -M 2755 -G $(GRP} ${PROG} install -f ${DOC} -M 444 ${MAN} The -S and -M options I know FSF's install don't like. #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1995-04-05 05:46 EDT by . # Source directory was `/src/lsof_3.24'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 705 -rw-r--r-- Configure.diff # 1516 -rw-r--r-- dialects/bsdrt/Makefile # 1046 -rwxr-xr-x dialects/bsdrt/Mksrc # 1701 -rw-r--r-- dialects/bsdrt/ddev.c # 1639 -rw-r--r-- dialects/bsdrt/dfile.c # 3704 -rw-r--r-- dialects/bsdrt/dlsof.h # 1619 -rw-r--r-- dialects/bsdrt/dmnt.c # 5260 -rw-r--r-- dialects/bsdrt/dnode.c # 7809 -rw-r--r-- dialects/bsdrt/dproc.c # 1512 -rw-r--r-- dialects/bsdrt/dproto.h # 6827 -rw-r--r-- dialects/bsdrt/dsock.c # 1973 -rw-r--r-- dialects/bsdrt/dstore.c # 5323 -rw-r--r-- dialects/bsdrt/machine.h # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo echo 'WARNING: not restoring timestamps. Consider getting and' echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 1231235999 $$.touch # # ============= Configure.diff ============== if test -f 'Configure.diff' && test X"$1" != X"-c"; then echo 'x - skipping Configure.diff (file already exists)' else echo 'x - extracting Configure.diff (text)' sed 's/^X//' << 'SHAR_EOF' > 'Configure.diff' && *** Configure.orig Wed Apr 5 04:36:21 1995 --- Configure Wed Apr 5 04:39:43 1995 *************** *** 89,94 **** --- 89,95 ---- X may be: X aix324 : IBM AIX 3.2.4 and 3.2.5 X aix41 : IBM AIX 4.1.0 + bsdrt : IBM RT/PC BSD 4.3 (AOS) X dcosx : Pyramid DC/OSx 1.1 For ES, Nile, and S series X decosf : DEC OSF/1 1.x, 2.0, and 3.0 X dynix : Purdue Dynix 3.0.12 *************** *** 172,177 **** --- 173,184 ---- X LSOF_CFGL="" X LSOF_DIALECT_DIR=aix X ;; + + bsdrt) + LSOF_CFGF="" + LSOF_CFGL="" + LSOF_DIALECT_DIR=bsdrt + ;; X X dcosx) X LSOF_CFGL="-lc -lsocket -lnsl -lelf -L/usr/ucblib -lucb" SHAR_EOF $shar_touch -am 0405044295 'Configure.diff' && chmod 0644 'Configure.diff' || echo 'restore of Configure.diff failed' shar_count="`wc -c < 'Configure.diff'`" test 705 -eq "$shar_count" || echo "Configure.diff: original size 705, current size $shar_count" fi # ============= dialects/bsdrt/Makefile ============== if test ! -d 'dialects'; then echo 'x - creating directory dialects' mkdir 'dialects' fi if test ! -d 'dialects/bsdrt'; then echo 'x - creating directory dialects/bsdrt' mkdir 'dialects/bsdrt' fi if test -f 'dialects/bsdrt/Makefile' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/Makefile (file already exists)' else echo 'x - extracting dialects/bsdrt/Makefile (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/Makefile' && PROG= lsof X BIN= ${DESTDIR}/usr/local/bin X DOC= ${DESTDIR}/usr/man/man8 X I=/usr/include S=/usr/include/sys L=/usr/include/local P= X DEBUG= -O -DCANDOCHILD X CDEF= -Dbsdrt CDEFS= ${CDEF} ${CFGF} INCL= ${DINC} CFLAGS= ${DEBUG} ${CDEFS} ${INCL} X GRP= kmem X HDR= lsof.h dlsof.h machine.h proto.h dproto.h X SRC= ddev.c dfile.c dmnt.c dnode.c dproc.c dsock.c dstore.c \ X arg.c main.c misc.c node.c print.c proc.c store.c X OBJ= ddev.o dfile.o dmnt.o dnode.o dproc.o dsock.o dstore.o \ X arg.o main.o misc.o node.o print.o proc.o store.o X MAN= lsof.8 X OTHER= X SOURCE= Makefile ${OTHER} ${MAN} ${HDR} ${SRC} X all: ${PROG} X ${PROG}:$P ${OBJ} X ${CC} -o $@ ${CFLAGS} ${OBJ} ${CFGL} X clean: FRC X rm -f Makefile.bak ${PROG} a.out core errs lint.out tags *.o version.h X deinstall: ${MAN} ${DOC} FRC X rm -f ${BIN}/${PROG} ${DOC}/${MAN} X dirs: ${BIN} ${LIB} X install: all dirs FRC X install -c -s -m 2755 -g ${GRP} ${PROG} ${BIN}/${PROG} X install -m 444 ${MAN} ${DOC} X version.h: version X sed '/VN/s/.ds VN \(.*\)/#define VERSION "\1"/' < version > version.h X FRC: X # DO NOT DELETE THIS LINE - make depend DEPENDS ON IT X ddev.o: ${HDR} ddev.c X dfile.o: ${HDR} dfile.c X dmnt.o: ${HDR} dmnt.c X dnode.o: ${HDR} dnode.c X dproc.o: ${HDR} dproc.c X dsock.o: ${HDR} dsock.c X dstore.o: ${HDR} dstore.c X arg.o: ${HDR} version.h arg.c X main.o: ${HDR} main.c X misc.o: ${HDR} misc.c X node.o: ${HDR} node.c X print.o: ${HDR} print.c X proc.o: ${HDR} proc.c X store.o: ${HDR} store.c X # *** Do not add anything here - It will go away. *** SHAR_EOF $shar_touch -am 0401222895 'dialects/bsdrt/Makefile' && chmod 0644 'dialects/bsdrt/Makefile' || echo 'restore of dialects/bsdrt/Makefile failed' shar_count="`wc -c < 'dialects/bsdrt/Makefile'`" test 1516 -eq "$shar_count" || echo "dialects/bsdrt/Makefile: original size 1516, current size $shar_count" fi # ============= dialects/bsdrt/Mksrc ============== if test -f 'dialects/bsdrt/Mksrc' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/Mksrc (file already exists)' else echo 'x - extracting dialects/bsdrt/Mksrc (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/Mksrc' && #!/bin/sh # # Makesrc - make IBM RT/PC BSD 4.3 source files # # WARNING: This script assumes it is running from the main directory # of the lsof, version 3 distribution. # # One environment variable applies: # # LSOF_MKC is the method for creating the source files. # It defaults to "ln -s". A common alternative is "cp". # # Cp may be used when it is necessary to assemble a # source module from fragments. # # $Id: Mksrc,v 1.4 94/09/02 13:22:40 abe Exp $ X X D=dialects/bsdrt F=dialects/common L="dlsof.h dmnt.c dnode.c dproc.c dproto.h dsock.c dstore.c machine.h" X for i in $L do X rm -f $i X $LSOF_MKC $D/$i $i X echo "$LSOF_MKC $D/$i $i" done X # Assemble ddev.c. X NM=ddev.c P="$D/$NM $F/fchi.frag $F/pcdn.frag $F/rdev.frag" rm -f $NM cat $P > $NM echo "$NM assembled." X # Assemble dfile.c. X NM=dfile.c P="$D/$NM $F/ckfa.frag $F/isfn.frag $F/prfp.frag $F/prtf.frag" rm -f $NM cat $P > $NM echo "$NM assembled." X # Assemble dmnt.c. X NM=dmnt.c P="$D/$NM $F/cvfs.frag $F/rmnt.frag $F/rvfs.frag" rm -f $NM cat $P > $NM echo "$NM assembled." SHAR_EOF $shar_touch -am 0401203195 'dialects/bsdrt/Mksrc' && chmod 0755 'dialects/bsdrt/Mksrc' || echo 'restore of dialects/bsdrt/Mksrc failed' shar_count="`wc -c < 'dialects/bsdrt/Mksrc'`" test 1046 -eq "$shar_count" || echo "dialects/bsdrt/Mksrc: original size 1046, current size $shar_count" fi # ============= dialects/bsdrt/ddev.c ============== if test -f 'dialects/bsdrt/ddev.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/ddev.c (file already exists)' else echo 'x - extracting dialects/bsdrt/ddev.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/ddev.c' && /* X * ddev.c - IBM RT/PC BSD 4.3 device support functions for lsof X */ X X /* Contributed and modified from Ultrix ddev.c by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: ddev.c,v 1.3 94/05/06 16:13:26 abe Exp $"; #endif X X #include "lsof.h" X X #define DIRTYPE direct X X _PROTOTYPE(extern void readdev,(void)); _PROTOTYPE(static void stkdir,(char ***d, int *n, int *x, char *p)); X X /* X * The find_ch_ino() function is obtained from ../common/fchi.frag. X * The printchdevname() function is obtained from ../common/pcdn.frag. X * The readdev() and stkdir() functions are obtained from ../common/rdev.frag. X */ SHAR_EOF $shar_touch -am 0405045695 'dialects/bsdrt/ddev.c' && chmod 0644 'dialects/bsdrt/ddev.c' || echo 'restore of dialects/bsdrt/ddev.c failed' shar_count="`wc -c < 'dialects/bsdrt/ddev.c'`" test 1701 -eq "$shar_count" || echo "dialects/bsdrt/ddev.c: original size 1701, current size $shar_count" fi # ============= dialects/bsdrt/dfile.c ============== if test -f 'dialects/bsdrt/dfile.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dfile.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dfile.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dfile.c' && /* X * dfile.c - IBM RT/PC BSD 4.3 file processing functions for lsof X */ X X /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dfile.c,v 1.2 94/04/22 10:42:37 abe Exp Locker: abe $"; #endif X X #include "lsof.h" X X /* X * The ck_file_arg() function is obtained from ../common/ckfa.frag. X * The is_file_named() function is obtained from ../common/isfn.frag. X * The print_file() function is obtained from ../common/prtf.frag. X * The process_file() function is obtained from ../common/prfp.frag. X */ X /* CKFA_EXPDEV is not defined. */ /* CKFA_MPXCHAN is not defined. */ SHAR_EOF $shar_touch -am 0401205795 'dialects/bsdrt/dfile.c' && chmod 0644 'dialects/bsdrt/dfile.c' || echo 'restore of dialects/bsdrt/dfile.c failed' shar_count="`wc -c < 'dialects/bsdrt/dfile.c'`" test 1639 -eq "$shar_count" || echo "dialects/bsdrt/dfile.c: original size 1639, current size $shar_count" fi # ============= dialects/bsdrt/dlsof.h ============== if test -f 'dialects/bsdrt/dlsof.h' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dlsof.h (file already exists)' else echo 'x - extracting dialects/bsdrt/dlsof.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dlsof.h' && /* X * dlsof.h - IBM RT/PC BSD 4.3 header file for lsof X */ X X /* Contributed and modified from Ultrix and epix dlsof.h by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X X #if !defined(BSDRT_LSOF_H) #define BSDRT_LSOF_H 1 X #include #include #include #include #include #include #include #include #undef VFS #include #define VFS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define KERNEL #include #undef KERNEL #include X # if defined(HASPWSTAYOPEN) extern int _pw_stayopen; #define pw_stay_open() _pw_stayopen=1 # endif X extern char *sys_errlist[]; #define strerror(errno) sys_errlist[errno] X #define COMP_P const void X #define DEVINCR 1024 /* device table malloc() increment */ #define KA_T off_t #define KMEM "/dev/kmem" #define MALLOC_P char #define FREE_P MALLOC_P #define MALLOC_S unsigned #define N_UNIX "/vmunix" #define QSORT_P char X #define READLEN_T size_t #define STRNCPY_L size_t X #define SWAP "/dev/drum" #define U_SIZE ctob(UPAGES) X X /* X * Global storage definitions (including their structure definitions) X */ X extern int Kmem; X struct l_vfs { X struct vfs *addr; /* kernel address */ X dev_t dev; /* device */ X char *dir; /* mounted directory */ X char *fsname; /* file system name */ X struct l_vfs *next; /* forward link */ }; extern struct l_vfs *Lvfs; X extern int Mem; X struct mounts { X dev_t dev; /* st_dev */ X char *dir; /* directory */ X char *fsname; /* file system */ X ino_t inode; /* st_ino */ X mode_t mode; /* st_mode */ X struct mounts *next; /* forward link */ X dev_t rdev; /* st_rdev */ }; X #define X_PROC 0 #define X_NPROC 1 #define X_USRPTMAP 2 #define X_USRPT 3 #define X_TEXT 4 #define X_SYSMAP 5 #define X_FILE 6 #define X_NFS_OPS 7 X struct sfile { X char *aname; /* argument file name */ X char *name; /* file name (after readlink()) */ X char *devnm; /* device name (optional) */ X dev_t dev; /* device */ X u_short mode; /* S_IFMT mode bits from stat() */ X int type; /* file type: 0 = file system X * 1 = regular file */ X ino_t i; /* inode number */ X int f; /* file found flag */ X struct sfile *next; /* forward link */ }; X extern int Swap; X #include X #endif /* BSDRT_LSOF_H */ SHAR_EOF $shar_touch -am 0401223495 'dialects/bsdrt/dlsof.h' && chmod 0644 'dialects/bsdrt/dlsof.h' || echo 'restore of dialects/bsdrt/dlsof.h failed' shar_count="`wc -c < 'dialects/bsdrt/dlsof.h'`" test 3704 -eq "$shar_count" || echo "dialects/bsdrt/dlsof.h: original size 3704, current size $shar_count" fi # ============= dialects/bsdrt/dmnt.c ============== if test -f 'dialects/bsdrt/dmnt.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dmnt.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dmnt.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dmnt.c' && /* X * dmnt.c - IBM RT/PC BSD 4.3 mount support functions for lsof X */ X X /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dmnt.c,v 1.1 94/04/13 08:48:51 abe Exp $"; #endif X X #include "lsof.h" X /* X * The readmnt() function is obtained from ../common/rmnt.frag. X * The readvfs() function is obtained from ../common/rvfs.frag X * The completevfs() function is obtained from ../common/cvfs.frag X */ X #define EXPDEV(n) n #define USECVFS 1 #define RVFS_DEVSAVE 1 #define MNTSKIP \ X { if (strcmp(mp->mnt_type, MNTTYPE_IGNORE) == 0) \ X continue; } SHAR_EOF $shar_touch -am 0401222295 'dialects/bsdrt/dmnt.c' && chmod 0644 'dialects/bsdrt/dmnt.c' || echo 'restore of dialects/bsdrt/dmnt.c failed' shar_count="`wc -c < 'dialects/bsdrt/dmnt.c'`" test 1619 -eq "$shar_count" || echo "dialects/bsdrt/dmnt.c: original size 1619, current size $shar_count" fi # ============= dialects/bsdrt/dnode.c ============== if test -f 'dialects/bsdrt/dnode.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dnode.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dnode.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dnode.c' && /* X * dnode.c - IBM RT/PC BSD 4.3 node functions for lsof X */ X X /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dnode.c,v 1.8 94/10/20 09:46:46 abe Exp $"; #endif X X #include "lsof.h" X X /* X * process_node() - process vnode X */ X void process_node(va) X caddr_t va; /* vnode kernel space address */ { X dev_t dev; X int ft = 0; X struct inode i; X struct rnode r; X char *ty; X enum vtype type; X struct vnode v; X struct l_vfs *vfs; /* X * Read the vnode. X */ X if ( ! va) { X enter_nm("no vnode address"); X return; X } X if (readvnode((caddr_t)va, &v)) { X enter_nm(Namech); X return; X } /* X * Determine the vnode type. X */ X if (Nl[X_NFS_OPS].n_value X && (unsigned long)v.v_op == Nl[X_NFS_OPS].n_value) X Ntype = N_NFS; X else { X switch (v.v_type) { X case VFIFO: X Ntype = N_FIFO; X break; X case VBLK: X Ntype = N_BLK; X break; X case VCHR: X Ntype = N_CHR; X break; X case VREG: X default: X Ntype = N_REGLR; X } X } /* X * Determine the lock type. X */ X if (v.v_shlockc || v.v_exlockc) { X if (v.v_shlockc && v.v_exlockc) X Lf->lock = '*'; X else if (v.v_shlockc) X Lf->lock = 'R'; X else X Lf->lock = 'W'; X } /* X * Establish the local virtual file system structure. X */ X if ((vfs = readvfs(v.v_vfsp)) == NULL) { X (void) sprintf(Namech, "can't read vfs for %#x at %#x", va, X v.v_vfsp); X enter_nm(Namech); X return; X } /* X * Read the fifonode, inode, rnode, or snode. X */ X switch (Ntype) { X case N_NFS: X if (!v.v_data || readrnode((caddr_t)v.v_data, &r)) { X (void) sprintf(Namech, X "vnode at %#x: can't read rnode (%#x)", X va, v.v_data); X enter_nm(Namech); X return; X } X break; X case N_REGLR: X if (!v.v_data || readinode((struct inode *)v.v_data, &i)) { X (void) sprintf(Namech, X "vnode at %#x: can't read inode (%#x)", X va, v.v_data); X enter_nm(Namech); X return; X } X dev = i.i_dev; X break; X default: ; X } X type = v.v_type; X switch (type) { X /* X * VCHR vnodes may be special. X */ X case VCHR: X case VBLK: X dev = v.v_rdev; X break; X case VDIR: X default: X dev = i.i_dev; X } X X if (vfs && vfs->dir == NULL) X (void) completevfs(vfs, &dev); /* X * Obtain the inode number. X */ X switch (Ntype) { X case N_NFS: X Lf->inode = (long)r.r_nfsattr.na_nodeid; X Lf->inp_ty = 1; X break; X case N_FIFO: X case N_REGLR: X Lf->inode = (long)i.i_number; X Lf->inp_ty = 1; X break; X } X /* X * Obtain the file size. X */ X if(Foffset) { X Lf->off_def = 1; X } else { X switch (Ntype) { X X case N_FIFO: X Lf->off_def = 1; X break; X X case N_NFS: X Lf->sz = r.r_nfsattr.na_size; X Lf->sz_def = 1; X break; X X case N_REGLR: X if (type == VREG || type == VDIR) { X Lf->sz = i.i_size; X Lf->sz_def = 1; X } X else if (type == VCHR) X Lf->off_def = 1; X break; X } X } X /* X * Record an NFS file selection. X */ X if (Ntype == N_NFS && Fnfs) X Lf->sf |= SELNFS; /* X * Save the file system names. X */ X if (vfs) { X if (ft <= 1 || Ntype != N_FIFO) { X Lf->fsdir = vfs->dir; X Lf->fsdev = vfs->fsname; X } X } /* X * Format the vnode type, and possibly the device name. X */ X switch (type) { X X case VNON: X ty ="VNON"; X break; X case VREG: X case VDIR: X ty = (type == VREG) ? "VREG" : "VDIR"; X Lf->dev_def = 1; X Lf->dev = dev; X break; X case VBLK: X ty = "VBLK"; X break; X case VCHR: X Lf->dev = dev; X Lf->dev_def = Lf->is_chr_dev = 1; X ty = "VCHR"; X break; X case VLNK: X ty = "VLNK"; X break; X #if defined(VSOCK) X case VSOCK: X ty = "SOCK"; X break; #endif X X case VBAD: X ty = "VBAD"; X break; X case VFIFO: X ty = "FIFO"; X break; X default: X if (type > 9999) X (void) sprintf(Lf->type, "*%03d", type % 1000); X else X (void) sprintf(Lf->type, "%4d", type); X (void) strcpy(Namech, "unknown type"); X ty = NULL; X } X if (ty) X (void) strcpy(Lf->type, ty); /* X * If this is a VCHR file and it's missing an inode number, try to X * supply one. X */ X if (Lf->inp_ty == 0 && type == VCHR && Lf->dev_def) X find_ch_ino(); /* X * Test for specified file. X */ X if (Sfile && is_file_named(NULL, type)) X Lf->sf |= SELNM; /* X * Enter name characters. X */ X if (Namech[0]) X enter_nm(Namech); } SHAR_EOF $shar_touch -am 0405052395 'dialects/bsdrt/dnode.c' && chmod 0644 'dialects/bsdrt/dnode.c' || echo 'restore of dialects/bsdrt/dnode.c failed' shar_count="`wc -c < 'dialects/bsdrt/dnode.c'`" test 5260 -eq "$shar_count" || echo "dialects/bsdrt/dnode.c: original size 5260, current size $shar_count" fi # ============= dialects/bsdrt/dproc.c ============== if test -f 'dialects/bsdrt/dproc.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dproc.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dproc.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dproc.c' && /* X * dproc.c - IBM RT/PC BSD 4.3 process access functions for lsof X */ X X /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dproc.c,v 1.4 94/09/08 09:35:29 abe Exp $"; #endif X #include "lsof.h" #include #include X X _PROTOTYPE(static void get_kernel_access,(void)); X X extern struct pte *Usrptmap; extern struct pte *usrpt; X /* X * Local static values X */ X static int Np = 0; /* number of processes */ static long Kp; /* Kernel process table */ X X static int getu(struct proc *p, /* process area pointer */ X struct user *u /* user area destination */ ); X /* X * gather_proc_info() -- gather process information X */ X X void gather_proc_info() { X struct file *fp; X int i; X struct proc *p, ps; X KA_T pa; X short pss, sf; X int px; X struct text t; X struct user *u, us; X X for (p = &ps, px = 0, u = &us; px < Np; px++) { X X pa = (KA_T)(Kp + (long)(px * sizeof(struct proc))); X if (kread(pa, (char *)&ps, sizeof(ps))) X continue; X /* X * See if process is excluded. X */ X if (is_proc_excl(p->p_pid, p->p_pgrp, (UID_ARG)p->p_uid, X &pss, &sf)) X continue; X /* X * Read the proc structure. X */ X if (getu(p, u)) X continue; X /* X * Allocate a local process structure. X */ X alloc_lproc(p->p_pid, (int)p->p_pgrp, (uid_t)p->p_uid, X u->u_comm, (int)pss, (int)sf); X Plf = NULL; X /* X * Save current working directory information. X */ X if (u->u_cdir) { X alloc_lfile(CWD, -1); X process_node((caddr_t)u->u_cdir); X if (Lf->sf) X link_lfile(); X } X /* X * Save root directory information. X */ X if (u->u_rdir) { X alloc_lfile(RTD, -1); X process_node((caddr_t)u->u_rdir); X if (Lf->sf) X link_lfile(); X } X /* X * Print information on the text file. X */ X if (p->p_textp) { X if (kread((KA_T)p->p_textp, (char *)&t, sizeof(t)) == 0 X && t.x_vptr) { X alloc_lfile("txt", -1); X process_node((caddr_t)t.x_vptr); X if (Lf->sf) X link_lfile(); X } X } X /* X * Save information on file descriptors. X */ X X for (i = 0; i <= u->u_lastfile; i++) X { X fp = u->u_ofile[i]; X if (fp) { X alloc_lfile(NULL, i); X process_file(fp); X if (Lf->sf) X link_lfile(); X } X } X /* X * Examine results. X */ X if (examine_lproc()) X return; X } } X /* X * get_kernel_access() - get access to kernel memory X */ X static void get_kernel_access() { X if ((Core != NULL && !is_readable(Core)) X || (Nmlst != NULL && !is_readable(Nmlst))) X exit(1); /* X * Open kernel memory access. X */ X if ((Kmem = open(Core ? Core : KMEM, O_RDONLY, 0)) < 0) { X (void) fprintf(stderr, "%s: can't open %s: %s\n", Pn, X Core ? Core : KMEM, strerror(errno)); X exit(1); X } X if ((Mem = open("/dev/mem", O_RDONLY, 0)) < 0) { X (void) fprintf(stderr, "%s: can't open /dev/mem: %s\n", X Pn, strerror(errno)); X exit(1); X } X if (Core == NULL || strcmp(Core, KMEM) == 0) { X if ((Swap = open(SWAP, O_RDONLY, 0)) < 0) { X (void) fprintf(stderr, "%s: %s: %s\n", X Pn, SWAP, strerror(errno)); X exit(1); X } X } /* X * Access kernel symbols. X */ X if (nlist(Nmlst ? Nmlst : N_UNIX, Nl) == -1) { X (void) fprintf(stderr, X "%s: can't read kernel name list from %s\n", X Pn, Nmlst ? Nmlst : N_UNIX); X exit(1); X } X if (Nl[X_PROC].n_value == NULL X || kread((KA_T)Nl[X_PROC].n_value, (char *)&Kp, sizeof(Kp)) X || Nl[X_NPROC].n_value == NULL X || kread((KA_T)Nl[X_NPROC].n_value, (char *)&Np, sizeof(Np))) { X (void) fprintf(stderr, "%s: can't read proc table info\n", Pn); X exit(1); X } X if ((Usrptmap = (struct pte *)Nl[X_USRPTMAP].n_value) == NULL) { X (void) fprintf(stderr, "%s: can't get kernel's Usrptmap\n", Pn); X exit(1); X } X if ((usrpt = (struct pte *)Nl[X_USRPT].n_value) == NULL) { X (void) fprintf(stderr, "%s: can't get kernel's usrpt\n", Pn); X exit(1); X } } X X /* X * initialize() - perform all initialization X */ X void initialize() { X get_kernel_access(); X (void) iuidcache(Np); } X X /* X * kread() - read from kernel memory X */ X int kread(addr, buf, len) X KA_T addr; /* kernel memory address */ X char *buf; /* buffer to receive data */ X READLEN_T len; /* length to read */ { X int br; X X if (lseek(Kmem, addr, L_SET) == (off_t)-1L) X return(-1); X br = read(Kmem, buf, len); X return((br == len) ? 0 : 1); } X int mread(addr, buf, len) X KA_T addr; /* /dev/mem address */ X char *buf; /* buffer to receive data */ X READLEN_T len; /* length to read */ { X int br; X X if (lseek(Mem, addr, L_SET) == (off_t)-1L) X return(1); X br = read(Mem, buf, len); X return((br == len) ? 0 : 1); } X /* X getu() - get Romp user area. The arrangement here is: X 1. top of user stack X 2. red zone X 3. kernel stack X 4. kernel stack and u area X X Simple, isn't it? The u area is at the very end of P1. X */ X #define REDSIZE CLSIZE*2 /* red zone size plus reserved page */ X struct userx { X char userfill[UPAGES*NBPG-sizeof (struct user)]; X struct user user; }; X union { X struct userx userx; X char upages[UPAGES][NBPG]; } user; #define U user.userx.user X static int getu(struct proc *p, /* process area pointer */ X struct user *u /* user area destination */ ) { X off_t pte_off, pte_addr; X struct pte pte1; X struct pte arguutl[UPAGES+CLSIZE+REDSIZE]; X int i; X int ncl; X /* X * If the process has been swapped, read its user structure via X * its stack segment map's page table address. X */ X X if ((p->p_flag & SLOAD) == 0) { X if (Nmlst && strcmp(Nmlst, N_UNIX) == 0) X return(1); X if (lseek(Swap, (long)dtob(p->p_swaddr), L_SET) == -1) X return(1); X X if (read(Swap, (char *)u, U_SIZE) == U_SIZE) X return(0); X return(1); X } /* Read the user structure via its page table. */ X #ifdef ROCKY X printf("p->p_p0br %x, userpt %x, btokmx(p->p_p0br) %x, p->p_szpt %x\n", X p->p_p0br, usrpt, btokmx(p->p_p0br), p->p_szpt); /*rocky debug*/ X i = btokmx(p->p_p0br) + p->p_szpt - 1; /*rocky debug*/ X printf("pid: %d, i: %x &Usrptmap[i]: %x\n", X p->p_pid, i, &Usrptmap[i]); /*rocky debug*/ #endif X pte_off = (off_t) &Usrptmap[btokmx(p->p_p0br) + p->p_szpt - 1]; X if (kread(pte_off, (char *)&pte1, sizeof(pte1))) { X return (1); X } /* X Locate the last entry in the page table array which will include X the entry for the u area. X */ X pte_addr = (KA_T) (ctob(pte1.pg_pfnum + 1) X - ((UPAGES+CLSIZE+REDSIZE) * sizeof(struct pte))); X if (mread((KA_T)pte_addr, (char *) arguutl, sizeof(arguutl))) X return(1); X X /* _u is at end of upages */ X ncl = (U_SIZE + NBPG*CLSIZE - 1) / (NBPG*CLSIZE); X X while (--ncl >= 0) { X i = ncl * CLSIZE; X pte_addr = (off_t) ctob(arguutl[CLSIZE+REDSIZE+i].pg_pfnum); X if (pte_addr == 0) { X bzero((char *) u, sizeof (struct user)); X return(0); /* faked for swapper */ X } X if (mread(pte_addr, user.upages[i], CLSIZE*NBPG)) { X return(1); X } X } X /* return the structure */ X bcopy(&U, u, sizeof(struct user)); X return (0); } X SHAR_EOF $shar_touch -am 0402031695 'dialects/bsdrt/dproc.c' && chmod 0644 'dialects/bsdrt/dproc.c' || echo 'restore of dialects/bsdrt/dproc.c failed' shar_count="`wc -c < 'dialects/bsdrt/dproc.c'`" test 7809 -eq "$shar_count" || echo "dialects/bsdrt/dproc.c: original size 7809, current size $shar_count" fi # ============= dialects/bsdrt/dproto.h ============== if test -f 'dialects/bsdrt/dproto.h' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dproto.h (file already exists)' else echo 'x - extracting dialects/bsdrt/dproto.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dproto.h' && /* X * dproto.h - IBM RT/PC BSD 4.3 function prototypes for lsof X * X * The _PROTOTYPE macro is defined in the common proto.h. X */ X X /* Contributed and modified from dynix dproto.h by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X X _PROTOTYPE(extern void completevfs,(struct l_vfs *vfs, dev_t *dev)); _PROTOTYPE(extern int is_file_named,(char *p, enum vtype ty)); _PROTOTYPE(extern int readinode,(struct inode *ia, struct inode *i)); _PROTOTYPE(extern int readrnode,(caddr_t ra, struct rnode *r)); _PROTOTYPE(extern struct l_vfs *readvfs,(struct vfs *ka)); SHAR_EOF $shar_touch -am 0405050595 'dialects/bsdrt/dproto.h' && chmod 0644 'dialects/bsdrt/dproto.h' || echo 'restore of dialects/bsdrt/dproto.h failed' shar_count="`wc -c < 'dialects/bsdrt/dproto.h'`" test 1512 -eq "$shar_count" || echo "dialects/bsdrt/dproto.h: original size 1512, current size $shar_count" fi # ============= dialects/bsdrt/dsock.c ============== if test -f 'dialects/bsdrt/dsock.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dsock.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dsock.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dsock.c' && /* X * dsock.c - IBM RT/PC BSD 4.3 socket processing functions for lsof X */ X X /* Contributed and modified from epix dsock.c by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dsock.c,v 1.9 94/10/20 09:46:49 abe Exp $"; #endif X X #include "lsof.h" X X /* X * process_socket() - process socket X */ X void process_socket(sa) X caddr_t sa; /* socket address in kernel */ { X struct domain d; X char dev_ch[32]; X int fam; X struct inpcb inp; X struct mbuf mb; X struct protosw p; X struct rawcb raw; X struct socket s; X struct unpcb uc, unp; X struct sockaddr_un *ua = NULL; X struct sockaddr_un un; X X (void) strcpy(Lf->type, "sock"); X Lf->inp_ty = 2; /* X * Read socket structure. X */ X if (sa == NULL) { X enter_nm("no socket address"); X return; X } X if (kread((KA_T) sa, (char *) &s, sizeof(s))) { X (void) sprintf(Namech, "can't read socket struct from %#x", X sa); X enter_nm(Namech); X return; X } X if ( ! s.so_type) { X enter_nm("no socket type"); X return; X } /* X * Read protocol switch and domain structure. X */ X if (s.so_proto == NULL X || kread((KA_T) s.so_proto, (char *) &p, sizeof(p))) { X (void) strcpy(Namech, "no protocol switch"); X enter_nm(Namech); X return; X } X if (kread((KA_T) p.pr_domain, (char *) &d, sizeof(d))) { X (void) sprintf(Namech, "can't read domain struct from %#x", X p.pr_domain); X enter_nm(Namech); X return; X } /* X * Set size, based on access type. X */ X if (Fsize) { X if (Lf->access == 'r') X Lf->sz = s.so_rcv.sb_cc; X else if (Lf->access == 'w') X Lf->sz = s.so_snd.sb_cc; X else X Lf->sz = s.so_rcv.sb_cc + s.so_snd.sb_cc; X Lf->sz_def = 1; X } else X Lf->off_def = 1; /* X * Process socket by the associated domain family. X */ X switch ((fam = d.dom_family)) { /* X * Process an Internet domain socket. X */ X case AF_INET: X if (Fnet) X Lf->sf |= SELNET; X (void) strcpy(Lf->type, "inet"); X printiproto(p.pr_protocol); X /* X * Read protocol control block. X */ X if (s.so_pcb == NULL) { X enter_nm("no protocol control block"); X return; X } X if (s.so_type == SOCK_RAW) { X X /* X * Print raw socket information. X */ X if (kread((KA_T) s.so_pcb, (char *)&raw, sizeof(raw)) X || (struct socket *)sa != raw.rcb_socket) { X (void) sprintf(Namech, "can't read rawcb at %#x", X s.so_pcb); X enter_nm(Namech); X return; X } X (void) sprintf(dev_ch, "0x%08x", X (raw.rcb_pcb == NULL) ? s.so_pcb : raw.rcb_pcb); X enter_dev_ch(dev_ch); X if (raw.rcb_laddr.sa_family == AF_INET) X printinaddr((struct in_addr *)&raw.rcb_laddr.sa_data[2], X -1); X else if (raw.rcb_laddr.sa_family) X printrawaddr(&raw.rcb_laddr); X if (raw.rcb_faddr.sa_family == AF_INET) { X (void) strcat(endnm(), "->"); X printinaddr((struct in_addr *)&raw.rcb_faddr.sa_data[2], X -1); X } else if (raw.rcb_faddr.sa_family) { X (void) strcat(endnm(), "->"); X printrawaddr(&raw.rcb_faddr); X } X } else { X X /* X * Print Internet socket information. X */ X if (kread((KA_T) s.so_pcb, (char *) &inp, sizeof(inp)) X || (struct socket *)sa != inp.inp_socket) { X (void) sprintf(Namech, "can't read inpcb at %#x", X s.so_pcb); X enter_nm(Namech); X return; X } X (void) sprintf(dev_ch, "0x%08x", X (inp.inp_ppcb == NULL) ? s.so_pcb : inp.inp_ppcb); X enter_dev_ch(dev_ch); X printinaddr(&inp.inp_laddr, (int)inp.inp_lport); X if (inp.inp_faddr.s_addr != INADDR_ANY || inp.inp_fport X != 0) { X (void) strcat(endnm(), "->"); X printinaddr(&inp.inp_faddr, (int)inp.inp_fport); X } X } X break; /* X * Process a Unix domain socket. X */ X case AF_UNIX: X if (Funix) X Lf->sf |= SELUNX; X (void) strcpy(Lf->type, "unix"); X /* X * Read Unix protocol control block and the Unix address structure. X */ X (void) sprintf(dev_ch, "0x%08x", sa); X enter_dev_ch(dev_ch); X if (kread((KA_T) s.so_pcb, (char *) &unp, sizeof(unp))) { X (void) sprintf(Namech, "can't read unpcb at %#x", X s.so_pcb); X break; X } X if ((struct socket *)sa != unp.unp_socket) { X (void) sprintf(Namech, "unp_socket (%#x) mismatch", X unp.unp_socket); X break; X } X if (unp.unp_addr) { X if (kread((KA_T) unp.unp_addr, (char *) &mb, sizeof(mb))) { X (void) sprintf(Namech, X "can't read unp_addr at %#x", X unp.unp_addr); X break; X } X X ua = (struct sockaddr_un *)(((char *)&mb) + mb.m_off); X X } X if (ua == NULL) { X ua = &un; X (void) bzero((char *)ua, sizeof(un)); X ua->sun_family = AF_UNSPEC; X } X /* X * Print information on Unix socket that has no address bound X * to it, although it may be connected to another Unix domain X * socket as a pipe. X */ X if (ua->sun_family != AF_UNIX) { X if (ua->sun_family == AF_UNSPEC) { X if (unp.unp_conn) { X if (kread((KA_T) unp.unp_conn, X (char *) &uc, sizeof(uc))) { X (void) sprintf(Namech, X "can't read unp_conn at %#x", X unp.unp_conn); X } else { X (void) sprintf(Namech, X "->0x%08x", uc.unp_socket); X } X } else { X (void) strcpy(Namech, "->(none)"); X } X } else X (void) sprintf(Namech, X "unknown sun_family (%d)", X ua->sun_family); X break; X } X if (ua->sun_path[0]) { X if (mb.m_len >= sizeof(struct sockaddr_un)) X mb.m_len = sizeof(struct sockaddr_un) - 1; X *((char *)ua + mb.m_len) = '\0'; X if (Sfile && is_file_named(ua->sun_path, VSOCK)) X Lf->sf |= SELNM; X else X (void) strcpy(Namech, ua->sun_path); X } else X (void) strcpy(Namech, "no address"); X break; X default: X (void) sprintf(Namech, "unknown family %#x", fam); X } X if (Namech[0]) X enter_nm(Namech); } SHAR_EOF $shar_touch -am 0402031795 'dialects/bsdrt/dsock.c' && chmod 0644 'dialects/bsdrt/dsock.c' || echo 'restore of dialects/bsdrt/dsock.c failed' shar_count="`wc -c < 'dialects/bsdrt/dsock.c'`" test 6827 -eq "$shar_count" || echo "dialects/bsdrt/dsock.c: original size 6827, current size $shar_count" fi # ============= dialects/bsdrt/dstore.c ============== if test -f 'dialects/bsdrt/dstore.c' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/dstore.c (file already exists)' else echo 'x - extracting dialects/bsdrt/dstore.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/dstore.c' && /* X * dstore.c - RT/PC BSD 4.3 global storage for lsof X */ X X /* Contributed and modified from Ultrix dstore.c by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X #ifndef lint static char copyright[] = "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; static char *rcsid = "$Id: dstore.c,v 1.2 94/11/16 12:55:10 abe Exp $"; #endif X X #include "lsof.h" X X /* X * Global storage definitions X */ X int Kmem = -1; /* /dev/kmem file descriptor */ X struct l_vfs *Lvfs = NULL; /* local vfs structure table */ X int Mem = -1; /* /dev/mem file descriptor */ X struct nlist Nl[] = { X X { "_proc" }, X { "_nproc" }, X { "_Usrptmap" }, X { "_usrpt" }, X { "_text" }, X { "_Sysmap" }, X { "_file" }, X { "_nfs_vnodeops" }, X { "" } }; X int Swap = -1; /* swap device file descriptor */ X struct pte *Usrptmap; /* user page table map pointer */ struct pte *usrpt; /* user page table pointer X * (for bktomx from vmmac.h) */ SHAR_EOF $shar_touch -am 0401233195 'dialects/bsdrt/dstore.c' && chmod 0644 'dialects/bsdrt/dstore.c' || echo 'restore of dialects/bsdrt/dstore.c failed' shar_count="`wc -c < 'dialects/bsdrt/dstore.c'`" test 1973 -eq "$shar_count" || echo "dialects/bsdrt/dstore.c: original size 1973, current size $shar_count" fi # ============= dialects/bsdrt/machine.h ============== if test -f 'dialects/bsdrt/machine.h' && test X"$1" != X"-c"; then echo 'x - skipping dialects/bsdrt/machine.h (file already exists)' else echo 'x - extracting dialects/bsdrt/machine.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'dialects/bsdrt/machine.h' && /* X * machine.h - IBM RT/PC BSD4.3 definitions for lsof X */ X X /* Contributed and modified from Ultrix machine.h by R. Bernstein. */ /* X * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana X * 47907. All rights reserved. X * X * Written by Victor A. Abell X * X * This software is not subject to any license of the American Telephone X * and Telegraph Company or the Regents of the University of California. X * X * Permission is granted to anyone to use this software for any purpose on X * any computer system, and to alter it and redistribute it freely, subject X * to the following restrictions: X * X * 1. Neither the authors nor Purdue University are responsible for any X * consequences of the use of this software. X * X * 2. The origin of this software must not be misrepresented, either by X * explicit claim or by omission. Credit to the authors and Purdue X * University must appear in documentation and sources. X * X * 3. Altered versions must be plainly marked as such, and must not be X * misrepresented as being the original software. X * X * 4. This notice may not be removed or altered. X */ X X #include #include #include #include #include X X /* X * CANDOCHILD is defined for for dialects that can do readlink() and lstat() X * operations in child processes. X * X * The definition is made in the DEBUG string of the Makefile. X * X * All dialects can do readlink() and lstat() operations in child processes, X * as far as I know, but the debuggers of some dialects -- e.g., Motorola X * V/88 R40V42's tbx -- can't handle them, so this definition exists to allow X * debugging by eliminating -DCANDOCHILD from the Makefile's DEBUG string. X */ X X /* X * HASCOPT is defined for those dialects that support the reading of X * kernel memory from an alternate file. X */ X #define HASCOPT 1 X X /* X * HASCDRNODE is defined for those dialects that have CD-ROM nodes. X */ X /* #define HASCDRNODE 1 */ X X /* X * HASFIFONODE is defined for those dialects that have FIFO nodes. X */ X /* #define HASFIFONODE 1 */ X X /* X * HASGNODE is defined for those dialects that have gnodes. X */ X /*#define HASGNODE 1*/ X X /* X * HASHSNODE is defined for those dialects that have High Sierra nodes. X */ X /* #define HASHSNODE 1 */ X X /* X * HASINODE is defined for those dialects that have inodes. X */ X #define HASINODE 1 X X /* X * HASINTSIGNAL is defined for those dialects whose signal function returns X * an int. X */ X #define HASINTSIGNAL 1 X X /* X * HASKOPT is defined for those dialects that support the -k option of X * reading the kernel's name list from an optional file. X */ X #define HASKOPT 1 X X /* X * HASNLIST is defined for those dialects that use nlist() to acccess X * kernel symbols. X */ X #define HASNLIST 1 X X /* X * HASPIPENODE is defined for those dialects that have pipe nodes. X */ X /* #define HASPIPENODE 1 */ X X /* X * HASPROCFS is defined for those dialects that have a proc file system -- X * usually /proc and usually in SYSV4 derivatives. X * X * HASFSTYPE is defined for those systems that have a file system type X * string, st_fstype, in the stat() buffer. X * X * The defined value is the string that names the file system type. X * X * The HASPROCFS definition usually must be accompanied by the HASFSTYPE X * definition and the providing of an fstype element in the local mounts X * structure (defined in dlsof.h). X * X * The HASPROCFS definition may be accompanied by the HASPINFO definition. X * HASPINFO names the subdirectory of HASPROCFS that contains read-only X * information (typically /pinfo). X */ X /* #define HASPROCFS "proc" */ /* #define HASFSTYPE 1 */ /* #define HASPINFO "/pinfo" */ X X /* X * HASPWSTAYOPEN is defined for those dialects that have a method to hold X * the password data base open between searches. Setting this definition X * implies the availability of a dialect-specific pw_stay_open() function X * to implement the method. X */ X /* #define HASPWSTAYOPEN 1 */ X X /* X * HASRNODE is defined for those dialects that have rnodes. X */ X #define HASRNODE 1 X X /* X * Define HASSECURITY to restrict the listing of all open files to the X * root user. When HASSECURITY is defined, the non-root user may list X * only files whose processes have the same user ID as the real user ID X * (the one that its user logged on with) of the lsof process. X */ X /* #define HASSECURITY 1 */ X X /* X * HASSNODE is defined for those dialects that have snodes. X */ X /* #define HASSNODE 1 */ X X /* X * HASSTREAMS is defined for those dialects that support streams. X */ X /* #define HASSTREAMS 1 */ X X /* X * HASSWAPPORT is defined for those dialects whose /etc/services port X * number, provided by getservent(), must be converted from network X * byte order to host byte order with ntohs(). X */ X #define HASSWAPPORT 1 X X /* X * HASTMPNODE is defined for those dialects that have tmpnodes. X */ X /* #define HASTMPNODE 1 */ X X /* X * HASVNODE is defined for those dialects that use the Sun virtual file system X * node, the vnode. BSD derivatives usually do; System V derivatives prior to X * R4 usually don't. Ultrix has an equivalent, called a gnode. X */ X #define HASVNODE 1 X X /* X * UID_ARG defines the size of a User ID number when it is passed X * as a function argument. X */ X #define UID_ARG uid_t X X /* X * zeromem is a macro that uses bzero or memset. X */ X /* #define zeromem(a, l) */ SHAR_EOF $shar_touch -am 0401204995 'dialects/bsdrt/machine.h' && chmod 0644 'dialects/bsdrt/machine.h' || echo 'restore of dialects/bsdrt/machine.h failed' shar_count="`wc -c < 'dialects/bsdrt/machine.h'`" test 5323 -eq "$shar_count" || echo "dialects/bsdrt/machine.h: original size 5323, current size $shar_count" fi exit 0