create first beta release #23
@ -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 10000 //mark drive if at this limit or beyond
|
||||
@ -20,10 +20,15 @@
|
||||
|
||||
// Logger Settings
|
||||
#define LOG_PATH "./reHDD.log"
|
||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
|
||||
#define DEVICE_ID "generic"
|
||||
#define SOFTWARE_VERSION "alpha"
|
||||
#define HARDWARE_VERSION "generic"
|
||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
|
||||
#define DEVICE_ID "generic"
|
||||
#define SOFTWARE_VERSION "alpha"
|
||||
#define HARDWARE_VERSION "generic"
|
||||
|
||||
#define LOG_LEVEL_HIGH //log everything, like drive scann thread
|
||||
#ifndef LOG_LEVEL_HIGH
|
||||
#define LOG_LEVEL_LOW //log only user actions and tasks
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
@ -76,16 +76,22 @@ class Shred
|
||||
protected:
|
||||
|
||||
public:
|
||||
static void shredDrive(Drive* drive, int* ipSignalFd);
|
||||
|
||||
Shred();
|
||||
~Shred();
|
||||
void shredDrive(Drive* drive, int* ipSignalFd);
|
||||
|
||||
private:
|
||||
Shred(void);
|
||||
static inline double 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);
|
||||
|
||||
unsigned long blockcount = 0UL;
|
||||
long blockcount_max;
|
||||
double d32Percent;
|
||||
|
||||
inline double calcProgress();
|
||||
inline void tfnge_init_iv(struct tfnge_stream *tfe, const void *key, const void *iv);
|
||||
inline void tfnge_init(struct tfnge_stream *tfe, const void *key);
|
||||
inline void tfng_encrypt_rawblk(TFNG_UNIT_TYPE *O, const TFNG_UNIT_TYPE *I, const TFNG_UNIT_TYPE *K);
|
||||
inline void tfnge_emit(void *dst, size_t szdst, struct tfnge_stream *tfe);
|
||||
|
||||
};
|
||||
|
||||
|
@ -104,6 +104,7 @@ void reHDD::ThreadScannDevices()
|
||||
addSMARTData(&vecNewDrives); //add S.M.A.R.T. Data to the drives
|
||||
mxScannDrives.unlock();
|
||||
write(fdNewDrivesInformPipe[1], "A",1);
|
||||
printDrives(&vecNewDrives);
|
||||
sleep(5); //sleep 5 sec
|
||||
}
|
||||
}
|
||||
@ -177,8 +178,9 @@ void reHDD::ThreadShred()
|
||||
{
|
||||
if (getSelectedDrive() != nullptr)
|
||||
{
|
||||
Shred::shredDrive(getSelectedDrive(), &fdShredInformPipe[1]);
|
||||
Logger::logThis()->info("Finished shred for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
|
||||
Shred* pShredTask = new Shred(); //create new shred task
|
||||
pShredTask->shredDrive(getSelectedDrive(), &fdShredInformPipe[1]); //start new shred task
|
||||
delete pShredTask; //delete shred task
|
||||
ui->updateTUI(&vecDrives, u8SelectedEntry);
|
||||
}
|
||||
}
|
||||
@ -216,7 +218,6 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
||||
for (long unsigned int i=0; i<pvecNewDrives->size(); i++)
|
||||
{
|
||||
pvecOldDrives->push_back((*pvecNewDrives)[i]);
|
||||
Logger::logThis()->info("Attached drive: " + i + string("-") + pvecNewDrives->at(i).getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +229,7 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
||||
void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
// cout << "search drives ..." << endl;
|
||||
Logger::logThis()->info("--> search drives <--");
|
||||
char * cLine = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
@ -324,7 +326,9 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||
else
|
||||
{
|
||||
// same uuid found than in ignore file --> ignore this drive
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("same uuid found than in ignore file --> ignore this drive: " + it->getPath());
|
||||
#endif
|
||||
it = pvecDrives->erase(it);
|
||||
it--;
|
||||
}
|
||||
@ -340,22 +344,28 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||
*/
|
||||
void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
cout << "------------DRIVES---------------" << endl;
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("------------DRIVES---------------");
|
||||
//cout << "------------DRIVES---------------" << endl;
|
||||
vector <Drive>::iterator it;
|
||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||
{
|
||||
cout << " Drive: " << distance(pvecDrives->begin(), it) << endl;
|
||||
cout << "Path: " << it->getPath() << endl;
|
||||
cout << "ModelFamily: " << it->getModelFamily() << endl;
|
||||
cout << "ModelName: " << it->getModelName() << endl;
|
||||
cout << "Capacity: " << it->getCapacity() << endl;
|
||||
cout << "Serial: " << it->getSerial() << endl;
|
||||
cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
|
||||
cout << "PowerCycle: " << it->getPowerCycles() << endl;
|
||||
cout << "ErrorCount: " << it->getErrorCount() << endl;
|
||||
cout << endl;
|
||||
/*
|
||||
cout << " Drive: " << distance(pvecDrives->begin(), it) << endl;
|
||||
cout << "Path: " << it->getPath() << endl;
|
||||
cout << "ModelFamily: " << it->getModelFamily() << endl;
|
||||
cout << "ModelName: " << it->getModelName() << endl;
|
||||
cout << "Capacity: " << it->getCapacity() << endl;
|
||||
cout << "Serial: " << it->getSerial() << endl;
|
||||
cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
|
||||
cout << "PowerCycle: " << it->getPowerCycles() << endl;
|
||||
cout << "ErrorCount: " << it->getErrorCount() << endl;
|
||||
cout << endl;*/
|
||||
Logger::logThis()->info(to_string(it - pvecDrives->begin()) + ": " + it->getPath() + " - " + it->getModelFamily() + " - " + it->getSerial());
|
||||
}
|
||||
cout << "---------------------------------" << endl;
|
||||
Logger::logThis()->info("---------------------------------");
|
||||
//cout << "---------------------------------" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,7 +410,7 @@ void reHDD::handleArrowKey(TUI::UserInput userInput)
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
|
||||
Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
|
||||
}
|
||||
|
||||
void reHDD::handleEnter()
|
||||
|
@ -22,9 +22,18 @@ struct tfnge_stream
|
||||
|
||||
static struct tfnge_stream tfnge;
|
||||
|
||||
static unsigned long blockcount = 0UL;
|
||||
static long blockcount_max;
|
||||
static double d32Percent;
|
||||
Shred::Shred()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
Shred::~Shred()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
/**
|
||||
* \brief shred drive with shred
|
||||
@ -60,6 +69,10 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
|
||||
blockcount_max = SHRED_ITERATIONS*(drive->getCapacity()/4096);
|
||||
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("Shred-Task: Max-BlockCount: " + to_string(blockcount_max) + " - Drive: " + drive->getSerial());
|
||||
#endif
|
||||
|
||||
d32Percent = 0U;
|
||||
|
||||
rsf = open(randsrc, O_RDONLY | O_LARGEFILE);
|
||||
@ -80,13 +93,7 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
goto _return;
|
||||
}
|
||||
if (!blksz) blksz = (size_t)st.st_blksize;
|
||||
/*
|
||||
if (howmany != -1)
|
||||
{
|
||||
l = ll = howmany;
|
||||
noround = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
else l = ll = st.st_size;
|
||||
if (l == 0 && !S_ISREG(st.st_mode)) special = 1;
|
||||
memset(&st, 0, sizeof(struct stat));
|
||||
@ -148,20 +155,27 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
// write block loop
|
||||
while (1)
|
||||
{
|
||||
//usleep(10);
|
||||
|
||||
if(drive->state != Drive::SHRED_ACTIVE)
|
||||
{
|
||||
drive->setTaskPercentage(0);
|
||||
d32Percent = 0.00;
|
||||
blockcount = 0;
|
||||
blockcount_max = 0;
|
||||
Logger::logThis()->info("Aborted shred for: " + drive->getModelName() + "-" + drive->getSerial());
|
||||
goto _return;
|
||||
}
|
||||
|
||||
double d32TmpPercent = calcProgress();
|
||||
|
||||
|
||||
|
||||
if((d32TmpPercent-d32Percent) >= 0.09)
|
||||
{
|
||||
drive->setTaskPercentage(d32TmpPercent);
|
||||
d32Percent = d32TmpPercent;
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("Shred-Task: BlockCount: " + to_string(blockcount) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||
#endif
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
|
||||
@ -274,6 +288,7 @@ _return:
|
||||
drive->bWasShredded = true;
|
||||
drive->state= Drive::NONE;
|
||||
drive->setTaskPercentage(0);
|
||||
Logger::logThis()->info("Finished shred for: " + drive->getModelName() + "-" + drive->getSerial());
|
||||
}
|
||||
}
|
||||
#ifndef DRYRUN
|
||||
|
@ -47,7 +47,7 @@ void TUI::initTUI()
|
||||
init_pair(COLOR_AREA_DETAIL, COLOR_BLACK, COLOR_WHITE);
|
||||
|
||||
mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 ");
|
||||
Logger::logThis()->info("UI successfully initialized");
|
||||
Logger::logThis()->info("UI successfully initialized");
|
||||
}
|
||||
|
||||
void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
@ -88,7 +88,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
stringstream stream;
|
||||
|
||||
switch (it->state)
|
||||
{
|
||||
{
|
||||
case Drive::SHRED_ACTIVE:
|
||||
|
||||
stream << fixed << setprecision(2) << (it->getTaskPercentage());
|
||||
@ -122,7 +122,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
if(pvecDrives->size() == 0)
|
||||
{
|
||||
//no selected drive present
|
||||
Logger::logThis()->warning("no selected drive present");
|
||||
Logger::logThis()->warning("no selected drive present");
|
||||
struct MenuState menustate;
|
||||
menustate.bAbort = false;
|
||||
menustate.bConfirmDelete = false;
|
||||
@ -137,7 +137,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
wrefresh(detailview);
|
||||
}
|
||||
|
||||
mxUIrefresh.unlock();
|
||||
mxUIrefresh.unlock();
|
||||
}
|
||||
|
||||
enum TUI::UserInput TUI::readUserInput()
|
||||
|
Loading…
Reference in New Issue
Block a user