Commit 7845bc3e132605e3e8a1f37748e29281164b65f5
Committed by
OGAWA Hirofumi
1 parent
1bdb6f9199
Exists in
master
and in
7 other branches
fat: convert to unlocked_ioctl
FAT does not require the BKL in its ioctl function, which is already serialized through a mutex. Since we're already touching the ioctl code, also fix the missing handling of FAT_IOCTL_GET_ATTRIBUTES in the compat code. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Showing 3 changed files with 24 additions and 10 deletions Side-by-side Diff
fs/fat/dir.c
... | ... | @@ -753,9 +753,10 @@ |
753 | 753 | return ret; |
754 | 754 | } |
755 | 755 | |
756 | -static int fat_dir_ioctl(struct inode *inode, struct file *filp, | |
757 | - unsigned int cmd, unsigned long arg) | |
756 | +static long fat_dir_ioctl(struct file *filp, unsigned int cmd, | |
757 | + unsigned long arg) | |
758 | 758 | { |
759 | + struct inode *inode = filp->f_path.dentry->d_inode; | |
759 | 760 | struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg; |
760 | 761 | int short_only, both; |
761 | 762 | |
... | ... | @@ -769,7 +770,7 @@ |
769 | 770 | both = 1; |
770 | 771 | break; |
771 | 772 | default: |
772 | - return fat_generic_ioctl(inode, filp, cmd, arg); | |
773 | + return fat_generic_ioctl(filp, cmd, arg); | |
773 | 774 | } |
774 | 775 | |
775 | 776 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct __fat_dirent[2]))) |
... | ... | @@ -809,7 +810,7 @@ |
809 | 810 | both = 1; |
810 | 811 | break; |
811 | 812 | default: |
812 | - return -ENOIOCTLCMD; | |
813 | + return fat_generic_ioctl(filp, cmd, (unsigned long)arg); | |
813 | 814 | } |
814 | 815 | |
815 | 816 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct compat_dirent[2]))) |
... | ... | @@ -831,7 +832,7 @@ |
831 | 832 | .llseek = generic_file_llseek, |
832 | 833 | .read = generic_read_dir, |
833 | 834 | .readdir = fat_readdir, |
834 | - .ioctl = fat_dir_ioctl, | |
835 | + .unlocked_ioctl = fat_dir_ioctl, | |
835 | 836 | #ifdef CONFIG_COMPAT |
836 | 837 | .compat_ioctl = fat_compat_dir_ioctl, |
837 | 838 | #endif |
fs/fat/fat.h
... | ... | @@ -298,8 +298,8 @@ |
298 | 298 | extern int fat_count_free_clusters(struct super_block *sb); |
299 | 299 | |
300 | 300 | /* fat/file.c */ |
301 | -extern int fat_generic_ioctl(struct inode *inode, struct file *filp, | |
302 | - unsigned int cmd, unsigned long arg); | |
301 | +extern long fat_generic_ioctl(struct file *filp, unsigned int cmd, | |
302 | + unsigned long arg); | |
303 | 303 | extern const struct file_operations fat_file_operations; |
304 | 304 | extern const struct inode_operations fat_file_inode_operations; |
305 | 305 | extern int fat_setattr(struct dentry * dentry, struct iattr * attr); |
fs/fat/file.c
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | #include <linux/capability.h> |
10 | 10 | #include <linux/module.h> |
11 | +#include <linux/compat.h> | |
11 | 12 | #include <linux/mount.h> |
12 | 13 | #include <linux/time.h> |
13 | 14 | #include <linux/buffer_head.h> |
14 | 15 | |
... | ... | @@ -114,9 +115,9 @@ |
114 | 115 | return err; |
115 | 116 | } |
116 | 117 | |
117 | -int fat_generic_ioctl(struct inode *inode, struct file *filp, | |
118 | - unsigned int cmd, unsigned long arg) | |
118 | +long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |
119 | 119 | { |
120 | + struct inode *inode = filp->f_path.dentry->d_inode; | |
120 | 121 | u32 __user *user_attr = (u32 __user *)arg; |
121 | 122 | |
122 | 123 | switch (cmd) { |
... | ... | @@ -129,6 +130,15 @@ |
129 | 130 | } |
130 | 131 | } |
131 | 132 | |
133 | +#ifdef CONFIG_COMPAT | |
134 | +static long fat_generic_compat_ioctl(struct file *filp, unsigned int cmd, | |
135 | + unsigned long arg) | |
136 | + | |
137 | +{ | |
138 | + return fat_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); | |
139 | +} | |
140 | +#endif | |
141 | + | |
132 | 142 | static int fat_file_release(struct inode *inode, struct file *filp) |
133 | 143 | { |
134 | 144 | if ((filp->f_mode & FMODE_WRITE) && |
... | ... | @@ -159,7 +169,10 @@ |
159 | 169 | .aio_write = generic_file_aio_write, |
160 | 170 | .mmap = generic_file_mmap, |
161 | 171 | .release = fat_file_release, |
162 | - .ioctl = fat_generic_ioctl, | |
172 | + .unlocked_ioctl = fat_generic_ioctl, | |
173 | +#ifdef CONFIG_COMPAT | |
174 | + .compat_ioctl = fat_generic_compat_ioctl, | |
175 | +#endif | |
163 | 176 | .fsync = fat_file_fsync, |
164 | 177 | .splice_read = generic_file_splice_read, |
165 | 178 | }; |