Add --autopoweroff option

Fix non working --nowait option.
Update version info to 0.29-release candidate
This commit is contained in:
PartialVolume
2020-03-11 23:44:11 +00:00
parent 50079a15f9
commit e33c1bb06d
9 changed files with 78 additions and 13 deletions

View File

@@ -1,6 +1,14 @@
RELEASE NOTES
=============
v0.29-pre-release (Pending release May/Jun 2020)
-----------------------
Features/fixes in 0.29 that have been committed to the master are tagged with [DONE],
other items in 0.29 are proposed and yet to be implemented.
- [DONE] Add auto power off option on completion of wipe ( --autopoweroff ) (Thanks PartialVolume)
- [DONE] Fix --nowait option the wasn't working.
v0.28
-----------------------
- Fix premature exit when terminal resized on completion of wipes (Thanks PartialVolume)

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.64])
AC_INIT([nwipe], [0.28], [git@brumit.nl])
AC_INIT([nwipe], [0.29], [git@brumit.nl])
AM_INIT_AUTOMAKE(foreign subdir-objects)
AC_OUTPUT(Makefile src/Makefile man/Makefile)
AC_CONFIG_SRCDIR([src/nwipe.c])

View File

@@ -1,4 +1,4 @@
.TH NWIPE "1" "March 2020" "nwipe version 0.28" "User Commands"
.TH NWIPE "1" "March 2020" "nwipe version 0.29" "User Commands"
.SH NAME
nwipe \- securely erase disks
.SH SYNOPSIS
@@ -34,6 +34,10 @@ If no devices have been specified on the command line, starts wiping all
devices immediately. If devices have been specified, starts wiping only
those specified devices immediately.
.TP
\fB\-\-autopoweroff\fR
Power off system on completion of wipe delayed for for one minute. During
this one minute delay you can abort the shutdown by typing sudo shutdown -c
.TP
\fB\-\-sync\fR
Open devices in sync mode
.TP

View File

@@ -2317,7 +2317,7 @@ void* nwipe_gui_status( void* ptr )
case 0x0a:
/* Check whether we have finished all wipes, if yes exit while loop if user pressed spacebar or
* return */
* return. */
if( !nwipe_active || terminate_signal == 1 )
{
loop_control = 0;
@@ -2332,6 +2332,15 @@ void* nwipe_gui_status( void* ptr )
}
} /* keystroke */
/* if wipe has completed and user has specified auto poweroff or nowait then we can skip waiting for the user to press return */
if( !nwipe_active )
{
if( nwipe_options.autopoweroff || nwipe_options.nowait )
{
loop_control = 0;
}
}
/* Update screen if not blanked. */
if( nwipe_gui_blank == 0 )

View File

@@ -19,6 +19,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
@@ -439,13 +443,9 @@ int main( int argc, char** argv )
sleep( 2 ); /* DO NOT REMOVE ! Stops the routine hogging CPU cycles */
}
if( terminate_signal == 1 )
if( terminate_signal != 1 )
{
nwipe_log( NWIPE_LOG_INFO, "Program interrupted" );
}
else
{
if( !nwipe_options.nowait )
if( !nwipe_options.nowait && !nwipe_options.autopoweroff )
{
do
{
@@ -453,6 +453,7 @@ int main( int argc, char** argv )
} while( terminate_signal != 1 );
}
}
nwipe_log( NWIPE_LOG_INFO, "Exit in progress" );
/* Send a REQUEST for the wipe threads to be cancelled */
@@ -534,6 +535,8 @@ int main( int argc, char** argv )
}
cleanup();
check_for_autopoweroff();
/* Exit. */
return return_status;
@@ -688,3 +691,21 @@ int cleanup()
return 0;
}
void check_for_autopoweroff( void )
{
char cmd[]="shutdown -P +1 \"System going down in one minute\"";
FILE* fp;
int r; // A result buffer.
/* User request auto power down ? */
if( nwipe_options.autopoweroff == 1 )
{
fp = popen( cmd, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_INFO, "Failed to autopoweroff to %s", cmd );
return;
}
r = pclose( fp );
}
}

View File

@@ -25,6 +25,8 @@
/* Function prototypes */
int cleanup();
void check_for_autopoweroff( void);
void* signal_hand( void* );
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
@@ -111,6 +113,4 @@ typedef unsigned char u8;
/* This is required for ioctl FDFLUSH. */
#include <linux/fd.h>
void* signal_hand( void* );
#endif /* NWIPE_H_ */

View File

@@ -59,6 +59,9 @@ int nwipe_options_parse( int argc, char** argv )
static struct option nwipe_options_long[] = {
/* Set when the user wants to wipe without a confirmation prompt. */
{"autonuke", no_argument, 0, 0},
/* Set when the user wants to have the system powerdown on completion of wipe. */
{"autopoweroff", no_argument, 0, 0},
/* A GNU standard option. Corresponds to the 'h' short option. */
{"help", no_argument, 0, 'h'},
@@ -104,6 +107,7 @@ int nwipe_options_parse( int argc, char** argv )
/* Set default options. */
nwipe_options.autonuke = 0;
nwipe_options.autopoweroff = 0;
nwipe_options.method = &nwipe_dodshort;
nwipe_options.prng = &nwipe_twister;
nwipe_options.rounds = 1;
@@ -142,6 +146,12 @@ int nwipe_options_parse( int argc, char** argv )
nwipe_options.autonuke = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "autopoweroff" ) == 0 )
{
nwipe_options.autopoweroff = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "noblank" ) == 0 )
{
@@ -378,6 +388,15 @@ void nwipe_options_log( void )
{
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (off)", nwipe_options.autonuke );
}
if( nwipe_options.autopoweroff )
{
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (on)", nwipe_options.autopoweroff );
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (off)", nwipe_options.autopoweroff );
}
if( nwipe_options.noblank )
{
@@ -440,6 +459,9 @@ void display_help()
puts( " starts wiping all devices immediately. If devices have" );
puts( " been specified, starts wiping only those specified" );
puts( " devices immediately.\n" );
puts( " --autopoweroff Power off system on completion of wipe delayed for" );
puts( " for one minute. During this one minute delay you can" );
puts( " abort the shutdown by typing sudo shutdown -c\n" );
puts( " --sync=NUM Will perform a sync after NUM writes (default: 0)" );
puts( " 0 - fdatasync after the disk is completely written" );
puts( " 1 - fdatasync after every write" );

View File

@@ -48,6 +48,7 @@ void display_help();
typedef struct
{
int autonuke; // Do not prompt the user for confirmation when set.
int autopoweroff; // Power off on completion of wipe
int noblank; // Do not perform a final blanking pass.
int nowait; // Do not wait for a final key before exiting.
int nosignals; // Do not allow signals to interrupt a wipe.

View File

@@ -4,7 +4,7 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.28";
const char* version_string = "0.29";
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.28";
const char* banner = "nwipe 0.29-release candidate";