patch-2.1.132 linux/fs/minix/namei.c

Next file: linux/fs/msdos/namei.c
Previous file: linux/fs/hfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.131/linux/fs/minix/namei.c linux/fs/minix/namei.c
@@ -267,13 +267,6 @@
 	inode->i_op = NULL;
 	if (S_ISREG(inode->i_mode))
 		inode->i_op = &minix_file_inode_operations;
-	else if (S_ISDIR(inode->i_mode)) {
-		inode->i_op = &minix_dir_inode_operations;
-		if (dir->i_mode & S_ISGID)
-			inode->i_mode |= S_ISGID;
-	}
-	else if (S_ISLNK(inode->i_mode))
-		inode->i_op = &minix_symlink_inode_operations;
 	else if (S_ISCHR(inode->i_mode))
 		inode->i_op = &chrdev_inode_operations;
 	else if (S_ISBLK(inode->i_mode))
@@ -429,21 +422,8 @@
 	retval = -ENOENT;
 	if (!bh)
 		goto end_rmdir;
-	retval = -EPERM;
 	inode = dentry->d_inode;
 
-        if ((dir->i_mode & S_ISVTX) &&
-            current->fsuid != inode->i_uid &&
-            current->fsuid != dir->i_uid && !capable(CAP_FOWNER))
-		goto end_rmdir;
-	if (inode->i_dev != dir->i_dev)
-		goto end_rmdir;
-	if (inode == dir)	/* we may not delete ".", but "../dir" is ok */
-		goto end_rmdir;
-	if (!S_ISDIR(inode->i_mode)) {
-		retval = -ENOTDIR;
-		goto end_rmdir;
-	}
 	if (!empty_dir(inode)) {
 		retval = -ENOTEMPTY;
 		goto end_rmdir;
@@ -496,10 +476,6 @@
 		schedule();
 		goto repeat;
 	}
-	if ((dir->i_mode & S_ISVTX) &&
-	    current->fsuid != inode->i_uid &&
-	    current->fsuid != dir->i_uid && !capable(CAP_FOWNER))
-		goto end_unlink;
 	if (de->inode != inode->i_ino) {
 		retval = -ENOENT;
 		goto end_unlink;
@@ -655,10 +631,6 @@
 		goto end_rename;
 	old_inode = old_dentry->d_inode;
 	retval = -EPERM;
-	if ((old_dir->i_mode & S_ISVTX) && 
-	    current->fsuid != old_inode->i_uid &&
-	    current->fsuid != old_dir->i_uid && !capable(CAP_FOWNER))
-		goto end_rename;
 	new_inode = new_dentry->d_inode;
 	new_bh = minix_find_entry(new_dir, new_dentry->d_name.name,
 				  new_dentry->d_name.len, &new_de);
@@ -672,32 +644,21 @@
 		retval = 0;
 		goto end_rename;
 	}
-	if (new_inode && S_ISDIR(new_inode->i_mode)) {
-		retval = -EISDIR;
-		if (!S_ISDIR(old_inode->i_mode))
-			goto end_rename;
-		retval = -EINVAL;
-		if (is_subdir(new_dentry, old_dentry))
-			goto end_rename;
-		retval = -ENOTEMPTY;
-		if (!empty_dir(new_inode))
-			goto end_rename;
-		retval = -EBUSY;
-		if (new_inode->i_count > 1)
-			goto end_rename;
-	}
-	retval = -EPERM;
-	if (new_inode && (new_dir->i_mode & S_ISVTX) && 
-	    current->fsuid != new_inode->i_uid &&
-	    current->fsuid != new_dir->i_uid && !capable(CAP_FOWNER))
-		goto end_rename;
 	if (S_ISDIR(old_inode->i_mode)) {
-		retval = -ENOTDIR;
-		if (new_inode && !S_ISDIR(new_inode->i_mode))
-			goto end_rename;
 		retval = -EINVAL;
 		if (is_subdir(new_dentry, old_dentry))
 			goto end_rename;
+		if (new_inode) {
+			/* Prune any children before testing for busy */
+			if (new_dentry->d_count > 1)
+				shrink_dcache_parent(new_dentry);
+			retval = -EBUSY;
+			if (new_dentry->d_count > 1)
+			retval = -ENOTEMPTY;
+			if (!empty_dir(new_inode))
+				goto end_rename;
+			retval = -EBUSY;
+		}
 		retval = -EIO;
 		dir_bh = minix_bread(old_inode,0,0);
 		if (!dir_bh)

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