merge threading to develop #21
@ -8,7 +8,7 @@
|
||||
#ifndef REHDD_H_
|
||||
#define REHDD_H_
|
||||
|
||||
//#define DRYRUN
|
||||
#define DRYRUN
|
||||
|
||||
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
||||
#define WORSE_POWERUP 4000 //mark drive if at this limit or beyond
|
||||
|
@ -80,11 +80,11 @@ public:
|
||||
|
||||
private:
|
||||
Shred(void);
|
||||
static inline uint8_t calcProgress();
|
||||
static inline void tfnge_init_iv(struct tfnge_stream *tfe, const void *key, const void *iv);
|
||||
static inline void tfnge_init(struct tfnge_stream *tfe, const void *key);
|
||||
static inline void tfng_encrypt_rawblk(TFNG_UNIT_TYPE *O, const TFNG_UNIT_TYPE *I, const TFNG_UNIT_TYPE *K);
|
||||
static inline void tfnge_emit(void *dst, size_t szdst, struct tfnge_stream *tfe);
|
||||
static inline uint8_t calcProgress();
|
||||
static inline void tfnge_init_iv(struct tfnge_stream *tfe, const void *key, const void *iv);
|
||||
static inline void tfnge_init(struct tfnge_stream *tfe, const void *key);
|
||||
static inline void tfng_encrypt_rawblk(TFNG_UNIT_TYPE *O, const TFNG_UNIT_TYPE *I, const TFNG_UNIT_TYPE *K);
|
||||
static inline void tfnge_emit(void *dst, size_t szdst, struct tfnge_stream *tfe);
|
||||
|
||||
|
||||
};
|
||||
|
@ -223,6 +223,7 @@ void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
if (string(cLine).find("/dev/sd") != string::npos)
|
||||
{
|
||||
Drive* tmpDrive = new Drive(string(cLine).substr (2,8));
|
||||
tmpDrive->state = Drive::NONE;
|
||||
pvecDrives->push_back(*tmpDrive);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "../../include/reHDD.h"
|
||||
|
||||
#ifndef DRYRUN
|
||||
static char *randsrc = (char*) "/dev/urandom";
|
||||
static int force = 0, rmf = 0, zrf = 0, noround = 0, verbose = 0, syncio = 0, alwaysrand = 0, reqrand = 0;
|
||||
|
||||
@ -25,7 +25,7 @@ static struct tfnge_stream tfnge;
|
||||
static unsigned long blockcount = 0UL;
|
||||
static long blockcount_max;
|
||||
static uint8_t u8Percent;
|
||||
|
||||
#endif
|
||||
/**
|
||||
* \brief shred drive with shred
|
||||
* \param pointer of Drive instance
|
||||
@ -33,9 +33,18 @@ static uint8_t u8Percent;
|
||||
*/
|
||||
void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
{
|
||||
|
||||
#ifdef DRYRUN
|
||||
//TODO
|
||||
for(int i = 0; i<=10; i++)
|
||||
{
|
||||
if(drive->state != Drive::SHRED_ACTIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
drive->setTaskPercentage(i*10);
|
||||
write(*ipSignalFd, "A",1);
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DRYRUN
|
||||
@ -139,18 +148,21 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
// write block loop
|
||||
while (1)
|
||||
{
|
||||
usleep(10);
|
||||
|
||||
if(drive->state != Drive::SHRED_ACTIVE){
|
||||
goto _return;
|
||||
}
|
||||
if(drive->state != Drive::SHRED_ACTIVE)
|
||||
{
|
||||
goto _return;
|
||||
}
|
||||
|
||||
uint8_t u8TmpPercent = calcProgress();
|
||||
|
||||
if(u8Percent != u8TmpPercent){
|
||||
drive->setTaskPercentage(u8TmpPercent);
|
||||
u8Percent = u8TmpPercent;
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
if(u8Percent != u8TmpPercent)
|
||||
{
|
||||
drive->setTaskPercentage(u8TmpPercent);
|
||||
u8Percent = u8TmpPercent;
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
|
||||
if (!pat)
|
||||
{
|
||||
@ -257,10 +269,11 @@ _return:
|
||||
close(rsf);
|
||||
#endif
|
||||
}
|
||||
#ifndef DRYRUN
|
||||
|
||||
|
||||
uint8_t Shred::calcProgress(){
|
||||
blockcount++;
|
||||
uint8_t Shred::calcProgress()
|
||||
{
|
||||
blockcount++;
|
||||
return ((((double)blockcount/(double)blockcount_max))*100);
|
||||
}
|
||||
|
||||
@ -365,4 +378,5 @@ void Shred::tfnge_emit(void *dst, size_t szdst, struct tfnge_stream *tfe)
|
||||
tfe->carry_bytes = TFNG_BLOCK_SIZE-sz;
|
||||
memcpy(tfe->carry_block, udst+sz, tfe->carry_bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user