From: Sage Weil Date: Fri, 27 May 2011 20:42:10 +0000 (-0700) Subject: ncpfs: fix rename over directory with dangling references X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=76cc071a06afb4d2dd17bb1b855a233a419e7e02;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git ncpfs: fix rename over directory with dangling references ncpfs does not handle references to unlinked directories (or so it would seem given the ncp_rmdir check). Since it is also possible to rename over an empty directory, perform the same check here. CC: Petr Vandrovec CC: linux-kernel@vger.kernel.org Signed-off-by: Sage Weil Signed-off-by: Al Viro --- diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 81c287d105d5..9c51f621e901 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -1144,8 +1144,16 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, old_dentry->d_parent->d_name.name, old_dentry->d_name.name, new_dentry->d_parent->d_name.name, new_dentry->d_name.name); - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) + if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) { + /* + * fail with EBUSY if there are still references to this + * directory. + */ dentry_unhash(new_dentry); + error = -EBUSY; + if (!d_unhashed(new_dentry)) + goto out; + } ncp_age_dentry(server, old_dentry); ncp_age_dentry(server, new_dentry);