7f6230e
Path: news.gmane.org!not-for-mail
7f6230e
From: Matthew Garrett <mjg@redhat.com>
7f6230e
Newsgroups: gmane.linux.kernel,gmane.linux.file-systems
7f6230e
Subject: [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks
7f6230e
Date: Mon, 16 Apr 2012 16:57:18 -0400
7f6230e
Lines: 45
7f6230e
Approved: news@gmane.org
7f6230e
Message-ID: <1334609838-14831-1-git-send-email-mjg@redhat.com>
7f6230e
NNTP-Posting-Host: plane.gmane.org
7f6230e
X-Trace: dough.gmane.org 1334609870 7622 80.91.229.3 (16 Apr 2012 20:57:50 GMT)
7f6230e
X-Complaints-To: usenet@dough.gmane.org
7f6230e
NNTP-Posting-Date: Mon, 16 Apr 2012 20:57:50 +0000 (UTC)
7f6230e
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
7f6230e
	Matthew Garrett <mjg@redhat.com>
7f6230e
To: hch@infradead.org
7f6230e
Original-X-From: linux-kernel-owner@vger.kernel.org Mon Apr 16 22:57:49 2012
7f6230e
Return-path: <linux-kernel-owner@vger.kernel.org>
7f6230e
Envelope-to: glk-linux-kernel-3@plane.gmane.org
7f6230e
Original-Received: from vger.kernel.org ([209.132.180.67])
7f6230e
	by plane.gmane.org with esmtp (Exim 4.69)
7f6230e
	(envelope-from <linux-kernel-owner@vger.kernel.org>)
7f6230e
	id 1SJszc-0006G8-Gd
7f6230e
	for glk-linux-kernel-3@plane.gmane.org; Mon, 16 Apr 2012 22:57:48 +0200
7f6230e
Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
7f6230e
	id S1755330Ab2DPU5g (ORCPT <rfc822;glk-linux-kernel-3@m.gmane.org>);
7f6230e
	Mon, 16 Apr 2012 16:57:36 -0400
7f6230e
Original-Received: from mx1.redhat.com ([209.132.183.28]:44295 "EHLO mx1.redhat.com"
7f6230e
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
7f6230e
	id S1752969Ab2DPU5e (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
7f6230e
	Mon, 16 Apr 2012 16:57:34 -0400
7f6230e
Original-Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22])
7f6230e
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKvQoA029518
7f6230e
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
7f6230e
	Mon, 16 Apr 2012 16:57:26 -0400
7f6230e
Original-Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
7f6230e
	by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKvP1p017146
7f6230e
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
7f6230e
	Mon, 16 Apr 2012 16:57:26 -0400
7f6230e
Original-Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
7f6230e
	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
7f6230e
	(Exim 4.72)
7f6230e
	(envelope-from <mjg@redhat.com>)
7f6230e
	id 1SJszC-0003jY-P9; Mon, 16 Apr 2012 21:57:23 +0100
7f6230e
X-SA-Do-Not-Run: Yes
7f6230e
X-SA-Exim-Connect-IP: 66.187.233.202
7f6230e
X-SA-Exim-Mail-From: mjg@redhat.com
7f6230e
X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
7f6230e
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
7f6230e
Original-Sender: linux-kernel-owner@vger.kernel.org
7f6230e
Precedence: bulk
7f6230e
List-ID: <linux-kernel.vger.kernel.org>
7f6230e
X-Mailing-List: linux-kernel@vger.kernel.org
7f6230e
Xref: news.gmane.org gmane.linux.kernel:1282933 gmane.linux.file-systems:63394
7f6230e
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1282933>
7f6230e
7f6230e
HFS+ doesn't really implement hard links - instead, hardlinks are indicated
7f6230e
by a magic file type which refers to an indirect node in a hidden
7f6230e
directory. The spec indicates that stat() should return the inode number
7f6230e
of the indirect node, but it turns out that this doesn't satisfy the
7f6230e
firmware when it's looking for a bootloader - it wants the catalog ID of
7f6230e
the hardlink file instead. Fix up this case.
7f6230e
7f6230e
Signed-off-by: Matthew Garrett <mjg@redhat.com>
7f6230e
---
7f6230e
7f6230e
V2 cleans up the casting.
7f6230e
7f6230e
 fs/hfsplus/ioctl.c |    9 +++++++--
7f6230e
 1 file changed, 7 insertions(+), 2 deletions(-)
7f6230e
7f6230e
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
7f6230e
index c640ba5..09addc8 100644
7f6230e
--- a/fs/hfsplus/ioctl.c
7f6230e
+++ b/fs/hfsplus/ioctl.c
7f6230e
@@ -31,6 +31,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
7f6230e
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
7f6230e
 	struct hfsplus_vh *vh = sbi->s_vhdr;
7f6230e
 	struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
7f6230e
+	u32 cnid = (unsigned long)dentry->d_fsdata;
7f6230e
 
7f6230e
 	if (!capable(CAP_SYS_ADMIN))
7f6230e
 		return -EPERM;
7f6230e
@@ -41,8 +42,12 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
7f6230e
 	vh->finder_info[0] = bvh->finder_info[0] =
7f6230e
 		cpu_to_be32(parent_ino(dentry));
7f6230e
 
7f6230e
-	/* Bootloader */
7f6230e
-	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(inode->i_ino);
7f6230e
+	/*
7f6230e
+	 * Bootloader. Just using the inode here breaks in the case of
7f6230e
+	 * hard links - the firmware wants the ID of the hard link file,
7f6230e
+	 * but the inode points at the indirect inode
7f6230e
+	 */
7f6230e
+	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
7f6230e
 
7f6230e
 	/* Per spec, the OS X system folder - same as finder_info[0] here */
7f6230e
 	vh->finder_info[5] = bvh->finder_info[5] =
7f6230e
-- 
7f6230e
1.7.10
7f6230e