[-mm patch] relayfs: relayfs_remove fix

From: Tom Zanussi
Date: Wed Aug 31 2005 - 16:57:51 EST


This patch makes relayfs_remove use simple_rmdir for removing
directories instead of simple_unlink. Thanks to Nathan Scott for the
original patch.

Andrew, please apply.

Thanks,

Tom

Signed-off-by: Tom Zanussi <zanussi@xxxxxxxxxx>

diff -urpN -X dontdiff linux-2.6.13-rc6-mm2/fs/relayfs/inode.c linux-2.6.13-rc6-mm2-cur/fs/relayfs/inode.c
--- linux-2.6.13-rc6-mm2/fs/relayfs/inode.c 2005-08-25 18:21:31.000000000 -0500
+++ linux-2.6.13-rc6-mm2-cur/fs/relayfs/inode.c 2005-08-31 17:11:12.000000000 -0500
@@ -189,26 +189,39 @@ struct dentry *relayfs_create_dir(const
/**
* relayfs_remove - remove a file or directory in the relay filesystem
* @dentry: file or directory dentry
+ *
+ * Returns 0 if successful, negative otherwise.
*/
int relayfs_remove(struct dentry *dentry)
{
- struct dentry *parent = dentry->d_parent;
+ struct dentry *parent;
+ int error = 0;
+
+ if (!dentry)
+ return -EINVAL;
+ parent = dentry->d_parent;
if (!parent)
return -EINVAL;

parent = dget(parent);
down(&parent->d_inode->i_sem);
if (dentry->d_inode) {
- simple_unlink(parent->d_inode, dentry);
- d_delete(dentry);
+ if (S_ISDIR(dentry->d_inode->i_mode))
+ error = simple_rmdir(parent->d_inode, dentry);
+ else
+ error = simple_unlink(parent->d_inode, dentry);
+ if (!error)
+ d_delete(dentry);
}
- dput(dentry);
+ if (!error)
+ dput(dentry);
up(&parent->d_inode->i_sem);
dput(parent);

- simple_release_fs(&relayfs_mount, &relayfs_mount_count);
+ if (!error)
+ simple_release_fs(&relayfs_mount, &relayfs_mount_count);

- return 0;
+ return error;
}

/**
@@ -219,9 +232,6 @@ int relayfs_remove(struct dentry *dentry
*/
int relayfs_remove_dir(struct dentry *dentry)
{
- if (!dentry)
- return -EINVAL;
-
return relayfs_remove(dentry);
}



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/