Subject: patches to make DiskOnKey work on NetBSD 1.5.2
To: None <netbsd-users@netbsd.org>
From: Steve Bellovin <smb@research.att.com>
List: netbsd-users
Date: 09/20/2001 14:00:57
Enclosed below are diff's to three files to permit the DiskOnKey
USB compack flash "disk" to work on NetBSD 1.5.2.  It's a back-port
of Lennart's changes to -current.  The label is funky, but you can
ignore that and just mount partition 'd'.  (Andrew Brown says that
you can create a normal partition table, but I haven't bothered.)
It's working for me on a Thinkpad T21 and on a Dell Precision 410
desktop.  (The nice thing about the DiskOnKey is that it doesn't
require any special drivers on Win2K, newer Linuxes, and moderately
recent Macs, making it an excellent file exchange medium.)

Thanks to Andrew and Lennart.
-----

*** orig/scsiconf.c     Thu Sep 20 10:53:13 2001
--- /sys/dev/scsipi/scsiconf.c  Thu Sep 20 11:15:15 2001
***************
*** 602,607 ****
--- 602,611 ----
         "Y-E DATA", "USB-FDU",          "3.04"}, SDEV_NOMODESENSE},
        {{T_DIRECT, T_REMOV,
         "TEAC", "FD-05PUB",             "1026"}, SDEV_NOMODESENSE},
+       {{T_DIRECT, T_REMOV,
+        "M-Sys", "DiskOnKey",           "2.01"}, SDEV_NOMODESENSE
+             | ADEV_NODOORLOCK | SDEV_ONLYBIG | PQUIRK_NOBIGMODESENSE},
+ 
  
        /* XXX: QIC-36 tape behind Emulex adapter.  Very broken. */
        {{T_SEQUENTIAL, T_REMOV,
*** orig/scsipiconf.h   Thu Sep 20 10:53:13 2001
--- /sys/dev/scsipi/scsipiconf.h        Thu Sep 20 11:17:38 2001
***************
*** 192,198 ****
  #define       SDEV_DBX                0xf0    /* debuging flags (scsipi_debug.h) */
  #define       SDEV_WAITDRAIN          0x100   /* waiting for pending_xfers to drain */
  #define       SDEV_KEEP_LABEL         0x200   /* retain label after 'full' close */
!       u_int16_t quirks;               /* per-device oddities */
  #define       SDEV_AUTOSAVE           0x0001  /*
                                         * Do implicit SAVEDATAPOINTER on
                                         * disconnect (ancient).
--- 192,198 ----
  #define       SDEV_DBX                0xf0    /* debuging flags (scsipi_debug.h) */
  #define       SDEV_WAITDRAIN          0x100   /* waiting for pending_xfers to drain */
  #define       SDEV_KEEP_LABEL         0x200   /* retain label after 'full' close */
!       int quirks;             /* per-device oddities */
  #define       SDEV_AUTOSAVE           0x0001  /*
                                         * Do implicit SAVEDATAPOINTER on
                                         * disconnect (ancient).
***************
*** 212,217 ****
--- 212,218 ----
  #define ADEV_NODOORLOCK               0x2000  /* device can't lock door */
  #define ADEV_NOSENSE          0x4000  /* device can't handle request sense */
  #define SDEV_ONLYBIG          0x8000  /* only use SCSI_{READ,WRITE}_BIG */
+ #define       PQUIRK_NOBIGMODESENSE   0x10000 /*has no big mode-sense op */
  
        struct  scsipi_device *device;  /* device entry points etc. */
        void    *device_softc;          /* needed for call to foo_start */
***************
*** 380,386 ****
  
  struct scsi_quirk_inquiry_pattern {
        struct scsipi_inquiry_pattern pattern;
!       u_int16_t quirks;
  };
  
  /*
--- 381,387 ----
  
  struct scsi_quirk_inquiry_pattern {
        struct scsipi_inquiry_pattern pattern;
!       int quirks;
  };
  
  /*
*** orig/sd_scsi.c      Thu Sep 20 10:53:13 2001
--- /sys/dev/scsipi/sd_scsi.c   Thu Sep 20 11:18:29 2001
***************
*** 172,178 ****
         */
        bzero(scsipi_sense, sizeof(*scsipi_sense));
  
!       if (sd->sc_link->quirks & SDEV_ONLYBIG) {
                memset(&sensebig_cmd, 0, sizeof(sensebig_cmd));
                sensebig_cmd.opcode = SCSI_MODE_SENSE_BIG;
                sensebig_cmd.page = page;
--- 172,179 ----
         */
        bzero(scsipi_sense, sizeof(*scsipi_sense));
  
!       if ((sd->sc_link->quirks & SDEV_ONLYBIG) &&
!           !(sd->sc_link->quirks & PQUIRK_NOBIGMODESENSE)) {
                memset(&sensebig_cmd, 0, sizeof(sensebig_cmd));
                sensebig_cmd.opcode = SCSI_MODE_SENSE_BIG;
                sensebig_cmd.page = page;