Commit 004b361e authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] tmpfs 1/5 rename nlink

shmem_rename was not maintaining the correct link count on the
parent directories when a directory was moved from one to another.
This patch from Christoph Rohland <cr@sap.com>, already in 2.5-dj.
parent eccec1ce
......@@ -1137,19 +1137,25 @@ static int shmem_rmdir(struct inode * dir, struct dentry *dentry)
*/
static int shmem_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
{
int error = -ENOTEMPTY;
if (shmem_empty(new_dentry)) {
struct inode *inode = new_dentry->d_inode;
if (inode) {
inode->i_ctime = CURRENT_TIME;
inode->i_nlink--;
dput(new_dentry);
}
error = 0;
old_dentry->d_inode->i_ctime = old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
struct inode *inode;
if (!shmem_empty(new_dentry))
return -ENOTEMPTY;
inode = new_dentry->d_inode;
if (inode) {
inode->i_ctime = CURRENT_TIME;
inode->i_nlink--;
dput(new_dentry);
}
return error;
inode = old_dentry->d_inode;
if (S_ISDIR(inode->i_mode)) {
old_dir->i_nlink--;
new_dir->i_nlink++;
}
inode->i_ctime = old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
return 0;
}
static int shmem_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
......
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