diff --git a/src/logging.c b/src/logging.c index 7919384..0c70d3b 100644 --- a/src/logging.c +++ b/src/logging.c @@ -627,15 +627,21 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected ) /* Add this devices throughput to the total throughput */ total_throughput += c[i]->throughput; - /* Retrieve the duration of the wipe in seconds and convert hours and minutes and seconds */ - /* WARNING More work needs doing on .. - * - * model - * serial no - * the footer - * testing under various fault situations ... WARNING */ + /* Retrieve the duration of the wipe in seconds and convert to hours and minutes and seconds */ - c[i]->duration = difftime( c[i]->end_time, c[i]->start_time ); + if( c[i]->start_time != 0 && c[i]->end_time != 0 ) + { + /* For a summary when the wipe has finished */ + c[i]->duration = difftime( c[i]->end_time, c[i]->start_time ); + } + else + { + if( c[i]->start_time != 0 && c[i]->end_time == 0 ) + { + /* For a summary in the event of a system shutdown */ + c[i]->duration = difftime( t, c[i]->start_time ); + } + } total_duration_seconds = (u64) c[i]->duration; diff --git a/src/nwipe.c b/src/nwipe.c index dc352f2..325caca 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -269,8 +269,13 @@ int main( int argc, char** argv ) /* A result buffer for the BLKGETSIZE64 ioctl. */ u64 size64; + /* Initialise the spinner character index */ c2[i]->spinner_idx = 0; + /* Initialise the start and end time of the wipe */ + c2[i]->start_time = 0; + c2[i]->end_time = 0; + /* Initialise the wipe_status flag, -1 = wipe not yet started */ c2[i]->wipe_status = -1;