rasmus@contact.uucp (Rasmus Lerdorf) (06/28/90)
I am still looking for a fix to sps which will allow it to run under SunOS 4.1. Last I heard, the authors did not have 4.1 available, but I am sure someone somewhere has taken the time to patch this excellent program. I would appreciate any assistance. -- Rasmus Lerdorf | rasmus@contact.uucp (home) | WC '94 Prediction: SD Eng '93 | rasmus@dmntor.uucp (work) | Denmark will take the Cup!
cudcv@warwick.ac.uk (Rob McMahon) (07/03/90)
In article <1990Jun28.035921.1537@contact.uucp> rasmus@contact.uucp (Rasmus Lerdorf) writes: >I am still looking for a fix to sps which will allow it to run under SunOS >4.1. I've just done this last Friday, seems to work okay. Define -Dsunos41 in Makefile.sun. I've punted with the open files printout from -d, but it should give the correct results until more than NOFILE_IN_U (64) files have been open. Have fun, and please let me know what I've done wrong ... Rob =================================================================== RCS file: filecount.c,v retrieving revision 1.0 diff -c -r1.0 filecount.c *** /tmp/,RCSt1a00614 Tue Jul 3 11:08:47 1990 --- filecount.c Fri Jun 29 11:34:08 1990 *************** *** 9,15 **** --- 9,20 ---- extern union userstate User ; count = 0 ; + #ifdef sunos41 + /* too hard to do right at the moment ... */ + for ( i = 0, f = User.u_us.u_ofile_arr ; i < NOFILE_IN_U ; i++ ) + #else /*!sunos41*/ for ( i = 0, f = User.u_us.u_ofile ; i < NOFILE ; i++ ) + #endif /*sunos41*/ if ( *f++ ) count++ ; return ( count ) ; =================================================================== RCS file: getcmd.c,v retrieving revision 1.4 diff -c -r1.4 getcmd.c *** /tmp/,RCSt1a00614 Tue Jul 3 11:08:48 1990 --- getcmd.c Fri Jun 29 14:06:03 1990 *************** *** 28,34 **** int i; extern kvm_t *kvm_d; extern struct flags Flg ; ! extern struct userstate User; extern char *getcore(); p->pr_csaved = 0 ; --- 28,34 ---- int i; extern kvm_t *kvm_d; extern struct flags Flg ; ! extern union userstate User; extern char *getcore(); p->pr_csaved = 0 ; =================================================================== RCS file: getupage.c,v retrieving revision 1.4 diff -c -r1.4 getupage.c *** /tmp/,RCSt1a00614 Tue Jul 3 11:08:49 1990 --- getupage.c Fri Jun 29 11:18:18 1990 *************** *** 36,41 **** --- 36,44 ---- struct user *u, *kvm_getu(); extern kvm_t *kvm_d; extern union userstate User; + #ifdef sunos41 + static struct sess Sess; + #endif if ((u = kvm_getu(kvm_d, p)) == NULL) { *************** *** 46,53 **** else { bcopy((char *)u, (char *)&User.u_us, sizeof(User.u_us)); - return(1); } #else !sunos4 register int i ; register int ncl ; --- 49,69 ---- else { bcopy((char *)u, (char *)&User.u_us, sizeof(User.u_us)); } + #ifdef sunos41 + if (kvm_read(kvm_d, p->pr_p.p_sessp, (char *)&Sess, sizeof(Sess)) != sizeof(Sess)) + { + fprintf(stderr, "sps - Can't read session of process %d\n", + p->pr_p.p_pid); + return(0); + } + else + { + User.u_us.u_procp = &p->pr_p; + p->pr_p.p_sessp = &Sess; + } + #endif /*sunos41*/ + return(1); #else !sunos4 register int i ; register int ncl ; =================================================================== -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
cudcv@warwick.ac.uk (Rob McMahon) (07/04/90)
I'm really sorry for posting this here, but I've had a message from Chris Metcalf <metcalf@kailasa> asking for a pointer to sps, with no sign of a return address (except that kailasa is [18.111.0.209]). I guess other people may be prompted into looking for sps themselves anyway. The trouble with sps is that it has no `version' information in it. I don't believe the `26 Nov 1986' in main.c has been updated for years. The version I have is the most recent I know of, and it's main distinguishing feature is that it has support for sunos4 in it. I believe I got it from the archives at titan.rice.edu [128.42.1.30], under the directory sun-source. I've just checked and the date of the version there is Oct 88, which fits. It has Makefiles for BSD's 4.[123] and SunOS [234].?, so I would expect it to compile under Ultrix with no problem. Cheers, Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
cudcv@warwick.ac.uk (Rob McMahon) (07/05/90)
Well folks, it seems I was horribly wrong. The version of sps I had was not very much like the one on titan.rice.edu at all, and the patches wouldn't patch that version. As recompense I have spent the day doing it right to the version from titan, here are the changes. I've still punted on the NOFILE_IN_U business, but I've written a version of the stream grabbing stuff which works, and even fixed a bug in the environment printing code. The only nasty left is a warning about the inode table not being found. I'm not clear enough on what they've done with it to fix that. Also someone, someday ought to go chasing the processes' files when they fall off the end of the U area. Have fun, Rob =================================================================== *** /dev/null Thu Jul 5 17:56:04 1990 --- Makefile.sun.4.1 Thu Jul 5 17:19:29 1990 *************** *** 0 **** --- 1,52 ---- + # Makefile for SPS (Sun-2, Sun-3 and Sun-4, SunOS 4.1 Version) + + PROG = sps + OBJS = filecount.o findtty.o flagdecode.o flagsetup.o \ + getcmd.o getupage.o globals1.o globals2.o hashuid.o \ + initialise.o initsymbols.o inittty.o main.o mktree.o \ + needed.o openfiles.o percentmem.o prcmd.o prcpu.o \ + prheader.o printall.o printproc.o prsummary.o readstatus.o \ + selectproc.o selecttty.o stream.o termwidth.o ttystatus.o \ + waitingfor.o + INCS = sps.h + #CC = gcc + #OPT = -O -fstrength-reduce -fomit-frame-pointer -fdelayed-branch + #READONLY = + #READWRITE = -fwritable-strings + CC = cc + OPT = -O + READONLY = -R + READWRITE = + CFLAGS = -DSUN -DBSD42 -DNFS -DVPRINTF -DKVM -DSUNOS40 -DSUNOS41 \ + -DOLDSTATS -Isys + LIBS = -ltermlib -lkvm + DIRINSTALL = /usr/kvm + + all: $(PROG) + .c.o: + $(CC) $(CFLAGS) -c $(OPT) $(READONLY) $< + + globals1.o stream.o waitingfor.o: + $(CC) $(CFLAGS) -c $(OPT) $(READWRITE) $*.c + + $(OBJS): sys $(INCS) + + sys: + -mkdir sys + -ln -s /sys/* sys + -ln -s /sys/sys sys/h + + $(PROG): $(OBJS) + $(CC) $(OPT) -o $@ $(OBJS) $(LIBS) + + install: $(PROG) + strip $(PROG) + mv $(PROG) $(DIRINSTALL)/$(PROG) + /etc/chown root $(DIRINSTALL)/$(PROG) + chgrp kmem $(DIRINSTALL)/$(PROG) + chmod 2755 $(DIRINSTALL)/$(PROG) + + lint: + lint -x -b $(CFLAGS) *.c $(LIBS) + clean: + rm -f $(OBJS) $(PROG) =================================================================== RCS file: Makefile.sun.4.0,v retrieving revision 1.1 diff -c -r1.1 Makefile.sun.4.0 *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:28 1990 --- Makefile.sun.4.0 Thu Jul 5 17:21:02 1990 *************** *** 9,15 **** --- 9,22 ---- selectproc.o selecttty.o stream.o termwidth.o ttystatus.o \ waitingfor.o INCS = sps.h + #CC = gcc + #OPT = -O -fstrength-reduce -fomit-frame-pointer -fdelayed-branch + #READONLY = + #READWRITE = -fwritable-strings CC = cc + OPT = -O + READONLY = -R + READWRITE = CFLAGS = -DSUN -DBSD42 -DNFS -DVPRINTF -DKVM -DSUNOS40 -DOLDSTATS -Isys LIBS = -ltermlib -lkvm DIRINSTALL = /usr/kvm *************** *** 16,25 **** all: $(PROG) .c.o: ! $(CC) $(CFLAGS) -c -O -R $< globals1.o stream.o waitingfor.o: ! $(CC) $(CFLAGS) -c -O $< $(OBJS): sys $(INCS) --- 23,32 ---- all: $(PROG) .c.o: ! $(CC) $(CFLAGS) -c $(OPT) $(READONLY) $< globals1.o stream.o waitingfor.o: ! $(CC) $(CFLAGS) -c $(OPT) $(READWRITE) $*.c $(OBJS): sys $(INCS) *************** *** 29,35 **** -ln -s /sys/sys sys/h $(PROG): $(OBJS) ! $(CC) -o $@ $(OBJS) $(LIBS) install: $(PROG) strip $(PROG) --- 36,42 ---- -ln -s /sys/sys sys/h $(PROG): $(OBJS) ! $(CC) $(OPT) -o $@ $(OBJS) $(LIBS) install: $(PROG) strip $(PROG) =================================================================== RCS file: filecount.c,v retrieving revision 1.1 diff -c -r1.1 filecount.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:28 1990 --- filecount.c Thu Jul 5 10:13:43 1990 *************** *** 13,19 **** --- 13,24 ---- extern union userstate User ; count = 0 ; + #ifdef SUNOS41 + /* too hard to do right at the moment ... */ + for ( i = 0, f = User.u_us.u_ofile_arr ; i < NOFILE_IN_U ; i++ ) + #else /* ! SUNOS41 */ for ( i = 0, f = User.u_us.u_ofile ; i < NOFILE ; i++ ) + #endif /* SUNOS41 */ if ( *f++ ) count++ ; return ( count ) ; =================================================================== RCS file: getcmd.c,v retrieving revision 1.1 diff -c -r1.1 getcmd.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:28 1990 --- getcmd.c Thu Jul 5 17:12:31 1990 *************** *** 89,96 **** p->pr_csaved = 1 ; sp = argbuf.a_argc ; nbad = 0 ; ! for ( ap = argv ; *ap || ! ( argv && free( (char*)argv ), argv = 0, Flg.flg_e && *( ap = env ) ) ; *sp++ = ' ' ) for ( cp = *ap++ ; *cp ; *sp++ = *cp++ ) { --- 89,98 ---- p->pr_csaved = 1 ; sp = argbuf.a_argc ; nbad = 0 ; ! for ( ap = argv ; ! *ap || ( argv && ! ( free( (char*)argv ), argv = 0, ! Flg.flg_e && *( ap = env ) ) ); *sp++ = ' ' ) for ( cp = *ap++ ; *cp ; *sp++ = *cp++ ) { =================================================================== RCS file: getupage.c,v retrieving revision 1.1 diff -c -r1.1 getupage.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:29 1990 --- getupage.c Thu Jul 5 11:09:09 1990 *************** *** 113,128 **** struct user *upage ; extern union userstate User ; extern kvm_t *Flkvm ; ! if (upage = kvm_getu( Flkvm, &p->pr_p ) ) { ! bcopy( (char *) upage, User.u_pg[0], sizeof( struct user ) ) ; ! return ( 1 ) ; } ! fprintf( stderr, ! "sps - Can't read upage of process %d\n", ! p->pr_p.p_pid ) ; ! return ( 0 ) ; } # endif --- 113,143 ---- struct user *upage ; extern union userstate User ; extern kvm_t *Flkvm ; + #ifdef SUNOS41 + static struct sess Sess; + #endif ! if ( (upage = kvm_getu( Flkvm, &p->pr_p )) == NULL ) { ! fprintf( stderr, ! "sps - Can't read upage of process %d\n", ! p->pr_p.p_pid ) ; ! return ( 0 ) ; } ! bcopy( (char *) upage, User.u_pg[0], sizeof( struct user ) ) ; ! #ifdef SUNOS41 ! if ( kvm_read( Flkvm, p->pr_p.p_sessp, (char *)&Sess, sizeof( Sess )) ! != sizeof(Sess) ) ! { ! fprintf( stderr, ! "sps - Can't read session of process %d\n", ! p->pr_p.p_pid ) ; ! return ( 0 ) ; ! } ! User.u_us.u_procp = &p->pr_p ; ! p->pr_p.p_sessp = &Sess ; ! #endif /* SUNOS41 */ ! return ( 1 ) ; } # endif =================================================================== RCS file: globals2.c,v retrieving revision 1.1 diff -c -r1.1 globals2.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:29 1990 --- globals2.c Thu Jul 5 15:44:40 1990 *************** *** 74,81 **** --- 74,85 ---- { "_segvn_ops", 0, (caddr_t*)&Info.i_segvn_ops,(char*)0 }, { "_pty_softc", 0, (caddr_t*)&Info.i_ptybase, (char*)0 }, { "_npty", 1, (caddr_t*)&Info.i_npty, (char*)0 }, + # ifndef SUNOS41 { "_streams", 0, (caddr_t*)&Info.i_streams, (char*)0 }, { "_streamsNSTREAMS",1,(caddr_t*)&Info.i_streamsNSTREAMS,(char*)0}, + # else + { "_allstream", 0, (caddr_t*)&Info.i_allstream,(char*)0 }, + # endif { "_Sysbase", 1, (caddr_t*)&Info.i_sysbase, (char*)0 }, # endif /* Kernel addresses associated with process wait states. =================================================================== RCS file: main.c,v retrieving revision 1.1 diff -c -r1.1 main.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:30 1990 --- main.c Thu Jul 5 10:55:59 1990 *************** *** 26,31 **** --- 26,35 ---- <dupuy@ncs.columbia.edu> and Charlie Kim <cck@cunixc.cc.columbia.edu>. Ultrix 2.x support by Rob Lehman at CUCCA. */ + /* First attempt at SunOS 4.1 support by Rob McMahon <cudcv@warwick.ac.uk> + - 5 Jul 1990 + */ + main ( argc,argv ) int argc ; =================================================================== RCS file: sps.h,v retrieving revision 1.1 diff -c -r1.1 sps.h *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:30 1990 --- sps.h Thu Jul 5 15:44:28 1990 *************** *** 22,30 **** ** in a hash table, this should probably be at least double the number ** of actual users defined in /etc/passwd or by the Yellow Pages.) */ ! # define MAXUSERS 100 /* Maximum # ttys to be considered, plus 1 for the console ... */ ! # define MAXTTYS 65 /* Maximum user name length ... */ --- 22,30 ---- ** in a hash table, this should probably be at least double the number ** of actual users defined in /etc/passwd or by the Yellow Pages.) */ ! # define MAXUSERS 5000 /* Maximum # ttys to be considered, plus 1 for the console ... */ ! # define MAXTTYS 129 /* Maximum user name length ... */ *************** *** 146,153 **** --- 146,157 ---- struct seg_ops *i_segvn_ops ; /* ptr to vnode segment ops */ struct pty *i_ptybase ; int i_npty ; + # ifndef SUNOS41 struct stdata *i_streams ; /* streams list */ struct stdata *i_streamsNSTREAMS ; + # else + struct stdata *i_allstream ; /* streams list */ + # endif caddr_t i_sysbase ; # endif } ; =================================================================== RCS file: stream.c,v retrieving revision 1.1 diff -c -r1.1 stream.c *** /tmp/,RCSt1a02918 Thu Jul 5 17:47:30 1990 --- stream.c Thu Jul 5 16:40:25 1990 *************** *** 8,13 **** --- 8,82 ---- # include <h/vnode.h> static struct stdata *pstreams ; + + # ifdef SUNOS41 + + init_streams_tab() + { + struct stdata *s, *nexts, *p ; + struct vnode *v ; + extern struct info Info ; + + if ( pstreams ) + { + for ( s = pstreams ; s ; s = nexts ) + { + if ( s->sd_vnode != 0 ) + free( (char *)s->sd_vnode ) ; + nexts = s->sd_next ; + free( (char *)s ) ; + } + pstreams = 0; + } + + if ( getkmem( (long)Info.i_allstream, (char *)&p, sizeof( p )) + != sizeof( struct stdata * ) ) + return( 0 ); + s = pstreams = (struct stdata *)getcore( sizeof( struct stdata ) ) ; + while ( p ) + { + if ( getkmem( (long)p, (char *)s, sizeof( struct stdata ) ) + != sizeof( struct stdata ) ) + return ( 0 ); + if ( s->sd_vnode != 0 ) + { + if ( ( v = (struct vnode*)getcore( sizeof( *v ) ) ) + && getkmem( (long)s->sd_vnode, (char*)v, sizeof( *v ) ) + != sizeof( *v ) ) + { + s->sd_vnode = 0 ; + } + + s->sd_vnode = v ; + } + p = s->sd_next ; + if ( p ) + { + s->sd_next = (struct stdata *) + getcore( sizeof( struct stdata ) ) ; + } + s = s->sd_next ; + } + return( 1 ) ; + } + + struct stdata *getstdata ( st, dev ) + + struct streamtab *st ; + dev_t dev ; + + { + register struct stdata *s ; + + for ( s = pstreams ; s ; s = s->sd_next ) + if ( s->sd_strtab == st && s->sd_vnode + && s->sd_vnode->v_rdev == dev ) + return( s ); + return( 0 ) ; + } + + #else /* ! SUNOS41 */ + static struct stdata *pstreamsNSTREAMS ; init_streams_tab() *************** *** 68,73 **** --- 137,144 ---- return( 0 ) ; } + + #endif /* SUNOS41 */ /* 1 if `w' is in the address range defined by `a1' and `a2' ... */ # define INRANGE( w, a1, a2 ) \ -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England