| .. | .. |
|---|
| 290 | 290 | rc = tape_open(device); |
|---|
| 291 | 291 | if (rc == 0) { |
|---|
| 292 | 292 | filp->private_data = device; |
|---|
| 293 | | - nonseekable_open(inode, filp); |
|---|
| 293 | + stream_open(inode, filp); |
|---|
| 294 | 294 | } else |
|---|
| 295 | 295 | tape_put_device(device); |
|---|
| 296 | 296 | |
|---|
| .. | .. |
|---|
| 341 | 341 | */ |
|---|
| 342 | 342 | static int |
|---|
| 343 | 343 | __tapechar_ioctl(struct tape_device *device, |
|---|
| 344 | | - unsigned int no, unsigned long data) |
|---|
| 344 | + unsigned int no, void __user *data) |
|---|
| 345 | 345 | { |
|---|
| 346 | 346 | int rc; |
|---|
| 347 | 347 | |
|---|
| 348 | 348 | if (no == MTIOCTOP) { |
|---|
| 349 | 349 | struct mtop op; |
|---|
| 350 | 350 | |
|---|
| 351 | | - if (copy_from_user(&op, (char __user *) data, sizeof(op)) != 0) |
|---|
| 351 | + if (copy_from_user(&op, data, sizeof(op)) != 0) |
|---|
| 352 | 352 | return -EFAULT; |
|---|
| 353 | 353 | if (op.mt_count < 0) |
|---|
| 354 | 354 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 392 | 392 | if (rc < 0) |
|---|
| 393 | 393 | return rc; |
|---|
| 394 | 394 | pos.mt_blkno = rc; |
|---|
| 395 | | - if (copy_to_user((char __user *) data, &pos, sizeof(pos)) != 0) |
|---|
| 396 | | - return -EFAULT; |
|---|
| 397 | | - return 0; |
|---|
| 395 | + return put_user_mtpos(data, &pos); |
|---|
| 398 | 396 | } |
|---|
| 399 | 397 | if (no == MTIOCGET) { |
|---|
| 400 | 398 | /* MTIOCGET: query the tape drive status. */ |
|---|
| .. | .. |
|---|
| 424 | 422 | get.mt_blkno = rc; |
|---|
| 425 | 423 | } |
|---|
| 426 | 424 | |
|---|
| 427 | | - if (copy_to_user((char __user *) data, &get, sizeof(get)) != 0) |
|---|
| 428 | | - return -EFAULT; |
|---|
| 429 | | - |
|---|
| 430 | | - return 0; |
|---|
| 425 | + return put_user_mtget(data, &get); |
|---|
| 431 | 426 | } |
|---|
| 432 | 427 | /* Try the discipline ioctl function. */ |
|---|
| 433 | 428 | if (device->discipline->ioctl_fn == NULL) |
|---|
| 434 | 429 | return -EINVAL; |
|---|
| 435 | | - return device->discipline->ioctl_fn(device, no, data); |
|---|
| 430 | + return device->discipline->ioctl_fn(device, no, (unsigned long)data); |
|---|
| 436 | 431 | } |
|---|
| 437 | 432 | |
|---|
| 438 | 433 | static long |
|---|
| .. | .. |
|---|
| 445 | 440 | |
|---|
| 446 | 441 | device = (struct tape_device *) filp->private_data; |
|---|
| 447 | 442 | mutex_lock(&device->mutex); |
|---|
| 448 | | - rc = __tapechar_ioctl(device, no, data); |
|---|
| 443 | + rc = __tapechar_ioctl(device, no, (void __user *)data); |
|---|
| 449 | 444 | mutex_unlock(&device->mutex); |
|---|
| 450 | 445 | return rc; |
|---|
| 451 | 446 | } |
|---|
| .. | .. |
|---|
| 455 | 450 | tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) |
|---|
| 456 | 451 | { |
|---|
| 457 | 452 | struct tape_device *device = filp->private_data; |
|---|
| 458 | | - int rval = -ENOIOCTLCMD; |
|---|
| 459 | | - unsigned long argp; |
|---|
| 453 | + long rc; |
|---|
| 460 | 454 | |
|---|
| 461 | | - /* The 'arg' argument of any ioctl function may only be used for |
|---|
| 462 | | - * pointers because of the compat pointer conversion. |
|---|
| 463 | | - * Consider this when adding new ioctls. |
|---|
| 464 | | - */ |
|---|
| 465 | | - argp = (unsigned long) compat_ptr(data); |
|---|
| 466 | | - if (device->discipline->ioctl_fn) { |
|---|
| 467 | | - mutex_lock(&device->mutex); |
|---|
| 468 | | - rval = device->discipline->ioctl_fn(device, no, argp); |
|---|
| 469 | | - mutex_unlock(&device->mutex); |
|---|
| 470 | | - if (rval == -EINVAL) |
|---|
| 471 | | - rval = -ENOIOCTLCMD; |
|---|
| 472 | | - } |
|---|
| 455 | + if (no == MTIOCPOS32) |
|---|
| 456 | + no = MTIOCPOS; |
|---|
| 457 | + else if (no == MTIOCGET32) |
|---|
| 458 | + no = MTIOCGET; |
|---|
| 473 | 459 | |
|---|
| 474 | | - return rval; |
|---|
| 460 | + mutex_lock(&device->mutex); |
|---|
| 461 | + rc = __tapechar_ioctl(device, no, compat_ptr(data)); |
|---|
| 462 | + mutex_unlock(&device->mutex); |
|---|
| 463 | + return rc; |
|---|
| 475 | 464 | } |
|---|
| 476 | 465 | #endif /* CONFIG_COMPAT */ |
|---|
| 477 | 466 | |
|---|