]> git.ozlabs.org Git - ppp.git/commitdiff
take out non-KVMLIB code, use _PATH_UNIX on *bsd
authorPaul Mackerras <paulus@samba.org>
Wed, 15 Dec 1993 05:00:47 +0000 (05:00 +0000)
committerPaul Mackerras <paulus@samba.org>
Wed, 15 Dec 1993 05:00:47 +0000 (05:00 +0000)
pppstats/pppstats.c

index 5fb2f77af47d3ca1e1e7c4fc071031bb23e21705..97239de90db642369352582f0ef56ab5ac608c17 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #ifndef lint
  */
 
 #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 <sys/param.h>
 #endif
 
 #include <sys/param.h>
@@ -34,9 +34,6 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $";
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/file.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/file.h>
-#ifndef KVMLIB
-#include <machine/pte.h>
-#endif
 #ifdef sun
 #include <kvm.h>
 #endif
 #ifdef sun
 #include <kvm.h>
 #endif
@@ -45,6 +42,10 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $";
 #include <nlist.h>
 #include <stdio.h>
 #include <signal.h>
 #include <nlist.h>
 #include <stdio.h>
 #include <signal.h>
+#ifndef sun
+#include <paths.h>
+#endif
+
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -57,7 +58,7 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1993/11/11 03:54:25 paulus Exp $";
 
 #ifdef STREAMS
 #include <sys/stream.h>
 
 #ifdef STREAMS
 #include <sys/stream.h>
-#include "ppp_str.h"
+#include <net/ppp_str.h>
 #endif
 
 #ifdef STREAMS
 #endif
 
 #ifdef STREAMS
@@ -74,12 +75,6 @@ struct nlist nl[] = {
 };
 #endif
 
 };
 #endif
 
-#ifndef KVMLIB
-struct pte *Sysmap;
-int    kmem;
-extern off_t lseek();
-#endif
-
 #ifdef sun
 kvm_t  *kd;
 #endif
 #ifdef sun
 kvm_t  *kd;
 #endif
@@ -87,18 +82,10 @@ kvm_t       *kd;
 #ifdef sun
 char   *system = "/vmunix";
 #else
 #ifdef sun
 char   *system = "/vmunix";
 #else
-#ifdef __NetBSD__
-char   *system = "/netbsd";
-#else
-char   *system = "/386bsd";
-#endif
+char   *system = _PATH_UNIX;
 #endif
 
 #endif
 
-#ifndef KVMLIB
-char   *kmemf = "/dev/kmem";
-#else
 char   *kmemf;
 char   *kmemf;
-#endif
 int    kflag;
 int    vflag;
 unsigned interval = 5;
 int    kflag;
 int    vflag;
 unsigned interval = 5;
@@ -106,7 +93,6 @@ int  unit;
 
 extern char *malloc();
 
 
 extern char *malloc();
 
-
 main(argc, argv)
        int argc;
        char *argv[];
 main(argc, argv)
        int argc;
        char *argv[];
@@ -145,31 +131,6 @@ main(argc, argv)
                        kflag++;
                }
        }
                        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) {
 #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);
        }
          fprintf(stderr, "pppstats: can't find symbols in nlist\n");
          exit(1);
        }
-#endif
        intpr();
        exit(0);
 }
 
        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");
 usage()
 {
        fprintf(stderr,"usage: pppstats [-i interval] [-v] [unit] [system] [core]\n");
@@ -256,13 +198,6 @@ intpr()
        bzero((char *)osc, sizeof(STRUCT));
 
        while (1) {
        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
 #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");
                             sc, sizeof(STRUCT)) !=
                    sizeof(STRUCT))
                  perror("kvm_read");
-#endif
 
                (void)signal(SIGALRM, catchalarm);
                signalled = 0;
 
                (void)signal(SIGALRM, catchalarm);
                signalled = 0;