aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat_ioctl.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-11-05 13:13:51 -0500
committerArnd Bergmann <arnd@arndb.de>2009-12-10 16:52:10 -0500
commit789f0f89118a80a3ff5309371e5820f623ed2a53 (patch)
treeb4f178d169be07bdc9cbc629d4f9dab896233408 /fs/compat_ioctl.c
parent5a07ea0b97f206ed23a5850079b7f322e7730869 (diff)
compat_ioctl: simplify calling of handlers
The compat_ioctl array now contains only entries for ioctl numbers that do not require a separate handler. By special-casing the ULONG_IOCTL case in the do_ioctl_trans function, we can kill the final use of a function pointer in the array. text data bss dec hex filename 7539 13352 2080 22971 59bb before/fs/compat_ioctl.o 7910 8552 2080 18542 486e after/fs/compat_ioctl.o Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r--fs/compat_ioctl.c86
1 files changed, 39 insertions, 47 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 0cd76e9e843a..7895bdb0c304 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -115,12 +115,6 @@
115#include <asm/fbio.h> 115#include <asm/fbio.h>
116#endif 116#endif
117 117
118static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
119 unsigned long arg, struct file *f)
120{
121 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
122}
123
124static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) 118static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
125{ 119{
126 mm_segment_t old_fs = get_fs(); 120 mm_segment_t old_fs = get_fs();
@@ -1055,25 +1049,13 @@ static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
1055#endif 1049#endif
1056 1050
1057 1051
1058typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
1059 unsigned long, struct file *);
1060
1061struct ioctl_trans { 1052struct ioctl_trans {
1062 unsigned long cmd; 1053 unsigned long cmd;
1063 ioctl_trans_handler_t handler;
1064 struct ioctl_trans *next; 1054 struct ioctl_trans *next;
1065}; 1055};
1066 1056
1067#define HANDLE_IOCTL(cmd,handler) \
1068 { (cmd), (ioctl_trans_handler_t)(handler) },
1069
1070/* pointer to compatible structure or no argument */ 1057/* pointer to compatible structure or no argument */
1071#define COMPATIBLE_IOCTL(cmd) \ 1058#define COMPATIBLE_IOCTL(cmd) { (cmd), },
1072 { (cmd), do_ioctl32_pointer },
1073
1074/* argument is an unsigned long integer, not a pointer */
1075#define ULONG_IOCTL(cmd) \
1076 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
1077 1059
1078/* ioctl should not be warned about even if it's not implemented. 1060/* ioctl should not be warned about even if it's not implemented.
1079 Valid reasons to use this: 1061 Valid reasons to use this:
@@ -1095,7 +1077,6 @@ COMPATIBLE_IOCTL(TCSETA)
1095COMPATIBLE_IOCTL(TCSETAW) 1077COMPATIBLE_IOCTL(TCSETAW)
1096COMPATIBLE_IOCTL(TCSETAF) 1078COMPATIBLE_IOCTL(TCSETAF)
1097COMPATIBLE_IOCTL(TCSBRK) 1079COMPATIBLE_IOCTL(TCSBRK)
1098ULONG_IOCTL(TCSBRKP)
1099COMPATIBLE_IOCTL(TCXONC) 1080COMPATIBLE_IOCTL(TCXONC)
1100COMPATIBLE_IOCTL(TCFLSH) 1081COMPATIBLE_IOCTL(TCFLSH)
1101COMPATIBLE_IOCTL(TCGETS) 1082COMPATIBLE_IOCTL(TCGETS)
@@ -1105,7 +1086,6 @@ COMPATIBLE_IOCTL(TCSETSF)
1105COMPATIBLE_IOCTL(TIOCLINUX) 1086COMPATIBLE_IOCTL(TIOCLINUX)
1106COMPATIBLE_IOCTL(TIOCSBRK) 1087COMPATIBLE_IOCTL(TIOCSBRK)
1107COMPATIBLE_IOCTL(TIOCCBRK) 1088COMPATIBLE_IOCTL(TIOCCBRK)
1108ULONG_IOCTL(TIOCMIWAIT)
1109COMPATIBLE_IOCTL(TIOCGICOUNT) 1089COMPATIBLE_IOCTL(TIOCGICOUNT)
1110/* Little t */ 1090/* Little t */
1111COMPATIBLE_IOCTL(TIOCGETD) 1091COMPATIBLE_IOCTL(TIOCGETD)
@@ -1127,7 +1107,6 @@ COMPATIBLE_IOCTL(TIOCSTI)
1127COMPATIBLE_IOCTL(TIOCOUTQ) 1107COMPATIBLE_IOCTL(TIOCOUTQ)
1128COMPATIBLE_IOCTL(TIOCSPGRP) 1108COMPATIBLE_IOCTL(TIOCSPGRP)
1129COMPATIBLE_IOCTL(TIOCGPGRP) 1109COMPATIBLE_IOCTL(TIOCGPGRP)
1130ULONG_IOCTL(TIOCSCTTY)
1131COMPATIBLE_IOCTL(TIOCGPTN) 1110COMPATIBLE_IOCTL(TIOCGPTN)
1132COMPATIBLE_IOCTL(TIOCSPTLCK) 1111COMPATIBLE_IOCTL(TIOCSPTLCK)
1133COMPATIBLE_IOCTL(TIOCSERGETLSR) 1112COMPATIBLE_IOCTL(TIOCSERGETLSR)
@@ -1158,32 +1137,21 @@ COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
1158COMPATIBLE_IOCTL(RAID_AUTORUN) 1137COMPATIBLE_IOCTL(RAID_AUTORUN)
1159COMPATIBLE_IOCTL(CLEAR_ARRAY) 1138COMPATIBLE_IOCTL(CLEAR_ARRAY)
1160COMPATIBLE_IOCTL(ADD_NEW_DISK) 1139COMPATIBLE_IOCTL(ADD_NEW_DISK)
1161ULONG_IOCTL(HOT_REMOVE_DISK)
1162COMPATIBLE_IOCTL(SET_ARRAY_INFO) 1140COMPATIBLE_IOCTL(SET_ARRAY_INFO)
1163COMPATIBLE_IOCTL(SET_DISK_INFO) 1141COMPATIBLE_IOCTL(SET_DISK_INFO)
1164COMPATIBLE_IOCTL(WRITE_RAID_INFO) 1142COMPATIBLE_IOCTL(WRITE_RAID_INFO)
1165COMPATIBLE_IOCTL(UNPROTECT_ARRAY) 1143COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
1166COMPATIBLE_IOCTL(PROTECT_ARRAY) 1144COMPATIBLE_IOCTL(PROTECT_ARRAY)
1167ULONG_IOCTL(HOT_ADD_DISK)
1168ULONG_IOCTL(SET_DISK_FAULTY)
1169COMPATIBLE_IOCTL(RUN_ARRAY) 1145COMPATIBLE_IOCTL(RUN_ARRAY)
1170COMPATIBLE_IOCTL(STOP_ARRAY) 1146COMPATIBLE_IOCTL(STOP_ARRAY)
1171COMPATIBLE_IOCTL(STOP_ARRAY_RO) 1147COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1172COMPATIBLE_IOCTL(RESTART_ARRAY_RW) 1148COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1173COMPATIBLE_IOCTL(GET_BITMAP_FILE) 1149COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1174ULONG_IOCTL(SET_BITMAP_FILE)
1175/* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */
1176ULONG_IOCTL(KDSIGACCEPT)
1177COMPATIBLE_IOCTL(KDGETKEYCODE) 1150COMPATIBLE_IOCTL(KDGETKEYCODE)
1178COMPATIBLE_IOCTL(KDSETKEYCODE) 1151COMPATIBLE_IOCTL(KDSETKEYCODE)
1179ULONG_IOCTL(KIOCSOUND)
1180ULONG_IOCTL(KDMKTONE)
1181COMPATIBLE_IOCTL(KDGKBTYPE) 1152COMPATIBLE_IOCTL(KDGKBTYPE)
1182ULONG_IOCTL(KDSETMODE)
1183COMPATIBLE_IOCTL(KDGETMODE) 1153COMPATIBLE_IOCTL(KDGETMODE)
1184ULONG_IOCTL(KDSKBMODE)
1185COMPATIBLE_IOCTL(KDGKBMODE) 1154COMPATIBLE_IOCTL(KDGKBMODE)
1186ULONG_IOCTL(KDSKBMETA)
1187COMPATIBLE_IOCTL(KDGKBMETA) 1155COMPATIBLE_IOCTL(KDGKBMETA)
1188COMPATIBLE_IOCTL(KDGKBENT) 1156COMPATIBLE_IOCTL(KDGKBENT)
1189COMPATIBLE_IOCTL(KDSKBENT) 1157COMPATIBLE_IOCTL(KDSKBENT)
@@ -1193,9 +1161,7 @@ COMPATIBLE_IOCTL(KDGKBDIACR)
1193COMPATIBLE_IOCTL(KDSKBDIACR) 1161COMPATIBLE_IOCTL(KDSKBDIACR)
1194COMPATIBLE_IOCTL(KDKBDREP) 1162COMPATIBLE_IOCTL(KDKBDREP)
1195COMPATIBLE_IOCTL(KDGKBLED) 1163COMPATIBLE_IOCTL(KDGKBLED)
1196ULONG_IOCTL(KDSKBLED)
1197COMPATIBLE_IOCTL(KDGETLED) 1164COMPATIBLE_IOCTL(KDGETLED)
1198ULONG_IOCTL(KDSETLED)
1199#ifdef CONFIG_BLOCK 1165#ifdef CONFIG_BLOCK
1200/* Big S */ 1166/* Big S */
1201COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) 1167COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
@@ -1241,7 +1207,6 @@ IGNORE_IOCTL(LOOP_CLR_FD)
1241COMPATIBLE_IOCTL(SG_SET_TIMEOUT) 1207COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
1242COMPATIBLE_IOCTL(SG_GET_TIMEOUT) 1208COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
1243COMPATIBLE_IOCTL(SG_EMULATED_HOST) 1209COMPATIBLE_IOCTL(SG_EMULATED_HOST)
1244ULONG_IOCTL(SG_SET_TRANSFORM)
1245COMPATIBLE_IOCTL(SG_GET_TRANSFORM) 1210COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
1246COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) 1211COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
1247COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) 1212COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
@@ -1478,8 +1443,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
1478COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) 1443COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
1479COMPATIBLE_IOCTL(OSS_GETVERSION) 1444COMPATIBLE_IOCTL(OSS_GETVERSION)
1480/* AUTOFS */ 1445/* AUTOFS */
1481ULONG_IOCTL(AUTOFS_IOC_READY)
1482ULONG_IOCTL(AUTOFS_IOC_FAIL)
1483COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) 1446COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
1484COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) 1447COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
1485COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) 1448COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
@@ -1588,14 +1551,10 @@ COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
1588COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) 1551COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
1589COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) 1552COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
1590/* NBD */ 1553/* NBD */
1591ULONG_IOCTL(NBD_SET_SOCK)
1592ULONG_IOCTL(NBD_SET_BLKSIZE)
1593ULONG_IOCTL(NBD_SET_SIZE)
1594COMPATIBLE_IOCTL(NBD_DO_IT) 1554COMPATIBLE_IOCTL(NBD_DO_IT)
1595COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) 1555COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
1596COMPATIBLE_IOCTL(NBD_CLEAR_QUE) 1556COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
1597COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) 1557COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
1598ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
1599COMPATIBLE_IOCTL(NBD_DISCONNECT) 1558COMPATIBLE_IOCTL(NBD_DISCONNECT)
1600/* i2c */ 1559/* i2c */
1601COMPATIBLE_IOCTL(I2C_SLAVE) 1560COMPATIBLE_IOCTL(I2C_SLAVE)
@@ -1833,6 +1792,43 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
1833 case LPSETTIMEOUT: 1792 case LPSETTIMEOUT:
1834 return lp_timeout_trans(fd, cmd, arg); 1793 return lp_timeout_trans(fd, cmd, arg);
1835 } 1794 }
1795
1796 /*
1797 * These take an integer instead of a pointer as 'arg',
1798 * so we must not do a compat_ptr() translation.
1799 */
1800 switch (cmd) {
1801 /* Big T */
1802 case TCSBRKP:
1803 case TIOCMIWAIT:
1804 case TIOCSCTTY:
1805 /* RAID */
1806 case HOT_REMOVE_DISK:
1807 case HOT_ADD_DISK:
1808 case SET_DISK_FAULTY:
1809 case SET_BITMAP_FILE:
1810 /* Big K */
1811 case KDSIGACCEPT:
1812 case KIOCSOUND:
1813 case KDMKTONE:
1814 case KDSETMODE:
1815 case KDSKBMODE:
1816 case KDSKBMETA:
1817 case KDSKBLED:
1818 case KDSETLED:
1819 /* SG stuff */
1820 case SG_SET_TRANSFORM:
1821 /* AUTOFS */
1822 case AUTOFS_IOC_READY:
1823 case AUTOFS_IOC_FAIL:
1824 /* NBD */
1825 case NBD_SET_SOCK:
1826 case NBD_SET_BLKSIZE:
1827 case NBD_SET_SIZE:
1828 case NBD_SET_SIZE_BLOCKS:
1829 return do_vfs_ioctl(file, fd, cmd, arg);
1830 }
1831
1836 return -ENOIOCTLCMD; 1832 return -ENOIOCTLCMD;
1837} 1833}
1838 1834
@@ -1944,11 +1940,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1944 goto out_fput; 1940 goto out_fput;
1945 1941
1946 found_handler: 1942 found_handler:
1947 if (t->handler) { 1943 arg = (unsigned long)compat_ptr(arg);
1948 error = t->handler(fd, cmd, arg, filp);
1949 goto out_fput;
1950 }
1951
1952 do_ioctl: 1944 do_ioctl:
1953 error = do_vfs_ioctl(filp, fd, cmd, arg); 1945 error = do_vfs_ioctl(filp, fd, cmd, arg);
1954 out_fput: 1946 out_fput: