From 50af89af0b2da34d548c1f1bdc8f2479a7407d2e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 29 Nov 2012 00:26:53 +0100 Subject: [PATCH] Put the swapped ATA model/serial strings into the SCSI inquiry. The ATA info block has the model, serial and firmware revision byte swapped that we already converted and then printed out correctly. The original values were however copied to the SCSI inquiry data so the device names that end up in different places were incorrect. This fixes #7926. Also added a comment explaining that there's way too little space in the SCSI inquiry block to fit in the full ATA data. --- .../kernel/busses/scsi/ahci/ahci_port.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp index 85e4403775..3d51f71281 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp @@ -599,12 +599,6 @@ AHCIPort::ScsiInquiry(scsi_ccb *request) scsiData.write_bus16 = true; scsiData.write_bus32 = false; scsiData.relative_address = false; - memcpy(scsiData.vendor_ident, ataData.model_number, - sizeof(scsiData.vendor_ident)); - memcpy(scsiData.product_ident, ataData.model_number + 8, - sizeof(scsiData.product_ident)); - memcpy(scsiData.product_rev, ataData.serial_number, - sizeof(scsiData.product_rev)); if (!fIsATAPI) { bool lba = ataData.dma_supported != 0; @@ -645,6 +639,17 @@ AHCIPort::ScsiInquiry(scsi_ccb *request) TRACE("firmware rev.: %s\n", firmwareRev); TRACE("trim support: %s\n", fTrim ? "yes" : "no"); + // There's not enough space to fit all of the data in. ATA has 40 bytes for + // the model number, 20 for the serial number and another 8 for the + // firmware revision. SCSI has room for 8 for vendor ident, 16 for product + // ident and another 4 for product revision. We just try and fit in as much + // as possible of the model number into the vendor and product ident fields + // and put a little of the serial number into the product revision field. + memcpy(scsiData.vendor_ident, modelNumber, sizeof(scsiData.vendor_ident)); + memcpy(scsiData.product_ident, modelNumber + 8, + sizeof(scsiData.product_ident)); + memcpy(scsiData.product_rev, serialNumber, sizeof(scsiData.product_rev)); + if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) { request->subsys_status = SCSI_DATA_RUN_ERR;