Various fixes to methods

1. Allows zero fill to be verified when blanking off.
Prior to this if you wanted to verify a zero pass,
blanking had to be on. This meant a zero pass, then a
blanking pass then a verify, effectively two zero passes
and a verify. This is now fixed so you can now do a zero
pass with verification without a blanking pass. This knocks
a third off the wipe time of a zero fill with verification.

This also means all other methods can have either all their
passes or just the last pass verified without blanking being
enabled.

2. OPS2 method requires the last pass to be random, the GUI
now disables the use of the blanking option for this message
and displays a warning message that a final blanking pass is
not allowed for OPS2. It never did a final blanking pass
anyway, even if it was selected, but this makes it clearer in
the GUI.

3. The caculate_round_size() function was improved by reducing
some duplicated code and bring the full calculation into this function.

4. On completion of each pass or verification the total number of
bytes written or read for each pass or verification is logged.
This commit is contained in:
PartialVolume
2021-06-03 23:56:30 +01:00
parent 970d74f0d5
commit 4b1c7007ff
3 changed files with 143 additions and 117 deletions

View File

@@ -125,6 +125,13 @@ const char* stats_title = " Statistics ";
/* Footer labels. */
const char* main_window_footer = "S=Start m=Method p=PRNG v=Verify r=Rounds b=Blanking Space=Select CTRL+C=Quit";
const char* main_window_footer_warning_lower_case_s = " WARNING: To start the wipe press SHIFT+S (uppercase S) ";
const char* main_window_fotter_warning_no_blanking_with_ops2 =
" WARNING: Zero blanking is not allowed with ops2 method ";
const char* main_window_fotter_warning_no_blanking_with_verify_only =
" WARNING: Zero blanking is not allowed with verify method ";
const char* main_window_footer_warning_no_drive_selected =
" No drives selected, use spacebar to select a drive, then press S to start ";
@@ -970,6 +977,38 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
validkeyhit = 1;
if( nwipe_options.method == &nwipe_ops2 )
{
/* Warn the user about that zero blanking with the ops2 method is not allowed */
wattron( footer_window, COLOR_PAIR( 10 ) );
nwipe_gui_amend_footer_window( main_window_fotter_warning_no_blanking_with_ops2 );
doupdate();
sleep( 3 );
wattroff( footer_window, COLOR_PAIR( 10 ) );
/* After the delay return footer text back to key help */
nwipe_gui_amend_footer_window( main_window_footer );
doupdate();
break;
}
if( nwipe_options.method == &nwipe_verify )
{
/* Warn the user about that zero blanking with the ops2 method is not allowed */
wattron( footer_window, COLOR_PAIR( 10 ) );
nwipe_gui_amend_footer_window( main_window_fotter_warning_no_blanking_with_verify_only );
doupdate();
sleep( 3 );
wattroff( footer_window, COLOR_PAIR( 10 ) );
/* After the delay return footer text back to key help */
nwipe_gui_amend_footer_window( main_window_footer );
doupdate();
break;
}
/* Run the noblank dialog. */
nwipe_gui_noblank();
break;
@@ -1148,6 +1187,13 @@ void nwipe_gui_options( void )
} /* switch verify */
mvwprintw( options_window, NWIPE_GUI_OPTIONS_ROUNDS_Y, NWIPE_GUI_OPTIONS_ROUNDS_X, "Rounds: " );
/* Disable blanking for ops2 and verify methods */
if( nwipe_options.method == &nwipe_ops2 || nwipe_options.method == &nwipe_verify )
{
nwipe_options.noblank = 1;
}
if( nwipe_options.noblank )
{
wprintw( options_window, "%i (no final blanking pass)", nwipe_options.rounds );
@@ -1821,10 +1867,6 @@ void nwipe_gui_noblank( void )
{
nwipe_options.noblank = focus;
}
if( nwipe_options.noblank )
{
nwipe_options.verify = NWIPE_VERIFY_NONE;
}
return;
case KEY_BACKSPACE:

View File

@@ -34,7 +34,7 @@
*
* WARNING: Never change nwipe_options after calling a method.
*
* NOTE: The nwipe_runmethod function appends a final pass to all methods.
* NOTE: The nwipe_runmethod function appends a user selectable final blanking (zero) pass to all methods.
*
*/
@@ -439,8 +439,6 @@ void* nwipe_gutmann( void* ptr )
/* Mark this element as having been used. */
book[j].length = 0;
nwipe_log( NWIPE_LOG_DEBUG, "nwipe_gutmann: Set patterns[%i] = book[%i].", i, j );
}
/* Ensure that the array is terminated. */
@@ -727,18 +725,6 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
/* Set the number of bytes that will be written across all passes in one round. */
c->pass_size = c->pass_count * c->device_size;
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
/* We must read back all passes, so double the byte count. */
c->pass_size *= 2;
}
/* Tell the parent the number of rounds that will be run. */
c->round_count = nwipe_options.rounds;
/* Set the initial number of bytes that will be written across all rounds. */
c->round_size = c->pass_size;
/* For the selected method, calculate the correct round_size value (for correct percentage calculation) */
calculate_round_size( c );
@@ -830,6 +816,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
r = nwipe_static_verify( c, &patterns[i] );
c->pass_type = NWIPE_PASS_NONE;
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
@@ -902,6 +890,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
r = nwipe_random_verify( c );
c->pass_type = NWIPE_PASS_NONE;
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
@@ -976,6 +966,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
/* The final ops2 pass. */
r = nwipe_random_pass( c );
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes written to %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
@@ -984,22 +976,22 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
if( nwipe_options.verify == NWIPE_VERIFY_LAST || nwipe_options.verify == NWIPE_VERIFY_ALL )
{
nwipe_log( NWIPE_LOG_NOTICE, "Verifying the final random pattern on %s is empty.", c->device_name );
nwipe_log( NWIPE_LOG_NOTICE, "Verifying final random pattern FRP on %s", c->device_name );
/* Verify the final zero pass. */
r = nwipe_random_verify( c );
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
return r;
}
nwipe_log( NWIPE_LOG_NOTICE, "Verified the final random pattern on '%s' is empty.", c->device_name );
nwipe_log( NWIPE_LOG_NOTICE, "[SUCCESS] Verified FRP on '%s' matches", c->device_name );
}
nwipe_log( NWIPE_LOG_NOTICE, "Wrote final random pattern to '%s'.", c->device_name );
} /* final ops2 */
else if( nwipe_options.method == &nwipe_verify )
@@ -1022,7 +1014,7 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "[FAILURE] %s IS NOT empty.", c->device_name );
nwipe_log( NWIPE_LOG_ERROR, "[FAILURE] %s is not empty .", c->device_name );
}
} /* verify */
@@ -1037,6 +1029,9 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
/* The final zero pass. */
r = nwipe_static_pass( c, &pattern_zero );
/* Log number of bytes written to disk */
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes written to %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
@@ -1052,6 +1047,9 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
r = nwipe_static_verify( c, &pattern_zero );
c->pass_type = NWIPE_PASS_NONE;
/* Log number of bytes read from disk */
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
/* Check for a fatal error. */
if( r < 0 )
{
@@ -1113,13 +1111,12 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
void calculate_round_size( nwipe_context_t* c )
{
/* This is where the round size is adjusted. round_size is used in the running percentage completion
/* This is where the round size is calculated. round_size is used in the running percentage completion
* calculation. round size is calculated based on pass_size, pass_count, number of rounds, blanking
* on/off and verification on/off
* on/off and verification All/Last/None
*
* To hopefully make this adjustment more understandable, I have presented each calculation
* under each method. This should make it easier to add a new method here without breaking the
* calculations for other methods.
* To hopefully make this calculation more understandable, I have separated the calculations that apply to
* all methods and processed first then created a switch statement that contains method specific changes if any
*/
/* Don't change the order of these values as the case statements use their index in the array */
@@ -1150,118 +1147,110 @@ void calculate_round_size( nwipe_context_t* c )
i++;
}
/* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method.
*/
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
/* We must read back all passes, so double the byte count. */
c->pass_size *= 2;
}
/* Tell the parent the number of rounds that will be run. */
c->round_count = nwipe_options.rounds;
/* Set the initial number of bytes that will be written across all rounds.
c->pass_size includes write AND verification passes if 'verify_all' is selected
but does not include the final blanking pass or the verify_last option */
c->round_size = c->pass_size;
/* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method. */
c->round_size *= c->round_count;
/* For each method create the correct round_size value */
/* Now increase size based on whether blanking is enabled and verification */
if( nwipe_options.noblank == 0 )
{
/* Blanking enabled so increase round size */
c->round_size += c->device_size;
if( nwipe_options.verify == NWIPE_VERIFY_LAST || nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
}
else
{
/* Blanking not enabled, check for 'Verify_last', increase round size if enabled. */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
}
/* Additional method specific round_size adjustments go in this switch statement */
switch( selected_method )
{
case 0:
/* NWIPE_ZERO
/* NWIPE_ZERO - No additional calculation required
* ---------- */
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
case 1:
/* NWIPE_OPS2
* ---------- */
/* Required for the 9th and final random pass */
/* Required for mandatory 9th and final random pass */
c->round_size += c->device_size;
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
/* Required for selectable 9th and final random verification */
if( nwipe_options.verify == NWIPE_VERIFY_ALL || nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
/* As no final zero blanking pass is permitted by this standard reduce round size if it's seelected */
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
/* Reduce for blanking pass */
c->round_size -= c->device_size;
/* Reduce for blanking pass verification */
if( nwipe_options.verify == NWIPE_VERIFY_ALL || nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size -= c->device_size;
}
}
else
{
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
/* If blanking off & verification on reduce round size */
c->round_size -= c->device_size;
}
}
break;
case 2:
/* DoD Short
/* DoD Short - No additional calculation required
* --------- */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
case 3:
/* DOD 522022m
/* DOD 522022m - No additional calculation required
* ----------- */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
case 4:
/* GutMann
/* GutMann - No additional calculation required
* ------- */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
case 5:
/* PRNG (random)
/* PRNG (random) - No additional calculation required
* ------------- */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
{
c->round_size += c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
case 6:
@@ -1269,25 +1258,20 @@ void calculate_round_size( nwipe_context_t* c )
* ------------ */
/* This method ALWAYS verifies the 3rd pass so increase by device size,
* and does not need to be increased by device size for VERIFY_ALL*/
* but NOT if VERIFY_ALL has been selected, but first .. */
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
/* Reduce as Verify_Last already included previously if blanking was off */
if( nwipe_options.verify == NWIPE_VERIFY_LAST && nwipe_options.noblank == 1 )
{
c->round_size += c->device_size;
c->round_size -= c->device_size;
}
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
/* Adjusts for verify on every third pass multiplied by number of rounds */
if( nwipe_options.verify != NWIPE_VERIFY_ALL )
{
c->round_size += c->device_size;
}
else
{
/* Adjusts for verify on every third pass multiplied by number of rounds */
c->round_size += ( c->device_size * c->round_count );
}
if( nwipe_options.noblank == 0 )
{
c->round_size += c->device_size;
}
break;
}
}

View File

@@ -4,7 +4,7 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.30.010";
const char* version_string = "0.30.011";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "git@brumit.nl";
@@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.30.010";
const char* banner = "nwipe 0.30.011";