home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1495 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  49.4 KB

  1. From: wht@n4hgf.uucp (Warren Tucker)
  2. Newsgroups: alt.sources
  3. Subject: u386mon x0.11, trying again, part 1/2
  4. Message-ID: <106@n4hgf.uucp>
  5. Date: 21 Jun 90 02:28:53 GMT
  6.  
  7. Archive-name: u386mon011/part01
  8.  
  9. Well, here is another, slightly enhanced u386mon, a hack monitor for SCO
  10. UNIX V/386.  It may work with other UNIX systems with a little work.  It
  11. requires terminfo style curses and will use color if you have it.
  12.  
  13. This time I promise all the sources are here.
  14. Thanks for all the mail telling me I skipped supplying 1/3 the source.
  15.  
  16. #!/bin/sh
  17. # This is u386mon.x0.11, a shell archive (shar 3.30)
  18. # made 06/21/1990 02:17 UTC by wht@n4hgf
  19. # Source directory /u1/src/u386mon
  20. #
  21. # existing files WILL be overwritten
  22. #
  23. # This shar contains:
  24. # length  mode       name
  25. # ------ ---------- ------------------------------------------
  26. #   6508 -rw-r--r-- README
  27. #   5273 -rw-r--r-- Makefile
  28. #   2358 -rw-r--r-- bootinfo.c
  29. #   3591 -rw-r--r-- detail.c
  30. #  12760 -rw-r--r-- det_proc.c
  31. #   4227 -rw-r--r-- disputil.c
  32. #   2280 -rw-r--r-- libkmem.c
  33. #   2290 -rw-r--r-- libmem.c
  34. #   2146 -rw-r--r-- libnlsym.c
  35. #   2390 -rw-r--r-- nlsym.c
  36. #   3085 -rw-r--r-- proc.c
  37. #   1602 -rw-r--r-- tune.c
  38. #  23942 -rw-r--r-- u386mon.c
  39. #   1453 -rw-r--r-- var.c
  40. #    584 -rw-r--r-- libkmem.h
  41. #    580 -rw-r--r-- libmem.h
  42. #    551 -rw-r--r-- libnlsym.h
  43. #   5612 -rw-r--r-- lint_args.h
  44. #   4869 -rw-r--r-- nlsym.h
  45. #   2941 -rw-r--r-- u386mon.h
  46. #
  47. if touch 2>&1 | fgrep 'mmdd' > /dev/null
  48.  then TOUCH=touch
  49.  else TOUCH=true
  50. fi
  51. # ============= README ==============
  52. echo "x - extracting README (Text)"
  53. sed 's/^X//' << 'SHAR_EOF' > README &&
  54. XWhat
  55. X====
  56. X
  57. XWell, here is another, slightly enhanced u386mon, a hack monitor for SCO
  58. XUNIX V/386.  It may work with other UNIX systems with a little work.  It
  59. Xrequires terminfo style curses and will use color if you have it.
  60. X
  61. XThis time I promise all the sources are here.
  62. XThanks for all the mail telling me I skipped supplying 1/3 the source.
  63. X
  64. XApology
  65. X=======
  66. X
  67. XThis is a horribly unreleasable, preliminary, experimental, hacked
  68. Xlittle light show, but it has already helped me diagnose the
  69. Xtraditional "stop-the-world-and-beat-disk-continually-for-15-seconds"
  70. Xproblem as memory exhaustion.
  71. X
  72. XThe process status display shows zero user and system times, but I
  73. Xhaven't figured out why yet.
  74. X
  75. XSample output
  76. X=============
  77. X(with 43-line screen)
  78. X
  79. X u386mon x0.09   n4hgf - i386 3.2                                     wht@n4hgf
  80. X---- CPU --- tot usr ker brk ---------------------------------------------------
  81. X Instant %    17   4  13   0 uukkkkkk
  82. X 5 Sec Avg %  71  48  23   0 uuuuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkk
  83. X10 Sec Avg %  82  66  16   0 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuukkkkkkkk
  84. X---- Wait -- tot  io swp pio -- (% of real time) -------------------------------
  85. X Instant %     0   0   0   0
  86. X 5 Sec Avg %   2   2   0   0 i
  87. X10 Sec Avg %   1   1   0   0
  88. X---- Sysinfo/Minfo --- (last 1 second activity) --------------------------------
  89. Xbread       0  rawch      0     pswitch    8    vfault    0    unmodfl   0
  90. Xbwrite      7  canch      0     syscall   16    demand    0    psoutok   0
  91. Xlread       0  outch   3076     sysread    4    pfault    0    psinfai   0
  92. Xlwrite      7                   syswrit    5    cw        0    psinok    0
  93. Xphread      0  msg        0     sysfork    0    steal     0    rsout     0
  94. Xphwrit      0  sema       0     sysexec    0    frdpgs    0    rsin      0
  95. Xiget        0                                   vfpg      0
  96. Xnamei       0  maxmem    5716k  runque     1    sfpg      0    pages on
  97. Xdirblk      0  frmem     3036k  runocc     1    vspg      0    swap      0
  98. Xreadch  34680  mem used    47%  swpque     0    sspg      0    cache     0
  99. Xwritch   3076  nswap    10000k  swpocc     0    unmodsw   0    file      0
  100. X               frswp    10000k
  101. X               swp used     0%
  102. X
  103. X
  104. X
  105. X-- var ---------  -- bootinfo ----------  -- tune ---------  -- proc ---
  106. Xv_buf        600  basemem    655360       t_gpgslo       25  sleep    23
  107. Xv_inode      200  extmem    6291456       t_gpgshi       40  run       0
  108. Xv_file       200  bflags   00000000       t_gpgsmsk   0x420  zombie    0
  109. Xv_mount        5  memory avail            t_ageintvl      9  stop      0
  110. Xv_proc       100  00000000 000a0000       t_maxsc         1  idle      0
  111. Xv_clist      200  00100000 00600000       t_maxfc         1  onproc    1
  112. Xv_sptmap      50  00f40000 00060000 NODM  t_maxumem    2560  xbrk      0
  113. Xv_vhndfrac    16  memory used             t_bdflushr      1  total    24
  114. Xv_maxpmem      0  00000000 00004000 RSVD  t_minarmem     25  in mem   24
  115. X                  006b9000 00038000 KBSS  t_minasmem     25
  116. X                  006f1000 0000f000 KDTA
  117. X                  00fa5000 0005b000 KTXT
  118. X
  119. X
  120. XWhat the display means
  121. X======================
  122. X
  123. XA brief description of reported information:
  124. X
  125. X1.  The CPU utilization is shown with smoothing of 1 ("instant"),
  126. X    5 and 10 seconds.  Total CPU usage is shown, with user, kernel
  127. X    and "break" subdivided.  Most performance utilities (vmstat)
  128. X    lump kernel (CPU_KERNEL) and wait (CPU_WAIT) times together
  129. X    as kernel time.  u386mon considers CPU_WAIT time as idle (the
  130. X    CPU could have been doing something if an otherwise ready process
  131. X    wasn't waited).
  132. X
  133. X    On a color display, total cpu utilization is displayed in
  134. X    green if the cpu utilization is below 70%, yellow (brown, sigh)
  135. X    if utilization is between 70% and 89% and red if 90% or above.
  136. X
  137. X2.  The Wait display shows the 1 ("instant"), 5 and 10 second smoothed
  138. X    percentages of real time no process could be run because otherwise
  139. X    ready to run processes were waiting on logical, swap or physical I/O.
  140. X
  141. X3.  Sysinfo/Minfo display shows, generally, the number of events for a
  142. X    measured value since the last display update.  For example, runque
  143. X    shows the number of times a process was placed on the run queue.
  144. X    An exception is the memory and swap space fields:  These numbers
  145. X    reflect absolute current utilization.
  146. X
  147. X4.  If you run u386mon on a 43 line display, extra information is displayed
  148. X    on the bottom of the screen (from the struct var v, bootinfo
  149. X    and proc kernel databases).
  150. X
  151. X5.  On a color display, static numeric values, such as maxmem appear
  152. X    in blue (the same color as screen literals/labels).  Dynamic
  153. X    numeric values are displayed in green, red or yellow.
  154. X
  155. X6.  An "INEXACT" indication on the top line means that u386mon was
  156. X    not scheduled quickly enough to capture accurate 1 second
  157. X    values.  Continued INEXACT indication suggests the 5 and 10
  158. X    second smoothed values are also wrong.
  159. X
  160. X    An "INVALID" indication means u386mon was not scheduled for 4
  161. X    seconds or more.  All dynamic values are suspect.
  162. X
  163. X7.  Pressing 'p' causes a process status display of sorts to be
  164. X    shown.  This is very preliminary.  Press 'm' to return to the
  165. X    main screen.
  166. X
  167. X
  168. XA $0.0002 tour
  169. X==============
  170. X
  171. XAccess to kernel memory is required for u386mon to do its thing.
  172. X
  173. XThe 'nlist' procedure is performed by a separate program (nlsym)
  174. Xand the resulting nlist structure array is stored in /unix.nlsym.
  175. Xu386mon thus may obtain nlist information rapidly without nlist(S) each
  176. Xtime it is executed.  Also stored in /unix.nlsym is a stat structure of
  177. X/unix at the time of nlsym execution.  A unique word is stored at the
  178. Xend of the file in case /unix.nlsym's nlist structure is expanded for
  179. Xother applications.  The u386mon program reads /unix.nlsym by means
  180. Xof facilities in libnlsym.c.  If the stat structure in /unix.nlsym
  181. Xdoes not match a dynamic stat of /unix or if the unique word does
  182. Xnot match, the nlist information is not trusted and u386mon prompts
  183. Xthe user to run (or have run) the nlsym program to update /unix.nlsym.
  184. X
  185. XHow to get going
  186. X================
  187. X
  188. X1.  you must run the make as root
  189. X
  190. X2.  nlsym must be run by root (the Makefile will do this the first time)
  191. X
  192. X3.  making against Makefile as root will
  193. X    a. make nlsym
  194. X    b. make u386mon and set-gid to group 'mem'
  195. X    c. run nlsym to produce /unix.nlsym
  196. X
  197. X4.  Sources are in 4-spaced tab format (please don't flame :-)).
  198. X
  199. XComments are appreciated.
  200. XWarren Tucker N4HGF emory!n4hgf!wht -or- wht%n4hgf.uucp@emory.mathcs.emory.edu
  201. X
  202. SHAR_EOF
  203. $TOUCH -am 0620214890 README &&
  204. chmod 0644 README ||
  205. echo "restore of README failed"
  206. set `wc -c README`;Wc_c=$1
  207. if test "$Wc_c" != "6508"; then
  208.     echo original size 6508, current size $Wc_c
  209. fi
  210. # ============= Makefile ==============
  211. echo "x - extracting Makefile (Text)"
  212. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  213. X#+--------------------------------------------------------------
  214. X#  Makefile for nlsym utilities for SCO UNIX V/386
  215. X#  ...!emory!n4hgf!wht
  216. X#---------------------------------------------------------------
  217. X#+:EDITS:
  218. X#:06-19-1990-21:37-wht@n4hgf-get ready for 0.08 release
  219. X
  220. XVERSION = x0.11
  221. X
  222. X#handle Sys V make "feature" of using SHELL
  223. XSHELL = /bin/sh
  224. X
  225. XCFLAGS = -c -Octl -DLINT_ARGS
  226. X
  227. XLIB = -lpanel -lcurses -lx
  228. X#FCRC = fcrc -u $*.c ;
  229. X
  230. X.c.o:;    $(FCRC) cc $(CFLAGS) $*.c 
  231. X
  232. XSRC = \
  233. X    bootinfo.c\
  234. X    detail.c\
  235. X    det_proc.c\
  236. X    disputil.c\
  237. X    libkmem.c\
  238. X    libmem.c\
  239. X    libnlsym.c\
  240. X    nlsym.c\
  241. X    proc.c\
  242. X    tune.c\
  243. X    u386mon.c\
  244. X    var.c
  245. X
  246. XHDR = \
  247. X    libkmem.h\
  248. X    libmem.h\
  249. X    libnlsym.h\
  250. X    lint_args.h\
  251. X    nlsym.h\
  252. X    u386mon.h
  253. X
  254. XNLSYM_OBJ =\
  255. X    nlsym.o
  256. X
  257. XU386MON_OBJ =\
  258. X    u386mon.o\
  259. X    detail.o\
  260. X    det_proc.o\
  261. X    bootinfo.o\
  262. X    proc.o\
  263. X    tune.o\
  264. X    var.o\
  265. X    disputil.o\
  266. X    libkmem.o\
  267. X    libmem.o\
  268. X    libnlsym.o
  269. X
  270. Xall: nlsym u386mon /unix.nlsym
  271. X
  272. Xnlsym: $(NLSYM_OBJ)
  273. X    cc -o $@ $(NLSYM_OBJ) $(LIB)
  274. X
  275. Xu386mon: $(U386MON_OBJ)
  276. X    cc -o $@ $(U386MON_OBJ) $(LIB)
  277. X    chmod 2711 u386mon
  278. X    chgrp mem u386mon
  279. X
  280. X/unix.nlsym: nlsym /unix
  281. X    nlsym
  282. X    chmod 644 /unix.nlsym
  283. X
  284. X#not delivered
  285. Xsrc.fls: $(SRC) Makefile
  286. X    ls $(SRC) > src.fls
  287. X
  288. Xlint: src.fls
  289. X    echo ' ' > lint_args.h
  290. X    csh zgcc src.fls lint_args.h $(CFLAGS)
  291. X
  292. Xclean:
  293. X    rm -f $(U386MON_OBJ) $(NLSYM_OBJ)
  294. X
  295. Xclobber: clean
  296. X    rm -f nlsym u386mon u386mon.sh.0[1234]
  297. X
  298. X#for shar 3.27 or later
  299. Xshar:
  300. X    shar -l 50 -n u386mon.$(VERSION) -o u386mon.sh \
  301. X        README Makefile $(SRC) $(HDR)
  302. X
  303. X# MAKE DEPEND: regenerate .c:.h, .ol:.c, .ol:.asm dependencies automatically
  304. X#
  305. Xdepend:
  306. X        rm -f depend.tmp
  307. X        if test '$(SRC)' ;\
  308. X        then (grep '^#include' $(SRC) \
  309. X        | sed    -e 's?:[^<]*<\([^>]*\)>.*?: /usr/include/\1?'\
  310. X            -e 's?:[^"]*"\([^"]*\)".*?: \1?'\
  311. X            -e 's?\(.*\)\.c?\1.o?'\
  312. X         >> depend.tmp) ;\
  313. X        fi
  314. X
  315. X        echo '/^# DO NOT DELETE THIS LINE' >exdep.tmp
  316. X        echo '.+1,$$d' >>exdep.tmp
  317. X        echo 'r depend.tmp' >> exdep.tmp
  318. X        echo 'w' >> exdep.tmp
  319. X        cp Makefile Makefile.new
  320. X        ex Makefile.new < exdep.tmp
  321. X        rm exdep.tmp depend.tmp
  322. X        echo '#    DEPENDENCIES MUST END AT END OF    FILE' >>Makefile.new
  323. X        echo '#    IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
  324. X        echo '#    see make depend    above'>>Makefile.new
  325. X        mv Makefile Makefile.bak
  326. X        mv Makefile.new Makefile
  327. X
  328. X# DO NOT DELETE THIS LINE
  329. Xbootinfo.o: /usr/include/curses.h
  330. Xbootinfo.o: /usr/include/panel.h
  331. Xbootinfo.o: /usr/include/sys/types.h
  332. Xbootinfo.o: /usr/include/sys/bootinfo.h
  333. Xbootinfo.o: u386mon.h
  334. Xdetail.o: /usr/include/curses.h
  335. Xdetail.o: /usr/include/panel.h
  336. Xdetail.o: /usr/include/signal.h
  337. Xdetail.o: /usr/include/string.h
  338. Xdetail.o: /usr/include/fcntl.h
  339. Xdetail.o: /usr/include/nlist.h
  340. Xdetail.o: /usr/include/errno.h
  341. Xdetail.o: /usr/include/time.h
  342. Xdetail.o: /usr/include/sys/types.h
  343. Xdetail.o: /usr/include/sys/utsname.h
  344. Xdetail.o: /usr/include/sys/stat.h
  345. Xdetail.o: /usr/include/sys/ascii.h
  346. Xdetail.o: /usr/include/sys/param.h
  347. Xdetail.o: /usr/include/sys/bootinfo.h
  348. Xdetail.o: /usr/include/sys/tuneable.h
  349. Xdetail.o: /usr/include/sys/sysinfo.h
  350. Xdetail.o: /usr/include/sys/sysmacros.h
  351. Xdetail.o: /usr/include/sys/immu.h
  352. Xdetail.o: /usr/include/sys/region.h
  353. Xdetail.o: /usr/include/sys/proc.h
  354. Xdetail.o: /usr/include/sys/var.h
  355. Xdetail.o: nlsym.h
  356. Xdetail.o: libkmem.h
  357. Xdetail.o: libnlsym.h
  358. Xdetail.o: u386mon.h
  359. Xdisputil.o: /usr/include/curses.h
  360. Xdisputil.o: /usr/include/panel.h
  361. Xdisputil.o: u386mon.h
  362. Xlibkmem.o: /usr/include/sys/types.h
  363. Xlibkmem.o: /usr/include/fcntl.h
  364. Xlibkmem.o: libkmem.h
  365. Xlibnlsym.o: /usr/include/stdio.h
  366. Xlibnlsym.o: /usr/include/sys/types.h
  367. Xlibnlsym.o: /usr/include/sys/stat.h
  368. Xlibnlsym.o: /usr/include/fcntl.h
  369. Xlibnlsym.o: /usr/include/nlist.h
  370. Xlibnlsym.o: nlsym.h
  371. Xlibnlsym.o: libnlsym.h
  372. Xnlsym.o: /usr/include/stdio.h
  373. Xnlsym.o: /usr/include/sys/types.h
  374. Xnlsym.o: /usr/include/sys/stat.h
  375. Xnlsym.o: /usr/include/fcntl.h
  376. Xnlsym.o: /usr/include/nlist.h
  377. Xnlsym.o: nlsym.h
  378. Xproc.o: /usr/include/curses.h
  379. Xproc.o: /usr/include/panel.h
  380. Xproc.o: /usr/include/sys/types.h
  381. Xproc.o: /usr/include/sys/param.h
  382. Xproc.o: /usr/include/sys/immu.h
  383. Xproc.o: /usr/include/sys/region.h
  384. Xproc.o: /usr/include/sys/proc.h
  385. Xproc.o: /usr/include/nlist.h
  386. Xproc.o: nlsym.h
  387. Xproc.o: libkmem.h
  388. Xproc.o: libnlsym.h
  389. Xproc.o: u386mon.h
  390. Xtune.o: /usr/include/curses.h
  391. Xtune.o: /usr/include/panel.h
  392. Xtune.o: /usr/include/sys/types.h
  393. Xtune.o: /usr/include/sys/tuneable.h
  394. Xtune.o: u386mon.h
  395. Xu386mon.o: /usr/include/curses.h
  396. Xu386mon.o: /usr/include/panel.h
  397. Xu386mon.o: /usr/include/signal.h
  398. Xu386mon.o: /usr/include/string.h
  399. Xu386mon.o: /usr/include/fcntl.h
  400. Xu386mon.o: /usr/include/nlist.h
  401. Xu386mon.o: /usr/include/errno.h
  402. Xu386mon.o: /usr/include/time.h
  403. Xu386mon.o: /usr/include/sys/types.h
  404. Xu386mon.o: /usr/include/sys/utsname.h
  405. Xu386mon.o: /usr/include/sys/stat.h
  406. Xu386mon.o: /usr/include/sys/ascii.h
  407. Xu386mon.o: /usr/include/sys/param.h
  408. Xu386mon.o: /usr/include/sys/bootinfo.h
  409. Xu386mon.o: /usr/include/sys/tuneable.h
  410. Xu386mon.o: /usr/include/sys/sysinfo.h
  411. Xu386mon.o: /usr/include/sys/sysmacros.h
  412. Xu386mon.o: /usr/include/sys/immu.h
  413. Xu386mon.o: /usr/include/sys/region.h
  414. Xu386mon.o: /usr/include/sys/proc.h
  415. Xu386mon.o: /usr/include/sys/var.h
  416. Xu386mon.o: nlsym.h
  417. Xu386mon.o: libkmem.h
  418. Xu386mon.o: libnlsym.h
  419. Xu386mon.o: u386mon.h
  420. Xvar.o: /usr/include/curses.h
  421. Xvar.o: /usr/include/panel.h
  422. Xvar.o: /usr/include/sys/types.h
  423. Xvar.o: /usr/include/sys/var.h
  424. Xvar.o: u386mon.h
  425. X#    DEPENDENCIES MUST END AT END OF    FILE
  426. X#    IF YOU PUT STUFF HERE IT WILL GO AWAY
  427. X#    see make depend    above
  428. SHAR_EOF
  429. $TOUCH -am 0620214890 Makefile &&
  430. chmod 0644 Makefile ||
  431. echo "restore of Makefile failed"
  432. set `wc -c Makefile`;Wc_c=$1
  433. if test "$Wc_c" != "5273"; then
  434.     echo original size 5273, current size $Wc_c
  435. fi
  436. # ============= bootinfo.c ==============
  437. echo "x - extracting bootinfo.c (Text)"
  438. sed 's/^X//' << 'SHAR_EOF' > bootinfo.c &&
  439. X/*+-------------------------------------------------------------------------
  440. X    bootinfo.c - u386mon bootinfo struct display
  441. X
  442. X  Defined functions:
  443. X    bmemf_text(flags)
  444. X    display_bootinfo(win,y,x)
  445. X
  446. X--------------------------------------------------------------------------*/
  447. X/*+:EDITS:*/
  448. X/*:06-17-1990-14:59-wht-creation */
  449. X
  450. X#define M_TERMINFO
  451. X
  452. X#include <curses.h>
  453. X#include <panel.h>
  454. X#include <sys/types.h>
  455. X#include <sys/bootinfo.h>
  456. X#include "u386mon.h"
  457. X
  458. X/*+-------------------------------------------------------------------------
  459. X    bmemf_text(flags)
  460. X--------------------------------------------------------------------------*/
  461. Xchar *
  462. Xbmemf_text(flags)
  463. Xulong flags;
  464. X{
  465. X    flags &= ~B_MEM_DOWN;
  466. X    if(!flags)
  467. X        return("    ");
  468. X    switch(flags)
  469. X    {
  470. X        case B_MEM_RSRVD: return("RSVD");
  471. X        case B_MEM_KTEXT: return("KTXT");
  472. X        case B_MEM_KDATA: return("KDTA");
  473. X        case B_MEM_KBSS:  return("KBSS");
  474. X        case B_MEM_NODMA: return("NODM");
  475. X    }
  476. X    return("????");
  477. X}    /* end of bmemf_text */
  478. X
  479. X/*+-------------------------------------------------------------------------
  480. X    display_bootinfo(win,y,x)
  481. X--------------------------------------------------------------------------*/
  482. Xvoid
  483. Xdisplay_bootinfo(win,y,x)
  484. XWINDOW *win;
  485. Xint y;
  486. Xint x;
  487. X{
  488. Xregister itmp;
  489. Xregister struct bootmem *bmem;
  490. X
  491. X    use_cp(win,cpBANNER);
  492. X    wmove(win,y++,x);
  493. X    waddstr(win,"-- bootinfo ----------");
  494. X    wmove(win,y++,x);
  495. X    disp_static_long(win,"basemem  ","%8ld",bootinfo.basemem);
  496. X    wmove(win,y++,x);
  497. X    disp_static_long(win,"extmem   ","%8ld",bootinfo.extmem);
  498. X    wmove(win,y++,x);
  499. X    disp_static_long(win,"bflags   ","%08lx",bootinfo.bootflags);
  500. X
  501. X    wmove(win,y++,x); waddstr(win,"memory avail");
  502. X    for(itmp = 0; itmp < bootinfo.memavailcnt; itmp++)
  503. X    {
  504. X        bmem = &bootinfo.memavail[itmp];
  505. X        if(bmem->flags & B_MEM_DOWN)
  506. X        {
  507. X            bmem->base -= bmem->extent;
  508. X            bmem->flags &= ~B_MEM_DOWN;
  509. X        }
  510. X        wmove(win,y++,x);
  511. X        wprintw(win,"%08lx %08lx %s",bmem->base,bmem->extent,
  512. X            bmemf_text(bmem->flags));
  513. X    }
  514. X
  515. X    wmove(win,y++,x); waddstr(win,"memory used");
  516. X    for(itmp = 0; itmp < bootinfo.memusedcnt; itmp++)
  517. X    {
  518. X        bmem = &bootinfo.memused[itmp];
  519. X        if(bmem->flags & B_MEM_DOWN)
  520. X        {
  521. X            bmem->base -= bmem->extent;
  522. X            bmem->flags &= ~B_MEM_DOWN;
  523. X        }
  524. X        wmove(win,y++,x);
  525. X        wprintw(win,"%08lx %08lx %s",bmem->base,bmem->extent,
  526. X            bmemf_text(bmem->flags));
  527. X    }
  528. X
  529. X}    /* end of display_bootinfo */
  530. X
  531. X/* vi: set tabstop=4 shiftwidth=4: */
  532. X/* end of bootinfo.c */
  533. SHAR_EOF
  534. $TOUCH -am 0620163490 bootinfo.c &&
  535. chmod 0644 bootinfo.c ||
  536. echo "restore of bootinfo.c failed"
  537. set `wc -c bootinfo.c`;Wc_c=$1
  538. if test "$Wc_c" != "2358"; then
  539.     echo original size 2358, current size $Wc_c
  540. fi
  541. # ============= detail.c ==============
  542. echo "x - extracting detail.c (Text)"
  543. sed 's/^X//' << 'SHAR_EOF' > detail.c &&
  544. X/*+-------------------------------------------------------------------------
  545. X    detail.c - UNIX 386 system monitor detail window
  546. X--------------------------------------------------------------------------*/
  547. X/*+:EDITS:*/
  548. X/*:06-15-1990-18:32-wht@n4hgf-creation */
  549. X
  550. X#define M_TERMINFO
  551. X
  552. X#include <curses.h>
  553. X#include <panel.h>
  554. X#include <signal.h>
  555. X#include <string.h>
  556. X#include <fcntl.h>
  557. X#include <nlist.h>
  558. X#include <errno.h>
  559. X#include <time.h>
  560. X#include <pwd.h>
  561. X#include <utmp.h>
  562. X#include <sys/types.h>
  563. X#include <sys/utsname.h>
  564. X#include <sys/stat.h>
  565. X#include <sys/ascii.h>
  566. X#undef NGROUPS_MAX
  567. X#undef NULL
  568. X#include <sys/param.h>
  569. X#include <sys/bootinfo.h>
  570. X#include <sys/tuneable.h>
  571. X#include <sys/sysinfo.h>
  572. X#include <sys/sysmacros.h>
  573. X#include <sys/immu.h>
  574. X#include <sys/region.h>
  575. X#include <sys/proc.h>
  576. X#include <sys/var.h>
  577. X
  578. X#include "nlsym.h"
  579. X#include "libkmem.h"
  580. X#include "libnlsym.h"
  581. X#include "u386mon.h"
  582. X
  583. X#define DPT_NONE        0
  584. X#define DPT_PROC_STATUS    1
  585. X
  586. XPANEL *mkpanel();
  587. X
  588. Xextern PANEL *pscr;
  589. Xextern WINDOW *wscr;
  590. X
  591. XPANEL *pdet;
  592. XWINDOW *wdet;
  593. Xu_char detail_panel_type = DPT_NONE;
  594. Xint detail_panel_length;
  595. Xint detail_panel_cols;
  596. X
  597. X/*+-------------------------------------------------------------------------
  598. X    detail_panel_proc_status_init()
  599. X--------------------------------------------------------------------------*/
  600. Xvoid
  601. Xdetail_panel_proc_status_init()
  602. X{
  603. Xregister y,x;
  604. X#define DETAIL_PROC_STATUS_COLS ((LINES >= 43) ? EXTRA4_TLX - 1 : PER_SEC4_TLX)
  605. X
  606. X    detail_panel_length = DETAIL_LENGTH;
  607. X/*
  608. X    detail_panel_cols = DETAIL_PROC_STATUS_COLS;
  609. X*/
  610. X    detail_panel_cols = COLS;
  611. X    if(!(pdet = mkpanel(detail_panel_length,detail_panel_cols,
  612. X        DETAIL_TLY,0)))
  613. X    {
  614. X        leave_text("cannot make detail panel",0);
  615. X    }
  616. X    wdet = panel_window(pdet);
  617. X    hide_panel(pdet);
  618. X    use_cp(wdet,cpBANNER);
  619. X    for(y = 0; y < getmaxy(wdet); y++)
  620. X    {
  621. X        for(x = 0; x < getmaxx(wdet); x++)
  622. X        {
  623. X            wmove(wdet,y,x);
  624. X            waddch(wdet,(chtype)' ');
  625. X        }
  626. X    }
  627. X    show_panel(pdet);
  628. X    top_panel(pdet);
  629. X
  630. X    display_proc_stats(wdet,1);
  631. X
  632. X}    /* end of detail_panel_proc_status_init */
  633. X
  634. X/*+-------------------------------------------------------------------------
  635. X    detail_panel_proc_status_update()
  636. X--------------------------------------------------------------------------*/
  637. Xvoid
  638. Xdetail_panel_proc_status_update()
  639. X{
  640. X
  641. X    display_proc_stats(wdet,0);
  642. X}    /* end of detail_panel_proc_status_update */
  643. X
  644. X/*+-------------------------------------------------------------------------
  645. X    detail_panel_cmd(cmd)
  646. X
  647. X  command: m main screen
  648. X           p proc status
  649. X--------------------------------------------------------------------------*/
  650. Xvoid
  651. Xdetail_panel_cmd(cmd)
  652. Xchtype cmd;
  653. X{
  654. X    switch(cmd)
  655. X    {
  656. X        case 'm':
  657. X            if(detail_panel_type == DPT_NONE)
  658. X                break;
  659. X            hide_panel(pdet);
  660. X            delwin(wdet);
  661. X            del_panel(pdet);
  662. X            top_panel(pscr);
  663. X            detail_panel_type = DPT_NONE;
  664. X            break;
  665. X
  666. X        case 'p':
  667. X            if(detail_panel_type == DPT_PROC_STATUS)
  668. X                break;
  669. X            detail_panel_proc_status_init();
  670. X            detail_panel_type = DPT_PROC_STATUS;
  671. X            break;
  672. X    }
  673. X}    /* end of detail_panel_cmd */
  674. X
  675. X/*+-------------------------------------------------------------------------
  676. X    detail_panel_update()
  677. X--------------------------------------------------------------------------*/
  678. Xvoid
  679. Xdetail_panel_update()
  680. X{
  681. X    switch(detail_panel_type)
  682. X    {
  683. X        case DPT_PROC_STATUS:
  684. X            detail_panel_proc_status_update();
  685. X            break;
  686. X    }
  687. X}    /* end of detail_panel_update */
  688. X
  689. X/*+-------------------------------------------------------------------------
  690. X    detail_init()
  691. X--------------------------------------------------------------------------*/
  692. Xvoid
  693. Xdetail_init()
  694. X{
  695. X}    /* end of detail_init */
  696. X
  697. X/* vi: set tabstop=4 shiftwidth=4: */
  698. X/* end of detail.c */
  699. SHAR_EOF
  700. $TOUCH -am 0620194290 detail.c &&
  701. chmod 0644 detail.c ||
  702. echo "restore of detail.c failed"
  703. set `wc -c detail.c`;Wc_c=$1
  704. if test "$Wc_c" != "3591"; then
  705.     echo original size 3591, current size $Wc_c
  706. fi
  707. # ============= det_proc.c ==============
  708. echo "x - extracting det_proc.c (Text)"
  709. sed 's/^X//' << 'SHAR_EOF' > det_proc.c &&
  710. X/* CHK=0xC5D1 */
  711. X/*+-------------------------------------------------------------------------
  712. X    det_proc.c - UNIX V/386 system monitor proc status detail
  713. X    ...!emory!n4hgf!wht
  714. X--------------------------------------------------------------------------*/
  715. X/*+:EDITS:*/
  716. X/*:01-05-1989-13:27-wht-creation */
  717. X
  718. X#define M_TERMINFO
  719. X
  720. X#include <curses.h>
  721. X#include <panel.h>
  722. X#include <signal.h>
  723. X#include <string.h>
  724. X#include <fcntl.h>
  725. X#include <nlist.h>
  726. X#include <errno.h>
  727. X#include <time.h>
  728. X#include <pwd.h>
  729. X#include <utmp.h>
  730. X#include <sys/types.h>
  731. X#include <sys/stat.h>
  732. X#include <sys/ascii.h>
  733. X#undef NGROUPS_MAX
  734. X#undef NULL
  735. X#include <sys/param.h>
  736. X#include <sys/bootinfo.h>
  737. X#include <sys/tuneable.h>
  738. X#include <sys/sysinfo.h>
  739. X#include <sys/sysmacros.h>
  740. X#include <sys/immu.h>
  741. X#include <sys/region.h>
  742. X#include <sys/proc.h>
  743. X#include <sys/ndir.h>
  744. X#undef DIRSIZ
  745. X#include <sys/mount.h>
  746. X#include <sys/user.h>
  747. X#include <sys/var.h>
  748. X
  749. X#include "nlsym.h"
  750. X#include "libkmem.h"
  751. X#include "libnlsym.h"
  752. X#include "u386mon.h"
  753. X
  754. Xextern int errno;
  755. X
  756. Xextern int nprocs;
  757. Xextern struct var v;
  758. Xextern struct proc *procs;
  759. Xextern struct proc *oldprocs;
  760. X
  761. Xint mypid;
  762. Xint noldprocs = 0;
  763. Xint nprocs = 0;
  764. X
  765. Xstruct user user;
  766. X
  767. X#define min(a,b) ((a > b) ? b : a)
  768. X
  769. X#define p_dummy0 p_hold    /* reuse a field we dont look at */
  770. X
  771. X#define MAX_UTMP 32
  772. Xint nutmps = 0;
  773. Xstruct utmp utmps[MAX_UTMP];
  774. X
  775. X/*+-------------------------------------------------------------------------
  776. X    proc_pid_compare(p1,p2)
  777. X--------------------------------------------------------------------------*/
  778. Xproc_pid_compare(p1,p2)
  779. Xstruct proc *p1;
  780. Xstruct proc *p2;
  781. X{
  782. X    return(p1->p_pid - p2->p_pid);
  783. X}    /* end of proc_pid_compare */
  784. X
  785. X/*+-------------------------------------------------------------------------
  786. X    read_and_sort_procs(initial)
  787. X--------------------------------------------------------------------------*/
  788. Xvoid
  789. Xread_and_sort_procs(initial)
  790. Xint initial;
  791. X{
  792. Xregister int iproc;
  793. Xregister int proc_size = v.v_proc * sizeof(struct proc);
  794. Xstruct proc *tproc;
  795. X
  796. X    if(!initial)
  797. X    {
  798. X        memcpy((char *)oldprocs,(char *)procs,proc_size);
  799. X        noldprocs = nprocs;
  800. X    }
  801. X
  802. X/* read current procs */
  803. X    grok_proc();
  804. X
  805. X/* if slot not in use, force to end when sorting */
  806. X    nprocs = 0;
  807. X    for(iproc = 0;iproc < v.v_proc;iproc++)
  808. X    {
  809. X        tproc = procs + iproc;
  810. X        tproc->p_dummy0 = iproc;        /* save slot number */
  811. X        if((tproc->p_stat == 0) ||
  812. X            ((tproc->p_pgrp == tproc->p_pid) && (LINES < 43)) ||
  813. X            (tproc->p_pgrp == 0))
  814. X            tproc->p_pid = 32767;
  815. X        else
  816. X            nprocs++;
  817. X    }
  818. X
  819. X/* sort new procs array */
  820. X    qsort((char *)procs,v.v_proc,sizeof(struct proc),proc_pid_compare);
  821. X
  822. X    if(initial)
  823. X    {
  824. X        memcpy((char *)oldprocs,(char *)procs,proc_size);
  825. X        noldprocs = nprocs;
  826. X    }
  827. X
  828. X}    /* end of read_and_sort_procs */
  829. X
  830. X/*+-------------------------------------------------------------------------
  831. X    read_utmp()
  832. X--------------------------------------------------------------------------*/
  833. Xvoid
  834. Xread_utmp()
  835. X{
  836. Xint utmpfd;
  837. Xregister struct utmp *tutmp = utmps;
  838. X
  839. X    nutmps = 0;
  840. X    if((utmpfd = open("/etc/utmp",O_RDONLY,755)) < 0)
  841. X        leave_text("/etc/utmp open error",errno);
  842. X
  843. X    while(read(utmpfd,(char *)(tutmp++),sizeof(struct utmp)) > 0)
  844. X    {
  845. X        if(++nutmps == MAX_UTMP)
  846. X            leave_text("too many utmp entries for me to handle",1);
  847. X    }
  848. X    close(utmpfd);
  849. X}    /* end of read_utmp */
  850. X
  851. X/*+-------------------------------------------------------------------------
  852. X    find_utmp_for_pgrp(pgrp)
  853. X--------------------------------------------------------------------------*/
  854. Xstruct utmp *
  855. Xfind_utmp_for_pgrp(pgrp)
  856. Xint pgrp;
  857. X{
  858. Xstruct utmp *tutmp = utmps;
  859. Xregister int count = nutmps;
  860. X
  861. X    while(count--)
  862. X    {
  863. X        if(tutmp->ut_pid == pgrp)
  864. X            return(tutmp);
  865. X        tutmp++;
  866. X    }
  867. X    return((struct utmp *)0);
  868. X}    /* end of find_utmp_for_pgrp */
  869. X
  870. X/*+-------------------------------------------------------------------------
  871. X    pgrp_to_ttyname(pgrp)
  872. X--------------------------------------------------------------------------*/
  873. Xchar *
  874. Xpgrp_to_ttyname(pgrp)
  875. Xint pgrp;
  876. X{
  877. Xstruct utmp *tutmp;
  878. X
  879. X    if(!(tutmp = find_utmp_for_pgrp(pgrp)))
  880. X    {
  881. X        read_utmp();
  882. X        tutmp = find_utmp_for_pgrp(pgrp);
  883. X    }
  884. X    if(!tutmp)
  885. X        return("??");
  886. X    else
  887. X        return(&tutmp->ut_id[strlen(tutmp->ut_id) - 2]);
  888. X}    /* end of pgrp_to_ttyname */
  889. X
  890. X/*+-------------------------------------------------------------------------
  891. X    get_user(tproc,slot,user)
  892. X--------------------------------------------------------------------------*/
  893. Xget_user(tproc,slot,user)
  894. Xstruct proc *tproc;
  895. Xint slot;    /* not used */
  896. Xstruct user *user;
  897. X{
  898. X    int ipde;
  899. X    int ubrdcount = sizeof(struct user);
  900. X    caddr_t uptr = (caddr_t)user;
  901. X    daddr_t mptr;
  902. X
  903. X    if(tproc->p_flag & SLOAD)
  904. X    {
  905. X        for(ipde = 0; ipde < tproc->p_usize; ipde++)
  906. X        {
  907. X            if(!tproc->p_ubptbl[ipde].pgm.pg_pres)    /* if not resident */
  908. X                return(0);
  909. X            mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
  910. X            mread(uptr,mptr,min(ubrdcount,NBPP));
  911. X            uptr += NBPP;
  912. X            if((ubrdcount -= NBPP) <= 0)
  913. X                break;
  914. X        }
  915. X        return(1);
  916. X    }
  917. X    return(0);
  918. X
  919. X}    /* end of get_user */
  920. X
  921. X/*+-------------------------------------------------------------------------
  922. Xuid to username conversion; thanks for the idea to William LeFebvre
  923. X--------------------------------------------------------------------------*/
  924. X#define UID_NAME_HASH_SIZE    127    /* prime */
  925. X#define HASH_EMPTY            -1
  926. X#define HASHIT(i)            ((i) % UID_NAME_HASH_SIZE)
  927. X
  928. Xstruct uid_name_hash_entry {
  929. X    int  uid;
  930. X    char name[10];
  931. X};
  932. X
  933. Xstruct uid_name_hash_entry uid_name_table[UID_NAME_HASH_SIZE];
  934. Xint uid_count = 0;
  935. X
  936. X/*+-------------------------------------------------------------------------
  937. X    init_uid_name_hash()
  938. X--------------------------------------------------------------------------*/
  939. Xvoid
  940. Xinit_uid_name_hash()
  941. X{
  942. Xregister int ihash = 0;
  943. Xregister struct uid_name_hash_entry *hashent = uid_name_table;
  944. X
  945. X    while(ihash++ < UID_NAME_HASH_SIZE)
  946. X    {
  947. X        hashent->uid = HASH_EMPTY;
  948. X        hashent++;
  949. X    }
  950. X}    /* end of init_uid_name_hash */
  951. X
  952. X/*+-------------------------------------------------------------------------
  953. X    uid_name_enter(uid,name)
  954. X--------------------------------------------------------------------------*/
  955. Xint
  956. Xuid_name_enter(uid,name)
  957. Xregister int uid;
  958. Xregister char *name;
  959. X{
  960. Xregister int table_uid;
  961. Xregister int hashval;
  962. X
  963. X    if(++uid_count >= UID_NAME_HASH_SIZE)
  964. X        leave_text("too many user names",1);
  965. X
  966. X    hashval = HASHIT(uid);
  967. X    while((table_uid = uid_name_table[hashval].uid) != HASH_EMPTY)
  968. X    {
  969. X        if(table_uid == uid)
  970. X            return(hashval);
  971. X        hashval = (hashval + 1) % UID_NAME_HASH_SIZE;
  972. X    }
  973. X
  974. X    uid_name_table[hashval].uid = uid;
  975. X    strncpy(uid_name_table[hashval].name,name,
  976. X        sizeof(uid_name_table[0].name));
  977. X
  978. X    return(hashval);
  979. X
  980. X}    /* end of uid_name_enter */
  981. X
  982. X/*+-------------------------------------------------------------------------
  983. X    getpwent_and_enter(uid)
  984. X--------------------------------------------------------------------------*/
  985. Xgetpwent_and_enter(uid)
  986. Xregister int uid;
  987. X{
  988. Xregister int hashval;
  989. Xregister struct passwd *pwd;
  990. Xchar errant[10];
  991. Xstruct passwd *getpwuid();
  992. X
  993. X    pwd = getpwuid(uid);
  994. X    endpwent();
  995. X    if(pwd)
  996. X    {
  997. X        hashval = uid_name_enter(pwd->pw_uid,pwd->pw_name);
  998. X        return(hashval);
  999. X    }
  1000. X    sprintf(errant,"%d",uid);
  1001. X    return(uid_name_enter(uid,errant));
  1002. X}    /* end of getpwent_and_enter */
  1003. X
  1004. X/*+-------------------------------------------------------------------------
  1005. X    uid_to_name(uid)
  1006. X--------------------------------------------------------------------------*/
  1007. Xchar *
  1008. Xuid_to_name(uid)
  1009. Xregister int uid;
  1010. X{
  1011. Xregister int uid_hash;
  1012. Xregister int table_uid;
  1013. Xregister char *name;
  1014. X
  1015. X    uid_hash = HASHIT(uid);
  1016. X    while((table_uid = uid_name_table[uid_hash].uid) != uid)
  1017. X    {
  1018. X        if(table_uid == HASH_EMPTY)
  1019. X        {
  1020. X            /* not in hash table */
  1021. X            uid_hash = getpwent_and_enter(uid);
  1022. X            break;        /* out of while */
  1023. X        }
  1024. X        uid_hash = (uid_hash + 1) % UID_NAME_HASH_SIZE;
  1025. X    }
  1026. X    return(uid_name_table[uid_hash].name);
  1027. X}    /* end of char *uid_to_name */
  1028. X
  1029. X/*+-----------------------------------------------------------------------
  1030. X    char *get_cpu_time_str(ticks)
  1031. X  6-char static string address is returned
  1032. X------------------------------------------------------------------------*/
  1033. Xchar *get_cpu_time_str(ticks)
  1034. Xtime_t ticks;
  1035. X{
  1036. Xstatic char timestr[10];
  1037. Xtime_t mm,ss;
  1038. Xstatic int hz;
  1039. X
  1040. X    if(!hz)
  1041. X    {
  1042. X    char *cptr;
  1043. X    char *getenv();
  1044. X        if(cptr = getenv("HZ"))
  1045. X            hz = atoi(cptr);
  1046. X        else
  1047. X            hz = HZ;
  1048. X    }
  1049. X
  1050. X    ticks /= hz;
  1051. X    mm = ticks / 60L;
  1052. X    ticks -= mm * 60L;
  1053. X    ss = ticks;
  1054. X
  1055. X    if(mm > 999)
  1056. X        sprintf(timestr,"%5ldm",mm);
  1057. X    else
  1058. X        sprintf(timestr,"%3lu:%02lu",mm,ss);
  1059. X    return(timestr);
  1060. X}    /* end of get_cpu_time_str */
  1061. X
  1062. X#define PROC_Y        1
  1063. X#define PROC_X        0
  1064. X#define UID_X        2
  1065. X#define PID_X        12
  1066. X#define PPID_X        18
  1067. X#define CPU_X        24
  1068. X#define PRI_X        28
  1069. X#define NICE_X        32
  1070. X#define UTIME_X        35
  1071. X#define STIME_X        42
  1072. X#define TTY_X        49
  1073. X#define CMD_X        53
  1074. X
  1075. X/*+-------------------------------------------------------------------------
  1076. X    display_proc_stat(win,iproc,initial)
  1077. X00000000001111111111222222222233333333334444444444555555555566666666667777777777
  1078. X01234567890123456789012345678901234567890123456789012345678901234567890123456789
  1079. XS     USER   PID  PPID  CPU PRI NI UCPU   SCPU   TTY CMD
  1080. X# ########X ##### ##### ### ### ## ###### ###### ### ########
  1081. X--------------------------------------------------------------------------*/
  1082. Xvoid
  1083. Xdisplay_proc_stat(win,iproc,initial)
  1084. XWINDOW *win;
  1085. Xregister int iproc;
  1086. Xregister int initial;
  1087. X{
  1088. Xregister int positioned = 0;
  1089. Xregister int itmp;
  1090. Xregister int got_user;
  1091. Xstruct proc *tproc = procs + iproc;
  1092. Xstruct proc *oproc = oldprocs + iproc;
  1093. Xstatic char *p_stat_str = " sRzji*x";    /* dependent on values of SSLEEP etc */
  1094. Xchar buf[20];
  1095. X
  1096. X    use_cp(win,cpINFO);
  1097. X    if((itmp = (tproc->p_stat == SRUN)) ||
  1098. X        ((tproc->p_stat != SRUN) && (oproc->p_stat == SRUN)))
  1099. X    {
  1100. X        initial = 1;
  1101. X        use_cp(win,cpMED);
  1102. X    }
  1103. X
  1104. X    if(initial || (tproc->p_stat != oproc->p_stat))
  1105. X    {
  1106. X        wmove(win,PROC_Y + iproc,PROC_X);
  1107. X        waddch(win,p_stat_str[tproc->p_stat]);
  1108. X        waddch(win,' ');
  1109. X        positioned = 1;
  1110. X    }
  1111. X
  1112. X    if(initial || (tproc->p_uid != oproc->p_uid))
  1113. X    {
  1114. X        if(!positioned)
  1115. X            wmove(win,PROC_Y + iproc,PROC_X + UID_X);
  1116. X        sprintf(buf,"%8s",uid_to_name(tproc->p_uid));
  1117. X        waddstr(win,buf);
  1118. X        waddch(win,(tproc->p_uid != tproc->p_suid) ? '#' : ' ');
  1119. X        waddch(win,' ');
  1120. X        positioned = 1;
  1121. X    }
  1122. X    else
  1123. X        positioned = 0;
  1124. X
  1125. X    if(initial || (tproc->p_pid != oproc->p_pid))
  1126. X    {
  1127. X        if(!positioned)
  1128. X            wmove(win,PROC_Y + iproc,PROC_X + PID_X);
  1129. X        sprintf(buf,"%5d ",tproc->p_pid);
  1130. X        waddstr(win,buf);
  1131. X        positioned = 1;
  1132. X    }
  1133. X    else
  1134. X        positioned = 0;
  1135. X
  1136. X    if(initial || (tproc->p_ppid != oproc->p_ppid))
  1137. X    {
  1138. X        if(!positioned)
  1139. X            wmove(win,PROC_Y + iproc,PROC_X + PPID_X);
  1140. X        sprintf(buf,"%5d ",tproc->p_ppid);
  1141. X        waddstr(win,buf);
  1142. X        positioned = 1;
  1143. X    }
  1144. X    else
  1145. X        positioned = 0;
  1146. X
  1147. X    if(initial || (tproc->p_cpu != oproc->p_cpu))
  1148. X    {
  1149. X        if(!positioned)
  1150. X            wmove(win,PROC_Y + iproc,PROC_X + CPU_X);
  1151. X        sprintf(buf,"%3u ",tproc->p_cpu);
  1152. X        waddstr(win,buf);
  1153. X        positioned = 1;
  1154. X    }
  1155. X    else
  1156. X        positioned = 0;
  1157. X
  1158. X    if(initial || (tproc->p_pri != oproc->p_pri))
  1159. X    {
  1160. X        if(!positioned)
  1161. X            wmove(win,PROC_Y + iproc,PROC_X + PRI_X);
  1162. X        sprintf(buf,"%3u ",tproc->p_pri);
  1163. X        waddstr(win,buf);
  1164. X        positioned = 1;
  1165. X    }
  1166. X    else
  1167. X        positioned = 0;
  1168. X
  1169. X    if(initial || (tproc->p_nice != oproc->p_nice))
  1170. X    {
  1171. X        if(!positioned)
  1172. X            wmove(win,PROC_Y + iproc,PROC_X + NICE_X);
  1173. X        sprintf(buf,"%2d ",tproc->p_nice);
  1174. X        waddstr(win,buf);
  1175. X        positioned = 1;
  1176. X    }
  1177. X    else
  1178. X        positioned = 0;
  1179. X
  1180. X/* since not saving user area, always update fields from it */
  1181. X    if(!positioned)
  1182. X        wmove(win,PROC_Y + iproc,PROC_X + UTIME_X);
  1183. X    if(got_user = get_user(tproc,iproc,&user))
  1184. X    {
  1185. X        waddstr(win,get_cpu_time_str(user.u_utime));
  1186. X        waddch(win,' ');
  1187. X        waddstr(win,get_cpu_time_str(user.u_stime));
  1188. X        waddch(win,' ');
  1189. X    }
  1190. X    else
  1191. X        waddstr(win,"------ ------ ");
  1192. X    positioned = 1;
  1193. X
  1194. X    if(!positioned)
  1195. X        wmove(win,PROC_Y + iproc,PROC_X + TTY_X);
  1196. X    sprintf(buf,"%3.3s ",pgrp_to_ttyname(tproc->p_pgrp));
  1197. X    waddstr(win,buf);
  1198. X    positioned = 1;
  1199. X
  1200. X    if(!positioned)
  1201. X        wmove(win,PROC_Y + iproc,PROC_X + CMD_X);
  1202. X    if(got_user)
  1203. X    {
  1204. X    register char *cptr = user.u_psargs;
  1205. X    int y,x,maxx = getmaxx(win);
  1206. X        getyx(win,y,x);
  1207. X        while(*cptr && (x < maxx))
  1208. X        {
  1209. X            *cptr &= 0x7F;
  1210. X            if(*cptr < 0x20)
  1211. X                *cptr = 0x20;
  1212. X            waddch(win,*cptr);
  1213. X            cptr++,x++;
  1214. X        }
  1215. X    }
  1216. X    else
  1217. X    {
  1218. X        switch(tproc->p_stat)
  1219. X        {
  1220. X            case SIDL:
  1221. X                waddstr(win,"<idle>");
  1222. X                break;
  1223. X            case SZOMB:
  1224. X                waddstr(win,"<zomb>");
  1225. X                break;
  1226. X            default:
  1227. X                waddstr(win,"<swap>");
  1228. X        }
  1229. X    }
  1230. X
  1231. X    wclrtoeol(win);
  1232. X
  1233. X}    /* end of display_proc_stat */
  1234. X
  1235. X/*+-------------------------------------------------------------------------
  1236. X    display_proc_stats(win,initial)
  1237. X--------------------------------------------------------------------------*/
  1238. Xvoid
  1239. Xdisplay_proc_stats(win,initial)
  1240. XWINDOW *win;
  1241. Xint initial;
  1242. X{
  1243. Xregister int iproc;
  1244. X
  1245. X    if(initial)
  1246. X    {
  1247. X        use_cp(win,cpBANNER);
  1248. X        wmove(win,0,0);
  1249. X        waddstr(win,
  1250. X            "S     USER   PID  PPID  CPU PRI NI UCPU   SCPU   TTY CMD");
  1251. X    }
  1252. X    mypid = getpid();
  1253. X    read_and_sort_procs(1);
  1254. X    for(iproc = 0; iproc < min(nprocs,getmaxy(win) - PROC_Y); iproc++)
  1255. X        display_proc_stat(win,iproc,1);
  1256. X    wclrtobot(win);
  1257. X}    /* end of display_proc_stats */
  1258. X
  1259. X/* vi: set tabstop=4 shiftwidth=4: */
  1260. X/* end of det_proc.c */
  1261. SHAR_EOF
  1262. $TOUCH -am 0620220890 det_proc.c &&
  1263. chmod 0644 det_proc.c ||
  1264. echo "restore of det_proc.c failed"
  1265. set `wc -c det_proc.c`;Wc_c=$1
  1266. if test "$Wc_c" != "12760"; then
  1267.     echo original size 12760, current size $Wc_c
  1268. fi
  1269. # ============= disputil.c ==============
  1270. echo "x - extracting disputil.c (Text)"
  1271. sed 's/^X//' << 'SHAR_EOF' > disputil.c &&
  1272. X/*+-------------------------------------------------------------------------
  1273. X    disputil.c - u386mon display utilities
  1274. X
  1275. X  Defined functions:
  1276. X    clear_area(win,y,x,len)
  1277. X    clear_area_char(win,y,x,len,fillchar)
  1278. X    disp_info_int(win,label,fmt,value)
  1279. X    disp_info_long(win,label,fmt,value)
  1280. X    disp_static_int(win,label,fmt,value)
  1281. X    disp_static_long(win,label,fmt,value)
  1282. X    mkpanel(rows,cols,tly,tlx)
  1283. X    pflush()
  1284. X    wperror(win,desc)
  1285. X
  1286. X--------------------------------------------------------------------------*/
  1287. X/*+:EDITS:*/
  1288. X/*:06-17-1990-15:15-wht-creation */
  1289. X
  1290. X#define M_TERMINFO
  1291. X
  1292. X#include <curses.h>
  1293. X#include <panel.h>
  1294. X#include <sys/types.h>
  1295. X#include "u386mon.h"
  1296. X
  1297. X/*+-------------------------------------------------------------------------
  1298. X    clear_area_char(win,y,x,len,fillchar)
  1299. X--------------------------------------------------------------------------*/
  1300. Xvoid
  1301. Xclear_area_char(win,y,x,len,fillchar)
  1302. XWINDOW *win;
  1303. Xint y;
  1304. Xint x;
  1305. Xint len;
  1306. Xu_char fillchar;
  1307. X{
  1308. X    wmove(win,y,x);
  1309. X    while(len-- > 0)
  1310. X        waddch(win,(chtype)fillchar);
  1311. X    wmove(win,y,x);
  1312. X
  1313. X}    /* end of clear_area_char */
  1314. X
  1315. X/*+-------------------------------------------------------------------------
  1316. X    clear_area(win,y,x,len)
  1317. X--------------------------------------------------------------------------*/
  1318. Xvoid
  1319. Xclear_area(win,y,x,len)
  1320. XWINDOW *win;
  1321. Xint y;
  1322. Xint x;
  1323. Xint len;
  1324. X{
  1325. X    clear_area_char(win,y,x,len,' ');
  1326. X}    /* end of clear_area_char */
  1327. X
  1328. X/*+-------------------------------------------------------------------------
  1329. X    pflush() - do update_panels() and doupdate()
  1330. X--------------------------------------------------------------------------*/
  1331. Xvoid
  1332. Xpflush()
  1333. X{
  1334. X    update_panels();
  1335. X    curs_set(0);
  1336. X    doupdate();
  1337. X    curs_set(1);
  1338. X}    /* end of pflush */
  1339. X
  1340. X/*+-------------------------------------------------------------------------
  1341. X    wperror(win,desc)
  1342. X--------------------------------------------------------------------------*/
  1343. Xvoid
  1344. Xwperror(win,desc)
  1345. XWINDOW *win;
  1346. Xchar *desc;
  1347. X{
  1348. Xextern int errno;
  1349. Xextern int sys_nerr;
  1350. Xextern char *sys_errlist[];
  1351. X
  1352. X    waddstr(win,desc);
  1353. X    waddstr(win,": ");
  1354. X    if(errno < sys_nerr)
  1355. X        waddstr(win,sys_errlist[errno]);
  1356. X    else
  1357. X        wprintw(win,"error %u",errno);
  1358. X
  1359. X}    /* end of wperror */
  1360. X
  1361. X/*+-------------------------------------------------------------------------
  1362. X    mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
  1363. X--------------------------------------------------------------------------*/
  1364. XPANEL *
  1365. Xmkpanel(rows,cols,tly,tlx)
  1366. Xint rows;
  1367. Xint cols;
  1368. Xint tly;
  1369. Xint tlx;
  1370. X{
  1371. XWINDOW *win = newwin(rows,cols,tly,tlx);
  1372. XPANEL *pan;
  1373. X
  1374. X    if(!win)
  1375. X        return((PANEL *)0);
  1376. X    if(pan = new_panel(win))
  1377. X        return(pan);
  1378. X    delwin(win);
  1379. X    return((PANEL *)0);
  1380. X}    /* end of mkpanel */
  1381. X
  1382. X/*+-------------------------------------------------------------------------
  1383. X    disp_info_long(win,label,fmt,value)
  1384. X--------------------------------------------------------------------------*/
  1385. Xvoid
  1386. Xdisp_info_long(win,label,fmt,value)
  1387. XWINDOW *win;
  1388. Xchar *label;
  1389. Xchar *fmt;
  1390. Xlong value;
  1391. X{
  1392. X    use_cp(win,cpLIT);
  1393. X    waddstr(win,label);
  1394. X    use_cp(win,cpINFO);
  1395. X    wprintw(win,fmt,value);
  1396. X}    /* end of disp_info_long */
  1397. X
  1398. X/*+-------------------------------------------------------------------------
  1399. X    disp_info_int(win,label,fmt,value)
  1400. X--------------------------------------------------------------------------*/
  1401. Xvoid
  1402. Xdisp_info_int(win,label,fmt,value)
  1403. XWINDOW *win;
  1404. Xchar *label;
  1405. Xchar *fmt;
  1406. Xint value;
  1407. X{
  1408. X    use_cp(win,cpLIT);
  1409. X    waddstr(win,label);
  1410. X    use_cp(win,cpINFO);
  1411. X    wprintw(win,fmt,value);
  1412. X}    /* end of disp_info_int */
  1413. X
  1414. X/*+-------------------------------------------------------------------------
  1415. X    disp_static_long(win,label,fmt,value)
  1416. X--------------------------------------------------------------------------*/
  1417. Xvoid
  1418. Xdisp_static_long(win,label,fmt,value)
  1419. XWINDOW *win;
  1420. Xchar *label;
  1421. Xchar *fmt;
  1422. Xlong value;
  1423. X{
  1424. X    use_cp(win,cpLIT);
  1425. X    waddstr(win,label);
  1426. X    wprintw(win,fmt,value);
  1427. X}    /* end of disp_static_long */
  1428. X
  1429. X/*+-------------------------------------------------------------------------
  1430. X    disp_static_int(win,label,fmt,value)
  1431. X--------------------------------------------------------------------------*/
  1432. Xvoid
  1433. Xdisp_static_int(win,label,fmt,value)
  1434. XWINDOW *win;
  1435. Xchar *label;
  1436. Xchar *fmt;
  1437. Xint value;
  1438. X{
  1439. X    use_cp(win,cpLIT);
  1440. X    waddstr(win,label);
  1441. X    wprintw(win,fmt,value);
  1442. X}    /* end of disp_static_int */
  1443. X
  1444. X/* vi: set tabstop=4 shiftwidth=4: */
  1445. X/* end of disputil.c */
  1446. SHAR_EOF
  1447. $TOUCH -am 0620155490 disputil.c &&
  1448. chmod 0644 disputil.c ||
  1449. echo "restore of disputil.c failed"
  1450. set `wc -c disputil.c`;Wc_c=$1
  1451. if test "$Wc_c" != "4227"; then
  1452.     echo original size 4227, current size $Wc_c
  1453. fi
  1454. # ============= libkmem.c ==============
  1455. echo "x - extracting libkmem.c (Text)"
  1456. sed 's/^X//' << 'SHAR_EOF' > libkmem.c &&
  1457. X/*+-------------------------------------------------------------------------
  1458. X    libkmem.c -- /dev/kmem routines for SCO UNIX V/286 (maybe other *NIX)
  1459. X    ...!emory!n4hgf!wht
  1460. X
  1461. X  Defined functions:
  1462. X    kinit(write_needed)
  1463. X    kread(caddr,kaddr,len)
  1464. X    kwrite(kaddr,caddr,len)
  1465. X
  1466. X routines were originally written by Mike "Ford" Ditto: kudos!!!
  1467. X--------------------------------------------------------------------------*/
  1468. X/*+:EDITS:*/
  1469. X/*:12-07-1988-22:06-wht-put in test for initialized fdkmem */
  1470. X/*:10-27-1988-22:44-wht-creation of file */
  1471. X
  1472. X#include <sys/types.h>
  1473. X#include <fcntl.h>
  1474. X#include "libkmem.h"
  1475. X
  1476. Xextern int errno;
  1477. X
  1478. Xstatic int fdkmem = -2;
  1479. Xdaddr_t lseek();
  1480. X
  1481. X/*+-------------------------------------------------------------------------
  1482. X    kinit(write_needed)
  1483. X--------------------------------------------------------------------------*/
  1484. Xvoid
  1485. Xkinit(write_needed)
  1486. Xint write_needed;
  1487. X{
  1488. X    if(fdkmem >= 0)
  1489. X        return;
  1490. X    if((fdkmem=open("/dev/kmem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0)
  1491. X        leave_text("can't open /dev/kmem",1);
  1492. X
  1493. X}    /* end of kinit */
  1494. X
  1495. X/*+-------------------------------------------------------------------------
  1496. X    kread(caddr,kaddr,len)
  1497. X--------------------------------------------------------------------------*/
  1498. Xvoid
  1499. Xkread(caddr,kaddr,len)
  1500. Xcaddr_t caddr;
  1501. Xdaddr_t kaddr;
  1502. Xint len;
  1503. X{
  1504. Xchar s80[80];
  1505. X
  1506. X#if defined(M_I286)
  1507. X    kaddr &= 0xFFFFL;
  1508. X#endif
  1509. X
  1510. X    if(fdkmem == -2)
  1511. X        leave_text("kinit() not called",1);
  1512. X
  1513. X    if(lseek(fdkmem,kaddr,0) == -1L)
  1514. X    {
  1515. X        sprintf(s80,"kmem seek err (%08lx)",kaddr);
  1516. X        leave_text(s80,1);
  1517. X    }
  1518. X
  1519. X    if(read(fdkmem,caddr,len) != len)
  1520. X    {
  1521. X        sprintf(s80,"kmem read errno %d len %d addr %08lx",errno,len,kaddr);
  1522. X        leave_text(s80,1);
  1523. X    }
  1524. X}    /* end of kread */
  1525. X
  1526. X/*+-------------------------------------------------------------------------
  1527. X    kwrite(kaddr,caddr,len)
  1528. X--------------------------------------------------------------------------*/
  1529. X#ifdef KWRITE_NEEDED
  1530. Xvoid
  1531. Xkwrite(kaddr,caddr,len)
  1532. Xdaddr_t kaddr;
  1533. Xcaddr_t caddr;
  1534. Xint len;
  1535. X{
  1536. Xchar s80[80];
  1537. X
  1538. X#if defined(M_I286)
  1539. X    kaddr &= 0xFFFFL;
  1540. X#endif
  1541. X
  1542. X    if(fdkmem == -2)
  1543. X        leave_text("kinit() not called",1);
  1544. X
  1545. X    if((lseek(fdkmem,kaddr,0) < 0L) || (write(fdkmem,caddr,len) != len))
  1546. X    {
  1547. X        sprintf(s80,"/dev/kmem write addr %08lx len %08lx",kaddr,len);
  1548. X        leave_text(s80,1);
  1549. X    }
  1550. X}    /* end of kwrite */
  1551. X#endif
  1552. X
  1553. X/* vi: set tabstop=4 shiftwidth=4: */
  1554. SHAR_EOF
  1555. $TOUCH -am 0620184790 libkmem.c &&
  1556. chmod 0644 libkmem.c ||
  1557. echo "restore of libkmem.c failed"
  1558. set `wc -c libkmem.c`;Wc_c=$1
  1559. if test "$Wc_c" != "2280"; then
  1560.     echo original size 2280, current size $Wc_c
  1561. fi
  1562. # ============= libmem.c ==============
  1563. echo "x - extracting libmem.c (Text)"
  1564. sed 's/^X//' << 'SHAR_EOF' > libmem.c &&
  1565. X/*+-------------------------------------------------------------------------
  1566. X    libmem.c -- /dev/mem routines for SCO UNIX V/286 (maybe other *NIX)
  1567. X    ...!gatech!emory!tridom!wht
  1568. X
  1569. X  Defined functions:
  1570. X    minit(write_needed)
  1571. X    mread(caddr,maddr,len)
  1572. X    mwrite(maddr,caddr,len)
  1573. X
  1574. X routines were originally written by Mike "Ford" Ditto: kudos!!!
  1575. X--------------------------------------------------------------------------*/
  1576. X/*+:EDITS:*/
  1577. X/*:12-07-1988-22:06-wht-put in test for initialized fdmem */
  1578. X/*:10-27-1988-22:44-wht-creation of file */
  1579. X
  1580. X#include <sys/types.h>
  1581. X#include <fcntl.h>
  1582. X#include "libmem.h"
  1583. X
  1584. Xextern int errno;
  1585. X
  1586. Xstatic int fdmem = -2;
  1587. Xdaddr_t lseek();
  1588. X
  1589. X/*+-------------------------------------------------------------------------
  1590. X    minit(write_needed)
  1591. X--------------------------------------------------------------------------*/
  1592. Xvoid
  1593. Xminit(write_needed)
  1594. Xint write_needed;
  1595. X{
  1596. X    if(fdmem >= 0)
  1597. X        return;
  1598. X    if((fdmem=open("/dev/mem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0)
  1599. X        leave_text("can't open /dev/mem",1);
  1600. X
  1601. X}    /* end of minit */
  1602. X
  1603. X/*+-------------------------------------------------------------------------
  1604. X    mread(caddr,maddr,len)
  1605. X--------------------------------------------------------------------------*/
  1606. Xvoid
  1607. Xmread(caddr,maddr,len)
  1608. Xcaddr_t caddr;
  1609. Xdaddr_t maddr;
  1610. Xint len;
  1611. X{
  1612. Xchar s80[80];
  1613. X
  1614. X#if defined(M_I286)
  1615. X    maddr &= 0xFFFFL;
  1616. X#endif
  1617. X
  1618. X    if(fdmem == -2)
  1619. X        leave_text("minit() not called",1);
  1620. X
  1621. X    if(lseek(fdmem,maddr,0) == -1L)
  1622. X    {
  1623. X        sprintf(s80,"mem seek err (%08lx)",maddr);
  1624. X        leave_text(s80,1);
  1625. X    }
  1626. X
  1627. X    if(read(fdmem,caddr,len) != len)
  1628. X    {
  1629. X        sprintf(s80,"mem read errno %d len %d addr %08lx",errno,len,maddr);
  1630. X        leave_text(s80,1);
  1631. X    }
  1632. X}    /* end of mread */
  1633. X
  1634. X/*+-------------------------------------------------------------------------
  1635. X    mwrite(maddr,caddr,len)
  1636. X--------------------------------------------------------------------------*/
  1637. X#ifdef MWRITE_NEEDED
  1638. Xvoid
  1639. Xmwrite(maddr,caddr,len)
  1640. Xdaddr_t maddr;
  1641. Xcaddr_t caddr;
  1642. Xint len;
  1643. X{
  1644. Xchar s80[80];
  1645. X
  1646. X#if defined(M_I286)
  1647. X    maddr &= 0xFFFFL;
  1648. X#endif
  1649. X
  1650. X    if(fdmem == -2)
  1651. X        leave_text("minit() not called",1);
  1652. X
  1653. X    if((lseek(fdmem,maddr,0) < 0L) || (write(fdmem,caddr,len) != len))
  1654. X    {
  1655. X        sprintf(s80,"/dev/mem write addr %08lx len %08lx",maddr,len);
  1656. X        leave_text(s80,1);
  1657. X    }
  1658. X}    /* end of mwrite */
  1659. X#endif /* MWRITE_NEEDED */
  1660. X
  1661. X/* vi: set tabstop=4 shiftwidth=4: */
  1662. SHAR_EOF
  1663. $TOUCH -am 0620184690 libmem.c &&
  1664. chmod 0644 libmem.c ||
  1665. echo "restore of libmem.c failed"
  1666. set `wc -c libmem.c`;Wc_c=$1
  1667. if test "$Wc_c" != "2290"; then
  1668.     echo original size 2290, current size $Wc_c
  1669. fi
  1670. # ============= libnlsym.c ==============
  1671. echo "x - extracting libnlsym.c (Text)"
  1672. sed 's/^X//' << 'SHAR_EOF' > libnlsym.c &&
  1673. X/*+-------------------------------------------------------------------------
  1674. X    libnlsym.c -- common runtime for nlsym users
  1675. X    ...!gatech!emory!tridom!wht
  1676. X
  1677. X  Defined functions:
  1678. X    nlsym_error(text)
  1679. X    nlsym_read()
  1680. X
  1681. X--------------------------------------------------------------------------*/
  1682. X/*+:EDITS:*/
  1683. X/*:10-27-1988-11:44-wht-creation */
  1684. X
  1685. X#include <stdio.h>
  1686. X#include <sys/types.h>
  1687. X#include <sys/stat.h>
  1688. X#include <fcntl.h>
  1689. X#include <nlist.h>
  1690. X
  1691. X#define DEFINE_NLSYM
  1692. X#include "nlsym.h"
  1693. X#include "libnlsym.h"
  1694. X
  1695. Xextern int errno;
  1696. Xextern char *sys_errlist[];
  1697. X
  1698. X/*+-------------------------------------------------------------------------
  1699. X    nlsym_error(text)
  1700. X--------------------------------------------------------------------------*/
  1701. Xvoid
  1702. Xnlsym_error(text)
  1703. Xchar *text;
  1704. X{
  1705. Xchar s128[128];
  1706. X
  1707. X    strcpy(s128,text);
  1708. X    if(errno)
  1709. X    {
  1710. X        strcat(s128," (");
  1711. X        strcat(s128,sys_errlist[errno]);
  1712. X        strcat(s128,")");
  1713. X    }
  1714. X    strcat(s128," run nlsym");
  1715. X    leave_text(s128,1);
  1716. X}    /* end of nlsym_error */
  1717. X
  1718. X/*+-------------------------------------------------------------------------
  1719. X    nlsym_read()
  1720. X--------------------------------------------------------------------------*/
  1721. Xvoid
  1722. Xnlsym_read()
  1723. X{
  1724. Xchar s80[80];
  1725. Xint itmp;
  1726. Xint fdnlsym;
  1727. Xstruct stat curstat;    /* current /unix status */
  1728. Xstruct stat unixstat;        /* /unix status at nlsym run time */
  1729. Xlong unique;
  1730. X
  1731. X    if(stat(UNIX_KERNEL,&curstat) < 0)
  1732. X    {
  1733. X        sprintf(s80,"cannot stat %s",UNIX_KERNEL);
  1734. X        nlsym_error(s80);
  1735. X    }
  1736. X
  1737. X    errno = 0;
  1738. X    if((fdnlsym = open(UNIX_NLSYM,O_RDONLY,0)) < 0)
  1739. X    {
  1740. X        sprintf(s80,"%s open error\n",UNIX_NLSYM);
  1741. X        nlsym_error(s80);
  1742. X    }
  1743. X
  1744. X    if((itmp = read(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat))
  1745. X        nlsym_error("unix stat error");
  1746. X
  1747. X    if((itmp = read(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym))
  1748. X        nlsym_error("nlsym error: ");
  1749. X
  1750. X    if((itmp = read(fdnlsym,&unique,sizeof(unique))) != sizeof(unique))
  1751. X        nlsym_error("`unique' read error");
  1752. X
  1753. X    close(fdnlsym);
  1754. X
  1755. X    if( (unique != NLSYM_UNIQUE) ||
  1756. X        (unixstat.st_ino != curstat.st_ino) ||
  1757. X        (unixstat.st_mtime != curstat.st_mtime) ||
  1758. X        (unixstat.st_size != curstat.st_size))
  1759. X    {
  1760. X        sprintf(s80,"%s out of date\n",UNIX_NLSYM);
  1761. X        nlsym_error(s80);
  1762. X    }
  1763. X
  1764. X}    /* end of nlsym_read */
  1765. SHAR_EOF
  1766. $TOUCH -am 0620150490 libnlsym.c &&
  1767. chmod 0644 libnlsym.c ||
  1768. echo "restore of libnlsym.c failed"
  1769. set `wc -c libnlsym.c`;Wc_c=$1
  1770. if test "$Wc_c" != "2146"; then
  1771.     echo original size 2146, current size $Wc_c
  1772. fi
  1773. # ============= nlsym.c ==============
  1774. echo "x - extracting nlsym.c (Text)"
  1775. sed 's/^X//' << 'SHAR_EOF' > nlsym.c &&
  1776. X/*+-------------------------------------------------------------------------
  1777. X    nlsym.c -- utility nlist - fast access to kernel /dev/kmem offsets
  1778. X    ...!gatech!emory!tridom!wht
  1779. X
  1780. X  Defined functions:
  1781. X    main(argc,argv,envp)
  1782. X    nlsym_write_error(code)
  1783. X
  1784. X--------------------------------------------------------------------------*/
  1785. X/*+:EDITS:*/
  1786. X/*:05-12-1989-18:27-wht-fix endless loop error on cannot nlist */
  1787. X/*:10-27-1988-10:58-wht-creation */
  1788. X
  1789. X#include <stdio.h>
  1790. X#include <sys/types.h>
  1791. X#include <sys/stat.h>
  1792. X#include <fcntl.h>
  1793. X#include <nlist.h>
  1794. X
  1795. X#define DEFINE_NLSYM
  1796. X#include "nlsym.h"
  1797. X
  1798. X/*+-------------------------------------------------------------------------
  1799. X    nlsym_write_error(code)
  1800. X--------------------------------------------------------------------------*/
  1801. Xvoid
  1802. Xnlsym_write_error(code)
  1803. Xint code;
  1804. X{
  1805. X    fprintf(stderr,"code %d: ",code);
  1806. X    perror(UNIX_NLSYM);
  1807. X    exit(1);
  1808. X}    /* end of nlsym_write_error */
  1809. X
  1810. X/*+-------------------------------------------------------------------------
  1811. X    main(argc,argv,envp)
  1812. X--------------------------------------------------------------------------*/
  1813. Xmain(argc,argv,envp)
  1814. Xint argc;
  1815. Xchar **argv;
  1816. Xchar **envp;
  1817. X{
  1818. Xregister int itmp;
  1819. Xregister struct nlist *nn;
  1820. Xstruct stat unixstat;        /* /unix status at nlsym run time */
  1821. Xint fdnlsym;
  1822. Xint nlist_error = 0;
  1823. Xlong unique;
  1824. XFILE *kludge;
  1825. X
  1826. X    nlist(UNIX_KERNEL,nlsym);
  1827. X
  1828. X    nn = nlsym;
  1829. X    while(nn->n_name)
  1830. X    {
  1831. X        if(!nn->n_sclass)
  1832. X        {
  1833. X            printf("%s: can't nlist\n", nn->n_name);
  1834. X            nlist_error = 1;
  1835. X            nn++;
  1836. X            continue;
  1837. X        }
  1838. X        printf("%-12.12s  storage class: %04x value: %08lx\n",
  1839. X            nn->n_name,
  1840. X            nn->n_sclass,
  1841. X            nn->n_value);
  1842. X        nn++;
  1843. X    }
  1844. X
  1845. X    if(nlist_error)
  1846. X    {
  1847. X        fprintf(stderr,"%s NOT produced\n",UNIX_NLSYM);
  1848. X        exit(1);
  1849. X    }
  1850. X
  1851. X    if((kludge = fopen(UNIX_NLSYM,"w")) == NULL)    /* scratch/create */
  1852. X        nlsym_write_error(-1);
  1853. X    fclose(kludge);
  1854. X
  1855. X    if((fdnlsym = open(UNIX_NLSYM,O_WRONLY,0)) < 0)
  1856. X        nlsym_write_error(fdnlsym);
  1857. X
  1858. X    if(stat(UNIX_KERNEL,&unixstat) < 0)
  1859. X    {
  1860. X        fputs("cannot stat ",stderr);
  1861. X        perror(UNIX_KERNEL);
  1862. X        exit(1);
  1863. X    }
  1864. X
  1865. X    if((itmp = write(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat))
  1866. X        nlsym_write_error(itmp);
  1867. X
  1868. X    if((itmp = write(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym))
  1869. X        nlsym_write_error(itmp);
  1870. X
  1871. X    unique = NLSYM_UNIQUE;
  1872. X    if((itmp = write(fdnlsym,&unique,sizeof(unique))) != sizeof(unique))
  1873. X        nlsym_write_error(itmp);
  1874. X
  1875. X    close(fdnlsym);
  1876. X    exit(0);
  1877. X}    /* end of main */
  1878. X
  1879. X/* vi: set tabstop=4 shiftwidth=4: */
  1880. SHAR_EOF
  1881. $TOUCH -am 0620150490 nlsym.c &&
  1882. chmod 0644 nlsym.c ||
  1883. echo "restore of nlsym.c failed"
  1884. set `wc -c nlsym.c`;Wc_c=$1
  1885. if test "$Wc_c" != "2390"; then
  1886.     echo original size 2390, current size $Wc_c
  1887. fi
  1888. echo "End of part 1, continue with part 2"
  1889. exit 0
  1890.  
  1891. ---------------------------------------------------------------------
  1892. Warren Tucker, TuckerWare    gatech!n4hgf!wht or wht%n4hgf@gatech.edu
  1893. Any perceptible delay will eventually get on your nerves. --Bob Hyers
  1894.