Deleted Added
full compact
39c39
< "$FreeBSD: head/usr.bin/netstat/mbuf.c 80720 2001-07-31 08:19:49Z bmilekic $";
---
> "$FreeBSD: head/usr.bin/netstat/mbuf.c 84153 2001-09-30 01:58:39Z bmilekic $";
57,58d56
< /* XXX: mbtypes stats temporarily disactivated. */
< #if 0
60c58
< int mt_type;
---
> short mt_type;
95d92
< #endif /* 0 */
105c102
< int i, nmbufs, nmbclusters, page_size, num_objs;
---
> int i, j, nmbufs, nmbclusters, page_size, num_objs;
107a105
> short nmbtypes;
108a107
> long *mbtypes = NULL;
111,115d109
<
< /* XXX: mbtypes stats temporarily disabled. */
< #if 0
< int nmbtypes;
< size_t mbtypeslen;
117d110
< u_long *mbtypes = NULL;
120,140d112
< /*
< * XXX
< * We can't kread() mbtypeslen from a core image so we'll
< * bogusly assume it's the same as in the running kernel.
< */
< if (sysctlbyname("kern.ipc.mbtypes", NULL, &mbtypeslen, NULL, 0) < 0) {
< warn("sysctl: retrieving mbtypes length");
< goto err;
< }
< if ((mbtypes = malloc(mbtypeslen)) == NULL) {
< warn("malloc: %lu bytes for mbtypes", (u_long)mbtypeslen);
< goto err;
< }
<
< nmbtypes = mbtypeslen / sizeof(*mbtypes);
< if ((seen = calloc(nmbtypes, sizeof(*seen))) == NULL) {
< warn("calloc");
< goto err;
< }
< #endif
<
171,174d142
< #if 0
< if (kread(mbtaddr, (char *)mbtypes, mbtypeslen))
< goto err;
< #endif
197,203d164
< #if 0
< if (sysctlbyname("kern.ipc.mbtypes", mbtypes, &mbtypeslen, NULL,
< 0) < 0) {
< warn("sysctl: retrieving mbtypes");
< goto err;
< }
< #endif
235a197,206
> nmbtypes = mbstat->m_numtypes;
> if ((seen = calloc(nmbtypes, sizeof(*seen))) == NULL) {
> warn("calloc: cannot allocate memory for mbtypes seen flag");
> goto err;
> }
> if ((mbtypes = calloc(nmbtypes, sizeof(long *))) == NULL) {
> warn("calloc: cannot allocate memory for mbtypes");
> goto err;
> }
>
252a224,225
> for (j = 1; j < nmbtypes; j++)
> mbtypes[j] += mbpstat[GENLST]->mb_mbtypes[j];
262a236,237
> for (j = 1; j < nmbtypes; j++)
> mbtypes[j] += mbpstat[i]->mb_mbtypes[j];
267a243,255
> printf("\tAllocated mbuf types:\n");
> for (mp = mbtypenames; mp->mt_name; mp++) {
> if (mbtypes[mp->mt_type]) {
> seen[mp->mt_type] = YES;
> printf("\t %lu mbufs allocated to %s\n",
> mbtypes[mp->mt_type], mp->mt_name);
> }
> }
> for (i = 1; i < nmbtypes; i++) {
> if (!seen[i] && mbtypes[i])
> printf("\t %lu mbufs allocated to <mbuf type: %d>\n",
> mbtypes[i], i);
> }
303d290
< #if 0
308d294
< #endif