revert previous

This commit is contained in:
mrg 2003-02-11 00:45:02 +00:00
parent 158b157b2a
commit 3b06b649fe

View File

@ -1,4 +1,4 @@
/* $NetBSD: pstat.c,v 1.80 2003/02/10 23:58:27 mrg Exp $ */
/* $NetBSD: pstat.c,v 1.81 2003/02/11 00:45:02 mrg Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95";
#else
__RCSID("$NetBSD: pstat.c,v 1.80 2003/02/10 23:58:27 mrg Exp $");
__RCSID("$NetBSD: pstat.c,v 1.81 2003/02/11 00:45:02 mrg Exp $");
#endif
#endif /* not lint */
@ -161,10 +161,10 @@ int getfiles __P((char **, int *));
int getflags __P((const struct flagbit_desc *, char *, u_int));
struct mount *
getmnt __P((struct mount *));
void kinfo_vnodes __P((int *, char **));
char * kinfo_vnodes __P((int *));
void layer_header __P((void));
int layer_print __P((struct vnode *, int));
void loadvnodes __P((int *, char **));
char * loadvnodes __P((int *));
int main __P((int, char **));
void mount_print __P((struct mount *));
void nfs_header __P((void));
@ -287,12 +287,11 @@ vnodemode()
__P((struct vnode *, int)); /* per-fs data printer */
mp = NULL;
e_vnodebase = loadvnodes(&numvnodes);
if (totalflag) {
loadvnodes(&numvnodes, NULL);
(void)printf("%7d vnodes\n", numvnodes);
return;
goto out;
}
loadvnodes(&numvnodes, &e_vnodebase);
endvnode = e_vnodebase + numvnodes * (VPTRSZ + VNODESZ);
(void)printf("%d active vnodes\n", numvnodes);
@ -339,6 +338,8 @@ vnodemode()
(*vnode_fsprint)(vp, ovflw);
(void)printf("\n");
}
out:
free(e_vnodebase);
}
@ -681,42 +682,41 @@ mount_print(mp)
(void)printf("\n");
}
void
loadvnodes(avnodes, vnodebase)
char *
loadvnodes(avnodes)
int *avnodes;
char **vnodebase;
{
int mib[2];
size_t copysize;
char *vnodebase;
if (memf != NULL) {
/*
* do it by hand
*/
return (kinfo_vnodes(avnodes, vnodebase));
return (kinfo_vnodes(avnodes));
}
mib[0] = CTL_KERN;
mib[1] = KERN_VNODE;
if (sysctl(mib, 2, NULL, &copysize, NULL, 0) == -1)
err(1, "sysctl: KERN_VNODE");
*avnodes = copysize / (VPTRSZ + VNODESZ);
if (vnodebase == NULL)
return;
if (((*vnodebase) = malloc(copysize)) == NULL)
if ((vnodebase = malloc(copysize)) == NULL)
err(1, "malloc");
if (sysctl(mib, 2, *vnodebase, &copysize, NULL, 0) == -1)
if (sysctl(mib, 2, vnodebase, &copysize, NULL, 0) == -1)
err(1, "sysctl: KERN_VNODE");
if (copysize % (VPTRSZ + VNODESZ))
errx(1, "vnode size mismatch");
*avnodes = copysize / (VPTRSZ + VNODESZ);
return (vnodebase);
}
/*
* simulate what a running kernel does in in kinfo_vnode
*/
void
kinfo_vnodes(avnodes, vnodebase)
char *
kinfo_vnodes(avnodes)
int *avnodes;
char **vnodebase;
{
struct mntlist mountlist;
struct mount *mp, mount;
@ -725,8 +725,6 @@ kinfo_vnodes(avnodes, vnodebase)
int numvnodes;
KGET(V_NUMV, numvnodes);
if (vnodebase == NULL)
return;
if ((bp = malloc((numvnodes + 20) * (VPTRSZ + VNODESZ))) == NULL)
err(1, "malloc");
beg = bp;
@ -750,7 +748,7 @@ kinfo_vnodes(avnodes, vnodebase)
break;
}
*avnodes = (bp - beg) / (VPTRSZ + VNODESZ);
*vnodebase = beg;
return (beg);
}
void