From 366249b76a753f6cb5c520c48aedf833eb7a6801 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Fri, 5 Nov 2021 23:43:43 +0000 Subject: [PATCH] Check smartctl for unresolved bus types SATA For some controllers/drivers the readlink method of obtaining the bus type for GUI display does not work. If we haven't already resolved the bus type, we then also check smartctl for the transport protocol for SATA. --- src/device.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/device.c b/src/device.c index eaa9570..894e068 100644 --- a/src/device.c +++ b/src/device.c @@ -633,6 +633,7 @@ int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, c strncpy( serialnumber, &result[15], 20 ); } + if( *bus == 0 ) { if( strstr( result, "Transport protocol:" ) != 0 ) @@ -645,6 +646,18 @@ int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, c *bus = NWIPE_DEVICE_SAS; } } + + if( strstr( result, "SATA Version is:" ) != 0 ) + { + + /* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */ + trim( &result[16] ); + + if( strncmp( &result[16], "SATA", 4 ) == 0 ) + { + *bus = NWIPE_DEVICE_ATA; + } + } } }