diff options
author | Arnd Bergmann <arnd@arndb.de> | 2007-10-09 07:23:52 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:26:00 -0400 |
commit | 7199d4cdd8485f802df3e1bc131245c69009b9a4 (patch) | |
tree | d4a0a46192724a2e5ce25beb80cc5de40dcb6c8a | |
parent | f58c4c0a17e500e767473598b3deafaa1d64051d (diff) |
compat_ioctl: add compat_blkdev_driver_ioctl()
Handle those blockdev ioctl calls that are compatible
directly from the compat_blkdev_ioctl() function, instead
of having to go through the compat_ioctl hash lookup.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/compat_ioctl.c | 121 | ||||
-rw-r--r-- | fs/compat_ioctl.c | 83 |
2 files changed, 120 insertions, 84 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index d20fdb436f68..500cc9e761c1 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -40,6 +40,122 @@ static int compat_put_u64(unsigned long arg, u64 val) | |||
40 | #define BLKBSZSET_32 _IOW(0x12, 113, int) | 40 | #define BLKBSZSET_32 _IOW(0x12, 113, int) |
41 | #define BLKGETSIZE64_32 _IOR(0x12, 114, int) | 41 | #define BLKGETSIZE64_32 _IOR(0x12, 114, int) |
42 | 42 | ||
43 | static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, | ||
44 | struct gendisk *disk, unsigned cmd, unsigned long arg) | ||
45 | { | ||
46 | int ret; | ||
47 | |||
48 | switch (arg) { | ||
49 | /* | ||
50 | * No handler required for the ones below, we just need to | ||
51 | * convert arg to a 64 bit pointer. | ||
52 | */ | ||
53 | case BLKSECTSET: | ||
54 | /* | ||
55 | * 0x03 -- HD/IDE ioctl's used by hdparm and friends. | ||
56 | * Some need translations, these do not. | ||
57 | */ | ||
58 | case HDIO_GET_IDENTITY: | ||
59 | case HDIO_DRIVE_TASK: | ||
60 | case HDIO_DRIVE_CMD: | ||
61 | case HDIO_SCAN_HWIF: | ||
62 | /* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */ | ||
63 | case 0x330: | ||
64 | /* 0x02 -- Floppy ioctls */ | ||
65 | case FDMSGON: | ||
66 | case FDMSGOFF: | ||
67 | case FDSETEMSGTRESH: | ||
68 | case FDFLUSH: | ||
69 | case FDWERRORCLR: | ||
70 | case FDSETMAXERRS: | ||
71 | case FDGETMAXERRS: | ||
72 | case FDGETDRVTYP: | ||
73 | case FDEJECT: | ||
74 | case FDCLRPRM: | ||
75 | case FDFMTBEG: | ||
76 | case FDFMTEND: | ||
77 | case FDRESET: | ||
78 | case FDTWADDLE: | ||
79 | case FDFMTTRK: | ||
80 | case FDRAWCMD: | ||
81 | /* CDROM stuff */ | ||
82 | case CDROMPAUSE: | ||
83 | case CDROMRESUME: | ||
84 | case CDROMPLAYMSF: | ||
85 | case CDROMPLAYTRKIND: | ||
86 | case CDROMREADTOCHDR: | ||
87 | case CDROMREADTOCENTRY: | ||
88 | case CDROMSTOP: | ||
89 | case CDROMSTART: | ||
90 | case CDROMEJECT: | ||
91 | case CDROMVOLCTRL: | ||
92 | case CDROMSUBCHNL: | ||
93 | case CDROMMULTISESSION: | ||
94 | case CDROM_GET_MCN: | ||
95 | case CDROMRESET: | ||
96 | case CDROMVOLREAD: | ||
97 | case CDROMSEEK: | ||
98 | case CDROMPLAYBLK: | ||
99 | case CDROMCLOSETRAY: | ||
100 | case CDROM_DISC_STATUS: | ||
101 | case CDROM_CHANGER_NSLOTS: | ||
102 | case CDROM_GET_CAPABILITY: | ||
103 | /* Ignore cdrom.h about these next 5 ioctls, they absolutely do | ||
104 | * not take a struct cdrom_read, instead they take a struct cdrom_msf | ||
105 | * which is compatible. | ||
106 | */ | ||
107 | case CDROMREADMODE2: | ||
108 | case CDROMREADMODE1: | ||
109 | case CDROMREADRAW: | ||
110 | case CDROMREADCOOKED: | ||
111 | case CDROMREADALL: | ||
112 | /* DVD ioctls */ | ||
113 | case DVD_READ_STRUCT: | ||
114 | case DVD_WRITE_STRUCT: | ||
115 | case DVD_AUTH: | ||
116 | arg = (unsigned long)compat_ptr(arg); | ||
117 | /* These intepret arg as an unsigned long, not as a pointer, | ||
118 | * so we must not do compat_ptr() conversion. */ | ||
119 | case HDIO_SET_MULTCOUNT: | ||
120 | case HDIO_SET_UNMASKINTR: | ||
121 | case HDIO_SET_KEEPSETTINGS: | ||
122 | case HDIO_SET_32BIT: | ||
123 | case HDIO_SET_NOWERR: | ||
124 | case HDIO_SET_DMA: | ||
125 | case HDIO_SET_PIO_MODE: | ||
126 | case HDIO_SET_NICE: | ||
127 | case HDIO_SET_WCACHE: | ||
128 | case HDIO_SET_ACOUSTIC: | ||
129 | case HDIO_SET_BUSSTATE: | ||
130 | case HDIO_SET_ADDRESS: | ||
131 | case CDROMEJECT_SW: | ||
132 | case CDROM_SET_OPTIONS: | ||
133 | case CDROM_CLEAR_OPTIONS: | ||
134 | case CDROM_SELECT_SPEED: | ||
135 | case CDROM_SELECT_DISC: | ||
136 | case CDROM_MEDIA_CHANGED: | ||
137 | case CDROM_DRIVE_STATUS: | ||
138 | case CDROM_LOCKDOOR: | ||
139 | case CDROM_DEBUG: | ||
140 | break; | ||
141 | default: | ||
142 | /* unknown ioctl number */ | ||
143 | return -ENOIOCTLCMD; | ||
144 | } | ||
145 | |||
146 | if (disk->fops->unlocked_ioctl) | ||
147 | return disk->fops->unlocked_ioctl(file, cmd, arg); | ||
148 | |||
149 | if (disk->fops->ioctl) { | ||
150 | lock_kernel(); | ||
151 | ret = disk->fops->ioctl(inode, file, cmd, arg); | ||
152 | unlock_kernel(); | ||
153 | return ret; | ||
154 | } | ||
155 | |||
156 | return -ENOTTY; | ||
157 | } | ||
158 | |||
43 | static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file, | 159 | static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file, |
44 | struct block_device *bdev, | 160 | struct block_device *bdev, |
45 | unsigned cmd, unsigned long arg) | 161 | unsigned cmd, unsigned long arg) |
@@ -117,5 +233,8 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
117 | ret = disk->fops->compat_ioctl(file, cmd, arg); | 233 | ret = disk->fops->compat_ioctl(file, cmd, arg); |
118 | unlock_kernel(); | 234 | unlock_kernel(); |
119 | 235 | ||
120 | return ret; | 236 | if (ret != -ENOIOCTLCMD) |
237 | return ret; | ||
238 | |||
239 | return compat_blkdev_driver_ioctl(inode, file, disk, cmd, arg); | ||
121 | } | 240 | } |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 6be121868c60..16d681c331f9 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -2477,47 +2477,8 @@ COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */ | |||
2477 | /* 0x00 */ | 2477 | /* 0x00 */ |
2478 | COMPATIBLE_IOCTL(FIBMAP) | 2478 | COMPATIBLE_IOCTL(FIBMAP) |
2479 | COMPATIBLE_IOCTL(FIGETBSZ) | 2479 | COMPATIBLE_IOCTL(FIGETBSZ) |
2480 | /* 0x03 -- HD/IDE ioctl's used by hdparm and friends. | ||
2481 | * Some need translations, these do not. | ||
2482 | */ | ||
2483 | COMPATIBLE_IOCTL(HDIO_GET_IDENTITY) | ||
2484 | COMPATIBLE_IOCTL(HDIO_DRIVE_TASK) | ||
2485 | COMPATIBLE_IOCTL(HDIO_DRIVE_CMD) | ||
2486 | ULONG_IOCTL(HDIO_SET_MULTCOUNT) | ||
2487 | ULONG_IOCTL(HDIO_SET_UNMASKINTR) | ||
2488 | ULONG_IOCTL(HDIO_SET_KEEPSETTINGS) | ||
2489 | ULONG_IOCTL(HDIO_SET_32BIT) | ||
2490 | ULONG_IOCTL(HDIO_SET_NOWERR) | ||
2491 | ULONG_IOCTL(HDIO_SET_DMA) | ||
2492 | ULONG_IOCTL(HDIO_SET_PIO_MODE) | ||
2493 | ULONG_IOCTL(HDIO_SET_NICE) | ||
2494 | ULONG_IOCTL(HDIO_SET_WCACHE) | ||
2495 | ULONG_IOCTL(HDIO_SET_ACOUSTIC) | ||
2496 | ULONG_IOCTL(HDIO_SET_BUSSTATE) | ||
2497 | ULONG_IOCTL(HDIO_SET_ADDRESS) | ||
2498 | COMPATIBLE_IOCTL(HDIO_SCAN_HWIF) | ||
2499 | /* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */ | ||
2500 | COMPATIBLE_IOCTL(0x330) | ||
2501 | /* 0x02 -- Floppy ioctls */ | ||
2502 | COMPATIBLE_IOCTL(FDMSGON) | ||
2503 | COMPATIBLE_IOCTL(FDMSGOFF) | ||
2504 | COMPATIBLE_IOCTL(FDSETEMSGTRESH) | ||
2505 | COMPATIBLE_IOCTL(FDFLUSH) | ||
2506 | COMPATIBLE_IOCTL(FDWERRORCLR) | ||
2507 | COMPATIBLE_IOCTL(FDSETMAXERRS) | ||
2508 | COMPATIBLE_IOCTL(FDGETMAXERRS) | ||
2509 | COMPATIBLE_IOCTL(FDGETDRVTYP) | ||
2510 | COMPATIBLE_IOCTL(FDEJECT) | ||
2511 | COMPATIBLE_IOCTL(FDCLRPRM) | ||
2512 | COMPATIBLE_IOCTL(FDFMTBEG) | ||
2513 | COMPATIBLE_IOCTL(FDFMTEND) | ||
2514 | COMPATIBLE_IOCTL(FDRESET) | ||
2515 | COMPATIBLE_IOCTL(FDTWADDLE) | ||
2516 | COMPATIBLE_IOCTL(FDFMTTRK) | ||
2517 | COMPATIBLE_IOCTL(FDRAWCMD) | ||
2518 | /* 0x12 */ | 2480 | /* 0x12 */ |
2519 | #ifdef CONFIG_BLOCK | 2481 | #ifdef CONFIG_BLOCK |
2520 | COMPATIBLE_IOCTL(BLKSECTSET) | ||
2521 | COMPATIBLE_IOCTL(BLKTRACESTART) | 2482 | COMPATIBLE_IOCTL(BLKTRACESTART) |
2522 | COMPATIBLE_IOCTL(BLKTRACESTOP) | 2483 | COMPATIBLE_IOCTL(BLKTRACESTOP) |
2523 | COMPATIBLE_IOCTL(BLKTRACESETUP) | 2484 | COMPATIBLE_IOCTL(BLKTRACESETUP) |
@@ -2770,50 +2731,6 @@ COMPATIBLE_IOCTL(PPGETMODE) | |||
2770 | COMPATIBLE_IOCTL(PPGETPHASE) | 2731 | COMPATIBLE_IOCTL(PPGETPHASE) |
2771 | COMPATIBLE_IOCTL(PPGETFLAGS) | 2732 | COMPATIBLE_IOCTL(PPGETFLAGS) |
2772 | COMPATIBLE_IOCTL(PPSETFLAGS) | 2733 | COMPATIBLE_IOCTL(PPSETFLAGS) |
2773 | /* CDROM stuff */ | ||
2774 | COMPATIBLE_IOCTL(CDROMPAUSE) | ||
2775 | COMPATIBLE_IOCTL(CDROMRESUME) | ||
2776 | COMPATIBLE_IOCTL(CDROMPLAYMSF) | ||
2777 | COMPATIBLE_IOCTL(CDROMPLAYTRKIND) | ||
2778 | COMPATIBLE_IOCTL(CDROMREADTOCHDR) | ||
2779 | COMPATIBLE_IOCTL(CDROMREADTOCENTRY) | ||
2780 | COMPATIBLE_IOCTL(CDROMSTOP) | ||
2781 | COMPATIBLE_IOCTL(CDROMSTART) | ||
2782 | COMPATIBLE_IOCTL(CDROMEJECT) | ||
2783 | COMPATIBLE_IOCTL(CDROMVOLCTRL) | ||
2784 | COMPATIBLE_IOCTL(CDROMSUBCHNL) | ||
2785 | ULONG_IOCTL(CDROMEJECT_SW) | ||
2786 | COMPATIBLE_IOCTL(CDROMMULTISESSION) | ||
2787 | COMPATIBLE_IOCTL(CDROM_GET_MCN) | ||
2788 | COMPATIBLE_IOCTL(CDROMRESET) | ||
2789 | COMPATIBLE_IOCTL(CDROMVOLREAD) | ||
2790 | COMPATIBLE_IOCTL(CDROMSEEK) | ||
2791 | COMPATIBLE_IOCTL(CDROMPLAYBLK) | ||
2792 | COMPATIBLE_IOCTL(CDROMCLOSETRAY) | ||
2793 | ULONG_IOCTL(CDROM_SET_OPTIONS) | ||
2794 | ULONG_IOCTL(CDROM_CLEAR_OPTIONS) | ||
2795 | ULONG_IOCTL(CDROM_SELECT_SPEED) | ||
2796 | ULONG_IOCTL(CDROM_SELECT_DISC) | ||
2797 | ULONG_IOCTL(CDROM_MEDIA_CHANGED) | ||
2798 | ULONG_IOCTL(CDROM_DRIVE_STATUS) | ||
2799 | COMPATIBLE_IOCTL(CDROM_DISC_STATUS) | ||
2800 | COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS) | ||
2801 | ULONG_IOCTL(CDROM_LOCKDOOR) | ||
2802 | ULONG_IOCTL(CDROM_DEBUG) | ||
2803 | COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY) | ||
2804 | /* Ignore cdrom.h about these next 5 ioctls, they absolutely do | ||
2805 | * not take a struct cdrom_read, instead they take a struct cdrom_msf | ||
2806 | * which is compatible. | ||
2807 | */ | ||
2808 | COMPATIBLE_IOCTL(CDROMREADMODE2) | ||
2809 | COMPATIBLE_IOCTL(CDROMREADMODE1) | ||
2810 | COMPATIBLE_IOCTL(CDROMREADRAW) | ||
2811 | COMPATIBLE_IOCTL(CDROMREADCOOKED) | ||
2812 | COMPATIBLE_IOCTL(CDROMREADALL) | ||
2813 | /* DVD ioctls */ | ||
2814 | COMPATIBLE_IOCTL(DVD_READ_STRUCT) | ||
2815 | COMPATIBLE_IOCTL(DVD_WRITE_STRUCT) | ||
2816 | COMPATIBLE_IOCTL(DVD_AUTH) | ||
2817 | /* pktcdvd */ | 2734 | /* pktcdvd */ |
2818 | COMPATIBLE_IOCTL(PACKET_CTRL_CMD) | 2735 | COMPATIBLE_IOCTL(PACKET_CTRL_CMD) |
2819 | /* Big A */ | 2736 | /* Big A */ |