patch-2.1.131 linux/fs/vfat/namei.c

Next file: linux/include/asm-i386/semaphore.h
Previous file: linux/fs/umsdos/rdir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.130/linux/fs/vfat/namei.c linux/fs/vfat/namei.c
@@ -1422,6 +1422,8 @@
 	if (dir->i_dev != dentry->d_inode->i_dev || dir == dentry->d_inode) {
 		return -EBUSY;
 	}
+	if (!list_empty(&dentry->d_hash))
+		return -EBUSY;
 
 	res = vfat_empty(dentry->d_inode);
 	if (res) {
@@ -1508,18 +1510,16 @@
 			tmp = next;
 			next = tmp->next;
 			alias = list_entry(tmp, struct dentry, d_alias);
+			if (alias == dentry)
+				continue;
+
 			if (inode) {
 				list_del(&alias->d_alias);
 				iput(alias->d_inode);
 				d_instantiate(alias, inode);
-				/* dentry is already accounted for */
-				if (alias != dentry) {
-					inode->i_count++;
-				}
-			}
-			if (alias != dentry) {
-				d_drop(alias);
+				inode->i_count++;
 			}
+			d_drop(alias);
 		}
 	}
 }
@@ -1551,10 +1551,12 @@
 {
 	int res;
 	PRINTK1(("vfat_rmdir: dentry=%p, inode=%p\n", dentry, dentry->d_inode));
-	res = vfat_rmdirx(dir, dentry);
-	if (res >= 0) {
-		drop_replace_inodes(dentry, NULL);
-		d_delete(dentry);
+
+	res = -EBUSY;
+	if (list_empty(&dentry->d_hash)) {
+		res = vfat_rmdirx(dir, dentry);
+		if (res >= 0)
+			drop_replace_inodes(dentry, NULL);
 	}
 	return res;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov