ls instead hwinfo; update UI even mutex is locked
This commit is contained in:
parent
04f46bb9d6
commit
66cfbb5da2
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
#define REHDD_VERSION "bV0.1.0"
|
#define REHDD_VERSION "bV0.1.0"
|
||||||
|
|
||||||
//#define DRYRUN
|
|
||||||
|
|
||||||
// Drive handling Settings
|
// Drive handling Settings
|
||||||
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
||||||
#define WORSE_POWERUP 10000 //mark drive if at this limit or beyond
|
#define WORSE_POWERUP 10000 //mark drive if at this limit or beyond
|
||||||
|
@ -25,6 +23,11 @@
|
||||||
#define SOFTWARE_VERSION "alpha"
|
#define SOFTWARE_VERSION "alpha"
|
||||||
#define HARDWARE_VERSION "generic"
|
#define HARDWARE_VERSION "generic"
|
||||||
|
|
||||||
|
// Logic
|
||||||
|
//#define DRYRUN //don´t touch the drives
|
||||||
|
#define FROZEN_ALERT //show alert if drive is frozen
|
||||||
|
|
||||||
|
|
||||||
#define LOG_LEVEL_HIGH //log everything, like drive scann thread
|
#define LOG_LEVEL_HIGH //log everything, like drive scann thread
|
||||||
#ifndef LOG_LEVEL_HIGH
|
#ifndef LOG_LEVEL_HIGH
|
||||||
#define LOG_LEVEL_LOW //log only user actions and tasks
|
#define LOG_LEVEL_LOW //log only user actions and tasks
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
static WINDOW *createSystemStats(int iXSize, int iYSize, int iYStart);
|
static WINDOW *createSystemStats(int iXSize, int iYSize, int iYStart);
|
||||||
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
||||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
||||||
static WINDOW* createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial);
|
static WINDOW* createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial, string sProgress);
|
||||||
|
|
||||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ static uint8_t u8SelectedEntry;
|
||||||
|
|
||||||
static fd_set selectSet;
|
static fd_set selectSet;
|
||||||
|
|
||||||
//static struct TUI::MenuState menustate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief app constructor
|
* \brief app constructor
|
||||||
* \param void
|
* \param void
|
||||||
|
@ -61,23 +59,27 @@ void reHDD::app_logic(void)
|
||||||
FD_SET(fdShredInformPipe[0], &selectSet);
|
FD_SET(fdShredInformPipe[0], &selectSet);
|
||||||
|
|
||||||
select(FD_SETSIZE, &selectSet, NULL, NULL, NULL);
|
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;
|
char dummy;
|
||||||
read (fdNewDrivesInformPipe[0],&dummy,1);
|
read (fdNewDrivesInformPipe[0],&dummy,1);
|
||||||
filterNewDrives(&vecDrives, &vecNewDrives); //filter and copy to app logic vector
|
filterNewDrives(&vecDrives, &vecNewDrives); //filter and copy to app logic vector
|
||||||
printDrives(&vecDrives);
|
printDrives(&vecDrives);
|
||||||
|
mxScannDrives.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FD_ISSET(fdShredInformPipe[0], &selectSet))
|
if(FD_ISSET(fdShredInformPipe[0], &selectSet))
|
||||||
{
|
{
|
||||||
char dummy;
|
char dummy;
|
||||||
read (fdShredInformPipe[0],&dummy,1);
|
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);
|
ui->updateTUI(&vecDrives, u8SelectedEntry);
|
||||||
mxScannDrives.unlock();
|
//mxScannDrives.unlock();
|
||||||
} //endless loop
|
} //endless loop
|
||||||
thDevices.join();
|
thDevices.join();
|
||||||
thUserInput.join();
|
thUserInput.join();
|
||||||
|
@ -112,8 +114,6 @@ void reHDD::ThreadScannDevices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void reHDD::ThreadCheckFrozenDrives()
|
void reHDD::ThreadCheckFrozenDrives()
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
|
@ -127,7 +127,7 @@ void reHDD::ThreadCheckFrozenDrives()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mxScannDrives.unlock();
|
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;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
FILE* outputfileHwinfo = popen("hwinfo --short --disk", "r");
|
FILE* outputfileHwinfo = popen("ls -1 /dev/sd*", "r");
|
||||||
|
|
||||||
if (outputfileHwinfo == NULL)
|
if (outputfileHwinfo == NULL)
|
||||||
{
|
{
|
||||||
|
Logger::logThis()->error("Unable to scann attached drives");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
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->state = Drive::NONE;
|
||||||
tmpDrive->bIsOffline = false;
|
tmpDrive->bIsOffline = false;
|
||||||
pvecDrives->push_back(*tmpDrive);
|
pvecDrives->push_back(*tmpDrive);
|
||||||
|
@ -397,7 +398,7 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||||
void reHDD::printDrives(vector <Drive>* pvecDrives)
|
void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||||
{
|
{
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("------------DRIVES---------------");
|
Logger::logThis()->info("------------DRIVES START------------");
|
||||||
//cout << "------------DRIVES---------------" << endl;
|
//cout << "------------DRIVES---------------" << endl;
|
||||||
vector <Drive>::iterator it;
|
vector <Drive>::iterator it;
|
||||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||||
|
@ -416,11 +417,9 @@ void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||||
|
|
||||||
ostringstream address;
|
ostringstream address;
|
||||||
address << (void const *)&pvecDrives->at(it - pvecDrives->begin());
|
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(to_string(it - pvecDrives->begin()) + ": " + it->getPath() + " - " + it->getModelFamily() + " - " + it->getSerial() + " @" + address.str());
|
||||||
}
|
}
|
||||||
Logger::logThis()->info("---------------------------------");
|
Logger::logThis()->info("------------DRIVES END--------------");
|
||||||
//cout << "---------------------------------" << endl;
|
//cout << "---------------------------------" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,11 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Drive::FROZEN:
|
case Drive::FROZEN:
|
||||||
dialog=createFrozenWarning(70, 16, ((stdscrX)-(int)(stdscrX/2)-35),(int)(stdscrY/2)-8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial());
|
#ifdef FROZEN_ALERT
|
||||||
|
stream << fixed << setprecision(2) << (it->getTaskPercentage());
|
||||||
|
dialog=createFrozenWarning(70, 16, ((stdscrX)-(int)(stdscrX/2)-35),(int)(stdscrY/2)-8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial(), stream.str() + "%");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -399,7 +402,7 @@ WINDOW* TUI::createDialog(int iXSize, int iYSize, int iXStart, int iYStart, stri
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial)
|
WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial, string sProgress)
|
||||||
{
|
{
|
||||||
WINDOW *newWindow;
|
WINDOW *newWindow;
|
||||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||||
|
@ -409,6 +412,7 @@ WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStar
|
||||||
|
|
||||||
string sHeader = "Drive " + sPath + " is frozen";
|
string sHeader = "Drive " + sPath + " is frozen";
|
||||||
string sLine01 = "Please detach this drive and check it manually:";
|
string sLine01 = "Please detach this drive and check it manually:";
|
||||||
|
string sShredState = "Shredding stopped after " + sProgress;
|
||||||
string sLinePath = "Path: " +sPath;
|
string sLinePath = "Path: " +sPath;
|
||||||
string sLineModelFamlily = "ModelFamily: " + sModelFamily;
|
string sLineModelFamlily = "ModelFamily: " + sModelFamily;
|
||||||
string sLineModelName = "ModelName: " + sModelName;
|
string sLineModelName = "ModelName: " + sModelName;
|
||||||
|
@ -429,6 +433,7 @@ WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStar
|
||||||
u16Line++;
|
u16Line++;
|
||||||
mvwaddstr(newWindow,u16Line++, 3, sLine02.c_str());
|
mvwaddstr(newWindow,u16Line++, 3, sLine02.c_str());
|
||||||
mvwaddstr(newWindow,u16Line++, 3, sLine03.c_str());
|
mvwaddstr(newWindow,u16Line++, 3, sLine03.c_str());
|
||||||
|
mvwaddstr(newWindow,u16Line++, 3, sShredState.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue