Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/dev/scsipi Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/e4d3de6b3b46
branches:  netbsd-3
changeset: 577656:e4d3de6b3b46
user:      riz <riz%NetBSD.org@localhost>
date:      Thu Dec 29 15:20:29 2005 +0000

description:
Pull up following revision(s) (requested by bouyer in ticket #1045):
        sys/dev/scsipi/sd.c: revision 1.242
Some USB devices reports themselves as removable, but have no door and
so don't support the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
When an "Illegal field in CDB" is reported for this command, mark the
device as non-removable (which is always true for USB keys from the SCSI
point of view), print a message and ignore the error.
For DIOCLOCK, return ENOTTY if the device is not removable instead of
trying a command which will fail.
Fix a problem reported by Hubert Feyrer for some USB umass devices, patch
tested by him.

diffstat:

 sys/dev/scsipi/sd.c |  29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r ba1172ce6b49 -r e4d3de6b3b46 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Thu Dec 29 15:15:50 2005 +0000
+++ b/sys/dev/scsipi/sd.c       Thu Dec 29 15:20:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.237.2.1 2005/04/06 11:56:38 tron Exp $        */
+/*     $NetBSD: sd.c,v 1.237.2.2 2005/12/29 15:20:29 riz Exp $ */
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.237.2.1 2005/04/06 11:56:38 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.237.2.2 2005/12/29 15:20:29 riz Exp $");
 
 #include "opt_scsi.h"
 #include "rnd.h"
@@ -1129,8 +1129,12 @@
                return (0);
 
        case DIOCLOCK:
-               return (scsipi_prevent(periph,
-                   (*(int *)addr) ? SPAMR_PREVENT_DT : SPAMR_ALLOW, 0));
+               if (periph->periph_flags & PERIPH_REMOVABLE)
+                       return (scsipi_prevent(periph,
+                           (*(int *)addr) ?
+                           SPAMR_PREVENT_DT : SPAMR_ALLOW, 0));
+               else
+                       return (ENOTTY);
 
        case DIOCEJECT:
                if ((periph->periph_flags & PERIPH_REMOVABLE) == 0)
@@ -1354,6 +1358,23 @@
                return (retval);
 
        /*
+        * Ignore errors from accessing illegal fields (e.g. trying to
+        * lock the door of a digicam, which doesn't have a door that
+        * can be locked) for the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
+        */
+       if (xs->cmd.opcode == SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL &&
+           (sense->flags & SSD_KEY) == SKEY_ILLEGAL_REQUEST &&
+           sense->add_sense_code == 0x24 &&
+           sense->add_sense_code_qual == 0x00) { /* Illegal field in CDB */
+               scsipi_printaddr(periph);
+               printf("no door lock\n");
+               periph->periph_flags &= ~PERIPH_REMOVABLE;
+               return 0;
+       }
+
+
+
+       /*
         * If the device is not open yet, let the generic code handle it.
         */
        if ((periph->periph_flags & PERIPH_MEDIA_LOADED) == 0)



Home | Main Index | Thread Index | Old Index