[PATCH 6/6] bsg: add SG_IO to SG v4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds SG_IO support to SG v4.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
 block/bsg.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 6d139d2..9dc5d36 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -945,8 +945,27 @@ bsg_ioctl(struct inode *inode, struct fi
 		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
 	 */
-- 
1.4.3.2

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux