forked from localhorst/reHDD
ls instead hwinfo; update UI even mutex is locked
This commit is contained in:
@ -23,8 +23,6 @@ static uint8_t u8SelectedEntry;
|
||||
|
||||
static fd_set selectSet;
|
||||
|
||||
//static struct TUI::MenuState menustate;
|
||||
|
||||
/**
|
||||
* \brief app constructor
|
||||
* \param void
|
||||
@ -61,23 +59,27 @@ void reHDD::app_logic(void)
|
||||
FD_SET(fdShredInformPipe[0], &selectSet);
|
||||
|
||||
select(FD_SETSIZE, &selectSet, NULL, NULL, NULL);
|
||||
mxScannDrives.lock();
|
||||
if( FD_ISSET(fdNewDrivesInformPipe[0], &selectSet))
|
||||
|
||||
if(FD_ISSET(fdNewDrivesInformPipe[0], &selectSet))
|
||||
{
|
||||
mxScannDrives.lock();
|
||||
char dummy;
|
||||
read (fdNewDrivesInformPipe[0],&dummy,1);
|
||||
filterNewDrives(&vecDrives, &vecNewDrives); //filter and copy to app logic vector
|
||||
printDrives(&vecDrives);
|
||||
|
||||
mxScannDrives.unlock();
|
||||
}
|
||||
|
||||
if (FD_ISSET(fdShredInformPipe[0], &selectSet))
|
||||
if(FD_ISSET(fdShredInformPipe[0], &selectSet))
|
||||
{
|
||||
char dummy;
|
||||
read (fdShredInformPipe[0],&dummy,1);
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("got progress signal from a shred task");
|
||||
#endif
|
||||
}
|
||||
//mxScannDrives.lock();
|
||||
ui->updateTUI(&vecDrives, u8SelectedEntry);
|
||||
mxScannDrives.unlock();
|
||||
//mxScannDrives.unlock();
|
||||
} //endless loop
|
||||
thDevices.join();
|
||||
thUserInput.join();
|
||||
@ -112,8 +114,6 @@ void reHDD::ThreadScannDevices()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void reHDD::ThreadCheckFrozenDrives()
|
||||
{
|
||||
while(true)
|
||||
@ -127,7 +127,7 @@ void reHDD::ThreadCheckFrozenDrives()
|
||||
}
|
||||
}
|
||||
mxScannDrives.unlock();
|
||||
sleep(5); //sleep 5 sec
|
||||
sleep(13); //sleep 13 sec
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,18 +284,19 @@ void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
char * cLine = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
FILE* outputfileHwinfo = popen("hwinfo --short --disk", "r");
|
||||
FILE* outputfileHwinfo = popen("ls -1 /dev/sd*", "r");
|
||||
|
||||
if (outputfileHwinfo == NULL)
|
||||
{
|
||||
Logger::logThis()->error("Unable to scann attached drives");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
||||
{
|
||||
if (string(cLine).find("/dev/sd") != string::npos)
|
||||
if (string(cLine).length() == 9)
|
||||
{
|
||||
Drive* tmpDrive = new Drive(string(cLine).substr (2,8));
|
||||
Drive* tmpDrive = new Drive(string(cLine).substr(0, 8));
|
||||
tmpDrive->state = Drive::NONE;
|
||||
tmpDrive->bIsOffline = false;
|
||||
pvecDrives->push_back(*tmpDrive);
|
||||
@ -397,7 +398,7 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||
void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("------------DRIVES---------------");
|
||||
Logger::logThis()->info("------------DRIVES START------------");
|
||||
//cout << "------------DRIVES---------------" << endl;
|
||||
vector <Drive>::iterator it;
|
||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||
@ -416,11 +417,9 @@ void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||
|
||||
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("---------------------------------");
|
||||
Logger::logThis()->info("------------DRIVES END--------------");
|
||||
//cout << "---------------------------------" << endl;
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user