[sane-devel] How to log transferred scsi data?
Major A
andras at users.sourceforge.net
Thu Oct 10 23:58:14 BST 2002
> >Hi everybody (especially the scsi-specialists),
> >
> >I have the following problem: A user has an (so far unsupported)
> >scsi-scanner. He also has vmware running the original windows driver. So
> >we want to log the commands and data during a scan. We managed logging the
> >commands with
> >echo "scsi log mlqueue 5" > /proc/scsi/scsi. Now the question is: What to
> >do to get also the data that is transfered between scanner and computer?
You will have to patch the kernel for this. The file to change is
drivers/scsi/sg.c. If you want to log write commands, add code to the
end of sg_common_write() that dumps the contents of SRpnt->sr_buffer
using printk. Here is what I've done, in 2.4.19:
--- sg.c.old 2002-10-10 23:54:33.000000000 +0100
+++ sg.c.new 2002-10-10 23:54:27.000000000 +0100
@@ -665,6 +670,7 @@
Sg_device * sdp = sfp->parentdp;
sg_io_hdr_t * hp = &srp->header;
request_queue_t * q;
+ int i;
srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */
hp->status = 0;
@@ -732,6 +738,12 @@
hp->duration = jiffies; /* unit jiffies now, millisecs after done */
/* Now send everything of to mid-level. The next time we hear about this
packet is when sg_cmd_done_bh() is called (i.e. a callback). */
+
+ SCSI_LOG_TIMEOUT(3, printk("dxferp[%li] = ", hp->dxfer_len));
+ for (i = 0; i < hp->dxfer_len; i ++)
+ SCSI_LOG_TIMEOUT(3, printk("%02x ", ((unsigned char *) (SRpnt->sr_buffer))[i]));
+ SCSI_LOG_TIMEOUT(3, printk("\n"));
+
scsi_do_req(SRpnt, (void *)cmnd,
(void *)SRpnt->sr_buffer, hp->dxfer_len,
sg_cmd_done_bh, timeout, SG_DEFAULT_RETRIES);
Logging of the sent data will then start at debug level 3 for
"timeout". Hope this helps,
Andras
===========================================================================
Major Andras
e-mail: andras at users.sourceforge.net
www: http://andras.webhop.org/
===========================================================================
More information about the sane-devel
mailing list