+ if (waitfor == MNT_WAIT)
+ error = bwrite(bp);
+ else
+ bawrite(bp);
+ }
+ return (error);
+}
+
+/*
+ * Print out statistics on the current allocation of the buffer pool.
+ * Can be enabled to print out on every ``sync'' by setting "syncprt"
+ * above.
+ */
+bufstats()
+{
+ int s, i, j, count;
+ register struct buf *bp, *dp;
+ int counts[MAXBSIZE/CLBYTES+1];
+ static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE", "EMPTY" };
+
+ for (bp = bfreelist, i = 0; bp < &bfreelist[BQUEUES]; bp++, i++) {
+ count = 0;
+ for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
+ counts[j] = 0;
+ s = splbio();
+ for (dp = bp->av_forw; dp != bp; dp = dp->av_forw) {
+ counts[dp->b_bufsize/CLBYTES]++;
+ count++;
+ }
+ splx(s);
+ printf("%s: total-%d", bname[i], count);
+ for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
+ if (counts[j] != 0)
+ printf(", %d-%d", j * CLBYTES, counts[j]);
+ printf("\n");
+ }
+}
+
+/*
+ * File handle to vnode
+ *
+ * Have to be really careful about stale file handles:
+ * - check that the inode number is in range
+ * - call iget() to get the locked inode
+ * - check for an unallocated inode (i_mode == 0)
+ * - check that the generation number matches
+ */
+ufs_fhtovp(mp, fhp, vpp)
+ register struct mount *mp;
+ struct fid *fhp;
+ struct vnode **vpp;
+{
+ register struct ufid *ufhp;
+ register struct fs *fs;
+ register struct inode *ip;
+ struct inode *nip;
+ struct vnode tvp;
+ int error;
+
+ ufhp = (struct ufid *)fhp;
+ fs = VFSTOUFS(mp)->um_fs;
+ if (ufhp->ufid_ino < ROOTINO ||
+ ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) {
+ *vpp = (struct vnode *)0;
+ return (EINVAL);
+ }
+ tvp.v_mount = mp;
+ ip = VTOI(&tvp);
+ ip->i_vnode = &tvp;
+ ip->i_dev = VFSTOUFS(mp)->um_dev;
+ if (error = iget(ip, ufhp->ufid_ino, &nip)) {
+ *vpp = (struct vnode *)0;
+ return (error);
+ }
+ ip = nip;
+ if (ip->i_mode == 0) {
+ iput(ip);
+ *vpp = (struct vnode *)0;
+ return (EINVAL);