X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppstats%2Fpppstats.c;h=97239de90db642369352582f0ef56ab5ac608c17;hp=5fb2f77af47d3ca1e1e7c4fc071031bb23e21705;hb=79e6517a798202917397da66a20201d725d2134f;hpb=0b63a24d54ba4708c88e31bdd74b0145956c1478 diff --git a/pppstats/pppstats.c b/pppstats/pppstats.c index 5fb2f77..97239de 100644 --- a/pppstats/pppstats.c +++ b/pppstats/pppstats.c @@ -26,7 +26,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; +static char rcsid[] = "$Id: pppstats.c,v 1.2 1993/12/15 05:00:47 paulus Exp $"; #endif #include @@ -34,9 +34,6 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; #include #include #include -#ifndef KVMLIB -#include -#endif #ifdef sun #include #endif @@ -45,6 +42,10 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; #include #include #include +#ifndef sun +#include +#endif + #include #include #include @@ -57,7 +58,7 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; #ifdef STREAMS #include -#include "ppp_str.h" +#include #endif #ifdef STREAMS @@ -74,12 +75,6 @@ struct nlist nl[] = { }; #endif -#ifndef KVMLIB -struct pte *Sysmap; -int kmem; -extern off_t lseek(); -#endif - #ifdef sun kvm_t *kd; #endif @@ -87,18 +82,10 @@ kvm_t *kd; #ifdef sun char *system = "/vmunix"; #else -#ifdef __NetBSD__ -char *system = "/netbsd"; -#else -char *system = "/386bsd"; -#endif +char *system = _PATH_UNIX; #endif -#ifndef KVMLIB -char *kmemf = "/dev/kmem"; -#else char *kmemf; -#endif int kflag; int vflag; unsigned interval = 5; @@ -106,7 +93,6 @@ int unit; extern char *malloc(); - main(argc, argv) int argc; char *argv[]; @@ -145,31 +131,6 @@ main(argc, argv) kflag++; } } -#ifndef KVMLIB - if (nlist(system, nl) < 0 || nl[0].n_type == 0) { - fprintf(stderr, "%s: no namelist\n", system); - exit(1); - } - kmem = open(kmemf, O_RDONLY); - if (kmem < 0) { - perror(kmemf); - exit(1); - } - if (kflag) { - off_t off; - - Sysmap = (struct pte *) - malloc((u_int)(nl[N_SYSSIZE].n_value * sizeof(struct pte))); - if (!Sysmap) { - fputs("netstat: can't get memory for Sysmap.\n", stderr); - exit(1); - } - off = nl[N_SYSMAP].n_value & ~KERNBASE; - (void)lseek(kmem, off, L_SET); - (void)read(kmem, (char *)Sysmap, - (int)(nl[N_SYSSIZE].n_value * sizeof(struct pte))); - } -#else #ifdef sun /* SunOS */ if ((kd = kvm_open(system, kmemf, (char *)0, O_RDONLY, NULL)) == NULL) { @@ -192,29 +153,10 @@ main(argc, argv) fprintf(stderr, "pppstats: can't find symbols in nlist\n"); exit(1); } -#endif intpr(); exit(0); } -#ifndef KVMLIB -/* - * Seek into the kernel for a value. - */ -off_t -klseek(fd, base, off) - int fd, off; - off_t base; -{ - if (kflag) { - /* get kernel pte */ - base &= ~KERNBASE; - base = ctob(Sysmap[btop(base)].pg_pfnum) + (base & PGOFSET); - } - return (lseek(fd, base, off)); -} -#endif - usage() { fprintf(stderr,"usage: pppstats [-i interval] [-v] [unit] [system] [core]\n"); @@ -256,13 +198,6 @@ intpr() bzero((char *)osc, sizeof(STRUCT)); while (1) { -#ifndef KVMLIB - if (klseek(kmem, (off_t)nl[N_SOFTC].n_value, 0) < 0) - if(errno != EINTR) - perror("kmem seek"); - if (read(kmem, (char *)sc, sizeof(STRUCT)) <= 0) - perror("kmem read"); -#else #ifdef sun if (kvm_read(kd, nl[N_SOFTC].n_value, #else @@ -271,7 +206,6 @@ intpr() sc, sizeof(STRUCT)) != sizeof(STRUCT)) perror("kvm_read"); -#endif (void)signal(SIGALRM, catchalarm); signalled = 0;