From: Tom Zanussi <zanussi@us.ibm.com>
To: akpm@osdl.org
Cc: nathans@sgi.com, axboe@suse.de, linux-kernel@vger.kernel.org
Subject: [-mm patch] relayfs: relayfs_remove fix
Date: Wed, 31 Aug 2005 16:56:01 -0500 [thread overview]
Message-ID: <17174.10097.194063.644921@tut.ibm.com> (raw)
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);
}
reply other threads:[~2005-08-31 21:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17174.10097.194063.644921@tut.ibm.com \
--to=zanussi@us.ibm.com \
--cc=akpm@osdl.org \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nathans@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®