Skip to content

Commit

Permalink
Merge pull request #373 from PartialVolume/Fix_intermittent_FAILED_me…
Browse files Browse the repository at this point in the history
…ssage_instead_of_UABORTED_on_control-C

Fix summary table - Control-C
  • Loading branch information
PartialVolume authored Nov 17, 2021
2 parents 5d0d0ec + fb6b47d commit bfe5939
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
36 changes: 12 additions & 24 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
/* Any errors ? if so set the exclamation_flag and fail message,
* All status messages should be eight characters EXACTLY !
*/
if( c[i]->result < 0 )
if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 || c[i]->fsyncdata_errors != 0 )
{
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;
Expand All @@ -768,44 +768,32 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
}
else
{

if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 )
if( c[i]->wipe_status == 0 )
{
strncpy( exclamation_flag, "!", 1 );
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;

strncpy( status, "-FAILED-", 8 );
strncpy( status, " Erased ", 8 );
status[8] = 0;
}
else
{
if( c[i]->wipe_status == 0 )
if( user_abort == 1 )
{
strncpy( exclamation_flag, " ", 1 );
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;

strncpy( status, " Erased ", 8 );
strncpy( status, "UABORTED", 8 );
status[8] = 0;
}
else
{
if( user_abort == 1 )
{
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;

strncpy( status, "UABORTED", 8 );
status[8] = 0;
}
else
{
/* If this ever happens, there is a bug ! */
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;
/* If this ever happens, there is a bug ! */
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;

strncpy( status, "INSANITY", 8 );
status[8] = 0;
}
strncpy( status, "INSANITY", 8 );
status[8] = 0;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/method.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,6 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
/* For the selected method, calculate the correct round_size value (for correct percentage calculation) */
calculate_round_size( c );

c->result = c->round_size;

/* If only verifying then the round size is the device size */
if( nwipe_options.method == &nwipe_verify_zero || nwipe_options.method == &nwipe_verify_one )
{
Expand Down
41 changes: 28 additions & 13 deletions src/nwipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ int main( int argc, char** argv )
{
nwipe_selected += 1;
}

/* Initialise the wipe result value */
c1[i]->result = 0;
}

/* Pass the number selected to the struct for other threads */
Expand Down Expand Up @@ -598,6 +601,19 @@ int main( int argc, char** argv )
close( c2[i]->device_fd );
}
}
if( nwipe_options.verbose )
{
for( i = 0; i < nwipe_selected; i++ )
{
nwipe_log( NWIPE_LOG_DEBUG,
"Status: %s, result=%d, pass_errors=%llu, verify_errors=%llu, fsync_errors=%llu",
c2[i]->device_name,
c2[i]->result,
c2[i]->pass_errors,
c2[i]->verify_errors,
c2[i]->fsyncdata_errors );
}
}

/* if no wipe threads started then zero each selected drive result flag,
* as we don't need to report fatal/non fatal errors if no wipes were ever started ! */
Expand All @@ -613,24 +629,23 @@ int main( int argc, char** argv )
for( i = 0; i < nwipe_selected; i++ )
{
/* Check for non-fatal errors. */
if( c2[i]->result > 0 )
if( c2[i]->result != 0 || c2[i]->pass_errors != 0 || c2[i]->verify_errors != 0
|| c2[i]->fsyncdata_errors != 0 )
{
nwipe_log( NWIPE_LOG_FATAL, "Nwipe exited with non fatal errors on device = %s\n", c2[i]->device_name );
nwipe_log( NWIPE_LOG_FATAL,
"Nwipe exited with errors on device = %s, see log for specific error\n",
c2[i]->device_name );
nwipe_log( NWIPE_LOG_DEBUG,
"Status: %s, result=%d, pass_errors=%llu, verify_errors=%llu, fsync_errors=%llu",
c2[i]->device_name,
c2[i]->result,
c2[i]->pass_errors,
c2[i]->verify_errors,
c2[i]->fsyncdata_errors );
non_fatal_errors_flag = 1;
return_status = 1;
}
}

for( i = 0; i < nwipe_selected; i++ )
{
/* Check for fatal errors. */
if( c2[i]->result < 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "Nwipe exited with fatal errors on device = %s\n", c2[i]->device_name );
fatal_errors_flag = 1;
return_status = -1;
}
}
}

/* Generate and send the drive status summary to the log */
Expand Down

0 comments on commit bfe5939

Please sign in to comment.