Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292380
b: refs/heads/master
c: a051f71
h: refs/heads/master
v: v3
  • Loading branch information
Matthew Garrett authored and Al Viro committed Mar 21, 2012
1 parent bc50361 commit 9417f99
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0347b6e95ceeb648631f89a0ced001e90e4daaa9
refs/heads/master: a051f71ce97c53cde3ac64de64eb02d658d9308e
1 change: 1 addition & 0 deletions trunk/Documentation/ioctl/ioctl-number.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Code Seq#(hex) Include File Comments
'h' 00-7F conflict! Charon filesystem
<mailto:zapman@interlan.net>
'h' 00-1F linux/hpet.h conflict!
'h' 80-8F fs/hfsplus/ioctl.c
'i' 00-3F linux/i2o-dev.h conflict!
'i' 0B-1F linux/ipmi.h conflict!
'i' 80-8F linux/i8k.h
Expand Down
5 changes: 5 additions & 0 deletions trunk/fs/hfsplus/hfsplus_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
#define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS


/*
* hfs+-specific ioctl for making the filesystem bootable
*/
#define HFSPLUS_IOC_BLESS _IO('h', 0x80)

/*
* Functions in any *.c used in other files
*/
Expand Down
34 changes: 34 additions & 0 deletions trunk/fs/hfsplus/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@
#include <asm/uaccess.h>
#include "hfsplus_fs.h"

/*
* "Blessing" an HFS+ filesystem writes metadata to the superblock informing
* the platform firmware which file to boot from
*/
static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
{
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
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;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

mutex_lock(&sbi->vh_mutex);

/* Directory containing the bootable system */
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);

/* Per spec, the OS X system folder - same as finder_info[0] here */
vh->finder_info[5] = bvh->finder_info[5] =
cpu_to_be32(parent_ino(dentry));

mutex_unlock(&sbi->vh_mutex);
return 0;
}

static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
{
struct inode *inode = file->f_path.dentry->d_inode;
Expand Down Expand Up @@ -108,6 +140,8 @@ long hfsplus_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return hfsplus_ioctl_getflags(file, argp);
case HFSPLUS_IOC_EXT2_SETFLAGS:
return hfsplus_ioctl_setflags(file, argp);
case HFSPLUS_IOC_BLESS:
return hfsplus_ioctl_bless(file, argp);
default:
return -ENOTTY;
}
Expand Down

0 comments on commit 9417f99

Please sign in to comment.