Allow removal of empty directories with high link counts. These can

occur on a filesystem running with soft updates after a crash and
before a background fsck has been run. To prevent discrepancies
from arising in a background fsck that may already be running,
the directory is removed but its inode is not freed and is left
with the residual reference count. When encountered by the
background fsck it will be reclaimed.
This commit is contained in:
mckusick 2005-05-18 22:18:21 +00:00
parent c7cb7f7317
commit 72bafed72f

View File

@ -1645,12 +1645,11 @@ ufs_rmdir(ap)
* tries to remove a locally mounted on directory).
*/
error = 0;
if (ip->i_flag & IN_RENAME) {
if ((ip->i_flag & IN_RENAME) || ip->i_effnlink < 2) {
error = EINVAL;
goto out;
}
if (ip->i_effnlink != 2 ||
!ufs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
if (!ufs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
error = ENOTEMPTY;
goto out;
}