-unmount1(fname, forcibly)
- caddr_t fname;
- int forcibly;
-{
- dev_t dev;
- register struct mount *mp;
- int stillopen, flag, error;
- register struct inode *ip;
- register struct fs *fs;
-
- error = getmdev(&dev, fname);
- if (error)
- return (error);
- for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
- if (mp->m_bufp != NULL && dev == mp->m_dev)
- goto found;
- return (EINVAL);
-found:
- xumount(dev); /* remove unused sticky files from text table */
- nchinval(dev); /* flush the name cache */
- update();
-#ifdef QUOTA
- if ((stillopen = iflush(dev, mp->m_qinod)) < 0 && !forcibly)
-#else
- if ((stillopen = iflush(dev)) < 0 && !forcibly)
-#endif
- return (EBUSY);
- if (stillopen < 0)
- return (EBUSY); /* XXX */
-#ifdef QUOTA
- closedq(mp);
- /*
- * Here we have to iflush again to get rid of the quota inode.
- * A drag, but it would be ugly to cheat, & this doesn't happen often
- */
- (void)iflush(dev, (struct inode *)NULL);
-#endif
- ip = mp->m_inodp;
- ip->i_flag &= ~IMOUNT;
- irele(ip);
- fs = mp->m_bufp->b_un.b_fs;
- wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
- flag = !fs->fs_ronly;
- brelse(mp->m_bufp);
- mp->m_bufp = 0;
- mp->m_dev = 0;
- mpurge(mp - &mount[0]);
- if (!stillopen) {
- (*bdevsw[major(dev)].d_close)(dev, flag);
- binval(dev);
- }
- return (0);
-}
-
-sbupdate(mp)
- struct mount *mp;