summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2006-12-20 11:20:57 +0100
committerJens Axboe <jens.axboe@oracle.com>2007-07-16 08:52:44 +0200
commit10e8855b945193a62801429af3aab9f7e27ef56a (patch)
treecb58b35ad27f0c9ee6b7d1adab5ce6ca3a5bc918 /block
parent70e36eceaf897da11aa0b4d82b46ca66e65a05f1 (diff)
downloadlwn-10e8855b945193a62801429af3aab9f7e27ef56a.tar.gz
lwn-10e8855b945193a62801429af3aab9f7e27ef56a.zip
bsg: add SG_IO to SG v4
This adds SG_IO support to SG v4. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/bsg.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/block/bsg.c b/block/bsg.c
index 6d139d20ec99..9dc5d36a52e5 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -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
*/