home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
1
/
1485
< prev
next >
Wrap
Internet Message Format
|
1990-12-28
|
32KB
From: wht@n4hgf.uucp (Warren Tucker)
Newsgroups: alt.sources
Subject: u386mon, UNIX/386 system monitor, part 01/02
Message-ID: <102@n4hgf.uucp>
Date: 20 Jun 90 01:47:42 GMT
Archive-name: u386mon008/part01
Submitted-by: wht@n4hgf
Well, here is u386mon, a hack monitor for SCO UNIX V/386. It may work
with other UNIX systems with a little work. It requires terminfo
style curses and will use color if you have it.
#!/bin/sh
# This is u386mon.x0.08, a shell archive (shar 3.27)
# made 06/20/1990 01:39 UTC by wht@n4hgf
# Source directory /u1/src/u386mon
#
# existing files WILL be overwritten
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 6572 -rw-r--r-- README
# 4178 -rw-r--r-- Makefile
# 2768 -rw-r--r-- sco_c16.t.src
# 4869 -rw-r--r-- nlsym.h
# 551 -rw-r--r-- libnlsym.h
# 584 -rw-r--r-- libkmem.h
# 2233 -rw-r--r-- libkmem.c
# 2146 -rw-r--r-- libnlsym.c
# 2390 -rw-r--r-- nlsym.c
# 25595 -rw-r--r-- u386mon.c
#
if touch 2>&1 | fgrep 'mmdd' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= README ==============
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
XWhat
X====
X
XWell, here is u386mon, a hack monitor for SCO UNIX V/386. It may work
Xwith other UNIX systems with a little work. It requires terminfo
Xstyle curses and will use color if you have it.
X
X
XApology
X=======
X
XThis is a horribly unreleasable, preliminary, experimental, hacked
Xlittle light show, but it has already helped me diagnose the
Xtraditional "stop-the-world-and-beat-disk-continually-for-15-seconds"
Xproblem as memory exhaustion.
X
X
XSample output
X=============
X(with 43-line screen)
X
X u386mon x0.08 n4hgf - i386 3.2 wht@n4hgf
X---- CPU --- tot usr ker brk ---------------------------------------------------
X Instant % 17 4 13 0 uukkkkkk
X 5 Sec Avg % 71 48 23 0 uuuuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkk
X10 Sec Avg % 82 66 16 0 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuukkkkkkkk
X---- Wait -- tot io swp pio -- (% of real time) -------------------------------
X Instant % 0 0 0 0
X 5 Sec Avg % 2 2 0 0 i
X10 Sec Avg % 1 1 0 0
X---- Sysinfo/Minfo --- (last 1 second activity) --------------------------------
Xbread 0 rawch 0 pswitch 8 vfault 0 unmodfl 0
Xbwrite 7 canch 0 syscall 16 demand 0 psoutok 0
Xlread 0 outch 3076 sysread 4 pfault 0 psinfai 0
Xlwrite 7 syswrit 5 cw 0 psinok 0
Xphread 0 msg 0 sysfork 0 steal 0 rsout 0
Xphwrit 0 sema 0 sysexec 0 frdpgs 0 rsin 0
Xiget 0 vfpg 0
Xnamei 0 maxmem 5716k runque 1 sfpg 0 pages on
Xdirblk 0 frmem 3036k runocc 1 vspg 0 swap 0
Xreadch 34680 mem used 47% swpque 0 sspg 0 cache 0
Xwritch 3076 nswap 10000k swpocc 0 unmodsw 0 file 0
X frswp 10000k
X swp used 0%
X
X
X
X-- var --------- -- bootinfo ---------- -- tune --------- -- proc ---
Xv_buf 600 basemem 655360 t_gpgslo 25 sleep 23
Xv_inode 200 extmem 6291456 t_gpgshi 40 run 0
Xv_file 200 bflags 00000000 t_gpgsmsk 0x420 zombie 0
Xv_mount 5 memory avail t_ageintvl 9 stop 0
Xv_proc 100 00000000 000a0000 t_maxsc 1 idle 0
Xv_clist 200 00100000 00600000 t_maxfc 1 onproc 1
Xv_sptmap 50 00f40000 00060000 NODM t_maxumem 2560 xbrk 0
Xv_vhndfrac 16 memory used t_bdflushr 1 total 24
Xv_maxpmem 0 00000000 00004000 RSVD t_minarmem 25 in mem 24
X 006b9000 00038000 KBSS t_minasmem 25
X 006f1000 0000f000 KDTA
X 00fa5000 0005b000 KTXT
X
X
XWhat the display means
X======================
X
XA brief description of reported information:
X
X1. The CPU utilization is shown with smoothing of 1 ("instant"),
X 5 and 10 seconds. Total CPU usage is shown, with user, kernel
X and "break" subdivided. Most performance utilities (vmstat)
X lump kernel (CPU_KERNEL) and wait (CPU_WAIT) times together
X as kernel time. u386mon considers CPU_WAIT time as idle (the
X CPU could have been doing something if an otherwise ready process
X wasn't waited).
X
X On a color display, total cpu utilization is displayed in
X green if the cpu utilization is below 70%, yellow (brown, sigh)
X if utilization is between 70% and 89% and red if 90% or above.
X
X2. The Wait display shows the 1 ("instant"), 5 and 10 second smoothed
X percentages of real time no process could be run because otherwise
X ready to run processes were waiting on logical, swap or physical I/O.
X
X3. Sysinfo/Minfo display shows, generally, the number of events for a
X measured value since the last display update. For example, runque
X shows the number of times a process was placed on the run queue.
X An exception is the memory and swap space fields: These numbers
X reflect absolute current utilization.
X
X4. If you run u386mon on a 43 line display, extra information is displayed
X on the bottom of the screen (from the struct var v, bootinfo
X and proc kernel databases).
X
X5. On a color display, static numeric values, such as maxmem appear
X in blue (the same color as screen literals/labels). Dynamic
X numeric values are displayed in green, red or yellow.
X
X6. An "INEXACT" indication on the top line means that u386mon was
X not scheduled quickly enough to capture accurate 1 second
X values. Continued INEXACT indication suggests the 5 and 10
X second smoothed values are also wrong.
X
X An "INVALID" indication means u386mon was not scheduled for 4
X seconds or more. All dynamic values are suspect.
X
X
XA $0.0002 tour
X==============
X
XAccess to kernel memory is required for u386mon to do its thing.
X
XThe 'nlist' procedure is performed by a separate program (nlsym)
Xand the resulting nlist structure array is stored in /unix.nlsym.
Xu386mon thus may obtain nlist information rapidly without nlist(S) each
Xtime it is executed. Also stored in /unix.nlsym is a stat structure of
X/unix at the time of nlsym execution. A unique word is stored at the
Xend of the file in case /unix.nlsym's nlist structure is expanded for
Xother applications. The u386mon program reads /unix.nlsym by means
Xof facilities in libnlsym.c. If the stat structure in /unix.nlsym
Xdoes not match a dynamic stat of /unix or if the unique word does
Xnot match, the nlist information is not trusted and u386mon prompts
Xthe user to run (or have run) the nlsym program to update /unix.nlsym.
X
XHow to get going
X================
X
X1. you must run the make as root
X
X2. nlsym must be run by root (the Makefile will do this the first time)
X
X3. making against Makefile as root will
X a. make nlsym
X b. make u386mon and set-gid to group 'mem'
X c. run nlsym to produce /unix.nlsym
X
X4. Sources are in 4-spaced tab format (please don't flame :-)).
X
X5. You MAY wish to use my hacked up terminfo for 'ansi' to get
X better colors. I am new at color curses and probably took a
X bad approach to getting 16 colors instead of 8. Rather than
X using the "standard ANSI" color sequences, sco_c16.t.src
X uses the SCO extensions for 16-color selection. Just tic
X sco_c16.t.src and use -DCOLOR_16_TERMINFO in the Makefile CFLAGS.
X Re-tic the standard source to get back to released reality.
X
XComments are appreciated.
XWarren Tucker N4HGF emory!n4hgf!wht -or- wht%n4hgf.uucp@emory.mathcs.emory.edu
X
SHAR_EOF
$TOUCH -am 0619212990 README &&
chmod 0644 README ||
echo "restore of README failed"
set `wc -c README`;Wc_c=$1
if test "$Wc_c" != "6572"; then
echo original size 6572, current size $Wc_c
fi
# ============= Makefile ==============
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#+--------------------------------------------------------------
X# Makefile for nlsym utilities for SCO UNIX V/386
X# ...!emory!n4hgf!wht
X#---------------------------------------------------------------
X#+:EDITS:
X#:06-19-1990-21:37-wht@n4hgf-get ready for 0.08 release
X
XVERSION = x0.08
X
X#handle Sys V make "feature" of using SHELL
XSHELL = /bin/sh
X
XCFLAGS = -c -Octl -DLINT_ARGS
X
X#if you use my hacked 16-color terminfo
X#CFLAGS = -c -Octl -DLINT_ARGS -D COLOR_16_TERMINFO
X
XLIB = -lpanel -lcurses -lx
X#FCRC = fcrc -u $*.c ;
X
X.c.o:; $(FCRC) cc $(CFLAGS) $*.c
X
XSRC = \
X bootinfo.c\
X disputil.c\
X libkmem.c\
X libnlsym.c\
X nlsym.c\
X proc.c\
X tune.c\
X u386mon.c\
X var.c
X
XNLSYM_OBJ =\
X nlsym.o
X
XU386MON_OBJ =\
X u386mon.o\
X bootinfo.o\
X proc.o\
X tune.o\
X var.o\
X disputil.o\
X libkmem.o\
X libnlsym.o
X
Xall: nlsym u386mon /unix.nlsym
X
Xnlsym: $(NLSYM_OBJ)
X cc -o $@ $(NLSYM_OBJ) $(LIB)
X
Xu386mon: $(U386MON_OBJ)
X cc -o $@ $(U386MON_OBJ) $(LIB)
X chmod 2711 u386mon
X chgrp mem u386mon
X
X/unix.nlsym: nlsym /unix
X nlsym
X chmod 644 /unix.nlsym
X
X#not delivered
X#src.fls: $(SRC) Makefile
X# ls $(SRC) > src.fls
X#
X#lint: src.fls
X# echo ' ' > lint_args.h
X# csh zgcc src.fls lint_args.h $(CFLAGS)
X
Xclean:
X rm -f $(U386MON_OBJ) $(NLSYM_OBJ)
X
Xclobber: clean
X rm -f nlsym u386mon u386mon.sh.0[1234]
X
X#for shar 3.27 or later
Xshar:
X shar -l 50 -n u386mon.$(VERSION) -o u386mon.sh \
X README Makefile sco_c16.t.src nlsym.h libnlsym.h libkmem.h \
X libkmem.c libnlsym.c nlsym.c u386mon.c
X
X# MAKE DEPEND: regenerate .c:.h, .ol:.c, .ol:.asm dependencies automatically
X#
Xdepend:
X rm -f depend.tmp
X if test '$(SRC)' ;\
X then (grep '^#include' $(SRC) \
X | sed -e 's?:[^<]*<\([^>]*\)>.*?: /usr/include/\1?'\
X -e 's?:[^"]*"\([^"]*\)".*?: \1?'\
X -e 's?\(.*\)\.c?\1.o?'\
X >> depend.tmp) ;\
X fi
X
X echo '/^# DO NOT DELETE THIS LINE' >exdep.tmp
X echo '.+1,$$d' >>exdep.tmp
X echo 'r depend.tmp' >> exdep.tmp
X echo 'w' >> exdep.tmp
X cp Makefile Makefile.new
X ex Makefile.new < exdep.tmp
X rm exdep.tmp depend.tmp
X echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile.new
X echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
X echo '# see make depend above'>>Makefile.new
X mv Makefile Makefile.bak
X mv Makefile.new Makefile
X
X# DO NOT DELETE THIS LINE
Xbootinfo.o: /usr/include/curses.h
Xbootinfo.o: /usr/include/panel.h
Xbootinfo.o: /usr/include/sys/types.h
Xbootinfo.o: /usr/include/sys/bootinfo.h
Xbootinfo.o: u386mon.h
Xdisputil.o: /usr/include/curses.h
Xdisputil.o: /usr/include/panel.h
Xdisputil.o: u386mon.h
Xlibkmem.o: /usr/include/sys/types.h
Xlibkmem.o: /usr/include/fcntl.h
Xlibkmem.o: libkmem.h
Xlibnlsym.o: /usr/include/stdio.h
Xlibnlsym.o: /usr/include/sys/types.h
Xlibnlsym.o: /usr/include/sys/stat.h
Xlibnlsym.o: /usr/include/fcntl.h
Xlibnlsym.o: /usr/include/nlist.h
Xlibnlsym.o: nlsym.h
Xlibnlsym.o: libnlsym.h
Xnlsym.o: /usr/include/stdio.h
Xnlsym.o: /usr/include/sys/types.h
Xnlsym.o: /usr/include/sys/stat.h
Xnlsym.o: /usr/include/fcntl.h
Xnlsym.o: /usr/include/nlist.h
Xnlsym.o: nlsym.h
Xtune.o: /usr/include/curses.h
Xtune.o: /usr/include/panel.h
Xtune.o: /usr/include/sys/types.h
Xtune.o: /usr/include/sys/tuneable.h
Xtune.o: u386mon.h
Xu386mon.o: /usr/include/curses.h
Xu386mon.o: /usr/include/panel.h
Xu386mon.o: /usr/include/signal.h
Xu386mon.o: /usr/include/string.h
Xu386mon.o: /usr/include/fcntl.h
Xu386mon.o: /usr/include/nlist.h
Xu386mon.o: /usr/include/errno.h
Xu386mon.o: /usr/include/time.h
Xu386mon.o: /usr/include/sys/types.h
Xu386mon.o: /usr/include/sys/utsname.h
Xu386mon.o: /usr/include/sys/stat.h
Xu386mon.o: /usr/include/sys/ascii.h
Xu386mon.o: /usr/include/sys/param.h
Xu386mon.o: /usr/include/sys/bootinfo.h
Xu386mon.o: /usr/include/sys/tuneable.h
Xu386mon.o: /usr/include/sys/sysinfo.h
Xu386mon.o: /usr/include/sys/sysmacros.h
Xu386mon.o: /usr/include/sys/immu.h
Xu386mon.o: /usr/include/sys/region.h
Xu386mon.o: /usr/include/sys/proc.h
Xu386mon.o: /usr/include/sys/var.h
Xu386mon.o: nlsym.h
Xu386mon.o: libkmem.h
Xu386mon.o: libnlsym.h
Xu386mon.o: u386mon.h
Xvar.o: /usr/include/curses.h
Xvar.o: /usr/include/panel.h
Xvar.o: /usr/include/sys/types.h
Xvar.o: /usr/include/sys/var.h
Xvar.o: u386mon.h
X# DEPENDENCIES MUST END AT END OF FILE
X# IF YOU PUT STUFF HERE IT WILL GO AWAY
X# see make depend above
SHAR_EOF
$TOUCH -am 0619213990 Makefile &&
chmod 0644 Makefile ||
echo "restore of Makefile failed"
set `wc -c Makefile`;Wc_c=$1
if test "$Wc_c" != "4178"; then
echo original size 4178, current size $Wc_c
fi
# ============= sco_c16.t.src ==============
echo "x - extracting sco_c16.t.src (Text)"
sed 's/^X//' << 'SHAR_EOF' > sco_c16.t.src &&
X#this is a hacked terminfo to allow direct 16-color access
X#using the SCO video driver extensions
X
Xansi|ansic|ansi80x25|Ansi standard console,
X am, eo, xon, bce,
X cols#80, lines#25, colors#16, pairs#64,
X initc=, op=\E[=11F\E[=0G\E[=4H\E[=7I\E[m,
X setf=\E[=%p1%dF\E[m,
X setb=\E[=%p1%dG\E[m,
X bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
X clear=\E[2J\E[H, cr=\r, cub1=\b, cud1=\E[B, cuf1=\E[C,
X cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
X dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
X ht=\t, ich1=\E[@, il1=\E[L, ind=\E[S, kbs=\b,
X kb2=\E[E,
X kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
X kf0=\E[V, kf1=\E[M, kf2=\E[N, kf3=\E[O, kf4=\E[P,
X kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
X khome=\E[H, kend=\E[F, kpp=\E[I, knp=\E[G,
X ri=\E[T, rmso=\E[m,
X rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
X it#8, ht=^I, cbt=\E[Z,
X#wht additions
X civis=\E[=8;7C,cnorm=\E[=4;8C,cvvis=\E[=0;8C,
X kb2=\E[E,
X#wht changes
X setf=\E[=%p1%dF\E[=0E\E[m,
X setb=\E[=%p1%dG\E[=0E\E[m,
X kich1=\E[L,kdch1=\177
X kf10=\E[U, kf11=\E[V,
X cols#80, lines#43, colors#16, pairs#64,
X
X
Xansi43|ansi80x43|Ansi standard console 80x43,
X am, eo, xon, bce,
X initc=, op=\E[=11F\E[=0G\E[=4H\E[=7I\E[m,
X bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
X clear=\E[2J\E[H, cr=\r, cub1=\b, cud1=\E[B, cuf1=\E[C,
X cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
X dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
X ht=\t, ich1=\E[@, il1=\E[L, ind=\E[S, kbs=\b,
X kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
X kf0=\E[V, kf1=\E[M, kf2=\E[N, kf3=\E[O, kf4=\E[P,
X kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
X khome=\E[H, kend=\E[F, kpp=\E[I, knp=\E[G,
X ri=\E[T, rmso=\E[m,
X rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
X it#8, ht=^I, cbt=\E[Z,
X#wht additions
X civis=\E[=8;7C,cnorm=\E[=4;8C,cvvis=\E[=0;8C,
X kb2=\E[E,
X#wht changes
X setf=\E[=%p1%dF\E[=0E\E[m,
X setb=\E[=%p1%dG\E[=0E\E[m,
X kich1=\E[L,kdch1=\177
X kf10=\E[U, kf11=\E[V,
X cols#80, lines#43, colors#16, pairs#64,
X
Xansi24|ansi80x24|Ansi standard console 80x24,
X am, eo, xon, bce,
X initc=, op=\E[=11F\E[=0G\E[=4H\E[=7I\E[m,
X bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
X clear=\E[2J\E[H, cr=\r, cub1=\b, cud1=\E[B, cuf1=\E[C,
X cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
X dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
X ht=\t, ich1=\E[@, il1=\E[L, ind=\E[S, kbs=\b,
X kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
X kf0=\E[V, kf1=\E[M, kf2=\E[N, kf3=\E[O, kf4=\E[P,
X kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
X khome=\E[H, kend=\E[F, kpp=\E[I, knp=\E[G,
X ri=\E[T, rmso=\E[m,
X rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
X it#8, ht=^I, cbt=\E[Z,
X#wht additions
X civis=\E[=8;7C,cnorm=\E[=4;8C,cvvis=\E[=0;8C,
X kb2=\E[E,
X#wht changes
X setf=\E[=%p1%dF\E[=0E\E[m,
X setb=\E[=%p1%dG\E[=0E\E[m,
X kich1=\E[L,kdch1=\177
X kf10=\E[U, kf11=\E[V,
X cols#80, lines#24, colors#16, pairs#64,
X
SHAR_EOF
$TOUCH -am 0617055290 sco_c16.t.src &&
chmod 0644 sco_c16.t.src ||
echo "restore of sco_c16.t.src failed"
set `wc -c sco_c16.t.src`;Wc_c=$1
if test "$Wc_c" != "2768"; then
echo original size 2768, current size $Wc_c
fi
# ============= nlsym.h ==============
echo "x - extracting nlsym.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > nlsym.h &&
X/*+-------------------------------------------------------------------------
X nlsym.h -- utility nlist - fast access to kernel /dev/kmem offsets
X ...!gatech!emory!tridom!wht
X
XThe nlsym file contains three records:
X1. struct stat unixstat - stat buffer from /unix at file creation time
X2. struct nlist nlsym - the structure of nlist'd information
X3. long unique - a unique identifier to help ensure correct nlsym length
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-27-1988-11:07-wht-creation */
X
X#define UNIX_KERNEL "/unix"
X#define UNIX_NLSYM "/unix.nlsym"
X#define NLSYM_UNIQUE 0xEFBC9A78L
X
X#define Nindex_AVAILRMEM 0
X#define Nindex_AVAILSMEM 1
X#define Nindex_BDEVCNT 2
X#define Nindex_BDEVSW 3
X#define Nindex_BOOTINFO 4
X#define Nindex_CDEVCNT 5
X#define Nindex_CDEVSW 6
X#define Nindex_CFREE 7
X#define Nindex_CFREECNT 8
X#define Nindex_CFREELIST 9
X#define Nindex_CMASK 10
X#define Nindex_CONSSW 11
X#define Nindex_CURPROC 12
X#define Nindex_DINFO 13
X#define Nindex_DISKINFO 14
X#define Nindex_DSTFLAG 15
X#define Nindex_DUMPDEV 16
X#define Nindex_EMAP 17
X#define Nindex_FFREELIST 18
X#define Nindex_FILE 19
X#define Nindex_FMODCNT 20
X#define Nindex_FMODSW 21
X#define Nindex_FREEMEM 22
X#define Nindex_FSINFO 23
X#define Nindex_FSTYPSW 24
X#define Nindex_HZ 25
X#define Nindex_IDLESERVER 26
X#define Nindex_IFREELIST 27
X#define Nindex_INODE 28
X#define Nindex_KPTBL 29
X#define Nindex_LBOLT 30
X#define Nindex_LINECNT 31
X#define Nindex_LINESW 32
X#define Nindex_MAXCLICK 33
X#define Nindex_MAXMEM 34
X#define Nindex_MFMAP 35
X#define Nindex_MFMAX 36
X#define Nindex_MINFO 37
X#define Nindex_MOUNT 38
X#define Nindex_MSGLISTCNT 39
X#define Nindex_NFSTYP 40
X#define Nindex_NPTALLOCED 41
X#define Nindex_NPTFREE 42
X#define Nindex_NSERVERS 43
X#define Nindex_NSWAP 44
X#define Nindex_NSYSENT 45
X#define Nindex_OLDPROC 46
X#define Nindex_OLD_CURPROC 47
X#define Nindex_PANICSTR 48
X#define Nindex_PHYSMEM 49
X#define Nindex_PIPEDEV 50
X#define Nindex_PROC 51
X#define Nindex_RCINFO 52
X#define Nindex_ROOTDEV 53
X#define Nindex_RUNQ 54
X#define Nindex_SHLBINFO 55
X#define Nindex_SWAPDEV 56
X#define Nindex_SWPLO 57
X#define Nindex_SYSERR 58
X#define Nindex_SYSINFO 59
X#define Nindex_SYSSEGS 60
X#define Nindex_SYSWAIT 61
X#define Nindex_TIME 62
X#define Nindex_TIMEZONE 63
X#define Nindex_TTHIWAT 64
X#define Nindex_TTLOWAT 65
X#define Nindex_TTNULQ 66
X#define Nindex_TTYHOG 67
X#define Nindex_TUNE 68
X#define Nindex_U 69
X#define Nindex_USERTABLE 70
X#define Nindex_V 71
X#define Nindex_WIN_UBLK 72
X
X#define bootinfoaddr (nlsym[Nindex_BOOTINFO].n_value)
X#define freememaddr (nlsym[Nindex_FREEMEM].n_value)
X#define lboltaddr (nlsym[Nindex_LBOLT].n_value)
X#define maxmemaddr (nlsym[Nindex_MAXMEM].n_value)
X#define minfoaddr (nlsym[Nindex_MINFO].n_value)
X#define nswapaddr (nlsym[Nindex_NSWAP].n_value)
X#define physmemaddr (nlsym[Nindex_PHYSMEM].n_value)
X#define procaddr (nlsym[Nindex_PROC].n_value)
X#define sysinfoaddr (nlsym[Nindex_SYSINFO].n_value)
X#define tuneaddr (nlsym[Nindex_TUNE].n_value)
X#define vaddr (nlsym[Nindex_V].n_value)
X
X#ifdef DEFINE_NLSYM
Xstruct nlist nlsym[] =
X{
X { "availrmem" },
X { "availsmem" },
X { "bdevcnt" },
X { "bdevsw" },
X { "bootinfo" },
X { "cdevcnt" },
X { "cdevsw" },
X { "cfree" },
X { "cfreecnt" },
X { "cfreelist" },
X { "Cmask" },
X { "conssw" },
X { "curproc" },
X { "dinfo" },
X { "diskinfo" },
X { "Dstflag" },
X { "dumpdev" },
X { "emap" },
X { "ffreelist" },
X { "file" },
X { "fmodcnt" },
X { "fmodsw" },
X { "freemem" },
X { "fsinfo" },
X { "fstypsw" },
X { "Hz" },
X { "idleserver" },
X { "ifreelist" },
X { "inode" },
X { "kptbl" },
X { "lbolt" },
X { "linecnt" },
X { "linesw" },
X { "maxclick" },
X { "maxmem" },
X { "mfmap" },
X { "mfmax" },
X { "minfo" },
X { "mount" },
X { "msglistcnt" },
X { "nfstyp" },
X { "nptalloced" },
X { "nptfree" },
X { "nservers" },
X { "nswap" },
X { "nsysent" },
X { "oldproc" },
X { "old_curproc" },
X { "panicstr" },
X { "physmem" },
X { "pipedev" },
X { "proc" },
X { "rcinfo" },
X { "rootdev" },
X { "runq" },
X { "shlbinfo" },
X { "swapdev" },
X { "swplo" },
X { "syserr" },
X { "sysinfo" },
X { "syssegs" },
X { "syswait" },
X { "time" },
X { "Timezone" },
X { "tthiwat" },
X { "ttlowat" },
X { "ttnulq" },
X { "ttyhog" },
X { "tune" },
X { "u" },
X { "usertable" },
X { "v" },
X { "win_ublk" },
X { (char *)0 }
X};
X#else
Xextern struct nlist nlsym[];
X#endif
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0619213590 nlsym.h &&
chmod 0644 nlsym.h ||
echo "restore of nlsym.h failed"
set `wc -c nlsym.h`;Wc_c=$1
if test "$Wc_c" != "4869"; then
echo original size 4869, current size $Wc_c
fi
# ============= libnlsym.h ==============
echo "x - extracting libnlsym.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > libnlsym.h &&
X/*+-----------------------------------------------------------------------
X libnlsym.h
X ...!gatech!emory!tridom!wht
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-28-1988-14:47-afterlint-creation */
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* libnlsym.c */
Xvoid nlsym_error(char * );
Xvoid nlsym_read(void);
X
X#else /* compiler doesn't know about prototyping */
X
X/* libnlsym.c */
Xvoid nlsym_error();
Xvoid nlsym_read();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of libnlsym.h */
SHAR_EOF
$TOUCH -am 0619213490 libnlsym.h &&
chmod 0644 libnlsym.h ||
echo "restore of libnlsym.h failed"
set `wc -c libnlsym.h`;Wc_c=$1
if test "$Wc_c" != "551"; then
echo original size 551, current size $Wc_c
fi
# ============= libkmem.h ==============
echo "x - extracting libkmem.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > libkmem.h &&
X/*+-----------------------------------------------------------------------
X libkmem.h
X ...!gatech!emory!tridom!wht
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-28-1988-14:46-afterlint-creation */
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* libkmem.c */
Xvoid kinit(int );
Xvoid kread(char *,long ,int );
Xvoid kwrite(long ,char *,int );
X
X#else /* compiler doesn't know about prototyping */
X
X/* libkmem.c */
Xvoid kinit();
Xvoid kread();
Xvoid kwrite();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of libkmem.h */
SHAR_EOF
$TOUCH -am 0619213490 libkmem.h &&
chmod 0644 libkmem.h ||
echo "restore of libkmem.h failed"
set `wc -c libkmem.h`;Wc_c=$1
if test "$Wc_c" != "584"; then
echo original size 584, current size $Wc_c
fi
# ============= libkmem.c ==============
echo "x - extracting libkmem.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libkmem.c &&
X/*+-------------------------------------------------------------------------
X libkmem.c -- /dev/kmem routines for SCO UNIX V/286 (maybe other *NIX)
X ...!gatech!emory!tridom!wht
X
X Defined functions:
X kinit(write_needed)
X kread(caddr,kaddr,len)
X kwrite(kaddr,caddr,len)
X
X routines were originally written by Mike "Ford" Ditto: kudos!!!
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-07-1988-22:06-wht-put in test for initialized fdkmem */
X/*:10-27-1988-22:44-wht-creation of file */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include "libkmem.h"
X
Xextern int errno;
X
Xstatic int fdkmem = -2;
Xdaddr_t lseek();
X
X/*+-------------------------------------------------------------------------
X kinit(write_needed)
X--------------------------------------------------------------------------*/
Xvoid
Xkinit(write_needed)
Xint write_needed;
X{
X if((fdkmem=open("/dev/kmem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0)
X leave_text("can't open /dev/kmem",1);
X
X} /* end of kinit */
X
X/*+-------------------------------------------------------------------------
X kread(caddr,kaddr,len)
X--------------------------------------------------------------------------*/
Xvoid
Xkread(caddr,kaddr,len)
Xcaddr_t caddr;
Xdaddr_t kaddr;
Xint len;
X{
Xchar s80[80];
X
X#if defined(M_I286)
X kaddr &= 0xFFFFL;
X#endif
X
X if(fdkmem == -2)
X leave_text("kinit() not called",1);
X
X if(lseek(fdkmem,kaddr,0) == -1L)
X {
X sprintf(s80,"kmem seek err (%08lx)",kaddr);
X leave_text(s80,1);
X }
X
X if(read(fdkmem,caddr,len) != len)
X {
X sprintf(s80,"kmem read errno %d len %d addr %08lx",errno,len,kaddr);
X leave_text(s80,1);
X }
X} /* end of kread */
X
X/*+-------------------------------------------------------------------------
X kwrite(kaddr,caddr,len)
X--------------------------------------------------------------------------*/
Xvoid
Xkwrite(kaddr,caddr,len)
Xdaddr_t kaddr;
Xcaddr_t caddr;
Xint len;
X{
Xchar s80[80];
X
X#if defined(M_I286)
X kaddr &= 0xFFFFL;
X#endif
X
X if(fdkmem == -2)
X leave_text("kinit() not called",1);
X
X if((lseek(fdkmem,kaddr,0) < 0L) || (write(fdkmem,caddr,len) != len))
X {
X sprintf(s80,"/dev/kmem write addr %08lx len %08lx",kaddr,len);
X leave_text(s80,1);
X }
X} /* end of kwrite */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0619213490 libkmem.c &&
chmod 0644 libkmem.c ||
echo "restore of libkmem.c failed"
set `wc -c libkmem.c`;Wc_c=$1
if test "$Wc_c" != "2233"; then
echo original size 2233, current size $Wc_c
fi
# ============= libnlsym.c ==============
echo "x - extracting libnlsym.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libnlsym.c &&
X/*+-------------------------------------------------------------------------
X libnlsym.c -- common runtime for nlsym users
X ...!gatech!emory!tridom!wht
X
X Defined functions:
X nlsym_error(text)
X nlsym_read()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-27-1988-11:44-wht-creation */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <nlist.h>
X
X#define DEFINE_NLSYM
X#include "nlsym.h"
X#include "libnlsym.h"
X
Xextern int errno;
Xextern char *sys_errlist[];
X
X/*+-------------------------------------------------------------------------
X nlsym_error(text)
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_error(text)
Xchar *text;
X{
Xchar s128[128];
X
X strcpy(s128,text);
X if(errno)
X {
X strcat(s128," (");
X strcat(s128,sys_errlist[errno]);
X strcat(s128,")");
X }
X strcat(s128," run nlsym");
X leave_text(s128,1);
X} /* end of nlsym_error */
X
X/*+-------------------------------------------------------------------------
X nlsym_read()
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_read()
X{
Xchar s80[80];
Xint itmp;
Xint fdnlsym;
Xstruct stat curstat; /* current /unix status */
Xstruct stat unixstat; /* /unix status at nlsym run time */
Xlong unique;
X
X if(stat(UNIX_KERNEL,&curstat) < 0)
X {
X sprintf(s80,"cannot stat %s",UNIX_KERNEL);
X nlsym_error(s80);
X }
X
X errno = 0;
X if((fdnlsym = open(UNIX_NLSYM,O_RDONLY,0)) < 0)
X {
X sprintf(s80,"%s open error\n",UNIX_NLSYM);
X nlsym_error(s80);
X }
X
X if((itmp = read(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat))
X nlsym_error("unix stat error");
X
X if((itmp = read(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym))
X nlsym_error("nlsym error: ");
X
X if((itmp = read(fdnlsym,&unique,sizeof(unique))) != sizeof(unique))
X nlsym_error("`unique' read error");
X
X close(fdnlsym);
X
X if( (unique != NLSYM_UNIQUE) ||
X (unixstat.st_ino != curstat.st_ino) ||
X (unixstat.st_mtime != curstat.st_mtime) ||
X (unixstat.st_size != curstat.st_size))
X {
X sprintf(s80,"%s out of date\n",UNIX_NLSYM);
X nlsym_error(s80);
X }
X
X} /* end of nlsym_read */
SHAR_EOF
$TOUCH -am 0619213490 libnlsym.c &&
chmod 0644 libnlsym.c ||
echo "restore of libnlsym.c failed"
set `wc -c libnlsym.c`;Wc_c=$1
if test "$Wc_c" != "2146"; then
echo original size 2146, current size $Wc_c
fi
# ============= nlsym.c ==============
echo "x - extracting nlsym.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > nlsym.c &&
X/*+-------------------------------------------------------------------------
X nlsym.c -- utility nlist - fast access to kernel /dev/kmem offsets
X ...!gatech!emory!tridom!wht
X
X Defined functions:
X main(argc,argv,envp)
X nlsym_write_error(code)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:05-12-1989-18:27-wht-fix endless loop error on cannot nlist */
X/*:10-27-1988-10:58-wht-creation */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <nlist.h>
X
X#define DEFINE_NLSYM
X#include "nlsym.h"
X
X/*+-------------------------------------------------------------------------
X nlsym_write_error(code)
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_write_error(code)
Xint code;
X{
X fprintf(stderr,"code %d: ",code);
X perror(UNIX_NLSYM);
X exit(1);
X} /* end of nlsym_write_error */
X
X/*+-------------------------------------------------------------------------
X main(argc,argv,envp)
X--------------------------------------------------------------------------*/
Xmain(argc,argv,envp)
Xint argc;
Xchar **argv;
Xchar **envp;
X{
Xregister int itmp;
Xregister struct nlist *nn;
Xstruct stat unixstat; /* /unix status at nlsym run time */
Xint fdnlsym;
Xint nlist_error = 0;
Xlong unique;
XFILE *kludge;
X
X nlist(UNIX_KERNEL,nlsym);
X
X nn = nlsym;
X while(nn->n_name)
X {
X if(!nn->n_sclass)
X {
X printf("%s: can't nlist\n", nn->n_name);
X nlist_error = 1;
X nn++;
X continue;
X }
X printf("%-12.12s storage class: %04x value: %08lx\n",
X nn->n_name,
X nn->n_sclass,
X nn->n_value);
X nn++;
X }
X
X if(nlist_error)
X {
X fprintf(stderr,"%s NOT produced\n",UNIX_NLSYM);
X exit(1);
X }
X
X if((kludge = fopen(UNIX_NLSYM,"w")) == NULL) /* scratch/create */
X nlsym_write_error(-1);
X fclose(kludge);
X
X if((fdnlsym = open(UNIX_NLSYM,O_WRONLY,0)) < 0)
X nlsym_write_error(fdnlsym);
X
X if(stat(UNIX_KERNEL,&unixstat) < 0)
X {
X fputs("cannot stat ",stderr);
X perror(UNIX_KERNEL);
X exit(1);
X }
X
X if((itmp = write(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat))
X nlsym_write_error(itmp);
X
X if((itmp = write(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym))
X nlsym_write_error(itmp);
X
X unique = NLSYM_UNIQUE;
X if((itmp = write(fdnlsym,&unique,sizeof(unique))) != sizeof(unique))
X nlsym_write_error(itmp);
X
X close(fdnlsym);
X exit(0);
X} /* end of main */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0619213590 nlsym.c &&
chmod 0644 nlsym.c ||
echo "restore of nlsym.c failed"
set `wc -c nlsym.c`;Wc_c=$1
if test "$Wc_c" != "2390"; then
echo original size 2390, current size $Wc_c
fi
echo "End of part 1, continue with part 2"
exit 0
---------------------------------------------------------------------
Warren Tucker, TuckerWare gatech!n4hgf!wht or wht%n4hgf@gatech.edu
Any perceptible delay will eventually get on your nerves. --Bob Hyers