Annotation of 42BSD/ucb/netstat/mbuf.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)mbuf.c     4.5 82/12/18";
                      3: #endif
                      4: 
                      5: #include <sys/param.h>
                      6: #include <sys/mbuf.h>
                      7: 
                      8: struct mbstat mbstat;
                      9: extern int kmem;
                     10: 
                     11: static struct mbtypes {
                     12:        int     mt_type;
                     13:        char    *mt_name;
                     14: } mbtypes[] = {
                     15:        { MT_DATA,      "data" },
                     16:        { MT_HEADER,    "packet headers" },
                     17:        { MT_SOCKET,    "socket structures" },
                     18:        { MT_PCB,       "protocol control blocks" },
                     19:        { MT_RTABLE,    "routing table entries" },
                     20:        { MT_HTABLE,    "IMP host table entries" },
                     21: #ifdef notdef
                     22:        { MT_ATABLE,    "address resolution tables" },
                     23: #endif
                     24:        { MT_FTABLE,    "fragment reassembly queue headers" },
                     25:        { MT_SONAME,    "socket names and addresses" },
                     26:        { MT_ZOMBIE,    "zombie process information" },
                     27:        { MT_SOOPTS,    "socket options" },
                     28:        { 0, 0 }
                     29: };
                     30: 
                     31: /*
                     32:  * Print mbuf statistics.
                     33:  */
                     34: mbpr(mbaddr)
                     35:        off_t mbaddr;
                     36: {
                     37:        register int totmem, totfree, totmbufs;
                     38:        register struct mbtypes *mp;
                     39: 
                     40:        if (mbaddr == 0) {
                     41:                printf("mbstat: symbol not in namelist\n");
                     42:                return;
                     43:        }
                     44:        klseek(kmem, mbaddr, 0);
                     45:        if (read(kmem, &mbstat, sizeof (mbstat)) != sizeof (mbstat)) {
                     46:                printf("mbstat: bad read\n");
                     47:                return;
                     48:        }
                     49:        printf("%d/%d mbufs in use:\n",
                     50:                mbstat.m_mbufs - mbstat.m_mbfree, mbstat.m_mbufs);
                     51:        totmbufs = 0;
                     52:        for (mp = mbtypes; mp->mt_name; mp++)
                     53:                if (mbstat.m_mtypes[mp->mt_type]) {
                     54:                        printf("\t%d mbufs allocated to %s\n",
                     55:                                mbstat.m_mtypes[mp->mt_type], mp->mt_name);
                     56:                        totmbufs += mbstat.m_mtypes[mp->mt_type];
                     57:                }
                     58:        if (totmbufs != mbstat.m_mbufs - mbstat.m_mbfree)
                     59:                printf("*** %d mbufs missing ***\n",
                     60:                        (mbstat.m_mbufs - mbstat.m_mbfree) - totmbufs);
                     61:        printf("%d/%d mapped pages in use\n",
                     62:                mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
                     63:        totmem = mbstat.m_mbufs * MSIZE + mbstat.m_clusters * CLBYTES;
                     64:        totfree = mbstat.m_mbfree * MSIZE + mbstat.m_clusters * CLBYTES;
                     65:        printf("%d Kbytes allocated to network (%d%% in use)\n",
                     66:                totmem / 1024, (totmem - totfree) * 100 / totmem);
                     67:        printf("%d requests for memory denied\n", mbstat.m_drops);
                     68: }

unix.superglobalmegacorp.com

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