|
|
|
@ -13,7 +13,7 @@ static int fdShredInformPipe[2];//File descriptor for pipe that informs if a wip
|
|
|
|
|
|
|
|
|
|
static std::mutex mxScannDrives;
|
|
|
|
|
|
|
|
|
|
static vector <Drive> vecNewDrives; //store found drives that are updated every 5sec
|
|
|
|
|
vector <Drive> vecNewDrives; //store found drives that are updated every 5sec
|
|
|
|
|
|
|
|
|
|
static vector <Drive> vecDrives; //stores all drive data from scann thread
|
|
|
|
|
|
|
|
|
@ -33,6 +33,8 @@ static fd_set selectSet;
|
|
|
|
|
reHDD::reHDD(void)
|
|
|
|
|
{
|
|
|
|
|
u8SelectedEntry = 0U;
|
|
|
|
|
|
|
|
|
|
vecDrives.reserve(128);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -64,8 +66,8 @@ void reHDD::app_logic(void)
|
|
|
|
|
char dummy;
|
|
|
|
|
read (fdNewDrivesInformPipe[0],&dummy,1);
|
|
|
|
|
mxScannDrives.lock();
|
|
|
|
|
|
|
|
|
|
filterNewDrives(&vecDrives, &vecNewDrives); //filter and copy to app logic vector
|
|
|
|
|
printDrives(&vecDrives);
|
|
|
|
|
mxScannDrives.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -104,7 +106,6 @@ 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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -190,35 +191,64 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
|
|
|
|
vector <Drive>::iterator itOld; //Iterator for current (old) drive list
|
|
|
|
|
vector <Drive>::iterator itNew; //Iterator for new drive list that was created from to scann thread
|
|
|
|
|
|
|
|
|
|
//remove offline old drives from previously run
|
|
|
|
|
for (itOld = pvecOldDrives->begin(); itOld != pvecOldDrives->end();)
|
|
|
|
|
{
|
|
|
|
|
if(itOld->bIsOffline == true)
|
|
|
|
|
{
|
|
|
|
|
Logger::logThis()->warning("Offline drive found: " + itOld->getPath());
|
|
|
|
|
itOld = pvecOldDrives->erase(itOld);
|
|
|
|
|
/*
|
|
|
|
|
if(pvecOldDrives->size() > 0){ //This can be a risk if the user starts a task for the selected drive and the selected drive changes
|
|
|
|
|
u8SelectedEntry = 0U;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++itOld;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//search offline drives and mark them
|
|
|
|
|
for (itOld = pvecOldDrives->begin(); itOld != pvecOldDrives->end(); ++itOld)
|
|
|
|
|
{
|
|
|
|
|
bool bOldDriveIsOffline = true;
|
|
|
|
|
for (itNew = pvecNewDrives->begin(); itNew != pvecNewDrives->end(); ++itNew)
|
|
|
|
|
itOld->bIsOffline = true; //set offline befor seachring in the new list
|
|
|
|
|
for (itNew = pvecNewDrives->begin(); itNew != pvecNewDrives->end();)
|
|
|
|
|
{
|
|
|
|
|
if(itOld->getSerial() == itNew->getSerial())
|
|
|
|
|
{
|
|
|
|
|
bOldDriveIsOffline = false;
|
|
|
|
|
// copy old drive instance date in new instance
|
|
|
|
|
itNew->state = itOld->state; //copy state
|
|
|
|
|
itNew->setTaskPercentage(itOld->getTaskPercentage()); //copy percentage
|
|
|
|
|
itNew->bWasDeleteted = itOld->bWasDeleteted; //copy finished task delete
|
|
|
|
|
itNew->bWasShredded = itOld->bWasShredded; //copy finished task shred
|
|
|
|
|
itOld->bIsOffline = false; //drive is still attached
|
|
|
|
|
#ifdef LOG_LEVEL_HIGH
|
|
|
|
|
Logger::logThis()->info("Delete new drive, because allready attached: " + itNew->getModelName());
|
|
|
|
|
#endif
|
|
|
|
|
itNew = pvecNewDrives->erase(itNew); //This drive is allready attached, remove from new list
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++itNew;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bOldDriveIsOffline == true)
|
|
|
|
|
//mark offline old drives
|
|
|
|
|
for (itOld = pvecOldDrives->begin(); itOld != pvecOldDrives->end(); ++itOld)
|
|
|
|
|
{
|
|
|
|
|
if(itOld->bIsOffline == true)
|
|
|
|
|
{
|
|
|
|
|
//cout << "offline drive found: " << itOld->getPath() << endl;
|
|
|
|
|
Logger::logThis()->warning("offline drive found delete for: " + itOld->getPath());
|
|
|
|
|
itOld->state = Drive::NONE;
|
|
|
|
|
Logger::logThis()->warning("Mark offline drive found: " + itOld->getPath());
|
|
|
|
|
itOld->state = Drive::NONE; //clear state --> shred task will terminate
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pvecOldDrives->clear();
|
|
|
|
|
for (long unsigned int i=0; i<pvecNewDrives->size(); i++)
|
|
|
|
|
//add new drives to drive list
|
|
|
|
|
for (itNew = pvecNewDrives->begin(); itNew != pvecNewDrives->end(); ++itNew)
|
|
|
|
|
{
|
|
|
|
|
pvecOldDrives->push_back((*pvecNewDrives)[i]);
|
|
|
|
|
pvecOldDrives->push_back(pvecNewDrives->at(itNew - pvecNewDrives->begin()));
|
|
|
|
|
Logger::logThis()->info("Add new drive: " + itNew->getModelName());
|
|
|
|
|
}
|
|
|
|
|
pvecNewDrives->clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -246,6 +276,7 @@ void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
|
|
|
|
{
|
|
|
|
|
Drive* tmpDrive = new Drive(string(cLine).substr (2,8));
|
|
|
|
|
tmpDrive->state = Drive::NONE;
|
|
|
|
|
tmpDrive->bIsOffline = false;
|
|
|
|
|
pvecDrives->push_back(*tmpDrive);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -361,7 +392,12 @@ void reHDD::printDrives(vector <Drive>* pvecDrives)
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
ostringstream address;
|
|
|
|
|
address << (void const *)&pvecDrives->at(it - pvecDrives->begin());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger::logThis()->info(to_string(it - pvecDrives->begin()) + ": " + it->getPath() + " - " + it->getModelFamily() + " - " + it->getSerial() + " @" + address.str());
|
|
|
|
|
}
|
|
|
|
|
Logger::logThis()->info("---------------------------------");
|
|
|
|
|
//cout << "---------------------------------" << endl;
|
|
|
|
@ -463,7 +499,7 @@ void reHDD::handleAbort()
|
|
|
|
|
if(getSelectedDrive()->state == Drive::SHRED_ACTIVE || getSelectedDrive()->state == Drive::DELETE_ACTIVE )
|
|
|
|
|
{
|
|
|
|
|
getSelectedDrive()->state = Drive::NONE;
|
|
|
|
|
Logger::logThis()->info("Abort-Shred for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
|
|
|
|
|
Logger::logThis()->info("Abort-Shred-Signal for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
|
|
|
|
|
//task for drive is running --> remove selection
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|