]> granicus.if.org Git - strace/commit
scsi: add bsg support
authorBart Van Assche <bart.vanassche@sandisk.com>
Fri, 6 Feb 2015 12:37:03 +0000 (13:37 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 8 Feb 2015 02:07:22 +0000 (02:07 +0000)
commit67d0a8ecfa288928c2096123a9ddfb0e5392edbf
tree901bdaa3102859eebd7c555d649089571e951d8f
parent791145ee6e373f510cfb2c87723df2f61e98d2ba
scsi: add bsg support

The Linux kernel supports two different versions of the SG_IO API,
namely v3 and v4. This patch adds support for version 4 of this API.
At least the sg3_utils package supports version 4 of this API.  Version
4 of this API is used if /dev/bsg/H:C:I:L is used as device name.

This patch has been tested by inspecting the output of the following
commands:

modprobe scsi_debug dev_size_mb=16 delay=0
dev=$(lsscsi | sed -n '/ scsi_debug /s,^[^/]*,,p')
./strace -eioctl -s256 sg_inq $dev
echo 'Test XDWRITEREAD(10)'
bsg=/dev/bsg/$(lsscsi | sed -n '/ scsi_debug /s,^\[\([^]]\+\)\].*,\1,p')
dd if=/dev/zero bs=512 count=1 |
  ./strace -eioctl -s256 sg_raw -s 512 -r 1024 $bsg 53 00 00 00 00 01 00 00 01 00

* configure.ac (AC_CHECK_HEADERS): Add linux/bsg.h.
* xlat/bsg_protocol.in: New file.
* xlat/bsg_subprotocol.in: Likewise.
* scsi.c: Include them and <linux/bsg.h>.
(print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): New functions.
(print_sg_io_req, print_sg_io_res): Use them.
(scsi_ioctl): Update callers.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
configure.ac
scsi.c
xlat/bsg_protocol.in [new file with mode: 0644]
xlat/bsg_subprotocol.in [new file with mode: 0644]