diff options
Diffstat (limited to 'block/compat_ioctl.c')
-rw-r--r-- | block/compat_ioctl.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 44807d38b1e7..92b3e8d07ca6 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -92,6 +92,84 @@ static int compat_hdio_ioctl(struct inode *inode, struct file *file, | |||
92 | return error; | 92 | return error; |
93 | } | 93 | } |
94 | 94 | ||
95 | struct compat_cdrom_read_audio { | ||
96 | union cdrom_addr addr; | ||
97 | u8 addr_format; | ||
98 | compat_int_t nframes; | ||
99 | compat_caddr_t buf; | ||
100 | }; | ||
101 | |||
102 | struct compat_cdrom_generic_command { | ||
103 | unsigned char cmd[CDROM_PACKET_SIZE]; | ||
104 | compat_caddr_t buffer; | ||
105 | compat_uint_t buflen; | ||
106 | compat_int_t stat; | ||
107 | compat_caddr_t sense; | ||
108 | unsigned char data_direction; | ||
109 | compat_int_t quiet; | ||
110 | compat_int_t timeout; | ||
111 | compat_caddr_t reserved[1]; | ||
112 | }; | ||
113 | |||
114 | static int compat_cdrom_read_audio(struct inode *inode, struct file *file, | ||
115 | struct gendisk *disk, unsigned int cmd, unsigned long arg) | ||
116 | { | ||
117 | struct cdrom_read_audio __user *cdread_audio; | ||
118 | struct compat_cdrom_read_audio __user *cdread_audio32; | ||
119 | __u32 data; | ||
120 | void __user *datap; | ||
121 | |||
122 | cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); | ||
123 | cdread_audio32 = compat_ptr(arg); | ||
124 | |||
125 | if (copy_in_user(&cdread_audio->addr, | ||
126 | &cdread_audio32->addr, | ||
127 | (sizeof(*cdread_audio32) - | ||
128 | sizeof(compat_caddr_t)))) | ||
129 | return -EFAULT; | ||
130 | |||
131 | if (get_user(data, &cdread_audio32->buf)) | ||
132 | return -EFAULT; | ||
133 | datap = compat_ptr(data); | ||
134 | if (put_user(datap, &cdread_audio->buf)) | ||
135 | return -EFAULT; | ||
136 | |||
137 | return blkdev_driver_ioctl(inode, file, disk, cmd, | ||
138 | (unsigned long)cdread_audio); | ||
139 | } | ||
140 | |||
141 | static int compat_cdrom_generic_command(struct inode *inode, struct file *file, | ||
142 | struct gendisk *disk, unsigned int cmd, unsigned long arg) | ||
143 | { | ||
144 | struct cdrom_generic_command __user *cgc; | ||
145 | struct compat_cdrom_generic_command __user *cgc32; | ||
146 | u32 data; | ||
147 | unsigned char dir; | ||
148 | int itmp; | ||
149 | |||
150 | cgc = compat_alloc_user_space(sizeof(*cgc)); | ||
151 | cgc32 = compat_ptr(arg); | ||
152 | |||
153 | if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) || | ||
154 | get_user(data, &cgc32->buffer) || | ||
155 | put_user(compat_ptr(data), &cgc->buffer) || | ||
156 | copy_in_user(&cgc->buflen, &cgc32->buflen, | ||
157 | (sizeof(unsigned int) + sizeof(int))) || | ||
158 | get_user(data, &cgc32->sense) || | ||
159 | put_user(compat_ptr(data), &cgc->sense) || | ||
160 | get_user(dir, &cgc32->data_direction) || | ||
161 | put_user(dir, &cgc->data_direction) || | ||
162 | get_user(itmp, &cgc32->quiet) || | ||
163 | put_user(itmp, &cgc->quiet) || | ||
164 | get_user(itmp, &cgc32->timeout) || | ||
165 | put_user(itmp, &cgc->timeout) || | ||
166 | get_user(data, &cgc32->reserved[0]) || | ||
167 | put_user(compat_ptr(data), &cgc->reserved[0])) | ||
168 | return -EFAULT; | ||
169 | |||
170 | return blkdev_driver_ioctl(inode, file, disk, cmd, (unsigned long)cgc); | ||
171 | } | ||
172 | |||
95 | struct compat_blkpg_ioctl_arg { | 173 | struct compat_blkpg_ioctl_arg { |
96 | compat_int_t op; | 174 | compat_int_t op; |
97 | compat_int_t flags; | 175 | compat_int_t flags; |
@@ -190,6 +268,11 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, | |||
190 | case HDIO_GET_ADDRESS: | 268 | case HDIO_GET_ADDRESS: |
191 | case HDIO_GET_BUSSTATE: | 269 | case HDIO_GET_BUSSTATE: |
192 | return compat_hdio_ioctl(inode, file, disk, cmd, arg); | 270 | return compat_hdio_ioctl(inode, file, disk, cmd, arg); |
271 | case CDROMREADAUDIO: | ||
272 | return compat_cdrom_read_audio(inode, file, disk, cmd, arg); | ||
273 | case CDROM_SEND_PACKET: | ||
274 | return compat_cdrom_generic_command(inode, file, disk, cmd, arg); | ||
275 | |||
193 | /* | 276 | /* |
194 | * No handler required for the ones below, we just need to | 277 | * No handler required for the ones below, we just need to |
195 | * convert arg to a 64 bit pointer. | 278 | * convert arg to a 64 bit pointer. |