3 #include <linux/blktrace_api.h>
4 #include <linux/cdrom.h>
9 #include <linux/slab.h>
11 #include <linux/types.h>
14 static int compat_put_ushort(
unsigned long arg,
unsigned short val)
16 return put_user(val, (
unsigned short __user *)compat_ptr(arg));
19 static int compat_put_int(
unsigned long arg,
int val)
24 static int compat_put_uint(
unsigned long arg,
unsigned int val)
29 static int compat_put_long(
unsigned long arg,
long val)
39 static int compat_put_u64(
unsigned long arg,
u64 val)
51 static int compat_hdio_getgeo(
struct gendisk *disk,
struct block_device *bdev,
59 if (!disk->fops->getgeo)
66 geo.
start = get_start_sect(bdev);
67 ret = disk->fops->getgeo(bdev, &geo);
80 unsigned int cmd,
unsigned long arg)
89 cmd, (
unsigned long)(&kval));
93 uvp = compat_ptr(arg);
120 unsigned int cmd,
unsigned long arg)
128 cdread_audio32 = compat_ptr(arg);
131 &cdread_audio32->
addr,
132 (
sizeof(*cdread_audio32) -
138 datap = compat_ptr(data);
143 (
unsigned long)cdread_audio);
147 unsigned int cmd,
unsigned long arg)
156 cgc32 = compat_ptr(arg);
162 (
sizeof(
unsigned int) +
sizeof(
int))) ||
199 err |=
get_user(udata, &ua32->data);
207 #define BLKBSZGET_32 _IOR(0x12, 112, int)
208 #define BLKBSZSET_32 _IOW(0x12, 113, int)
209 #define BLKGETSIZE64_32 _IOR(0x12, 114, int)
276 #define FDSETPRM32 _IOW(2, 0x42, struct compat_floppy_struct)
277 #define FDDEFPRM32 _IOW(2, 0x43, struct compat_floppy_struct)
278 #define FDSETDRVPRM32 _IOW(2, 0x90, struct compat_floppy_drive_params)
279 #define FDGETDRVPRM32 _IOR(2, 0x11, struct compat_floppy_drive_params)
280 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct compat_floppy_drive_struct)
281 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct compat_floppy_drive_struct)
282 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct compat_floppy_fdc_state)
283 #define FDWERRORGET32 _IOR(2, 0x17, struct compat_floppy_write_errors)
288 } fd_ioctl_trans_table[] = {
300 #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
303 unsigned int cmd,
unsigned long arg)
307 unsigned int kcmd = 0;
311 if (cmd == fd_ioctl_trans_table[i].
cmd32) {
312 kcmd = fd_ioctl_trans_table[
i].cmd;
324 struct compat_floppy_struct __user *uf;
327 uf = compat_ptr(arg);
331 if (cmd == FDGETPRM32)
343 f->
name = compat_ptr(name);
356 uf = compat_ptr(arg);
415 struct compat_floppy_struct __user *uf = compat_ptr(arg);
434 uf = compat_ptr(arg);
462 uf = compat_ptr(arg);
485 uf = compat_ptr(arg);
503 uf = compat_ptr(arg);
524 unsigned cmd,
unsigned long arg)
538 return compat_hdio_ioctl(bdev, mode, cmd, arg);
548 return compat_fd_ioctl(bdev, mode, cmd, arg);
620 arg = (
unsigned long)compat_ptr(arg);
661 struct gendisk *disk = bdev->
bd_disk;
677 return compat_hdio_getgeo(disk, bdev, compat_ptr(arg));
679 return compat_put_uint(arg, bdev_physical_block_size(bdev));
681 return compat_put_uint(arg, bdev_io_min(bdev));
683 return compat_put_uint(arg, bdev_io_opt(bdev));
685 return compat_put_int(arg, bdev_alignment_offset(bdev));
687 return compat_put_uint(arg, bdev_discard_zeroes_data(bdev));
698 (
unsigned long)compat_ptr(arg));
701 (
unsigned long)compat_ptr(arg));
703 return compat_blkpg_ioctl(bdev, mode, cmd, compat_ptr(arg));
711 return compat_put_long(arg,
718 return compat_put_int(arg, bdev_logical_block_size(bdev));
720 return compat_put_ushort(arg,
721 queue_max_sectors(bdev_get_queue(bdev)));
723 return compat_put_ushort(arg,
724 !blk_queue_nonrot(bdev_get_queue(bdev)));
736 if ((size >> 9) > ~0
UL)
738 return compat_put_ulong(arg, size >> 9);
741 return compat_put_u64(arg, i_size_read(bdev->
bd_inode));
743 case BLKTRACESETUP32:
750 if (disk->fops->compat_ioctl)
751 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
753 ret = compat_blkdev_driver_ioctl(bdev, mode, cmd, arg);