diff options
-rw-r--r-- | fs/namei.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/namei.c b/fs/namei.c index 18c3293411f1..ecb16d3727ea 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2963,7 +2963,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
2963 | struct inode *new_dir, struct dentry *new_dentry) | 2963 | struct inode *new_dir, struct dentry *new_dentry) |
2964 | { | 2964 | { |
2965 | int error = 0; | 2965 | int error = 0; |
2966 | struct inode *target; | 2966 | struct inode *target = new_dentry->d_inode; |
2967 | 2967 | ||
2968 | /* | 2968 | /* |
2969 | * If we are going to change the parent - check write permissions, | 2969 | * If we are going to change the parent - check write permissions, |
@@ -2979,20 +2979,24 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
2979 | if (error) | 2979 | if (error) |
2980 | return error; | 2980 | return error; |
2981 | 2981 | ||
2982 | target = new_dentry->d_inode; | ||
2983 | if (target) | 2982 | if (target) |
2984 | mutex_lock(&target->i_mutex); | 2983 | mutex_lock(&target->i_mutex); |
2985 | if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) | 2984 | |
2986 | error = -EBUSY; | 2985 | error = -EBUSY; |
2987 | else | 2986 | if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry)) |
2988 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); | 2987 | goto out; |
2988 | |||
2989 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); | ||
2990 | if (error) | ||
2991 | goto out; | ||
2992 | |||
2989 | if (target) { | 2993 | if (target) { |
2990 | if (!error) { | 2994 | target->i_flags |= S_DEAD; |
2991 | target->i_flags |= S_DEAD; | 2995 | dont_mount(new_dentry); |
2992 | dont_mount(new_dentry); | ||
2993 | } | ||
2994 | mutex_unlock(&target->i_mutex); | ||
2995 | } | 2996 | } |
2997 | out: | ||
2998 | if (target) | ||
2999 | mutex_unlock(&target->i_mutex); | ||
2996 | if (!error) | 3000 | if (!error) |
2997 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) | 3001 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) |
2998 | d_move(old_dentry,new_dentry); | 3002 | d_move(old_dentry,new_dentry); |