From: Matthew Dharm <mdharm-kernel@one-eyed-alien.net>
To: Andries.Brouwer@cwi.nl
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-usb-devel@lists.sourceforge.net
Subject: Re: inquiry in scsi_scan.c
Date: Sat, 4 Jan 2003 16:41:13 -0800 [thread overview]
Message-ID: <20030104164113.A27421@one-eyed-alien.net> (raw)
In-Reply-To: <UTC200301040307.h0437pY06513.aeb@smtp.cwi.nl>; from Andries.Brouwer@cwi.nl on Sat, Jan 04, 2003 at 04:07:51AM +0100
[-- Attachment #1: Type: text/plain, Size: 3228 bytes --]
Instead of fixing this in usb-storage, I think I would rather make
scsi_scan.c just assume a minimum of 36.
Or, put another way, if the first request indicates less than 36, why
should we do a second request? We already have all the data...
Matt
On Sat, Jan 04, 2003 at 04:07:51AM +0100, Andries.Brouwer@cwi.nl wrote:
> Matthew Dharm writes:
>
> > There should probably be a sanity check to never ask for INQUIRY
> > less than 36 bytes. I thought there used to be such a thing....
>
> As Doug also points out, we ask for 36, but there is no
> guarantee that we get what we ask for.
>
> > Actually, 5 isn't minimal... it's sub-minimal.
> > That's an error in the INQUIRY data/
> > The minimum (by spec) is 36 bytes.
>
> No. Quoting:
>
> "The INQUIRY data (Table 7-9) contains a five byte header,
> followed by the vendor unique parameters, if any."
> (SCSI-1 standard)
>
> So, as long as we are willing to support SCSI-1 devices,
> we must accept that the INQUIRY data can be as short as this.
> And in fact all our other code is careful - look at
> print_inquiry() how before looking at a byte we check
> whether it really there.
>
>
> On the other hand, my case was not an ancient SCSI-1 device,
> it was a brand new USB device. So, I have the SCSI host in hand.
> Looking at what happens:
>
> usb-storage: usb_stor_bulk_transfer_buf(): xfer 36 bytes
> 00 80 00 00 00 00 00 00 4F 45 49 2D 55 53 42 20
> 53 6D 61 72 74 4D 65 64 69 61 20 20 20 20 20 20
> 32 2E 30 35
> usb-storage: Status code 0; transferred 36/36
> usb-storage: Fixing INQUIRY data to show SCSI rev 2 - was 0
> usb-storage: Fixing INQUIRY data to show length 36 - was 0
>
> and all is fine.
>
> Instead of the old garbage I now see:
> % cat /proc/scsi/scsi
> ...
> Host: scsi2 Channel: 00 Id: 00 Lun: 00
> Vendor: OEI-USB Model: SmartMedia Rev: 2.05
> Type: Direct-Access ANSI SCSI revision: 02
> ...
>
>
> Conclusion:
> (i) scsi_scan.c has to be careful about INQUIRY lengths,
> and some patch is required for devices that return a short length.
> (ii) usb-storage knows the transport length, and can fix it
> in case it is (5+)0. For example, in protocol.c:fix_inquiry_data():
>
> static void fix_inquiry_data(Scsi_Cmnd *srb)
> {
> unsigned char *data_ptr;
>
> /* verify that it's an INQUIRY command */
> if (srb->cmnd[0] != INQUIRY)
> return;
>
> data_ptr = find_data_location(srb);
>
> if ((data_ptr[2] & 7) != 2) {
> US_DEBUGP("Fixing INQUIRY data to show SCSI rev 2 - was %d\n",
> data_ptr[2] & 7);
>
> /* Change the SCSI revision number */
> data_ptr[2] = (data_ptr[2] & ~7) | 2;
> }
>
> if (data_ptr[4] == 0) {
> US_DEBUGP("Fixing INQUIRY data to show length 36 - was 0\n");
> data_ptr[4] = 36 - 5;
> }
> }
>
> Andries
--
Matthew Dharm Home: mdharm-usb@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver
It was a new hope.
-- Dust Puppy
User Friendly, 12/25/1998
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
next prev parent reply other threads:[~2003-01-05 0:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-04 3:07 inquiry in scsi_scan.c Andries.Brouwer
2003-01-05 0:41 ` Matthew Dharm [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-01-05 21:42 Andries.Brouwer
2003-01-06 20:52 ` Patrick Mansfield
2003-01-05 21:35 Andries.Brouwer
2003-01-05 22:05 ` Luben Tuikov
2003-01-05 13:07 Andries.Brouwer
2003-01-05 19:36 ` Luben Tuikov
2003-01-05 20:54 ` Zwane Mwaikambo
2003-01-04 3:24 Andries.Brouwer
2003-01-04 0:21 Andries.Brouwer
2003-01-04 1:04 ` Matthew Dharm
2003-01-04 2:14 ` Douglas Gilbert
2003-01-04 2:44 ` Patrick Mansfield
2003-01-05 0:45 ` Matthew Dharm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030104164113.A27421@one-eyed-alien.net \
--to=mdharm-kernel@one-eyed-alien.net \
--cc=Andries.Brouwer@cwi.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox