linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks
@ 2012-04-16 20:57 Matthew Garrett
  2012-06-13 11:57 ` Josh Boyer
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Garrett @ 2012-04-16 20:57 UTC (permalink / raw)
  To: hch; +Cc: linux-fsdevel, linux-kernel, Matthew Garrett

HFS+ doesn't really implement hard links - instead, hardlinks are indicated
by a magic file type which refers to an indirect node in a hidden
directory. The spec indicates that stat() should return the inode number
of the indirect node, but it turns out that this doesn't satisfy the
firmware when it's looking for a bootloader - it wants the catalog ID of
the hardlink file instead. Fix up this case.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---

V2 cleans up the casting.

 fs/hfsplus/ioctl.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index c640ba5..09addc8 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -31,6 +31,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
 	struct hfsplus_vh *vh = sbi->s_vhdr;
 	struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
+	u32 cnid = (unsigned long)dentry->d_fsdata;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -41,8 +42,12 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
 	vh->finder_info[0] = bvh->finder_info[0] =
 		cpu_to_be32(parent_ino(dentry));
 
-	/* Bootloader */
-	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(inode->i_ino);
+	/*
+	 * Bootloader. Just using the inode here breaks in the case of
+	 * hard links - the firmware wants the ID of the hard link file,
+	 * but the inode points at the indirect inode
+	 */
+	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
 
 	/* Per spec, the OS X system folder - same as finder_info[0] here */
 	vh->finder_info[5] = bvh->finder_info[5] =
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks
  2012-04-16 20:57 [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks Matthew Garrett
@ 2012-06-13 11:57 ` Josh Boyer
  2012-06-17 21:01   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Boyer @ 2012-06-13 11:57 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: hch, linux-fsdevel, linux-kernel

On Mon, Apr 16, 2012 at 4:57 PM, Matthew Garrett <mjg@redhat.com> wrote:
> HFS+ doesn't really implement hard links - instead, hardlinks are indicated
> by a magic file type which refers to an indirect node in a hidden
> directory. The spec indicates that stat() should return the inode number
> of the indirect node, but it turns out that this doesn't satisfy the
> firmware when it's looking for a bootloader - it wants the catalog ID of
> the hardlink file instead. Fix up this case.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
> ---
>
> V2 cleans up the casting.

Did this patch get dropped on the floor?  It's been almost 2 months
since it was submitted.

josh


>  fs/hfsplus/ioctl.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
> index c640ba5..09addc8 100644
> --- a/fs/hfsplus/ioctl.c
> +++ b/fs/hfsplus/ioctl.c
> @@ -31,6 +31,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
>        struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
>        struct hfsplus_vh *vh = sbi->s_vhdr;
>        struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
> +       u32 cnid = (unsigned long)dentry->d_fsdata;
>
>        if (!capable(CAP_SYS_ADMIN))
>                return -EPERM;
> @@ -41,8 +42,12 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
>        vh->finder_info[0] = bvh->finder_info[0] =
>                cpu_to_be32(parent_ino(dentry));
>
> -       /* Bootloader */
> -       vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(inode->i_ino);
> +       /*
> +        * Bootloader. Just using the inode here breaks in the case of
> +        * hard links - the firmware wants the ID of the hard link file,
> +        * but the inode points at the indirect inode
> +        */
> +       vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
>
>        /* Per spec, the OS X system folder - same as finder_info[0] here */
>        vh->finder_info[5] = bvh->finder_info[5] =
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks
  2012-06-13 11:57 ` Josh Boyer
@ 2012-06-17 21:01   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2012-06-17 21:01 UTC (permalink / raw)
  To: Josh Boyer; +Cc: Matthew Garrett, hch, linux-fsdevel, linux-kernel

On Wed, Jun 13, 2012 at 07:57:24AM -0400, Josh Boyer wrote:
> On Mon, Apr 16, 2012 at 4:57 PM, Matthew Garrett <mjg@redhat.com> wrote:
> > HFS+ doesn't really implement hard links - instead, hardlinks are indicated
> > by a magic file type which refers to an indirect node in a hidden
> > directory. The spec indicates that stat() should return the inode number
> > of the indirect node, but it turns out that this doesn't satisfy the
> > firmware when it's looking for a bootloader - it wants the catalog ID of
> > the hardlink file instead. Fix up this case.
> >
> > Signed-off-by: Matthew Garrett <mjg@redhat.com>
> > ---
> >
> > V2 cleans up the casting.
> 
> Did this patch get dropped on the floor?  It's been almost 2 months
> since it was submitted.

It just got missed, sorry.  I'll send it along ASAP.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-17 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-16 20:57 [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks Matthew Garrett
2012-06-13 11:57 ` Josh Boyer
2012-06-17 21:01   ` Christoph Hellwig

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).