* [-mm patch] relayfs: relayfs_remove fix
@ 2005-08-31 21:56 Tom Zanussi
0 siblings, 0 replies; only message in thread
From: Tom Zanussi @ 2005-08-31 21:56 UTC (permalink / raw)
To: akpm; +Cc: nathans, axboe, linux-kernel
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@us.ibm.com>
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-08-31 21:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-31 21:56 [-mm patch] relayfs: relayfs_remove fix Tom Zanussi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®