Compare commits
2 Commits
master
...
6732aacdc8
| Author | SHA1 | Date | |
|---|---|---|---|
| 6732aacdc8 | |||
| 1caa4ce6f2 |
16
README.md
16
README.md
@ -16,9 +16,9 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab
|
|||||||
## Screenshot
|
## Screenshot
|
||||||

|

|
||||||
|
|
||||||
## openSUSE Build Notes
|
## Debian Build Notes
|
||||||
|
|
||||||
* `zypper install ncurses-devel git make gcc-c++`
|
* `apt-get install ncurses-dev git make g++`
|
||||||
* `git submodule init`
|
* `git submodule init`
|
||||||
* `git submodule update`
|
* `git submodule update`
|
||||||
* `make release`
|
* `make release`
|
||||||
@ -28,8 +28,16 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab
|
|||||||
Just install [reHDDPrinter](https://git.mosad.xyz/localhorst/reHDDPrinter).
|
Just install [reHDDPrinter](https://git.mosad.xyz/localhorst/reHDDPrinter).
|
||||||
No further settings needed.
|
No further settings needed.
|
||||||
|
|
||||||
|
## Create Standalone with Debian 11
|
||||||
|
|
||||||
|
Instructions how to create a standalone machine that boots directly to reHDD. This is aimed for production use, like several drives a day shredding.
|
||||||
|
* Start reHDD after boot without login (as a tty1 shell)
|
||||||
|
* Start dmesg after boot without login (as a tty2 shell)
|
||||||
|
* Start htop after boot without login (as a tty3 shell)
|
||||||
|
* Upload reHDD log every 12h if wanted
|
||||||
|
|
||||||
### Software requirements
|
### Software requirements
|
||||||
* `zypper install hwinfo smartmontools curl htop sudo`
|
* `apt-get install hwinfo smartmontools curl htop sudo`
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -48,7 +56,7 @@ git submodule update
|
|||||||
|
|
||||||
If you want to upload the logs, edit `scripts/reHDDLogUploader.bash` with your nextcloud token
|
If you want to upload the logs, edit `scripts/reHDDLogUploader.bash` with your nextcloud token
|
||||||
|
|
||||||
Add ignored drives in `/root/reHDD/ignoreDrives.conf` like:
|
Add your system drive in `/root/reHDD/ignoreDrives.conf` like:
|
||||||
```e102f49d```
|
```e102f49d```
|
||||||
Get the first 8 Bytes from your UUID via `blkid /dev/sdX`
|
Get the first 8 Bytes from your UUID via `blkid /dev/sdX`
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#ifndef REHDD_H_
|
#ifndef REHDD_H_
|
||||||
#define REHDD_H_
|
#define REHDD_H_
|
||||||
|
|
||||||
#define REHDD_VERSION "V1.3.0"
|
#define REHDD_VERSION "V1.2.1"
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ private:
|
|||||||
static void ThreadScanDevices();
|
static void ThreadScanDevices();
|
||||||
static void ThreadUserInput();
|
static void ThreadUserInput();
|
||||||
static void ThreadShred(Drive *const pDrive);
|
static void ThreadShred(Drive *const pDrive);
|
||||||
static void ThreadDelete(Drive *const pDrive);
|
static void ThreadDelete();
|
||||||
static void ThreadCheckFrozenDrives();
|
static void ThreadCheckFrozenDrives();
|
||||||
static void handleArrowKey(TUI::UserInput userInput);
|
static void handleArrowKey(TUI::UserInput userInput);
|
||||||
static void handleEnter();
|
static void handleEnter();
|
||||||
|
|||||||
197
src/reHDD.cpp
197
src/reHDD.cpp
@ -218,16 +218,18 @@ void reHDD::ThreadUserInput()
|
|||||||
break;
|
break;
|
||||||
case TUI::UserInput::Print:
|
case TUI::UserInput::Print:
|
||||||
// cout << "Print" << endl;
|
// cout << "Print" << endl;
|
||||||
|
Logger::logThis()->info("User print single");
|
||||||
if (tmpSelectedDrive != nullptr)
|
if (tmpSelectedDrive != nullptr)
|
||||||
{
|
{
|
||||||
printDrive(tmpSelectedDrive);
|
// printDrive(tmpSelectedDrive);
|
||||||
}
|
}
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
// ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
break;
|
break;
|
||||||
case TUI::UserInput::PrintAll:
|
case TUI::UserInput::PrintAll:
|
||||||
// cout << "PrintAll" << endl;
|
// cout << "PrintAll" << endl;
|
||||||
printAllDrives(&listDrives);
|
Logger::logThis()->info("User print all");
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
// printAllDrives(&listDrives);
|
||||||
|
// ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -236,7 +238,7 @@ void reHDD::ThreadUserInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief print all shredded drives
|
* \brief start shred for all drives
|
||||||
* \param pointer of list <Drive>* plistDrives
|
* \param pointer of list <Drive>* plistDrives
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
@ -252,11 +254,6 @@ void reHDD::printAllDrives(list<Drive> *plistDrives)
|
|||||||
mxDrives.unlock();
|
mxDrives.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief print a shredded drives
|
|
||||||
* \param pointer of a drive
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
void reHDD::printDrive(Drive *const pDrive)
|
void reHDD::printDrive(Drive *const pDrive)
|
||||||
{
|
{
|
||||||
if (pDrive->bWasShredded)
|
if (pDrive->bWasShredded)
|
||||||
@ -268,7 +265,7 @@ void reHDD::printDrive(Drive *const pDrive)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Logger::logThis()->info("User print for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
|
Logger::logThis()->info("User print for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
|
||||||
Printer::getPrinter()->print(pDrive);
|
// TODO: Trigger printer for this drive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,24 +273,24 @@ void reHDD::ThreadShred(Drive *const pDrive)
|
|||||||
{
|
{
|
||||||
if (pDrive != nullptr)
|
if (pDrive != nullptr)
|
||||||
{
|
{
|
||||||
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
||||||
Shred *pShredInstance = new Shred(); // create new shred task
|
Shred *pShredTask = new Shred(); // create new shred task
|
||||||
pShredInstance->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
pShredTask->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
||||||
delete pShredInstance; // delete shred task
|
delete pShredTask; // delete shred task
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reHDD::ThreadDelete(Drive *const pDrive)
|
void reHDD::ThreadDelete()
|
||||||
{
|
{
|
||||||
if (pDrive != nullptr)
|
Drive *tmpSelectedDrive = getSelectedDrive();
|
||||||
|
if (tmpSelectedDrive != nullptr)
|
||||||
{
|
{
|
||||||
pDrive->state = Drive::TaskState::DELETE_ACTIVE;
|
tmpSelectedDrive->setActionStartTimestamp(); // save timestamp at start of deleting
|
||||||
pDrive->setActionStartTimestamp(); // save timestamp at start of deleting
|
Delete::deleteDrive(tmpSelectedDrive); // blocking, no thread
|
||||||
Delete::deleteDrive(pDrive); // blocking, no thread
|
tmpSelectedDrive->state = Drive::TaskState::NONE; // delete finished
|
||||||
pDrive->state = Drive::TaskState::NONE; // delete finished
|
tmpSelectedDrive->bWasDeleted = true;
|
||||||
pDrive->bWasDeleted = true;
|
Logger::logThis()->info("Finished delete for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
||||||
Logger::logThis()->info("Finished delete for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
|
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,8 +415,8 @@ void reHDD::searchDrives(std::list<Drive> *plistDrives)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief filter out drives that are listed in "ignoreDrives.conf", loop devices, and optical drives
|
* \brief filter out drives that are listed in "ignoreDrives.conf"
|
||||||
* \param pointer of list <Drive>* plistDrives
|
* \param pointer of list <Drive>* plistDrives
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
||||||
@ -428,17 +425,11 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
if (getSystemDrive(systemDrivePath))
|
if (getSystemDrive(systemDrivePath))
|
||||||
{
|
{
|
||||||
// Logger::logThis()->info("Found system drive: " + systemDrivePath);
|
// Logger::logThis()->info("Found system drive: " + systemDrivePath);
|
||||||
list<Drive>::iterator it = plistDrives->begin();
|
|
||||||
while (it != plistDrives->end())
|
|
||||||
{
|
|
||||||
string driveName = it->getPath();
|
|
||||||
// Remove /dev/ prefix
|
|
||||||
if (driveName.find("/dev/") == 0)
|
|
||||||
{
|
|
||||||
driveName = driveName.substr(5); // Skip "/dev/"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (systemDrivePath.find(driveName) != std::string::npos) // compare found system drive and current drive
|
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
|
// system drive found --> ignore this drive
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
@ -446,123 +437,59 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
#endif
|
#endif
|
||||||
it = plistDrives->erase(it);
|
it = plistDrives->erase(it);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out loop devices (loop0, loop1, etc.)
|
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
||||||
list<Drive>::iterator it = plistDrives->begin();
|
ifstream input("ignoreDrives.conf"); // read ignore file
|
||||||
while (it != plistDrives->end())
|
|
||||||
{
|
|
||||||
string driveName = it->getPath();
|
|
||||||
if (driveName.find("/dev/") == 0)
|
|
||||||
{
|
|
||||||
driveName = driveName.substr(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driveName.find("loop") == 0)
|
|
||||||
{
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
|
||||||
Logger::logThis()->info("loop device found --> ignore this drive: " + it->getPath());
|
|
||||||
#endif
|
|
||||||
it = plistDrives->erase(it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter out optical drives (sr0, sr1, cdrom, dvd, etc.)
|
|
||||||
it = plistDrives->begin();
|
|
||||||
while (it != plistDrives->end())
|
|
||||||
{
|
|
||||||
string driveName = it->getPath();
|
|
||||||
if (driveName.find("/dev/") == 0)
|
|
||||||
{
|
|
||||||
driveName = driveName.substr(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driveName.find("sr") == 0 ||
|
|
||||||
driveName.find("cdrom") == 0 ||
|
|
||||||
driveName.find("dvd") == 0 ||
|
|
||||||
driveName.find("cdrw") == 0)
|
|
||||||
{
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
|
||||||
Logger::logThis()->info("optical drive found --> ignore this drive: " + it->getPath());
|
|
||||||
#endif
|
|
||||||
it = plistDrives->erase(it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read ignored drives from config file
|
|
||||||
list<tuple<string>> vtlIgnoredDevices;
|
|
||||||
ifstream input("ignoreDrives.conf");
|
|
||||||
|
|
||||||
for (string sLine; getline(input, sLine);)
|
for (string sLine; getline(input, sLine);)
|
||||||
{
|
{
|
||||||
// Skip empty lines and comments
|
// Logger::logThis()->info("read uuid: " + sLine);
|
||||||
if (!sLine.empty() && sLine[0] != '#')
|
vtlIgnoredDevices.emplace_back(sLine); // add found path and uuid from ignore file to vector
|
||||||
{
|
|
||||||
vtlIgnoredDevices.emplace_back(sLine);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// loop through found entries in ignore file
|
||||||
// Loop through found entries in ignore file
|
|
||||||
for (auto row : vtlIgnoredDevices)
|
for (auto row : vtlIgnoredDevices)
|
||||||
{
|
{
|
||||||
it = plistDrives->begin();
|
list<Drive>::iterator it;
|
||||||
while (it != plistDrives->end())
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
string sUUID;
|
string sUUID;
|
||||||
char *cLine = NULL;
|
char *cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
string sCMD = "blkid ";
|
string sCMD = "blkid ";
|
||||||
sCMD.append(it->getPath());
|
sCMD.append(it->getPath());
|
||||||
|
// cout << "cmd: " << sCMD << endl;
|
||||||
FILE *outputfileBlkid = popen(sCMD.c_str(), "r");
|
FILE *outputfileBlkid = popen(sCMD.c_str(), "r"); // get UUID from drive
|
||||||
if (outputfileBlkid == NULL)
|
if (outputfileBlkid == NULL)
|
||||||
{
|
{
|
||||||
Logger::logThis()->error("Failed to execute blkid for: " + it->getPath());
|
exit(EXIT_FAILURE);
|
||||||
++it;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((getline(&cLine, &len, outputfileBlkid)) != -1)
|
while ((getline(&cLine, &len, outputfileBlkid)) != -1) // parse UUID from blkid
|
||||||
{
|
{
|
||||||
size_t ptuuidPos = string(cLine).find("PTUUID");
|
size_t ptuuidPos = string(cLine).find("PTUUID");
|
||||||
if (ptuuidPos != string::npos)
|
if (ptuuidPos != string::npos)
|
||||||
{
|
{
|
||||||
string sBlkidOut = string(cLine);
|
string sBlkidOut = string(cLine);
|
||||||
sBlkidOut.erase(0, ptuuidPos + 8);
|
sBlkidOut.erase(0, ptuuidPos + 8);
|
||||||
if (sBlkidOut.length() >= 8)
|
sBlkidOut.erase(8, sBlkidOut.length());
|
||||||
{
|
|
||||||
sBlkidOut.erase(8, sBlkidOut.length());
|
|
||||||
}
|
|
||||||
sUUID = sBlkidOut;
|
sUUID = sBlkidOut;
|
||||||
|
// cout << "blkid uuid:" << sUUID << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(cLine);
|
free(cLine);
|
||||||
pclose(outputfileBlkid);
|
pclose(outputfileBlkid);
|
||||||
|
// cout << "blkid uuid:" << sUUID << endl;
|
||||||
|
|
||||||
if (!get<0>(row).compare(sUUID))
|
if (!get<0>(row).compare(sUUID)) // compare uuid from ignore file and uuid from drive
|
||||||
{
|
{
|
||||||
|
// same uuid found than in ignore file --> ignore this drive
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("same uuid found in ignore file --> ignore this drive: " + it->getPath());
|
Logger::logThis()->info("same uuid found than in ignore file --> ignore this drive: " + it->getPath());
|
||||||
#endif
|
#endif
|
||||||
it = plistDrives->erase(it);
|
it = plistDrives->erase(it);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,6 +533,7 @@ void reHDD::startShredAllDrives(list<Drive> *plistDrives)
|
|||||||
address << (void const *)&(*pTmpDrive);
|
address << (void const *)&(*pTmpDrive);
|
||||||
Logger::logThis()->info("Started shred (all) for: " + pTmpDrive->getModelName() + "-" + pTmpDrive->getSerial() + " @" + address.str());
|
Logger::logThis()->info("Started shred (all) for: " + pTmpDrive->getModelName() + "-" + pTmpDrive->getSerial() + " @" + address.str());
|
||||||
#endif
|
#endif
|
||||||
|
pTmpDrive->state = Drive::TaskState::SHRED_ACTIVE;
|
||||||
thread(ThreadShred, pTmpDrive).detach();
|
thread(ThreadShred, pTmpDrive).detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -757,13 +685,17 @@ void reHDD::handleEnter()
|
|||||||
if (tmpSelectedDrive->state == Drive::TaskState::SHRED_SELECTED)
|
if (tmpSelectedDrive->state == Drive::TaskState::SHRED_SELECTED)
|
||||||
{
|
{
|
||||||
Logger::logThis()->info("Started shred/check for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
Logger::logThis()->info("Started shred/check for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
||||||
|
tmpSelectedDrive->state = Drive::TaskState::SHRED_ACTIVE;
|
||||||
|
// task for drive is running --> don't show more task option
|
||||||
thread(ThreadShred, tmpSelectedDrive).detach();
|
thread(ThreadShred, tmpSelectedDrive).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpSelectedDrive->state == Drive::TaskState::DELETE_SELECTED)
|
if (tmpSelectedDrive->state == Drive::TaskState::DELETE_SELECTED)
|
||||||
{
|
{
|
||||||
Logger::logThis()->info("Started delete for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
Logger::logThis()->info("Started delete for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
||||||
thread(ThreadDelete, tmpSelectedDrive).detach();
|
tmpSelectedDrive->state = Drive::TaskState::DELETE_ACTIVE;
|
||||||
|
// task for drive is running --> don't show more task options
|
||||||
|
thread(ThreadDelete).detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -824,23 +756,14 @@ bool reHDD::getSystemDrive(string &systemDrive)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract drive name from line (removing tree characters)
|
// Logger::logThis()->info(currentLine);
|
||||||
|
|
||||||
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
||||||
{
|
{
|
||||||
systemDrive = currentLine;
|
systemDrive = currentLine;
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); // remove newline
|
||||||
// Find the actual drive name (after tree characters like └─, ├─)
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces
|
||||||
size_t lastAlpha = 0;
|
// Logger::logThis()->info("Drive found: " + systemDrive);
|
||||||
for (size_t i = 0; i < systemDrive.length(); i++)
|
|
||||||
{
|
|
||||||
if (isalpha(systemDrive[i]))
|
|
||||||
{
|
|
||||||
lastAlpha = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
systemDrive = systemDrive.substr(lastAlpha);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLine.ends_with(" /boot/efi\n"s))
|
if (currentLine.ends_with(" /boot/efi\n"s))
|
||||||
@ -863,17 +786,5 @@ bool reHDD::getSystemDrive(string &systemDrive)
|
|||||||
}
|
}
|
||||||
pclose(outputfileHwinfo);
|
pclose(outputfileHwinfo);
|
||||||
|
|
||||||
// Remove mountpoint (everything after first space)
|
|
||||||
size_t spacePos = systemDrive.find(' ');
|
|
||||||
if (spacePos != std::string::npos)
|
|
||||||
{
|
|
||||||
systemDrive = systemDrive.substr(0, spacePos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove all unwanted characters
|
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end());
|
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '/'), systemDrive.end());
|
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\r'), systemDrive.end());
|
|
||||||
|
|
||||||
return systemDriveFound;
|
return systemDriveFound;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,14 +38,14 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
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
|
drive->bWasShredStarted = true; // Mark drive as partly shredded
|
||||||
drive->bWasShredded = false;
|
|
||||||
drive->setTaskPercentage(0.0);
|
|
||||||
drive->u32DriveChecksumAfterShredding = UINT32_MAX;
|
|
||||||
drive->state = Drive::TaskState::SHRED_ACTIVE;
|
|
||||||
|
|
||||||
#ifdef DRYRUN
|
#ifdef DRYRUN
|
||||||
for (int i = 0; i <= 100; i++)
|
for (int i = 0; i <= 500; i++)
|
||||||
{
|
{
|
||||||
|
if (drive->state.load() != Drive::TaskState::SHRED_ACTIVE)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
drive->setTaskPercentage(i + 0.05);
|
drive->setTaskPercentage(i + 0.05);
|
||||||
write(*ipSignalFd, "A", 1);
|
write(*ipSignalFd, "A", 1);
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
@ -204,9 +204,10 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cleanup();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
if ((drive->state.load() == Drive::TaskState::SHRED_ACTIVE) || (drive->state.load() == Drive::TaskState::CHECK_SUCCESSFUL) || (drive->state == Drive::TaskState::CHECK_FAILED))
|
if ((drive->state.load() == Drive::TaskState::SHRED_ACTIVE) || (drive->state.load() == Drive::TaskState::CHECK_SUCCESSFUL) || (drive->state == Drive::TaskState::CHECK_FAILED))
|
||||||
{
|
{
|
||||||
if (drive->state != Drive::TaskState::CHECK_FAILED)
|
if (drive->state != Drive::TaskState::CHECK_FAILED)
|
||||||
|
|||||||
Reference in New Issue
Block a user