Commit 3e1b0887 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] simple_rename() link count fix

From Hugh Dickins

simple_rename, like shmem_rename until I fixed that a few weeks ago,
got the parent directory's link count wrong in the exceptional case
of renaming a directory in place of an existing empty directory.
parent 7f384002
...@@ -262,17 +262,16 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -262,17 +262,16 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry)
int simple_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) int simple_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
{ {
struct inode *inode; int they_are_dirs = S_ISDIR(old_dentry->d_inode->i_mode);
if (!simple_empty(new_dentry)) if (!simple_empty(new_dentry))
return -ENOTEMPTY; return -ENOTEMPTY;
inode = new_dentry->d_inode; if (new_dentry->d_inode) {
if (inode) { simple_unlink(new_dir, new_dentry);
inode->i_nlink--; if (they_are_dirs)
dput(new_dentry); old_dir->i_nlink--;
} } else if (they_are_dirs) {
if (S_ISDIR(old_dentry->d_inode->i_mode)) {
old_dir->i_nlink--; old_dir->i_nlink--;
new_dir->i_nlink++; new_dir->i_nlink++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment