Compare commits
14 Commits
282c294ae7
...
test/ipc-d
Author | SHA1 | Date | |
---|---|---|---|
a35cb111ee | |||
575cb73d95 | |||
1ceffa56f8 | |||
4ff1888333 | |||
4b33fb6fdb | |||
87a859f187 | |||
952e8c8eeb | |||
1055ef57ee | |||
6dd4c44688 | |||
feed1b4a97 | |||
5d2094939b | |||
b1b9870150 | |||
77b322d47d | |||
a665f8638e |
@ -9,7 +9,7 @@
|
|||||||
* process multiple drives at once
|
* process multiple drives at once
|
||||||
|
|
||||||
## Download USB Image ##
|
## Download USB Image ##
|
||||||
[2.5GB image v1.0.0](https://schuttercloud.com/s/ggxGH9sA326aRfK) (`wget` is your friend)
|
See reHDD-Bootable how the live image created: https://git.mosad.xyz/localhorst/reHDD-Bootable
|
||||||
|
|
||||||
Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootable USB drive .
|
Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootable USB drive .
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
} sShredSpeed;
|
} sShredSpeed;
|
||||||
|
|
||||||
bool bWasShredded = false; // all shred iterations done
|
bool bWasShredded = false; // all shred iterations done
|
||||||
|
bool bWasShredStarted = false; // shred was atleast once started
|
||||||
bool bWasChecked = false; // all shred iterations and optional checking done
|
bool bWasChecked = false; // all shred iterations and optional checking done
|
||||||
bool bWasDeleted = false;
|
bool bWasDeleted = false;
|
||||||
bool bIsOffline = false;
|
bool bIsOffline = false;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef REHDD_H_
|
#ifndef REHDD_H_
|
||||||
#define REHDD_H_
|
#define REHDD_H_
|
||||||
|
|
||||||
#define REHDD_VERSION "V1.1.2"
|
#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
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Logic
|
// Logic
|
||||||
//#define DRYRUN //don´t touch the drives
|
//#define DRYRUN // don't touch the drives
|
||||||
#define FROZEN_ALERT // show alert if drive is frozen
|
#define FROZEN_ALERT // show alert if drive is frozen
|
||||||
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
|
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ private:
|
|||||||
static void handleESC();
|
static void handleESC();
|
||||||
static void handleAbort();
|
static void handleAbort();
|
||||||
static Drive *getSelectedDrive();
|
static Drive *getSelectedDrive();
|
||||||
|
static bool getSystemDrive(string &systemDrive);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REHDD_H_
|
#endif // REHDD_H_
|
||||||
|
@ -32,6 +32,9 @@ void Delete::deleteDrive(Drive *drive)
|
|||||||
const char *cpComand = sCMD.c_str();
|
const char *cpComand = sCMD.c_str();
|
||||||
// cout << "delete: " << cpComand << endl;
|
// cout << "delete: " << cpComand << endl;
|
||||||
|
|
||||||
|
if (drive->bWasShredStarted == false)
|
||||||
|
{
|
||||||
|
//only start delete if the drive was not shredded before
|
||||||
FILE *deleteCmdOutput = popen(cpComand, "r");
|
FILE *deleteCmdOutput = popen(cpComand, "r");
|
||||||
|
|
||||||
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
|
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
|
||||||
@ -40,3 +43,4 @@ void Delete::deleteDrive(Drive *drive)
|
|||||||
}
|
}
|
||||||
pclose(deleteCmdOutput);
|
pclose(deleteCmdOutput);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
@ -344,6 +344,26 @@ void reHDD::searchDrives(list<Drive> *plistDrives)
|
|||||||
*/
|
*/
|
||||||
void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
||||||
{
|
{
|
||||||
|
string systemDrivePath;
|
||||||
|
if (getSystemDrive(systemDrivePath))
|
||||||
|
{
|
||||||
|
// Logger::logThis()->info("Found system drive: " + systemDrivePath);
|
||||||
|
|
||||||
|
list<Drive>::iterator it;
|
||||||
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->getPath().find(systemDrivePath) != std::string::npos) // compare found system drive and current drive
|
||||||
|
{
|
||||||
|
// system drive found --> ignore this drive
|
||||||
|
#ifdef LOG_LEVEL_HIGH
|
||||||
|
Logger::logThis()->info("system drive found --> ignore this drive: " + it->getPath());
|
||||||
|
#endif
|
||||||
|
it = plistDrives->erase(it);
|
||||||
|
it--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
||||||
ifstream input("ignoreDrives.conf"); // read ignore file
|
ifstream input("ignoreDrives.conf"); // read ignore file
|
||||||
|
|
||||||
@ -605,3 +625,59 @@ void reHDD::handleAbort()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool reHDD::getSystemDrive(string &systemDrive)
|
||||||
|
{
|
||||||
|
char *cLine = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
bool systemDriveFound = false;
|
||||||
|
|
||||||
|
FILE *outputfileHwinfo = popen("lsblk -e 11 -o NAME,MOUNTPOINT", "r");
|
||||||
|
|
||||||
|
if (outputfileHwinfo == NULL)
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Unable to scan attached drives for system drive");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
||||||
|
{
|
||||||
|
string currentLine = cLine;
|
||||||
|
|
||||||
|
if (currentLine.find("NAME") != std::string::npos)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logger::logThis()->info(currentLine);
|
||||||
|
|
||||||
|
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
||||||
|
{
|
||||||
|
systemDrive = currentLine;
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); // remove newline
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces
|
||||||
|
// Logger::logThis()->info("Drive found: " + systemDrive);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.ends_with(" /boot/efi\n"s))
|
||||||
|
{
|
||||||
|
systemDriveFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.ends_with(" /run/overlay/live\n"s))
|
||||||
|
{
|
||||||
|
systemDriveFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.ends_with(" /\n"s))
|
||||||
|
{
|
||||||
|
systemDriveFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pclose(outputfileHwinfo);
|
||||||
|
|
||||||
|
return systemDriveFound;
|
||||||
|
}
|
@ -36,6 +36,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
ostringstream address;
|
ostringstream address;
|
||||||
address << (void const *)&(*drive);
|
address << (void const *)&(*drive);
|
||||||
Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
||||||
|
drive->bWasShredStarted = true; //Mark drive as partly shredded
|
||||||
|
|
||||||
#ifdef DRYRUN
|
#ifdef DRYRUN
|
||||||
for (int i = 0; i <= 500; i++)
|
for (int i = 0; i <= 500; i++)
|
||||||
@ -48,6 +49,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
write(*ipSignalFd, "A", 1);
|
write(*ipSignalFd, "A", 1);
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
}
|
}
|
||||||
|
drive->bWasShredded = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
|
@ -613,6 +613,7 @@ void TUI::vTruncateText(string *psText, uint16_t u16MaxLenght)
|
|||||||
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
||||||
{
|
{
|
||||||
struct MenuState menustate;
|
struct MenuState menustate;
|
||||||
|
static bool dialogIsActive;
|
||||||
menustate.bAbort = false;
|
menustate.bAbort = false;
|
||||||
menustate.bConfirmDelete = false;
|
menustate.bConfirmDelete = false;
|
||||||
menustate.bConfirmShred = false;
|
menustate.bConfirmShred = false;
|
||||||
@ -659,15 +660,21 @@ void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
|||||||
{
|
{
|
||||||
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm SHRED", "Press ENTER for SHRED", "Press ESC for cancel");
|
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm SHRED", "Press ENTER for SHRED", "Press ESC for cancel");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
|
dialogIsActive = true;
|
||||||
}
|
}
|
||||||
else if (menustate.bConfirmDelete == true)
|
else if (menustate.bConfirmDelete == true)
|
||||||
{
|
{
|
||||||
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm DELETE", "Press ENTER for DELETE", "Press ESC for cancel");
|
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm DELETE", "Press ENTER for DELETE", "Press ESC for cancel");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
|
dialogIsActive = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (dialogIsActive)
|
||||||
{
|
{
|
||||||
delwin(dialog);
|
delwin(dialog);
|
||||||
|
dialogIsActive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user