linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustav Munkby <grddev@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>, linux-fsdevel@vger.kernel.org
Subject: [PATCH] hfsplus: disable rename of directory hardlinks
Date: Tue,  3 May 2011 16:26:13 +0200	[thread overview]
Message-ID: <1304432773-6212-1-git-send-email-grddev@gmail.com> (raw)
In-Reply-To: <4DC00D13.5060903@gmail.com>

Signed-off-by: Gustav Munkby <grddev@gmail.com>
---
 fs/hfsplus/dir.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 4df5059..3c35296 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -108,7 +108,7 @@ again:
 	inode = hfsplus_iget(dir->i_sb, cnid);
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
-	if (S_ISREG(inode->i_mode))
+	if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))
 		HFSPLUS_I(inode)->linkid = linkid;
 out:
 	d_add(dentry, inode);
@@ -465,6 +465,13 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
 {
 	int res;
 
+	/* Renaming directory hardlinks to could create loops.
+	 * Conservatively prevent any hardlink renaming.
+	 */
+	if (S_ISDIR(old_dentry->d_inode->i_mode) &&
+			HFSPLUS_I(old_dentry->d_inode)->linkid)
+		return -EPERM;
+
 	/* Unlink destination if it already exists */
 	if (new_dentry->d_inode) {
 		if (S_ISDIR(new_dentry->d_inode->i_mode))
-- 
1.7.5


  reply	other threads:[~2011-05-03 14:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29 10:20 [PATCH] hfsplus: read support for directory hardlinks Gustav Munkby
2011-05-02  8:46 ` Christoph Hellwig
2011-05-02 12:40   ` Al Viro
2011-05-03 14:11     ` Gustav Munkby
2011-05-03 14:26       ` Gustav Munkby [this message]
2011-05-03 17:10         ` [PATCH] hfsplus: disable rename of " Andreas Dilger
2011-05-03 21:29           ` Gustav Munkby
2011-05-04  9:30       ` [PATCH] hfsplus: read support for " Christoph Hellwig
2011-05-04 15:04         ` Gustav Munkby
2011-05-19 11:09           ` Christoph Hellwig
2011-05-19 15:57             ` Gustav Munkby
2011-05-20 10:30               ` [PATCH v2] hfsplus: readonly " Gustav Munkby

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=1304432773-6212-1-git-send-email-grddev@gmail.com \
    --to=grddev@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).