mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-20 22:15:41 +00:00
Fixes spurious character at the end of serial no string.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
|
||||
10
src/device.c
10
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;
|
||||
|
||||
|
||||
12
src/gui.c
12
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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user