From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Dilger Subject: Re: [PATCH] hfsplus: disable rename of directory hardlinks Date: Tue, 3 May 2011 11:10:20 -0600 Message-ID: References: <4DC00D13.5060903@gmail.com> <1304432773-6212-1-git-send-email-grddev@gmail.com> Mime-Version: 1.0 (iPhone Mail 8H7) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Cc: Christoph Hellwig , Al Viro , "linux-fsdevel@vger.kernel.org" To: Gustav Munkby Return-path: Received: from shawmail.shawcable.com ([64.59.128.220]:51651 "EHLO mail.shawcable.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753988Ab1ECRKS convert rfc822-to-8bit (ORCPT ); Tue, 3 May 2011 13:10:18 -0400 In-Reply-To: <1304432773-6212-1-git-send-email-grddev@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 2011-05-03, at 8:26 AM, Gustav Munkby wrote: > Signed-off-by: Gustav Munkby > --- > 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. > + */ It should also be safe to rename a directory hard link if the source and target parent directories are the same. This would allow the case of changing the directory name without moving it to another location. > + 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html