From 3c4e51a1ff9ad9f8883b22f063d265392b9cefe1 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Mon, 1 Nov 2021 22:54:55 +0000 Subject: [PATCH] Add SAS to GUI. 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 SAS. --- src/context.h | 3 ++- src/device.c | 17 +++++++++++++++++ src/version.c | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/context.h b/src/context.h index 9132492..260d070 100644 --- a/src/context.h +++ b/src/context.h @@ -34,7 +34,8 @@ typedef enum nwipe_device_t_ { NWIPE_DEVICE_IEEE1394, // Unimplemented. NWIPE_DEVICE_ATA, NWIPE_DEVICE_NVME, - NWIPE_DEVICE_VIRT + NWIPE_DEVICE_VIRT, + NWIPE_DEVICE_SAS } nwipe_device_t; typedef enum nwipe_pass_t_ { diff --git a/src/device.c b/src/device.c index b38c9e0..2e092dc 100644 --- a/src/device.c +++ b/src/device.c @@ -289,6 +289,10 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) case NWIPE_DEVICE_VIRT: strcpy( next_device->device_type_str, "VIRT" ); break; + + case NWIPE_DEVICE_SAS: + strcpy( next_device->device_type_str, " SAS" ); + break; } if( strlen( (const char*) next_device->device_serial_no ) ) @@ -629,6 +633,19 @@ 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 ) + { + /* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */ + trim( &result[19] ); + + if( strncmp( &result[19], "SAS", 3 ) == 0 ) + { + *bus = NWIPE_DEVICE_SAS; + } + } + } } /* close */ diff --git a/src/version.c b/src/version.c index c591fe5..1f84eab 100644 --- a/src/version.c +++ b/src/version.c @@ -4,7 +4,7 @@ * used by configure to dynamically assign those values * to documentation files. */ -const char* version_string = "0.32"; +const char* version_string = "0.32.001"; const char* program_name = "nwipe"; const char* author_name = "Martijn van Brummelen"; const char* email_address = "git@brumit.nl"; @@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley \n\ This is free software; see the source for copying conditions.\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\ FOR A PARTICULAR PURPOSE.\n"; -const char* banner = "nwipe 0.32"; +const char* banner = "nwipe 0.32.001";