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

Next file: linux/fs/autofs/inode.c
Previous file: linux/fs/affs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.131/linux/fs/affs/namei.c linux/fs/affs/namei.c
@@ -241,10 +241,6 @@
 		goto unlink_done;
 
 	inode  = dentry->d_inode;
-	retval = -EPERM;
-	if (current->fsuid != inode->i_uid &&
-	    current->fsuid != dir->i_uid && !capable(CAP_FOWNER))
-		goto unlink_done;
 
 	if ((retval = affs_remove_header(bh,inode)) < 0)
 		goto unlink_done;
@@ -319,7 +315,7 @@
 	error       = affs_add_entry(dir,NULL,inode,dentry,ST_USERDIR);
 	if (error)
 		goto out_iput;
-	inode->i_mode = S_IFDIR | (mode & 0777 & ~current->fs->umask);
+	inode->i_mode = S_IFDIR | S_ISVTX | (mode & 0777 & ~current->fs->umask);
 	inode->u.affs_i.i_protect = mode_to_prot(inode->i_mode);
 	d_instantiate(dentry,inode);
 	mark_inode_dirty(inode);
@@ -360,17 +356,6 @@
 	if (!(bh = affs_find_entry(dir,dentry,&ino)))
 		goto rmdir_done;
 
-	retval = -EPERM;
-        if (current->fsuid != inode->i_uid &&
-            current->fsuid != dir->i_uid && !capable(CAP_FOWNER))
-		goto rmdir_done;
-	if (inode->i_dev != dir->i_dev)
-		goto rmdir_done;
-	if (inode == dir)	/* we may not delete ".", but "../dir" is ok */
-		goto rmdir_done;
-	retval = -ENOTDIR;
-	if (!S_ISDIR(inode->i_mode))
-		goto rmdir_done;
 	/*
 	 * Make sure the directory is empty and the dentry isn't busy.
 	 */
@@ -574,29 +559,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;
-		if (new_dentry->d_count > 1)
-			shrink_dcache_parent(new_dentry);
-		retval = -ENOTEMPTY;
-		if (!empty_dir(new_bh,AFFS_I2HSIZE(new_inode)))
-			goto end_rename;
-		retval = -EBUSY;
-		if (new_dentry->d_count > 1)
-			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) {
+			if (new_dentry->d_count > 1)
+				shrink_dcache_parent(new_dentry);
+			retval = -EBUSY;
+			if (new_dentry->d_count > 1)
+				goto end_rename;
+			retval = -ENOTEMPTY;
+			if (!empty_dir(new_bh,AFFS_I2HSIZE(new_inode)))
+				goto end_rename;
+		}
+
 		if (affs_parent_ino(old_inode) != old_dir->i_ino)
 			goto end_rename;
 	}

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