patch-2.2.6 linux/fs/ufs/namei.c

Next file: linux/fs/ufs/super.c
Previous file: linux/fs/sysv/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.5/linux/fs/ufs/namei.c linux/fs/ufs/namei.c
@@ -250,12 +250,6 @@
 	swab = sb->u.ufs_sb.s_swab;
 	uspi = sb->u.ufs_sb.s_uspi;
 
-	if (namelen > UFS_MAXNAMLEN)
-	{
-		*err = -ENAMETOOLONG;
-		return NULL;
-	}
-
 	if (!namelen)
 		return NULL;
 	/*
@@ -469,10 +463,6 @@
 	sb = dir->i_sb;
 	flags = sb->u.ufs_sb.s_flags;
 	swab = sb->u.ufs_sb.s_swab;
-	
-	err = -ENAMETOOLONG;
-	if (dentry->d_name.len > UFS_MAXNAMLEN)
-		goto out;
 
 	inode = ufs_new_inode (dir, mode, &err);
 	if (!inode)
@@ -528,10 +518,6 @@
 	sb = dir->i_sb;
 	flags = sb->u.ufs_sb.s_flags;
 	swab = sb->u.ufs_sb.s_swab;
-	
-	err = -ENAMETOOLONG;
-	if (dentry->d_name.len > UFS_MAXNAMLEN)
-		goto out;
 
 	err = -EMLINK;
 	if (dir->i_nlink >= UFS_LINK_MAX)
@@ -670,10 +656,6 @@
 	swab = sb->u.ufs_sb.s_swab;
 		
 	UFSD(("ENTER\n"))
-	
-	retval = -ENAMETOOLONG;
-	if (dentry->d_name.len > UFS_MAXNAMLEN)
-		goto out;
 
 	retval = -ENOENT;
 	bh = ufs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &de);
@@ -687,14 +669,12 @@
 	if (SWAB32(de->d_ino) != inode->i_ino)
 		goto end_rmdir;
 
+	retval = -ENOTEMPTY;
 	if (!ufs_empty_dir (inode))
-		retval = -ENOTEMPTY;
-	else if (SWAB32(de->d_ino) != inode->i_ino)
-		retval = -ENOENT;
-	else {
-		retval = ufs_delete_entry (dir, de, bh);
-		dir->i_version = ++event;
-	}
+		goto end_rmdir;
+
+	retval = ufs_delete_entry (dir, de, bh);
+	dir->i_version = ++event;
 	if (retval)
 		goto end_rmdir;
 	mark_buffer_dirty(bh, 1);
@@ -717,7 +697,6 @@
 
 end_rmdir:
 	brelse (bh);
-out:
 	UFSD(("EXIT\n"))
 	
 	return retval;
@@ -735,10 +714,6 @@
 	sb = dir->i_sb;
 	flags = sb->u.ufs_sb.s_flags;
 	swab = sb->u.ufs_sb.s_swab;
-		
-	retval = -ENAMETOOLONG;
-	if (dentry->d_name.len > UFS_MAXNAMLEN)
-		goto out;
 
 	retval = -ENOENT;
 	bh = ufs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &de);
@@ -779,7 +754,6 @@
 
 end_unlink:
 	brelse (bh);
-out:
 	return retval;
 }
 
@@ -881,9 +855,6 @@
 	if (S_ISDIR(inode->i_mode))
 		return -EPERM;
 
-	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
-		return -EPERM;
-
 	if (inode->i_nlink >= UFS_LINK_MAX)
 		return -EMLINK;
 
@@ -912,17 +883,10 @@
 	((struct ufs_dir_entry *) ((char *) buffer + \
 	SWAB16(((struct ufs_dir_entry *) buffer)->d_reclen)))->d_ino
 /*
- * rename uses retrying to avoid race-conditions: at least they should be
- * minimal.
- * it tries to allocate all the blocks, then sanity-checks, and if the sanity-
- * checks fail, it tries to restart itself again. Very practical - no changes
- * are done until we know everything works ok.. and then all the changes can be
- * done in one fell swoop when we have claimed all the buffers needed.
- *
  * Anybody can rename anything with this: the permission checks are left to the
  * higher-level routines.
  */
-static int do_ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
+int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
 	struct inode * new_dir,	struct dentry * new_dentry )
 {
 	struct super_block * sb;
@@ -941,9 +905,6 @@
 	old_inode = new_inode = NULL;
 	old_bh = new_bh = dir_bh = NULL;
 	new_de = NULL;
-	retval = -ENAMETOOLONG;
-	if (old_dentry->d_name.len > UFS_MAXNAMLEN)
-		goto end_rename;
 
 	old_bh = ufs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len, &old_de);
 	/*
@@ -967,25 +928,14 @@
 			DQUOT_INIT(new_inode);
 		}
 	}
-	retval = 0;
-	if (new_inode == old_inode)
-		goto end_rename;
 	if (S_ISDIR(old_inode->i_mode)) {
-		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)
-				goto end_rename;
 			retval = -ENOTEMPTY;
 			if (!ufs_empty_dir (new_inode))
 				goto end_rename;
 		}
 
+		retval = -EIO;
 		dir_bh = ufs_bread (old_inode, 0, 0, &retval);
 		if (!dir_bh)
 			goto end_rename;
@@ -1042,8 +992,6 @@
 		wait_on_buffer (new_bh);
 	}
 
-	/* Update the dcache */
-	d_move(old_dentry, new_dentry);
 	retval = 0;
 end_rename:
 	brelse (dir_bh);
@@ -1054,36 +1002,3 @@
 	
 	return retval;
 }
-
-/*
- * Ok, rename also locks out other renames, as they can change the parent of
- * a directory, and we don't want any races. Other races are checked for by
- * "do_rename()", which restarts if there are inconsistencies.
- *
- * Note that there is no race between different filesystems: it's only within
- * the same device that races occur: many renames can happen at once, as long
- * as they are on different partitions.
- *
- * In the second extended file system, we use a lock flag stored in the memory
- * super-block.  This way, we really lock other renames only if they occur
- * on the same file system
- */
-int ufs_rename (struct inode * old_dir, struct dentry *old_dentry,
-	struct inode * new_dir,	struct dentry *new_dentry )
-{
-	int result;
-
-	UFSD(("ENTER\n"))
-	
-	while (old_dir->i_sb->u.ufs_sb.s_rename_lock)
-		sleep_on (&old_dir->i_sb->u.ufs_sb.s_rename_wait);
-	old_dir->i_sb->u.ufs_sb.s_rename_lock = 1;
-	result = do_ufs_rename (old_dir, old_dentry, new_dir, new_dentry);
-	old_dir->i_sb->u.ufs_sb.s_rename_lock = 0;
-	wake_up (&old_dir->i_sb->u.ufs_sb.s_rename_wait);
-	
-	UFSD(("EXIT\n"))
-	
-	return result;
-}
- 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)