From: yan <clouds.yan@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] fs/namei.c: only check mountpoint on non-negative dentry
Date: Fri, 24 Aug 2012 19:51:37 +0800 [thread overview]
Message-ID: <1345809097-854-2-git-send-email-clouds.yan@gmail.com> (raw)
In-Reply-To: <1345809097-854-1-git-send-email-clouds.yan@gmail.com>
Signed-off-by: yan <clouds.yan@gmail.com>
---
fs/namei.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index dd1ed1b..028f5c8 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3628,11 +3628,15 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
return error;
dget(new_dentry);
- if (target)
- mutex_lock(&target->i_mutex);
error = -EBUSY;
- if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry))
+ if (target){
+ mutex_lock(&target->i_mutex);
+ if (d_mountpoint(new_dentry))
+ goto out;
+ }
+
+ if (d_mountpoint(old_dentry))
goto out;
error = -EMLINK;
@@ -3671,11 +3675,15 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
return error;
dget(new_dentry);
- if (target)
- mutex_lock(&target->i_mutex);
error = -EBUSY;
- if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
+ if (target){
+ mutex_lock(&target->i_mutex);
+ if (d_mountpoint(new_dentry))
+ goto out;
+ }
+
+ if (d_mountpoint(old_dentry))
goto out;
error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
--
1.7.9.5
prev parent reply other threads:[~2012-08-24 11:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 11:51 [PATCH 1/2] fs/inode.c: fix legacy comment about inode lock yan
2012-08-24 11:51 ` yan [this message]
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=1345809097-854-2-git-send-email-clouds.yan@gmail.com \
--to=clouds.yan@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.