Subject: Re: old SCSI devices that don't support INQUIRY
To: Matthew Fredette <fredette@MIT.EDU>
From: Michael L. Hitch <mhitch@lightning.msu.montana.edu>
List: tech-kern
Date: 09/13/2001 21:46:01
On Thu, 13 Sep 2001, Matthew Fredette wrote:

> 
> Hi.  Sun-2s often have MFM hard drives sitting behind Adaptec ACB-4000
> SCSI->MFM converter boards.  These boards are really old and don't
> understand the INQUIRY command.  What's the best way to go about
> adding support for them?  Thanks -

  I've used the following patch for quite a while on my Amiga.

--- sys/dev/scsipi/scsipi_base.c.orig   Fri Jun  9 02:54:24 2000
+++ sys/dev/scsipi/scsipi_base.c        Mon Jan 15 00:05:23 2001
@@ -409,6 +409,13 @@ scsipi_interpret_sense(xs)
         * Not code 70, just report it
         */
        default:
+               if ((sense->error_code & SSD_ERRCODE) == 0x20) {
+                       if ((xs->xs_control & XS_CTL_IGNORE_ILLEGAL_REQUEST) != 0)
+                               return 0;
+                       return (EINVAL);        /* Adaptec A4000 invalid request */
+               }
+               if ((sense->error_code & SSD_ERRCODE) == 0x25)
+                       return (EACCES);        /* Adaptec A4000 invalid LUN */
 #if    defined(SCSIDEBUG) || defined(DEBUG)
        {
                static char *uc = "undecodable sense error";
@@ -511,15 +518,27 @@ scsipi_inquire(sc_link, inqbuf, flags)
        int flags;
 {
        struct scsipi_inquiry scsipi_cmd;
+       int error;

        bzero(&scsipi_cmd, sizeof(scsipi_cmd));
        scsipi_cmd.opcode = INQUIRY;
        scsipi_cmd.length = sizeof(struct scsipi_inquiry_data);

-       return (scsipi_command(sc_link,
+       error = scsipi_command(sc_link,
            (struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
            (u_char *) inqbuf, sizeof(struct scsipi_inquiry_data),
-           SCSIPIRETRIES, 10000, NULL, XS_CTL_DATA_IN | flags));
+           SCSIPIRETRIES, 10000, NULL, XS_CTL_DATA_IN | flags);
+       /*
+        * Kludge for Adaptec A4000, which doesn't support the inquire
+        * command.
+        */
+       if (error == EINVAL || error == EACCES) {
+               bzero (inqbuf, 4);
+               if (error == EACCES)
+                       inqbuf->device = SID_QUAL_BAD_LU | SID_TYPE;
+               error = 0;
+       }
+       return error;
 }

 /*


--
Michael L. Hitch			mhitch@montana.edu
Computer Consultant
Information Technology Center
Montana State University	Bozeman, MT	USA