Compare commits
2 Commits
master
...
test/ipc-d
Author | SHA1 | Date | |
---|---|---|---|
a35cb111ee | |||
575cb73d95 |
@ -25,14 +25,6 @@ public:
|
|||||||
FROZEN
|
FROZEN
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
enum ConnectionType
|
|
||||||
{
|
|
||||||
UNKNOWN,
|
|
||||||
USB,
|
|
||||||
SATA,
|
|
||||||
NVME
|
|
||||||
} connectionType;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
time_t u32ShredTimeDelta;
|
time_t u32ShredTimeDelta;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef REHDD_H_
|
#ifndef REHDD_H_
|
||||||
#define REHDD_H_
|
#define REHDD_H_
|
||||||
|
|
||||||
#define REHDD_VERSION "V1.2.0"
|
#define REHDD_VERSION "V1.1.3"
|
||||||
|
|
||||||
// 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
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
// Logger Settings
|
// Logger Settings
|
||||||
#define LOG_PATH "./reHDD.log"
|
#define LOG_PATH "./reHDD.log"
|
||||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2025"
|
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2024"
|
||||||
#define DEVICE_ID "generic"
|
#define DEVICE_ID "generic"
|
||||||
#define SOFTWARE_VERSION REHDD_VERSION
|
#define SOFTWARE_VERSION REHDD_VERSION
|
||||||
#define HARDWARE_VERSION "generic"
|
#define HARDWARE_VERSION "generic"
|
||||||
@ -86,7 +86,6 @@ private:
|
|||||||
static void searchDrives(list<Drive> *plistDrives);
|
static void searchDrives(list<Drive> *plistDrives);
|
||||||
static void printDrives(list<Drive> *plistDrives);
|
static void printDrives(list<Drive> *plistDrives);
|
||||||
static void startShredAllDrives(list<Drive> *plistDrives);
|
static void startShredAllDrives(list<Drive> *plistDrives);
|
||||||
static void stopShredAllDrives(list<Drive> *plistDrives);
|
|
||||||
static void updateShredMetrics(list<Drive> *plistDrives);
|
static void updateShredMetrics(list<Drive> *plistDrives);
|
||||||
static void filterIgnoredDrives(list<Drive> *plistDrives);
|
static void filterIgnoredDrives(list<Drive> *plistDrives);
|
||||||
static void filterInvalidDrives(list<Drive> *plistDrives);
|
static void filterInvalidDrives(list<Drive> *plistDrives);
|
||||||
|
@ -31,7 +31,6 @@ public:
|
|||||||
Delete,
|
Delete,
|
||||||
Enter,
|
Enter,
|
||||||
ESC,
|
ESC,
|
||||||
Terminate,
|
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
struct MenuState
|
struct MenuState
|
||||||
@ -67,7 +66,7 @@ private:
|
|||||||
static WINDOW *createOverViewWindow(int iXSize, int iYSize);
|
static WINDOW *createOverViewWindow(int iXSize, int iYSize);
|
||||||
static WINDOW *createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive drive);
|
static WINDOW *createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive drive);
|
||||||
static WINDOW *overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart);
|
static WINDOW *overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart);
|
||||||
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, string sConnection, bool bSelected);
|
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected);
|
||||||
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
|
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, 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);
|
||||||
|
30
src/main.cpp
30
src/main.cpp
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../include/reHDD.h"
|
#include "../include/reHDD.h"
|
||||||
|
#include "../include/printer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief app entry point
|
* \brief app entry point
|
||||||
@ -14,9 +15,32 @@
|
|||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// cout << "refurbishingHddTool" << endl;
|
cout << "refurbishingHddTool" << endl;
|
||||||
|
|
||||||
reHDD *app = new reHDD();
|
Drive *tmpDrive = new Drive("/dev/");
|
||||||
app->app_logic();
|
tmpDrive->setActionStartTimestamp();
|
||||||
|
tmpDrive->bWasShredded = true;
|
||||||
|
tmpDrive->setDriveSMARTData("modelFamily",
|
||||||
|
"modelName",
|
||||||
|
"serial",
|
||||||
|
420000,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46);
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
cout << "send" << endl;
|
||||||
|
Printer::getPrinter()->print(tmpDrive);
|
||||||
|
sleep(5); // sleep 5 sec
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cout << "exit" << endl;
|
||||||
|
|
||||||
|
// reHDD *app = new reHDD();
|
||||||
|
// app->app_logic();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
@ -197,12 +197,6 @@ void reHDD::ThreadUserInput()
|
|||||||
handleESC();
|
handleESC();
|
||||||
ui->updateTUI(&listDrives, u8SelectedEntry);
|
ui->updateTUI(&listDrives, u8SelectedEntry);
|
||||||
break;
|
break;
|
||||||
case TUI::UserInput::Terminate:
|
|
||||||
cout << "Terminate" << endl;
|
|
||||||
stopShredAllDrives(&listDrives);
|
|
||||||
sleep(5); // sleep 5 sec
|
|
||||||
std::exit(1); // Terminates main, doesn't wait for threads
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -306,51 +300,41 @@ void reHDD::filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDr
|
|||||||
* \param pointer of list <Drive>* plistDrives
|
* \param pointer of list <Drive>* plistDrives
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
void reHDD::searchDrives(std::list<Drive> *plistDrives)
|
void reHDD::searchDrives(list<Drive> *plistDrives)
|
||||||
{
|
{
|
||||||
FILE *fp = popen("lsblk -d -n -o NAME,TRAN", "r");
|
// Logger::logThis()->info("--> search drives <--");
|
||||||
if (!fp)
|
char *cLine = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
|
FILE *outputfileHwinfo = popen("lsblk -e 11 -d -o NAME", "r");
|
||||||
|
|
||||||
|
if (outputfileHwinfo == NULL)
|
||||||
{
|
{
|
||||||
Logger::logThis()->error("Unable to execute lsblk to scan drives");
|
Logger::logThis()->error("Unable to scan attached drives");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char line[256];
|
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
||||||
while (fgets(line, sizeof(line), fp))
|
|
||||||
{
|
{
|
||||||
std::string devName, transport;
|
if (string(cLine).length() == 4)
|
||||||
std::istringstream iss(line);
|
{
|
||||||
iss >> devName >> transport;
|
Drive *tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 3));
|
||||||
|
|
||||||
if (devName.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Drive *tmpDrive = new Drive("/dev/" + devName);
|
|
||||||
tmpDrive->state = Drive::NONE;
|
tmpDrive->state = Drive::NONE;
|
||||||
tmpDrive->bIsOffline = false;
|
tmpDrive->bIsOffline = false;
|
||||||
|
|
||||||
// Set connection type
|
|
||||||
if (transport == "sata")
|
|
||||||
tmpDrive->connectionType = Drive::SATA;
|
|
||||||
else if (transport == "usb")
|
|
||||||
tmpDrive->connectionType = Drive::USB;
|
|
||||||
else if (transport == "nvme")
|
|
||||||
tmpDrive->connectionType = Drive::NVME;
|
|
||||||
else
|
|
||||||
tmpDrive->connectionType = Drive::UNKNOWN;
|
|
||||||
|
|
||||||
plistDrives->push_back(*tmpDrive);
|
plistDrives->push_back(*tmpDrive);
|
||||||
|
// Logger::logThis()->info("SATA drive found: " + tmpDrive->getPath());
|
||||||
Logger::logThis()->info(
|
|
||||||
"Drive found: " + tmpDrive->getPath() +
|
|
||||||
" (type: " +
|
|
||||||
(tmpDrive->connectionType == Drive::USB ? "USB" : tmpDrive->connectionType == Drive::SATA ? "SATA"
|
|
||||||
: tmpDrive->connectionType == Drive::NVME ? "NVME"
|
|
||||||
: "UNKNOWN") +
|
|
||||||
")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(fp);
|
if (string(cLine).length() == 8)
|
||||||
|
{
|
||||||
|
Drive *tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 7));
|
||||||
|
tmpDrive->state = Drive::NONE;
|
||||||
|
tmpDrive->bIsOffline = false;
|
||||||
|
plistDrives->push_back(*tmpDrive);
|
||||||
|
// Logger::logThis()->info("NVME drive found: " + tmpDrive->getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pclose(outputfileHwinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -480,34 +464,6 @@ void reHDD::startShredAllDrives(list<Drive> *plistDrives)
|
|||||||
mxDrives.unlock();
|
mxDrives.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief stop shred for all drives
|
|
||||||
* \param pointer of list <Drive>* plistDrives
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
void reHDD::stopShredAllDrives(list<Drive> *plistDrives)
|
|
||||||
{
|
|
||||||
list<Drive>::iterator it;
|
|
||||||
mxDrives.lock();
|
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (it->state == Drive::SHRED_ACTIVE || it->state == Drive::DELETE_ACTIVE)
|
|
||||||
{
|
|
||||||
it->state = Drive::NONE;
|
|
||||||
Logger::logThis()->info("Abort-Shred-Signal for: " + it->getModelName() + "-" + it->getSerial());
|
|
||||||
// task for drive is running --> remove selection
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
|
||||||
ostringstream address;
|
|
||||||
address << (void const *)&(*it);
|
|
||||||
Logger::logThis()->info("Started shred (all) for: " + it->getModelName() + "-" + it->getSerial() + " @" + address.str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
mxDrives.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief print drives with all information
|
* \brief print drives with all information
|
||||||
* \param pointer of list <Drive>* plistDrives
|
* \param pointer of list <Drive>* plistDrives
|
||||||
|
@ -187,7 +187,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
Logger::logThis()->info("Check-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
Logger::logThis()->info("Check-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
||||||
drive->u32DriveChecksumAfterShredding = uiCalcChecksum(driveFileDiscr, drive, ipSignalFd);
|
drive->u32DriveChecksumAfterShredding = uiCalcChecksum(driveFileDiscr, drive, ipSignalFd);
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
if (drive->u32DriveChecksumAfterShredding != 0)
|
if (drive->u32DriveChecksumAferShredding != 0)
|
||||||
{
|
{
|
||||||
Logger::logThis()->info("Shred-Task: Checksum not zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: Checksum not zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
||||||
}
|
}
|
||||||
|
16
src/tui.cpp
16
src/tui.cpp
@ -93,9 +93,6 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
|
|||||||
string sSpeed = " ";
|
string sSpeed = " ";
|
||||||
string sTime = " ";
|
string sTime = " ";
|
||||||
string sTemp = it->sTemperatureToText();
|
string sTemp = it->sTemperatureToText();
|
||||||
string sConnection = (it->connectionType == Drive::USB ? "USB" : it->connectionType == Drive::SATA ? "SATA"
|
|
||||||
: it->connectionType == Drive::NVME ? "NVME"
|
|
||||||
: "");
|
|
||||||
|
|
||||||
bool bSelectedEntry = false;
|
bool bSelectedEntry = false;
|
||||||
|
|
||||||
@ -185,7 +182,7 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
|
|||||||
|
|
||||||
uint16_t u16StartOffsetY = (2 * (u8Index));
|
uint16_t u16StartOffsetY = (2 * (u8Index));
|
||||||
|
|
||||||
WINDOW *tmp = createEntryWindow((int)(u16StdscrX * (float)(3.0 / 7.0) - 2), 2, 3, u16StartOffsetY + 2, (distance(plistDrives->begin(), it) + 1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, sTemp, sConnection, bSelectedEntry);
|
WINDOW *tmp = createEntryWindow((int)(u16StdscrX * (float)(3.0 / 7.0) - 2), 2, 3, u16StartOffsetY + 2, (distance(plistDrives->begin(), it) + 1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, sTemp, bSelectedEntry);
|
||||||
wrefresh(tmp);
|
wrefresh(tmp);
|
||||||
u8Index++;
|
u8Index++;
|
||||||
} // end loop though drives
|
} // end loop though drives
|
||||||
@ -240,9 +237,6 @@ enum TUI::UserInput TUI::readUserInput()
|
|||||||
case 'S':
|
case 'S':
|
||||||
return TUI::UserInput::ShredAll;
|
return TUI::UserInput::ShredAll;
|
||||||
break;
|
break;
|
||||||
case 'T':
|
|
||||||
return TUI::UserInput::Terminate;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return TUI::UserInput::Undefined;
|
return TUI::UserInput::Undefined;
|
||||||
break;
|
break;
|
||||||
@ -348,7 +342,7 @@ WINDOW *TUI::overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart)
|
|||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, string sConnection, bool bSelected)
|
WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected)
|
||||||
{
|
{
|
||||||
WINDOW *newWindow;
|
WINDOW *newWindow;
|
||||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||||
@ -393,7 +387,6 @@ WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
|||||||
37-43: Capacity
|
37-43: Capacity
|
||||||
44: space
|
44: space
|
||||||
47-49: Temp
|
47-49: Temp
|
||||||
57-60: Connection Type
|
|
||||||
|
|
||||||
line:02
|
line:02
|
||||||
0-2: space
|
0-2: space
|
||||||
@ -410,7 +403,6 @@ WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
|||||||
mvwaddstr(newWindow, 0, 3, sModelFamily.c_str());
|
mvwaddstr(newWindow, 0, 3, sModelFamily.c_str());
|
||||||
mvwaddstr(newWindow, 0, 37, sCapacity.c_str());
|
mvwaddstr(newWindow, 0, 37, sCapacity.c_str());
|
||||||
mvwaddstr(newWindow, 0, 47, sTemp.c_str());
|
mvwaddstr(newWindow, 0, 47, sTemp.c_str());
|
||||||
mvwaddstr(newWindow, 0, 57, sConnection.c_str());
|
|
||||||
|
|
||||||
vTruncateText(&sSerial, 28);
|
vTruncateText(&sSerial, 28);
|
||||||
mvwaddstr(newWindow, 1, 3, sSerial.c_str());
|
mvwaddstr(newWindow, 1, 3, sSerial.c_str());
|
||||||
@ -490,12 +482,8 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
|||||||
{
|
{
|
||||||
string sLineTmp = "Press d for Delete";
|
string sLineTmp = "Press d for Delete";
|
||||||
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
||||||
u16Line++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string sLineTmp = "Press T for terminating reHDD";
|
|
||||||
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user