.. | .. |
---|
19 | 19 | |
---|
20 | 20 | #define IDETAPE_VERSION "1.20" |
---|
21 | 21 | |
---|
| 22 | +#include <linux/compat.h> |
---|
22 | 23 | #include <linux/module.h> |
---|
23 | 24 | #include <linux/types.h> |
---|
24 | 25 | #include <linux/string.h> |
---|
.. | .. |
---|
639 | 640 | goto out; |
---|
640 | 641 | } |
---|
641 | 642 | if (req->cmd[13] & REQ_IDETAPE_PC1) { |
---|
642 | | - pc = (struct ide_atapi_pc *)rq->special; |
---|
| 643 | + pc = (struct ide_atapi_pc *)ide_req(rq)->special; |
---|
643 | 644 | req->cmd[13] &= ~(REQ_IDETAPE_PC1); |
---|
644 | 645 | req->cmd[13] |= REQ_IDETAPE_PC2; |
---|
645 | 646 | goto out; |
---|
.. | .. |
---|
1407 | 1408 | if (tape->drv_write_prot) |
---|
1408 | 1409 | mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); |
---|
1409 | 1410 | |
---|
1410 | | - if (copy_to_user(argp, &mtget, sizeof(struct mtget))) |
---|
1411 | | - return -EFAULT; |
---|
1412 | | - return 0; |
---|
| 1411 | + return put_user_mtget(argp, &mtget); |
---|
1413 | 1412 | case MTIOCPOS: |
---|
1414 | 1413 | mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; |
---|
1415 | | - if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) |
---|
1416 | | - return -EFAULT; |
---|
1417 | | - return 0; |
---|
| 1414 | + return put_user_mtpos(argp, &mtpos); |
---|
1418 | 1415 | default: |
---|
1419 | 1416 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
---|
1420 | 1417 | ide_tape_discard_merge_buffer(drive, 1); |
---|
.. | .. |
---|
1426 | 1423 | unsigned int cmd, unsigned long arg) |
---|
1427 | 1424 | { |
---|
1428 | 1425 | long ret; |
---|
| 1426 | + mutex_lock(&ide_tape_mutex); |
---|
| 1427 | + ret = do_idetape_chrdev_ioctl(file, cmd, arg); |
---|
| 1428 | + mutex_unlock(&ide_tape_mutex); |
---|
| 1429 | + return ret; |
---|
| 1430 | +} |
---|
| 1431 | + |
---|
| 1432 | +static long idetape_chrdev_compat_ioctl(struct file *file, |
---|
| 1433 | + unsigned int cmd, unsigned long arg) |
---|
| 1434 | +{ |
---|
| 1435 | + long ret; |
---|
| 1436 | + |
---|
| 1437 | + if (cmd == MTIOCPOS32) |
---|
| 1438 | + cmd = MTIOCPOS; |
---|
| 1439 | + else if (cmd == MTIOCGET32) |
---|
| 1440 | + cmd = MTIOCGET; |
---|
| 1441 | + |
---|
1429 | 1442 | mutex_lock(&ide_tape_mutex); |
---|
1430 | 1443 | ret = do_idetape_chrdev_ioctl(file, cmd, arg); |
---|
1431 | 1444 | mutex_unlock(&ide_tape_mutex); |
---|
.. | .. |
---|
1886 | 1899 | .read = idetape_chrdev_read, |
---|
1887 | 1900 | .write = idetape_chrdev_write, |
---|
1888 | 1901 | .unlocked_ioctl = idetape_chrdev_ioctl, |
---|
| 1902 | + .compat_ioctl = IS_ENABLED(CONFIG_COMPAT) ? |
---|
| 1903 | + idetape_chrdev_compat_ioctl : NULL, |
---|
1889 | 1904 | .open = idetape_chrdev_open, |
---|
1890 | 1905 | .release = idetape_chrdev_release, |
---|
1891 | 1906 | .llseek = noop_llseek, |
---|
.. | .. |
---|
1930 | 1945 | return err; |
---|
1931 | 1946 | } |
---|
1932 | 1947 | |
---|
| 1948 | +static int idetape_compat_ioctl(struct block_device *bdev, fmode_t mode, |
---|
| 1949 | + unsigned int cmd, unsigned long arg) |
---|
| 1950 | +{ |
---|
| 1951 | + if (cmd == 0x0340 || cmd == 0x350) |
---|
| 1952 | + arg = (unsigned long)compat_ptr(arg); |
---|
| 1953 | + |
---|
| 1954 | + return idetape_ioctl(bdev, mode, cmd, arg); |
---|
| 1955 | +} |
---|
| 1956 | + |
---|
1933 | 1957 | static const struct block_device_operations idetape_block_ops = { |
---|
1934 | 1958 | .owner = THIS_MODULE, |
---|
1935 | 1959 | .open = idetape_open, |
---|
1936 | 1960 | .release = idetape_release, |
---|
1937 | 1961 | .ioctl = idetape_ioctl, |
---|
| 1962 | + .compat_ioctl = IS_ENABLED(CONFIG_COMPAT) ? |
---|
| 1963 | + idetape_compat_ioctl : NULL, |
---|
1938 | 1964 | }; |
---|
1939 | 1965 | |
---|
1940 | 1966 | static int ide_tape_probe(ide_drive_t *drive) |
---|