+/*
+ * remove any inodes in the inode cache belonging to dev
+ *
+ * There should not be any active ones, return error if any are found
+ * (nb: this is a user error, not a system err)
+ *
+ * Also, count the references to dev by block devices - this really
+ * has nothing to do with the object of the procedure, but as we have
+ * to scan the inode table here anyway, we might as well get the
+ * extra benefit.
+ *
+ * this is called from sumount()/sys3.c when dev is being unmounted
+ */
+iflush(dev)
+ dev_t dev;
+{
+ register struct inode *ip;
+ register open = 0;
+
+ for (ip = inode; ip < inodeNINODE; ip++) {
+ if (ip->i_dev == dev)
+ if (ip->i_count)
+ return(-1);
+ else {
+ remque(ip);
+ ip->i_forw = ip;
+ ip->i_back = ip;
+ /*
+ * as i_count == 0, the inode was on the free
+ * list already, just leave it there, it will
+ * fall off the bottom eventually. We could
+ * perhaps move it to the head of the free
+ * list, but as umounts are done so
+ * infrequently, we would gain very little,
+ * while making the code bigger.
+ */
+ }
+ else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
+ ip->i_rdev == dev)
+ open++;
+ }
+ return (open);
+}
+