Added progress and time estimates
This commit is contained in:
parent
41f611c1e6
commit
3041e409ed
12
wipe.pl
12
wipe.pl
@ -158,6 +158,7 @@ sub wipethemdrives {
|
||||
}
|
||||
# If long flag than zero whole disk and give a progress bar
|
||||
if ($longrun && !$pretend) {
|
||||
my $diskStartTime = time();
|
||||
open(my $longdiskw, ">:raw", $disks->{$diskid}{path}) or return warning("could not open $disks->{$diskid}{path}");
|
||||
binmode($longdiskw);
|
||||
my $old_file_handle = select($longdiskw); #Disable I/O buffering on $longdiskw
|
||||
@ -172,10 +173,11 @@ sub wipethemdrives {
|
||||
system("hdparm -F ".$disks->{$diskid}{path}." 1>/dev/null 2>/dev/null");
|
||||
}
|
||||
if ( !($_ % 16) ) {
|
||||
printf("\r%31.31s%-".($spacer+11).".".($spacer+11)."s%6.2f%% ",
|
||||
printf("\r%31.31s%-".($spacer+11).".".($spacer+11)."s%6.2f%% %s",
|
||||
"Zeroing ".$disks->{$diskid}{path},
|
||||
"."x(tell($longdiskw)/$totalBytes*($spacer+11)),
|
||||
(tell($longdiskw)/$totalBytes)*100 );
|
||||
(tell($longdiskw)/$totalBytes)*100 ),
|
||||
"ETA: ".gmtime((time()-$diskStartTime)*($totalBytes/tell($longdiskw)));
|
||||
}
|
||||
}
|
||||
my $leftover = $totalBytes - tell($longdiskw);
|
||||
@ -237,12 +239,18 @@ sub smartcheck {
|
||||
while () {
|
||||
my %disks = getdisks();
|
||||
my $batchcount = keys %disks;
|
||||
my $startTime = time();
|
||||
my $currentCount = 0;
|
||||
say "$color{red}WARNING:$color{reset} This program will completely destroy all data on $batchcount drives with the following serial numbers:";
|
||||
foreach my $diskid (sort {$disks{$a}{serial} cmp $disks{$b}{serial}} keys %disks) {
|
||||
say $disks{$diskid}{serial};
|
||||
}
|
||||
# exit unless "\n" eq anykey("Last chance to save your data, hit ENTER to DESTROY ALL DATA, or any other key to abort!\n");
|
||||
foreach my $diskid (sort {$a cmp $b}keys %disks) {
|
||||
$currentCount++;
|
||||
print "="x80;
|
||||
print "\nCurrent Overall Progress ".$currentCount."/".$batchcount." (".sprintf("%5f%%",100*$currentCount/$batchcount).")\n";
|
||||
print "Current Overall ETA: ".gmtime((time() - $startTime) * ($batchcount/$currentCount))."\n";
|
||||
print "="x33;
|
||||
printf '[ %-10s ]', $diskid;
|
||||
say "="x33;
|
||||
|
Loading…
x
Reference in New Issue
Block a user