patch-2.1.49 linux/fs/ext2/namei.c

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

diff -u --recursive --new-file v2.1.48/linux/fs/ext2/namei.c linux/fs/ext2/namei.c
@@ -201,7 +201,7 @@
 
 	*err = -EINVAL;
 	*res_dir = NULL;
-	if (!dir)
+	if (!dir || !dir->i_nlink)
 		return NULL;
 	sb = dir->i_sb;
 
@@ -351,10 +351,13 @@
 	struct inode * inode;
 	struct buffer_head * bh;
 	struct ext2_dir_entry * de;
-	int err;
+	int err = -EIO;
 
 	if (!dir)
 		return -ENOENT;
+	/*
+	 * N.B. Several error exits in ext2_new_inode don't set err.
+	 */
 	inode = ext2_new_inode (dir, mode, &err);
 	if (!inode)
 		return err;
@@ -386,7 +389,7 @@
 	struct inode * inode;
 	struct buffer_head * bh;
 	struct ext2_dir_entry * de;
-	int err;
+	int err = -EIO;
 
 	if (!dir)
 		return -ENOENT;
@@ -443,7 +446,7 @@
 	struct inode * inode;
 	struct buffer_head * bh, * dir_block;
 	struct ext2_dir_entry * de;
-	int err;
+	int err = -EIO;
 
 	if (dentry->d_name.len > EXT2_NAME_LEN)
 		return -ENAMETOOLONG;
@@ -714,8 +717,7 @@
 	struct inode * inode = NULL;
 	struct buffer_head * bh = NULL, * name_block = NULL;
 	char * link;
-	int i, err;
-	int l;
+	int i, l, err = -EIO;
 	char c;
 
 	if (!(inode = ext2_new_inode (dir, S_IFLNK, &err))) {
@@ -975,8 +977,7 @@
 	}
 
 	/* Update the dcache */
-	d_move(old_dentry, new_dentry->d_parent, &new_dentry->d_name);
-	d_delete(new_dentry);
+	d_move(old_dentry, new_dentry);
 	retval = 0;
 end_rename:
 	brelse (dir_bh);

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