]> granicus.if.org Git - strace/commitdiff
scsi: on exit, print only initialized part of the buffer
authorBart Van Assche <bart.vanassche@sandisk.com>
Fri, 6 Feb 2015 12:36:26 +0000 (13:36 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 8 Feb 2015 01:42:00 +0000 (01:42 +0000)
* scsi.c (print_sg_io_res): Only print that part of the data in buffer
that has been initialized by the SCSI LLD driver.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
scsi.c

diff --git a/scsi.c b/scsi.c
index 1ca74b8b922b18e3d57c04231c1f593b60f05ea9..5a6838f6557efd7ad44c8e0e37e3adaffdf45c3f 100644 (file)
--- a/scsi.c
+++ b/scsi.c
@@ -88,9 +88,13 @@ print_sg_io_res(struct tcb *tcp, struct sg_io_hdr *sg_io)
 {
        if (sg_io->dxfer_direction == SG_DXFER_FROM_DEV ||
            sg_io->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
-               tprintf(", data[%u]=[", sg_io->dxfer_len);
-               printstr(tcp, (unsigned long) sg_io->dxferp,
-                        sg_io->dxfer_len);
+               uint32_t din_len = sg_io->dxfer_len;
+
+               if (sg_io->resid > 0)
+                       din_len -= sg_io->resid;
+
+               tprintf(", data[%u]=[", din_len);
+               printstr(tcp, (unsigned long) sg_io->dxferp, din_len);
                tprints("]");
        }
        tprintf(", status=%02x, ", sg_io->status);