Compare commits
6 Commits
550dd6a59f
...
feature/sh
| Author | SHA1 | Date | |
|---|---|---|---|
| 62f6a1c7ab | |||
| 157e769268 | |||
| 612d531dae | |||
| 8a42ccf9c0 | |||
| 1dce303ab6 | |||
| 1449e807ad |
@ -8,7 +8,7 @@
|
|||||||
#ifndef REHDD_H_
|
#ifndef REHDD_H_
|
||||||
#define REHDD_H_
|
#define REHDD_H_
|
||||||
|
|
||||||
#define REHDD_VERSION "V1.2.1"
|
#define REHDD_VERSION "V1.3.0"
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@ -90,10 +90,12 @@ private:
|
|||||||
static void filterInvalidDrives(list<Drive> *plistDrives);
|
static void filterInvalidDrives(list<Drive> *plistDrives);
|
||||||
static void filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDrives);
|
static void filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDrives);
|
||||||
static void addSMARTData(list<Drive> *plistDrives);
|
static void addSMARTData(list<Drive> *plistDrives);
|
||||||
|
static void printAllDrives(list<Drive> *plistDrives);
|
||||||
|
static void printDrive(Drive *const pDrive);
|
||||||
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();
|
static void ThreadDelete(Drive *const pDrive);
|
||||||
static void ThreadCheckFrozenDrives();
|
static void ThreadCheckFrozenDrives();
|
||||||
static void handleArrowKey(TUI::UserInput userInput);
|
static void handleArrowKey(TUI::UserInput userInput);
|
||||||
static void handleEnter();
|
static void handleEnter();
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#define CHUNK_SIZE 1024 * 1024 * 32 // amount of bytes that are overwritten at once --> 32MB
|
#define CHUNK_SIZE 1024 * 1024 * 32 // amount of bytes that are overwritten at once --> 32MB
|
||||||
#define TFNG_DATA_SIZE CHUNK_SIZE // amount of bytes used by tfng
|
#define TFNG_DATA_SIZE CHUNK_SIZE // amount of bytes used by tfng
|
||||||
|
#define O_DIRECT_PAGE_SIZE 4096 // needed page size for O_DIRECT
|
||||||
|
|
||||||
// #define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
// #define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
||||||
// #define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
// #define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
||||||
@ -38,8 +39,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
fileDescriptor randomSrcFileDiscr;
|
fileDescriptor randomSrcFileDiscr;
|
||||||
fileDescriptor driveFileDiscr;
|
fileDescriptor driveFileDiscr;
|
||||||
unsigned char caTfngData[TFNG_DATA_SIZE];
|
unsigned char *caTfngData;
|
||||||
unsigned char caReadBuffer[CHUNK_SIZE];
|
unsigned char *caReadBuffer;
|
||||||
unsigned long ulDriveByteSize;
|
unsigned long ulDriveByteSize;
|
||||||
unsigned long ulDriveByteOverallCount = 0; // all bytes shredded in all iterations + checking -> used for progress calculation
|
unsigned long ulDriveByteOverallCount = 0; // all bytes shredded in all iterations + checking -> used for progress calculation
|
||||||
double d32Percent = 0.0;
|
double d32Percent = 0.0;
|
||||||
|
|||||||
@ -32,6 +32,8 @@ public:
|
|||||||
Enter,
|
Enter,
|
||||||
ESC,
|
ESC,
|
||||||
Terminate,
|
Terminate,
|
||||||
|
Print,
|
||||||
|
PrintAll,
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
struct MenuState
|
struct MenuState
|
||||||
|
|||||||
181
src/reHDD.cpp
181
src/reHDD.cpp
@ -216,12 +216,62 @@ void reHDD::ThreadUserInput()
|
|||||||
sleep(5); // sleep 5 sec
|
sleep(5); // sleep 5 sec
|
||||||
std::exit(1); // Terminates main, doesn't wait for threads
|
std::exit(1); // Terminates main, doesn't wait for threads
|
||||||
break;
|
break;
|
||||||
|
case TUI::UserInput::Print:
|
||||||
|
// cout << "Print" << endl;
|
||||||
|
if (tmpSelectedDrive != nullptr)
|
||||||
|
{
|
||||||
|
printDrive(tmpSelectedDrive);
|
||||||
|
}
|
||||||
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
|
break;
|
||||||
|
case TUI::UserInput::PrintAll:
|
||||||
|
// cout << "PrintAll" << endl;
|
||||||
|
printAllDrives(&listDrives);
|
||||||
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief print all shredded drives
|
||||||
|
* \param pointer of list <Drive>* plistDrives
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
void reHDD::printAllDrives(list<Drive> *plistDrives)
|
||||||
|
{
|
||||||
|
list<Drive>::iterator it;
|
||||||
|
mxDrives.lock();
|
||||||
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
|
{
|
||||||
|
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
|
||||||
|
printDrive(pTmpDrive);
|
||||||
|
}
|
||||||
|
mxDrives.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief print a shredded drives
|
||||||
|
* \param pointer of a drive
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
void reHDD::printDrive(Drive *const pDrive)
|
||||||
|
{
|
||||||
|
if (pDrive->bWasShredded)
|
||||||
|
{
|
||||||
|
#ifdef ZERO_CHECK
|
||||||
|
if (pDrive->bWasChecked && (pDrive->u32DriveChecksumAfterShredding != 0U))
|
||||||
|
{
|
||||||
|
return; // Drive was shredded&checked but checksum failed, don't print label
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Logger::logThis()->info("User print for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
|
||||||
|
Printer::getPrinter()->print(pDrive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reHDD::ThreadShred(Drive *const pDrive)
|
void reHDD::ThreadShred(Drive *const pDrive)
|
||||||
{
|
{
|
||||||
if (pDrive != nullptr)
|
if (pDrive != nullptr)
|
||||||
@ -234,16 +284,16 @@ void reHDD::ThreadShred(Drive *const pDrive)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reHDD::ThreadDelete()
|
void reHDD::ThreadDelete(Drive *const pDrive)
|
||||||
{
|
{
|
||||||
Drive *tmpSelectedDrive = getSelectedDrive();
|
if (pDrive != nullptr)
|
||||||
if (tmpSelectedDrive != nullptr)
|
|
||||||
{
|
{
|
||||||
tmpSelectedDrive->setActionStartTimestamp(); // save timestamp at start of deleting
|
pDrive->state = Drive::TaskState::DELETE_ACTIVE;
|
||||||
Delete::deleteDrive(tmpSelectedDrive); // blocking, no thread
|
pDrive->setActionStartTimestamp(); // save timestamp at start of deleting
|
||||||
tmpSelectedDrive->state = Drive::TaskState::NONE; // delete finished
|
Delete::deleteDrive(pDrive); // blocking, no thread
|
||||||
tmpSelectedDrive->bWasDeleted = true;
|
pDrive->state = Drive::TaskState::NONE; // delete finished
|
||||||
Logger::logThis()->info("Finished delete for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
pDrive->bWasDeleted = true;
|
||||||
|
Logger::logThis()->info("Finished delete for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,8 +418,8 @@ void reHDD::searchDrives(std::list<Drive> *plistDrives)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief filter out drives that are listed in "ignoreDrives.conf"
|
* \brief filter out drives that are listed in "ignoreDrives.conf", loop devices, and optical drives
|
||||||
* \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)
|
||||||
@ -378,9 +428,8 @@ 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();
|
||||||
list<Drive>::iterator it;
|
while (it != plistDrives->end())
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
|
||||||
{
|
{
|
||||||
string driveName = it->getPath();
|
string driveName = it->getPath();
|
||||||
// Remove /dev/ prefix
|
// Remove /dev/ prefix
|
||||||
@ -388,6 +437,7 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
{
|
{
|
||||||
driveName = driveName.substr(5); // Skip "/dev/"
|
driveName = driveName.substr(5); // Skip "/dev/"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemDrivePath.find(driveName) != std::string::npos) // compare found system drive and current drive
|
if (systemDrivePath.find(driveName) != std::string::npos) // compare found system drive and current drive
|
||||||
{
|
{
|
||||||
// system drive found --> ignore this drive
|
// system drive found --> ignore this drive
|
||||||
@ -396,59 +446,123 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
#endif
|
#endif
|
||||||
it = plistDrives->erase(it);
|
it = plistDrives->erase(it);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
// Filter out loop devices (loop0, loop1, etc.)
|
||||||
ifstream input("ignoreDrives.conf"); // read ignore file
|
list<Drive>::iterator it = plistDrives->begin();
|
||||||
|
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);)
|
||||||
{
|
{
|
||||||
// Logger::logThis()->info("read uuid: " + sLine);
|
// Skip empty lines and comments
|
||||||
vtlIgnoredDevices.emplace_back(sLine); // add found path and uuid from ignore file to vector
|
if (!sLine.empty() && sLine[0] != '#')
|
||||||
|
{
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
list<Drive>::iterator it;
|
it = plistDrives->begin();
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
while (it != plistDrives->end())
|
||||||
{
|
{
|
||||||
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"); // get UUID from drive
|
FILE *outputfileBlkid = popen(sCMD.c_str(), "r");
|
||||||
if (outputfileBlkid == NULL)
|
if (outputfileBlkid == NULL)
|
||||||
{
|
{
|
||||||
exit(EXIT_FAILURE);
|
Logger::logThis()->error("Failed to execute blkid for: " + it->getPath());
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((getline(&cLine, &len, outputfileBlkid)) != -1) // parse UUID from blkid
|
while ((getline(&cLine, &len, outputfileBlkid)) != -1)
|
||||||
{
|
{
|
||||||
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);
|
||||||
sBlkidOut.erase(8, sBlkidOut.length());
|
if (sBlkidOut.length() >= 8)
|
||||||
|
{
|
||||||
|
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)) // compare uuid from ignore file and uuid from drive
|
if (!get<0>(row).compare(sUUID))
|
||||||
{
|
{
|
||||||
// same uuid found than in ignore file --> ignore this drive
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("same uuid found than in ignore file --> ignore this drive: " + it->getPath());
|
Logger::logThis()->info("same uuid found in ignore file --> ignore this drive: " + it->getPath());
|
||||||
#endif
|
#endif
|
||||||
it = plistDrives->erase(it);
|
it = plistDrives->erase(it);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +606,6 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -644,17 +757,13 @@ 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());
|
||||||
tmpSelectedDrive->state = Drive::TaskState::DELETE_ACTIVE;
|
thread(ThreadDelete, tmpSelectedDrive).detach();
|
||||||
// task for drive is running --> don't show more task options
|
|
||||||
thread(ThreadDelete).detach();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,10 +21,30 @@ const static char *randomsrc = (char *)"/dev/urandom";
|
|||||||
|
|
||||||
Shred::Shred()
|
Shred::Shred()
|
||||||
{
|
{
|
||||||
|
// Allocate aligned buffers for O_DIRECT
|
||||||
|
if (posix_memalign((void **)&caTfngData, O_DIRECT_PAGE_SIZE, TFNG_DATA_SIZE) != 0)
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Failed to allocate aligned buffer for tfng data");
|
||||||
|
caTfngData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (posix_memalign((void **)&caReadBuffer, O_DIRECT_PAGE_SIZE, CHUNK_SIZE) != 0)
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Failed to allocate aligned buffer for read buffer");
|
||||||
|
caReadBuffer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shred::~Shred()
|
Shred::~Shred()
|
||||||
{
|
{
|
||||||
|
if (caTfngData != nullptr)
|
||||||
|
{
|
||||||
|
free(caTfngData);
|
||||||
|
}
|
||||||
|
if (caReadBuffer != nullptr)
|
||||||
|
{
|
||||||
|
free(caReadBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +58,16 @@ 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;
|
||||||
|
|
||||||
|
if ((caTfngData == nullptr) || (caReadBuffer == nullptr))
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Shred-Task: Aligned memory not available! - Drive: " + drive->getSerial());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DRYRUN
|
#ifdef DRYRUN
|
||||||
for (int i = 0; i <= 100; i++)
|
for (int i = 0; i <= 100; i++)
|
||||||
@ -65,7 +95,13 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open disk
|
// open disk
|
||||||
driveFileDiscr = open(cpDrivePath, O_RDWR | O_LARGEFILE);
|
driveFileDiscr = open(cpDrivePath, O_RDWR | O_LARGEFILE | O_DIRECT);
|
||||||
|
if (driveFileDiscr == -1 && errno == EINVAL)
|
||||||
|
{
|
||||||
|
driveFileDiscr = open(cpDrivePath, O_RDWR | O_LARGEFILE);
|
||||||
|
Logger::logThis()->warning("O_DIRECT not supported, using standard I/O - Drive: " + drive->getSerial());
|
||||||
|
}
|
||||||
|
|
||||||
if (driveFileDiscr == -1)
|
if (driveFileDiscr == -1)
|
||||||
{
|
{
|
||||||
std::string errorMsg(strerror(errno));
|
std::string errorMsg(strerror(errno));
|
||||||
|
|||||||
18
src/tui.cpp
18
src/tui.cpp
@ -259,6 +259,12 @@ enum TUI::UserInput TUI::readUserInput()
|
|||||||
case 'T':
|
case 'T':
|
||||||
return TUI::UserInput::Terminate;
|
return TUI::UserInput::Terminate;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
return TUI::UserInput::Print;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
return TUI::UserInput::PrintAll;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return TUI::UserInput::Undefined;
|
return TUI::UserInput::Undefined;
|
||||||
break;
|
break;
|
||||||
@ -348,7 +354,7 @@ WINDOW *TUI::overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart)
|
|||||||
|
|
||||||
string sLine01 = "reHDD - hard drive refurbishing tool";
|
string sLine01 = "reHDD - hard drive refurbishing tool";
|
||||||
string sLine02 = "Version: " + string(REHDD_VERSION);
|
string sLine02 = "Version: " + string(REHDD_VERSION);
|
||||||
string sLine03 = "Available under GPL 3.0";
|
string sLine03 = "Free software under the GNU GPL 3.0";
|
||||||
string sLine04 = "https://git.mosad.xyz/localhorst/reHDD";
|
string sLine04 = "https://git.mosad.xyz/localhorst/reHDD";
|
||||||
string sLine05 = "Delete: Wipe format table - this is NOT secure";
|
string sLine05 = "Delete: Wipe format table - this is NOT secure";
|
||||||
string sLine06 = "Shred: Overwrite drive " + to_string(SHRED_ITERATIONS) + " iterations - this is secure";
|
string sLine06 = "Shred: Overwrite drive " + to_string(SHRED_ITERATIONS) + " iterations - this is secure";
|
||||||
@ -466,7 +472,7 @@ WINDOW *TUI::createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart)
|
|||||||
sLine03.append(__DATE__);
|
sLine03.append(__DATE__);
|
||||||
sLine03.append(" ");
|
sLine03.append(" ");
|
||||||
sLine03.append(__TIME__);
|
sLine03.append(__TIME__);
|
||||||
string sLine04 = "Available under GPL 3.0";
|
string sLine04 = "Free software under the GNU GPL 3.0";
|
||||||
string sLine05 = "https://git.mosad.xyz/localhorst/reHDD";
|
string sLine05 = "https://git.mosad.xyz/localhorst/reHDD";
|
||||||
|
|
||||||
uint16_t u16Line = 2;
|
uint16_t u16Line = 2;
|
||||||
@ -493,7 +499,7 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
|||||||
|
|
||||||
centerTitle(newWindow, "Controls");
|
centerTitle(newWindow, "Controls");
|
||||||
|
|
||||||
uint16_t u16Line = 4;
|
uint16_t u16Line = 2;
|
||||||
|
|
||||||
if (menustate.bAbort)
|
if (menustate.bAbort)
|
||||||
{
|
{
|
||||||
@ -514,7 +520,11 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
|||||||
u16Line++;
|
u16Line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
string sLineTmp = "Press T for terminating reHDD";
|
string sLineTmp = "Press p for Print (P for all drives)";
|
||||||
|
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
||||||
|
u16Line++;
|
||||||
|
|
||||||
|
sLineTmp = "Press T for terminating reHDD";
|
||||||
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user