Skip to content

Commit

Permalink
bsg: add SG_IO to SG v4
Browse files Browse the repository at this point in the history
This adds SG_IO support to SG v4.

Signed-off-by: FUJITA Tomonori <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
FUJITA Tomonori authored and Jens Axboe committed Jul 16, 2007
1 parent 70e36ec commit 10e8855
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,27 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
void __user *uarg = (void __user *) arg;
return scsi_cmd_ioctl(file, bd->disk, cmd, uarg);
}
case SG_IO:
return -EINVAL;
case SG_IO: {
struct request *rq;
struct bio *bio;
struct sg_io_v4 hdr;

if (copy_from_user(&hdr, uarg, sizeof(hdr)))
return -EFAULT;

rq = bsg_map_hdr(bd, &hdr);
if (IS_ERR(rq))
return PTR_ERR(rq);

bio = rq->bio;
blk_execute_rq(bd->queue, bd->disk, rq, 0);
blk_complete_sgv4_hdr_rq(rq, &hdr, bio);

if (copy_to_user(uarg, &hdr, sizeof(hdr)))
return -EFAULT;
else
return 0;
}
/*
* block device ioctls
*/
Expand Down

0 comments on commit 10e8855

Please sign in to comment.