From 7ac6de99335e89cab84b57d0b5ef83533b2da169 Mon Sep 17 00:00:00 2001 From: Andy Beverley Date: Sat, 7 Sep 2013 00:19:37 +0100 Subject: [PATCH] Add additional info to status screen when blanking --- src/device.c | 2 ++ src/gui.c | 23 ++++++++++++++++++----- src/nwipe.c | 4 +--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/device.c b/src/device.c index 7f66a14..472790a 100644 --- a/src/device.c +++ b/src/device.c @@ -124,6 +124,8 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) next_device->label = dev->model; next_device->device_name = dev->path; next_device->device_size = dev->length * dev->sector_size; + /* Attempt to get serial number of device. */ + ioctl(next_device->device_fd, HDIO_GET_IDENTITY, &next_device->identity); (*c)[dcount] = next_device; diff --git a/src/gui.c b/src/gui.c index 6ea72de..daebbe2 100644 --- a/src/gui.c +++ b/src/gui.c @@ -442,35 +442,39 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) { case NWIPE_SELECT_TRUE: - wprintw( main_window, " [wipe] %i. %s - %s (%lld bytes)", (i + offset + 1), + wprintw( main_window, " [wipe] %i. %s - %s %s (%lld bytes)", (i + offset + 1), c[i+offset]->device_name, c[i+offset]->label, + c[i+offset]->identity.serial_no, c[i+offset]->device_size ); break; case NWIPE_SELECT_FALSE: /* Print an element that is not selected. */ - wprintw( main_window, " [ ] %i. %s - %s (%lld bytes)", (i + offset +1), + wprintw( main_window, " [ ] %i. %s - %s %s (%lld bytes)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, + c[i+offset]->identity.serial_no, c[i+offset]->device_size ); break; case NWIPE_SELECT_TRUE_PARENT: /* This element will be wiped when its parent is wiped. */ - wprintw( main_window, " [****] %i. %s - %s (%lld bytes)", (i + offset +1), + wprintw( main_window, " [****] %i. %s - %s %s (%lld bytes)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, + c[i+offset]->identity.serial_no, c[i+offset]->device_size ); break; case NWIPE_SELECT_FALSE_CHILD: /* We can't wipe this element because it has a child that is being wiped. */ - wprintw( main_window, " [----] %i. %s - %s (%lld bytes)", (i + offset +1), + wprintw( main_window, " [----] %i. %s - %s %s (%lld bytes)", (i + offset +1), c[i+offset]->device_name, c[i+offset]->label, + c[i+offset]->identity.serial_no, c[i+offset]->device_size ); break; @@ -1849,7 +1853,16 @@ void *nwipe_gui_status( void *ptr ) for( i = offset ; i < offset + slots && i < count ; i++ ) { /* Print the context label. */ - mvwprintw( main_window, yy++, 2, "%s", c[i]->label ); + if ( strlen(c[i]->identity.serial_no) ) + { + mvwprintw( main_window, yy++, 2, "%s - %s (%s)", c[i]->device_name, + c[i]->label, + c[i]->identity.serial_no); + } + else { + mvwprintw( main_window, yy++, 2, "%s - %s", c[i]->device_name, + c[i]->label ); + } /* Check whether the child process is still running the wipe. */ if( c[i]->thread > 0 ) diff --git a/src/nwipe.c b/src/nwipe.c index 83f1de8..c5ab011 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -287,9 +287,7 @@ int main( int argc, char** argv ) } */ - /* Attempt to get serial number of device. */ - - ioctl(c2[i]->device_fd, HDIO_GET_IDENTITY, &c2[i]->identity); + /* Print serial number of device if it exists. */ if ( 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); }