diff --git a/src/context.h b/src/context.h index 814f8e5..a942c66 100644 --- a/src/context.h +++ b/src/context.h @@ -114,7 +114,11 @@ typedef struct nwipe_context_t_ pthread_t thread; /* The ID of the thread. */ u64 throughput; /* Average throughput in bytes per second. */ u64 verify_errors; /* The number of verification errors across all passes. */ - struct hd_driveid identity; /* The serial number of the drive (where applicable) */ + char serial_no[21]; /* Serial number(processed), 20 characters, plus null termination */ + struct hd_driveid identity; /* Identity contains the raw serial number of the drive */ + /* (where applicable), however, for use within nwipe use the */ + /* processed serial_no[21] string above. To access serial no. use */ + /* c[i]->serial_no) and not c[i]->identity.serial_no); */ } nwipe_context_t; diff --git a/src/device.c b/src/device.c index 91f3100..edb33b8 100644 --- a/src/device.c +++ b/src/device.c @@ -148,8 +148,14 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) */ ioctl(fd, HDIO_GET_IDENTITY, &next_device->identity); close( fd ); - trim ( (char*) next_device->identity.serial_no ); /* Remove leading/training whitespace from serial number and left justify */ - nwipe_log( NWIPE_LOG_INFO,"Found drive model=\"%s\", device path=\"%s\", size=\"%s\", serial number=\"%s\"", next_device->label, next_device->device_name, next_device->device_size_text, next_device->identity.serial_no); + + int idx; + for (idx=0; idx<20; idx++) next_device->serial_no[idx]=next_device->identity.serial_no[idx]; + + next_device->serial_no[20]=0; /* terminate the string */ + trim ( (char*) next_device->serial_no ); /* Remove leading/training whitespace from serial number and left justify */ + + nwipe_log( NWIPE_LOG_INFO,"Found drive model=\"%s\", device path=\"%s\", size=\"%s\", serial number=\"%s\"", next_device->label, next_device->device_name, next_device->device_size_text, next_device->serial_no); (*c)[dcount] = next_device; diff --git a/src/gui.c b/src/gui.c index 5f31493..b4eee72 100644 --- a/src/gui.c +++ b/src/gui.c @@ -450,7 +450,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) wprintw( main_window, " [wipe] %i. %s - %s %s (%s)", (i + offset + 1), c[i+offset]->device_name, c[i+offset]->label, - c[i+offset]->identity.serial_no, + c[i+offset]->serial_no, c[i+offset]->device_size_text ); break; @@ -459,7 +459,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) wprintw( main_window, " [ ] %i. %s - %s %s (%s)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, - c[i+offset]->identity.serial_no, + c[i+offset]->serial_no, c[i+offset]->device_size_text ); break; @@ -469,7 +469,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) wprintw( main_window, " [****] %i. %s - %s %s (%s)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, - c[i+offset]->identity.serial_no, + c[i+offset]->serial_no, c[i+offset]->device_size_text ); break; @@ -479,7 +479,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) wprintw( main_window, " [----] %i. %s - %s %s (%s)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, - c[i+offset]->identity.serial_no, + c[i+offset]->serial_no, c[i+offset]->device_size_text ); break; @@ -1813,11 +1813,11 @@ void *nwipe_gui_status( void *ptr ) for( i = offset ; i < offset + slots && i < count ; i++ ) { /* Print the context label. */ - if ( strlen((const char*)c[i]->identity.serial_no) ) + if ( strlen((const char*)c[i]->serial_no) ) { mvwprintw( main_window, yy++, 2, "%s - %s (%s)", c[i]->device_name, c[i]->label, - c[i]->identity.serial_no); + c[i]->serial_no); } else { mvwprintw( main_window, yy++, 2, "%s - %s", c[i]->device_name, diff --git a/src/nwipe.c b/src/nwipe.c index 8a324cf..31e6a01 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -291,8 +291,8 @@ int main( int argc, char** argv ) */ /* Print serial number of device if it exists. */ - if ( strlen((const char*)c2[i]->identity.serial_no) ) { - nwipe_log( NWIPE_LOG_INFO, "Device %s has serial number %s", c2[i]->device_name, c2[i]->identity.serial_no); + if ( strlen((const char*)c2[i]->serial_no) ) { + nwipe_log( NWIPE_LOG_INFO, "Device %s has serial number %s", c2[i]->device_name, c2[i]->serial_no); }