Annotation of researchv9/ipc/src/bin/ilstat.c, revision 1.1.1.1

1.1       root        1: #include <sys/param.h>
                      2: #include <sys/types.h>
                      3: #include <sys/stream.h>
                      4: #include <nlist.h>
                      5: #include <stdio.h>
                      6: 
                      7: struct nlist nl[] = {
                      8:        {"_il", 0},
                      9:        {0, 0},
                     10: };
                     11: 
                     12: int kern_fd;
                     13: 
                     14: main(argc, argv)
                     15: char *argv[];
                     16: {
                     17:        char *nuxi, *core;
                     18:        struct block b;
                     19:        struct il{
                     20:                int attached, active, rcvpending;
                     21:                int ipackets, opackets;
                     22:                int ierrors, oerrors;
                     23:                int collisions;
                     24:                int bp;
                     25:                int nbp;
                     26:                int len;
                     27:                int tq;
                     28:                int freebp;
                     29:                unsigned char addr[6];
                     30:        } il;
                     31: 
                     32:        nuxi = "/unix";
                     33:        core = "/dev/kmem";
                     34:        if(argc > 1)
                     35:                nuxi = argv[1];
                     36:        if(argc > 2)
                     37:                core = argv[2];
                     38:        if((kern_fd = open(core, 0)) < 0){
                     39:                perror(core);
                     40:                exit(1);
                     41:        }
                     42:        nlist(nuxi, nl);
                     43:        if(nl[0].n_value == 0){
                     44:                printf("nlist %s error\n", nuxi);
                     45:                exit(1);
                     46:        }
                     47:        if(strcmp(core, "/dev/kmem"))
                     48:                nl[0].n_value &= 0xffffff;
                     49:        lseek(kern_fd, nl[0].n_value, 0);
                     50:        if(read(kern_fd, &il, sizeof(il)) != sizeof(il)){
                     51:                perror("read");
                     52:                exit(1);
                     53:        }
                     54:        printf("%7d input\n", il.ipackets);
                     55:        printf("%7d input errors\n", il.ierrors);
                     56:        printf("%7d output\n", il.opackets);
                     57:        printf("%7d output errors\n", il.oerrors);
                     58:        printf("%7d collisions\n", il.collisions);
                     59: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.