0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <linux/capability.h>
0017 #include <linux/fs.h>
0018 #include <linux/mount.h>
0019 #include <linux/sched.h>
0020 #include <linux/uaccess.h>
0021 #include "hfsplus_fs.h"
0022
0023
0024
0025
0026
0027 static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
0028 {
0029 struct dentry *dentry = file->f_path.dentry;
0030 struct inode *inode = d_inode(dentry);
0031 struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
0032 struct hfsplus_vh *vh = sbi->s_vhdr;
0033 struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
0034 u32 cnid = (unsigned long)dentry->d_fsdata;
0035
0036 if (!capable(CAP_SYS_ADMIN))
0037 return -EPERM;
0038
0039 mutex_lock(&sbi->vh_mutex);
0040
0041
0042 vh->finder_info[0] = bvh->finder_info[0] =
0043 cpu_to_be32(parent_ino(dentry));
0044
0045
0046
0047
0048
0049
0050 vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
0051
0052
0053 vh->finder_info[5] = bvh->finder_info[5] =
0054 cpu_to_be32(parent_ino(dentry));
0055
0056 mutex_unlock(&sbi->vh_mutex);
0057 return 0;
0058 }
0059
0060 long hfsplus_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
0061 {
0062 void __user *argp = (void __user *)arg;
0063
0064 switch (cmd) {
0065 case HFSPLUS_IOC_BLESS:
0066 return hfsplus_ioctl_bless(file, argp);
0067 default:
0068 return -ENOTTY;
0069 }
0070 }