Ticket #871: scsiata-scsi_only.patch

File scsiata-scsi_only.patch, 3.5 KB (added by Christian Franke, 7 years ago)

Patch adds '-d scsi+TYPE' prefix to disable auto-detection of TYPE

  • dev_interface.cpp

     
    401401  }
    402402
    403403  else if (  ((!strncmp(type, "sat", 3) && (!type[3] || strchr(",+", type[3])))
     404           || str_starts_with(type, "scsi+")
    404405           || (!strncmp(type, "usb", 3)))) {
    405406    // Split "sat...+base..." -> ("sat...", "base...")
    406407    unsigned satlen = strcspn(type, "+");
  • scsiata.cpp

     
    112112  virtual public /*implements*/ scsi_device
    113113{
    114114public:
     115  enum sat_scsi_mode {
     116    sat_always,
     117    sat_auto,
     118    scsi_always
     119  };
     120
    115121  sat_device(smart_interface * intf, scsi_device * scsidev,
    116     const char * req_type, int passthrulen = 0, bool enable_auto = false);
     122    const char * req_type, sat_scsi_mode mode = sat_always, int passthrulen = 0);
    117123
    118124  virtual ~sat_device() throw();
    119125
     
    125131
    126132private:
    127133  int m_passthrulen;
    128   bool m_enable_auto;
     134  sat_scsi_mode m_mode;
    129135};
    130136
    131137
    132138sat_device::sat_device(smart_interface * intf, scsi_device * scsidev,
    133   const char * req_type, int passthrulen /* = 0 */, bool enable_auto /* = false */)
     139  const char * req_type, sat_scsi_mode mode /* = sat_always */,
     140  int passthrulen /* = 0 */)
    134141: smart_device(intf, scsidev->get_dev_name(),
    135     (enable_auto ? "sat,auto" : "sat"), req_type),
     142    (mode == sat_always ? "sat" : mode == sat_auto ? "sat,auto" : "scsi"), req_type),
    136143  tunnelled_device<ata_device, scsi_device>(scsidev),
    137144  m_passthrulen(passthrulen),
    138   m_enable_auto(enable_auto)
     145  m_mode(mode)
    139146{
    140   if (enable_auto)
     147  if (mode != sat_always)
    141148    hide_ata(); // Start as SCSI, switch to ATA in autodetect_open()
    142149  else
    143150    hide_scsi(); // ATA always
     
    144151  if (strcmp(scsidev->get_dev_type(), "scsi"))
    145152    set_info().dev_type += strprintf("+%s", scsidev->get_dev_type());
    146153
    147   set_info().info_name = strprintf("%s [%sSAT]", scsidev->get_info_name(),
    148                                    (enable_auto ? "SCSI/" : ""));
     154  set_info().info_name = strprintf("%s [%s]", scsidev->get_info_name(),
     155    (mode == sat_always ? "SAT" : mode == sat_auto ? "SCSI/SAT" : "SCSI"));
    149156}
    150157
    151158sat_device::~sat_device() throw()
     
    509516
    510517smart_device * sat_device::autodetect_open()
    511518{
    512   if (!open() || !m_enable_auto)
     519  if (!open() || m_mode != sat_auto)
    513520    return this;
    514521
    515522  scsi_device * scsidev = get_tunnel_dev();
     
    14941501
    14951502  if (!strncmp(type, "sat", 3)) {
    14961503    const char * t = type + 3;
    1497     bool enable_auto = false;
     1504    sat_device::sat_scsi_mode mode = sat_device::sat_always;
    14981505    if (!strncmp(t, ",auto", 5)) {
    14991506      t += 5;
    1500       enable_auto = true;
     1507      mode = sat_device::sat_auto;
    15011508    }
    15021509    int ptlen = 0, n = -1;
    15031510    if (*t && !(sscanf(t, ",%d%n", &ptlen, &n) == 1 && n == (int)strlen(t)
     
    15051512      set_err(EINVAL, "Option '-d sat[,auto][,N]' requires N to be 0, 12 or 16");
    15061513      return 0;
    15071514    }
    1508     satdev = new sat_device(this, scsidev, type, ptlen, enable_auto);
     1515    satdev = new sat_device(this, scsidev, type, mode, ptlen);
    15091516  }
    15101517
     1518  else if (!strcmp(type, "scsi")) {
     1519    satdev = new sat_device(this, scsidev, type, sat_device::scsi_always);
     1520  }
     1521
    15111522  else if (!strncmp(type, "usbcypress", 10)) {
    15121523    unsigned signature = 0x24; int n1 = -1, n2 = -1;
    15131524    if (!(((sscanf(type, "usbcypress%n,0x%x%n", &n1, &signature, &n2) == 1 && n2 == (int)strlen(type)) || n1 == (int)strlen(type))