Skip to contentSkip to conversation

hfsplus: Change finder_info to u32

PATCH Superseded Matthew Garrett 1 participant 2 messages Feb 2, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hfsplus: Change finder_info to u32

The finder_info block in the hfsplus volume header is currently defined as an array of 8 bit values, but TN1150 defines it as being an array of 32 bit values. Fix for convenience.

---
 fs/hfsplus/hfsplus_raw.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/hfsplus/hfsplus_raw.h +1 -1
index 927cdd6..921967e 100644
@@ -117,7 +117,7 @@ struct hfsplus_vh {
 	__be32 write_count;
 	__be64 encodings_bmp;
 
-	u8 finder_info[32];
+	u32 finder_info[8];
 
 	struct hfsplus_fork_raw alloc_file;
 	struct hfsplus_fork_raw ext_file;
Signature · 1 line
1.7.7.1
#1 lore raw

PATCH 2/2 hfsplus: Add an ioctl to bless files

Making an hfsplus partition bootable requires the ability to "bless" a file by putting its inode number in the volume header. Doing this from userspace on a mounted filesystem is impractical since the kernel will write back the original values on unmount. Add an ioctl to allow userspace to update the volume header information based on the target file.

---
 Documentation/ioctl/ioctl-number.txt |    1 +
 fs/hfsplus/hfsplus_fs.h              |    1 +
 fs/hfsplus/ioctl.c                   |   20 ++++++++++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)
Documentation/ioctl/ioctl-number.txt +1 -0
index 4840334..6965c1b 100644
@@ -213,6 +213,7 @@ Code  Seq#(hex)	Include File		Comments
 'f'	00-0F	fs/ext4/ext4.h		conflict!
 'f'	00-0F	linux/fs.h		conflict!
 'f'	00-0F	fs/ocfs2/ocfs2_fs.h	conflict!
+'f'	20-2F	fs/hfsplus/hfsplus_fs.h
 'g'	00-0F	linux/usb/gadgetfs.h
 'g'	20-2F	linux/usb/g_printer.h
 'h'	00-7F				conflict! Charon filesystem
fs/hfsplus/hfsplus_fs.h +1 -0
index 21a5b7f..1036936 100644
@@ -315,6 +315,7 @@ static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
 #define HFSPLUS_IOC_EXT2_GETFLAGS	FS_IOC_GETFLAGS
 #define HFSPLUS_IOC_EXT2_SETFLAGS	FS_IOC_SETFLAGS
 
+#define HFSPLUS_IOC_BLESS		_IO('f', 0x20)
 
 /*
  * Functions in any *.c used in other files
fs/hfsplus/ioctl.c +20 -0
index f66c765..cbd4c48 100644
@@ -20,6 +20,24 @@
 #include <asm/uaccess.h>
 #include "hfsplus_fs.h"
 
+static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
+{
+	struct inode *inode = file->f_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);
+	vh->finder_info[0] = bvh->finder_info[0] = parent_ino(file->f_dentry);
+	vh->finder_info[1] = bvh->finder_info[1] = inode->i_ino;
+	vh->finder_info[5] = bvh->finder_info[5] = parent_ino(file->f_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;
@@ -108,6 +126,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;
 	}
Signature · 1 line
1.7.7.1