Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!tut.cis.ohio-state.edu!purdue!mentor.cc.purdue.edu!mace.cc.purdue.edu!dls From: dls@mace.cc.purdue.edu (David L Stevens) Newsgroups: comp.sys.next Subject: Re: nlist initialization? Message-ID: <2504@mace.cc.purdue.edu> Date: 6 Jun 89 15:45:35 GMT References: <1499@uw-entropy.ms.washington.edu> <10985@orstcs.CS.ORST.EDU> Reply-To: dls@mace.cc.purdue.edu (David L Stevens) Distribution: usa Organization: PUCC UNIX Group Lines: 111 I run a version of rwhod on 0.9 that reads and prints the load average correctly. Diffs from the the 4.3 rwhod follow. The load average scaling should probably be done from "LSCALE" directly, but if memory serves, I ran into some problems in sys/kernel.h that made this way much easier. They probably aren't insurmountable, but just not worth it to me when I was doing it... *** 4.3BSD rwhod.c Tue Jun 6 10:39:57 1989 --- /usr/src/etc/rwhod.c Thu May 18 13:39:09 1989 *************** *** 51,60 **** struct nlist nl[] = { #define NL_AVENRUN 0 ! { "_avenrun" }, #define NL_BOOTTIME 1 ! { "_boottime" }, ! 0 }; /* --- 51,60 ---- struct nlist nl[] = { #define NL_AVENRUN 0 ! { { "_avenrun" } }, #define NL_BOOTTIME 1 ! { { "_boottime" } }, ! { {0} } }; /* *************** *** 80,86 **** #define RWHODIR "/usr/spool/rwho" int onalrm(); ! char *strcpy(), *sprintf(), *malloc(); char *whittle(); long lseek(); int getkmem(); --- 80,89 ---- #define RWHODIR "/usr/spool/rwho" int onalrm(); ! char *strcpy(), *malloc(); ! #ifndef NeXT ! char *sprintf(); ! #endif /* not NeXT */ char *whittle(); long lseek(); int getkmem(); *************** *** 255,265 **** struct stat stb; register struct whoent *we = mywd.wd_we, *wlast; int cc; ! #ifdef sun long avenrun[3]; ! #else NOT sun double avenrun[3]; ! #endif sun time_t now = time(0); register struct neighbor *np; --- 258,268 ---- struct stat stb; register struct whoent *we = mywd.wd_we, *wlast; int cc; ! #if defined(sun) || defined(NeXT) long avenrun[3]; ! #else /* NOT (sun || NeXT) */ double avenrun[3]; ! #endif /* sun || NeXT */ time_t now = time(0); register struct neighbor *np; *************** *** 321,331 **** (void) lseek(kmemf, (long)nl[NL_AVENRUN].n_value, L_SET); (void) read(kmemf, (char *)avenrun, sizeof (avenrun)); for (i = 0; i < 3; i++) ! #ifdef sun mywd.wd_loadav[i] = htonl((u_long)(((double)avenrun[i]/FSCALE) * 100.)); ! #else NOT sun mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); ! #endif sun cc = (char *)we - (char *)&mywd; mywd.wd_sendtime = htonl(time(0)); mywd.wd_vers = WHODVERSION; --- 324,339 ---- (void) lseek(kmemf, (long)nl[NL_AVENRUN].n_value, L_SET); (void) read(kmemf, (char *)avenrun, sizeof (avenrun)); for (i = 0; i < 3; i++) ! #if defined(sun) mywd.wd_loadav[i] = htonl((u_long)(((double)avenrun[i]/FSCALE) * 100.)); ! #endif /* sun */ ! #if defined(NeXT) ! /* LSCALE must match sys/kernel.h!!! */ ! /* divide by (LSCALE/100) (from sys/kernel.h, LSCALE == 1000) */ ! mywd.wd_loadav[i] = htonl((avenrun[i]+5)/10); ! #else mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); ! #endif cc = (char *)we - (char *)&mywd; mywd.wd_sendtime = htonl(time(0)); mywd.wd_vers = WHODVERSION; -- +-DLS (dls@mace.cc.purdue.edu)