diff --git a/src/context.h b/src/context.h index 8178738..4a00ae8 100644 --- a/src/context.h +++ b/src/context.h @@ -118,7 +118,7 @@ typedef struct nwipe_context_t_ nwipe_entropy_t prng_seed; // The random data that is used to seed the PRNG. void* prng_state; // The private internal state of the PRNG. int result; // The process return value. - int round_count; // The number of rounds performed by the working wipe method. + int round_count; // The number of rounds requested by the user for the working wipe method. u64 round_done; // The number of bytes that have already been i/o'd. u64 round_errors; // The number of errors across all rounds. u64 round_size; // The total number of i/o bytes across all rounds. @@ -156,6 +156,7 @@ typedef struct nwipe_context_t_ time_t start_time; // Start time of wipe time_t end_time; // End time of wipe u64 fsyncdata_errors; // The number of fsyncdata errors across all passes. + char PDF_filename[256]; // The filename of the PDF certificate/report. /* * Identity contains the raw serial number of the drive * (where applicable), however, for use within nwipe use the diff --git a/src/create_pdf.c b/src/create_pdf.c index 23f53c7..bbd4c56 100644 --- a/src/create_pdf.c +++ b/src/create_pdf.c @@ -59,7 +59,7 @@ int create_pdf( nwipe_context_t* ptr ) char HPA_post_erase[50] = ""; char DCO_pre_erase[50] = ""; char DCO_post_erase[50] = ""; - char PDF_filename[256] = ""; + char throughput_txt[50] = ""; struct pdf_info info = { .creator = "https://github.com/PartialVolume/shredos.x86_64", .producer = "https://github.com/martijnvanbrummelen/nwipe", @@ -310,9 +310,9 @@ int create_pdf( nwipe_context_t* ptr ) pdf_add_text( pdf, NULL, "*Bytes Erased:", 12, 60, 210, PDF_GRAY ); snprintf( bytes_erased, sizeof( bytes_erased ), - "%lli %.1i%%", + "%lli %.1lli%%", c->bytes_erased, - (int) ( c->bytes_erased / c->device_size ) * 100 ); + ( c->bytes_erased / c->device_size ) * 100 ); pdf_set_font( pdf, "Helvetica-Bold" ); if( c->bytes_erased == c->device_size ) { @@ -325,10 +325,18 @@ int create_pdf( nwipe_context_t* ptr ) pdf_set_font( pdf, "Helvetica" ); /* rounds */ - pdf_add_text( pdf, NULL, "Rounds:", 12, 300, 210, PDF_GRAY ); - snprintf( rounds, sizeof( rounds ), "%i", nwipe_options.rounds ); + pdf_add_text( pdf, NULL, "Rounds(completed/requested):", 12, 300, 210, PDF_GRAY ); pdf_set_font( pdf, "Helvetica-Bold" ); - pdf_add_text( pdf, NULL, rounds, 12, 350, 210, PDF_BLACK ); + if( nwipe_options.rounds == c->round_working ) + { + snprintf( rounds, sizeof( rounds ), "%i/%i", c->round_working, nwipe_options.rounds ); + pdf_add_text( pdf, NULL, rounds, 12, 470, 210, PDF_DARK_GREEN ); + } + else + { + snprintf( rounds, sizeof( rounds ), "%i/%i", c->round_working - 1, nwipe_options.rounds ); + pdf_add_text( pdf, NULL, rounds, 12, 470, 210, PDF_RED ); + } pdf_set_font( pdf, "Helvetica" ); /* HPA, DCO, post erase */ @@ -343,8 +351,9 @@ int create_pdf( nwipe_context_t* ptr ) /* Throughput */ pdf_add_text( pdf, NULL, "Throughput:", 12, 300, 170, PDF_GRAY ); + snprintf( throughput_txt, sizeof( throughput_txt ), "%s/sec", c->throughput_txt ); pdf_set_font( pdf, "Helvetica-Bold" ); - pdf_add_text( pdf, NULL, c->throughput_txt, 12, 370, 170, PDF_BLACK ); + pdf_add_text( pdf, NULL, throughput_txt, 12, 370, 170, PDF_BLACK ); pdf_set_font( pdf, "Helvetica" ); /* Information */ @@ -371,16 +380,15 @@ int create_pdf( nwipe_context_t* ptr ) replace_non_alphanumeric( end_time_text, '-' ); replace_non_alphanumeric( c->device_model, '_' ); replace_non_alphanumeric( c->device_serial_no, '_' ); - snprintf( PDF_filename, - sizeof( PDF_filename ), + snprintf( c->PDF_filename, + sizeof( c->PDF_filename ), "nwipe_report_%s_Model_%s_Serial_%s.pdf", end_time_text, c->device_model, c->device_serial_no ); - pdf_save( pdf, PDF_filename ); + pdf_save( pdf, c->PDF_filename ); pdf_destroy( pdf ); - nwipe_log( NWIPE_LOG_INFO, "%s", PDF_filename ); return 0; } void replace_non_alphanumeric( char* str, char replacement_char ) diff --git a/src/logging.c b/src/logging.c index 631134f..244b5e1 100644 --- a/src/logging.c +++ b/src/logging.c @@ -786,7 +786,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected ) } else { - if( c[i]->wipe_status == 0 ) + if( c[i]->wipe_status == 0 && user_abort != 1 ) { strncpy( exclamation_flag, " ", 1 ); exclamation_flag[1] = 0; @@ -842,8 +842,13 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected ) { if( c[i]->start_time != 0 && c[i]->end_time == 0 ) { - /* For a summary in the event of a system shutdown */ + /* For a summary in the event of a system shutdown, user abort */ c[i]->duration = difftime( t, c[i]->start_time ); + + /* If end_time is zero, which may occur if the wipe is aborted, then set + * end_time to current time. Important to do as endtime is used by + * the PDF report function */ + c[i]->end_time = time( &t ); } } diff --git a/src/method.c b/src/method.c index 5f5f298..875fe17 100644 --- a/src/method.c +++ b/src/method.c @@ -172,7 +172,7 @@ void* nwipe_one( void* ptr ) /* set wipe in progress flag for GUI */ c->wipe_status = 1; - /* setup for a zero-fill. */ + /* setup for a one-fill. */ char onefill[1] = { '\xFF' }; nwipe_pattern_t patterns[] = { { 1, &onefill[0] }, // pass 1: 1s