.. | .. |
---|
5 | 5 | |
---|
6 | 6 | #include <linux/kernel.h> |
---|
7 | 7 | #include <linux/ide.h> |
---|
| 8 | +#include <linux/compat.h> |
---|
8 | 9 | #include <linux/cdrom.h> |
---|
9 | 10 | #include <linux/mutex.h> |
---|
10 | 11 | |
---|
.. | .. |
---|
302 | 303 | mutex_unlock(&ide_floppy_ioctl_mutex); |
---|
303 | 304 | return err; |
---|
304 | 305 | } |
---|
| 306 | + |
---|
| 307 | +#ifdef CONFIG_COMPAT |
---|
| 308 | +int ide_floppy_compat_ioctl(ide_drive_t *drive, struct block_device *bdev, |
---|
| 309 | + fmode_t mode, unsigned int cmd, unsigned long arg) |
---|
| 310 | +{ |
---|
| 311 | + struct ide_atapi_pc pc; |
---|
| 312 | + void __user *argp = compat_ptr(arg); |
---|
| 313 | + int err; |
---|
| 314 | + |
---|
| 315 | + mutex_lock(&ide_floppy_ioctl_mutex); |
---|
| 316 | + if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { |
---|
| 317 | + err = ide_floppy_lockdoor(drive, &pc, arg, cmd); |
---|
| 318 | + goto out; |
---|
| 319 | + } |
---|
| 320 | + |
---|
| 321 | + err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); |
---|
| 322 | + if (err != -ENOTTY) |
---|
| 323 | + goto out; |
---|
| 324 | + |
---|
| 325 | + /* |
---|
| 326 | + * skip SCSI_IOCTL_SEND_COMMAND (deprecated) |
---|
| 327 | + * and CDROM_SEND_PACKET (legacy) ioctls |
---|
| 328 | + */ |
---|
| 329 | + if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) |
---|
| 330 | + err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); |
---|
| 331 | + |
---|
| 332 | + if (err == -ENOTTY) |
---|
| 333 | + err = generic_ide_ioctl(drive, bdev, cmd, arg); |
---|
| 334 | + |
---|
| 335 | +out: |
---|
| 336 | + mutex_unlock(&ide_floppy_ioctl_mutex); |
---|
| 337 | + return err; |
---|
| 338 | +} |
---|
| 339 | +#endif |
---|