Ticket #871: scsiata-scsi_only.patch
File scsiata-scsi_only.patch, 3.5 KB (added by , 7 years ago) |
---|
-
dev_interface.cpp
401 401 } 402 402 403 403 else if ( ((!strncmp(type, "sat", 3) && (!type[3] || strchr(",+", type[3]))) 404 || str_starts_with(type, "scsi+") 404 405 || (!strncmp(type, "usb", 3)))) { 405 406 // Split "sat...+base..." -> ("sat...", "base...") 406 407 unsigned satlen = strcspn(type, "+"); -
scsiata.cpp
112 112 virtual public /*implements*/ scsi_device 113 113 { 114 114 public: 115 enum sat_scsi_mode { 116 sat_always, 117 sat_auto, 118 scsi_always 119 }; 120 115 121 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); 117 123 118 124 virtual ~sat_device() throw(); 119 125 … … 125 131 126 132 private: 127 133 int m_passthrulen; 128 bool m_enable_auto;134 sat_scsi_mode m_mode; 129 135 }; 130 136 131 137 132 138 sat_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 */) 134 141 : 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), 136 143 tunnelled_device<ata_device, scsi_device>(scsidev), 137 144 m_passthrulen(passthrulen), 138 m_ enable_auto(enable_auto)145 m_mode(mode) 139 146 { 140 if ( enable_auto)147 if (mode != sat_always) 141 148 hide_ata(); // Start as SCSI, switch to ATA in autodetect_open() 142 149 else 143 150 hide_scsi(); // ATA always … … 144 151 if (strcmp(scsidev->get_dev_type(), "scsi")) 145 152 set_info().dev_type += strprintf("+%s", scsidev->get_dev_type()); 146 153 147 set_info().info_name = strprintf("%s [%s SAT]", 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")); 149 156 } 150 157 151 158 sat_device::~sat_device() throw() … … 509 516 510 517 smart_device * sat_device::autodetect_open() 511 518 { 512 if (!open() || !m_enable_auto)519 if (!open() || m_mode != sat_auto) 513 520 return this; 514 521 515 522 scsi_device * scsidev = get_tunnel_dev(); … … 1494 1501 1495 1502 if (!strncmp(type, "sat", 3)) { 1496 1503 const char * t = type + 3; 1497 bool enable_auto = false;1504 sat_device::sat_scsi_mode mode = sat_device::sat_always; 1498 1505 if (!strncmp(t, ",auto", 5)) { 1499 1506 t += 5; 1500 enable_auto = true;1507 mode = sat_device::sat_auto; 1501 1508 } 1502 1509 int ptlen = 0, n = -1; 1503 1510 if (*t && !(sscanf(t, ",%d%n", &ptlen, &n) == 1 && n == (int)strlen(t) … … 1505 1512 set_err(EINVAL, "Option '-d sat[,auto][,N]' requires N to be 0, 12 or 16"); 1506 1513 return 0; 1507 1514 } 1508 satdev = new sat_device(this, scsidev, type, ptlen, enable_auto);1515 satdev = new sat_device(this, scsidev, type, mode, ptlen); 1509 1516 } 1510 1517 1518 else if (!strcmp(type, "scsi")) { 1519 satdev = new sat_device(this, scsidev, type, sat_device::scsi_always); 1520 } 1521 1511 1522 else if (!strncmp(type, "usbcypress", 10)) { 1512 1523 unsigned signature = 0x24; int n1 = -1, n2 = -1; 1513 1524 if (!(((sscanf(type, "usbcypress%n,0x%x%n", &n1, &signature, &n2) == 1 && n2 == (int)strlen(type)) || n1 == (int)strlen(type))