hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/ide/ide-floppy_ioctl.c
....@@ -5,6 +5,7 @@
55
66 #include <linux/kernel.h>
77 #include <linux/ide.h>
8
+#include <linux/compat.h>
89 #include <linux/cdrom.h>
910 #include <linux/mutex.h>
1011
....@@ -302,3 +303,37 @@
302303 mutex_unlock(&ide_floppy_ioctl_mutex);
303304 return err;
304305 }
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