Compare commits
17 Commits
acc05dac8b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 157e769268 | |||
| 8a42ccf9c0 | |||
| 1dce303ab6 | |||
| 1449e807ad | |||
| c4a960f3cf | |||
| d749f23e77 | |||
| 238915bfee | |||
| 3afe3517e2 | |||
| 7bb9013c6c | |||
| 6060ae13d6 | |||
| 9aca86af0c | |||
| 26c42a7e5d | |||
| cbf781f0e5 | |||
| b953394c0d | |||
| 4b0ec380b1 | |||
| a4f15460d3 | |||
| 298192111d |
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
|
||||||

|

|
||||||
|
|
||||||
## Debian Build Notes
|
## openSUSE Build Notes
|
||||||
|
|
||||||
* `apt-get install ncurses-dev git make g++`
|
* `zypper install ncurses-devel git make gcc-c++`
|
||||||
* `git submodule init`
|
* `git submodule init`
|
||||||
* `git submodule update`
|
* `git submodule update`
|
||||||
* `make release`
|
* `make release`
|
||||||
@ -28,16 +28,8 @@ 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
|
||||||
* `apt-get install hwinfo smartmontools curl htop sudo`
|
* `zypper install hwinfo smartmontools curl htop sudo`
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -56,7 +48,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 your system drive in `/root/reHDD/ignoreDrives.conf` like:
|
Add ignored drives 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`
|
||||||
|
|
||||||
|
|||||||
@ -14,32 +14,39 @@ class Drive
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum TaskState
|
enum class TaskState
|
||||||
{
|
{
|
||||||
NONE,
|
NONE,
|
||||||
SHRED_SELECTED,
|
SHRED_SELECTED,
|
||||||
SHRED_ACTIVE, // shred iterations active
|
SHRED_ACTIVE, // shred iterations active
|
||||||
CHECK_ACTIVE, // optional checking active
|
CHECK_ACTIVE, // optional checking active
|
||||||
|
CHECK_SUCCESSFUL,
|
||||||
|
CHECK_FAILED,
|
||||||
DELETE_SELECTED,
|
DELETE_SELECTED,
|
||||||
DELETE_ACTIVE,
|
DELETE_ACTIVE,
|
||||||
FROZEN
|
FROZEN
|
||||||
} state;
|
};
|
||||||
|
|
||||||
enum ConnectionType
|
enum class ConnectionType
|
||||||
{
|
{
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
USB,
|
USB,
|
||||||
SATA,
|
SATA,
|
||||||
NVME
|
NVME
|
||||||
} connectionType;
|
};
|
||||||
|
|
||||||
struct
|
struct ShredSpeed
|
||||||
{
|
{
|
||||||
time_t u32ShredTimeDelta;
|
time_t u32ShredTimeDelta;
|
||||||
std::chrono::time_point<std::chrono::system_clock> chronoShredTimestamp;
|
std::chrono::time_point<std::chrono::system_clock>
|
||||||
|
chronoShredTimestamp;
|
||||||
unsigned long ulWrittenBytes;
|
unsigned long ulWrittenBytes;
|
||||||
unsigned long ulSpeedMetricBytesWritten;
|
unsigned long ulSpeedMetricBytesWritten;
|
||||||
} sShredSpeed;
|
};
|
||||||
|
|
||||||
|
std::atomic<TaskState> state;
|
||||||
|
std::atomic<ConnectionType> connectionType;
|
||||||
|
std::atomic<ShredSpeed> sShredSpeed;
|
||||||
|
|
||||||
bool bWasShredded = false; // all shred iterations done
|
bool bWasShredded = false; // all shred iterations done
|
||||||
bool bWasShredStarted = false; // shred was atleast once started
|
bool bWasShredStarted = false; // shred was atleast once started
|
||||||
@ -73,6 +80,18 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
// Copy constructor
|
||||||
|
Drive(const Drive &other);
|
||||||
|
|
||||||
|
// Copy assignment operator
|
||||||
|
Drive &operator=(const Drive &other);
|
||||||
|
|
||||||
|
// Move constructor
|
||||||
|
Drive(Drive &&other) noexcept;
|
||||||
|
|
||||||
|
// Move assignment operator
|
||||||
|
Drive &operator=(Drive &&other) noexcept;
|
||||||
|
|
||||||
Drive(std::string path)
|
Drive(std::string path)
|
||||||
{
|
{
|
||||||
this->sPath = path;
|
this->sPath = path;
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
@ -56,6 +56,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <atomic>
|
||||||
#include "drive.h"
|
#include "drive.h"
|
||||||
#include "smart.h"
|
#include "smart.h"
|
||||||
#include "shred.h"
|
#include "shred.h"
|
||||||
@ -89,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();
|
||||||
|
|||||||
@ -32,6 +32,8 @@ public:
|
|||||||
Enter,
|
Enter,
|
||||||
ESC,
|
ESC,
|
||||||
Terminate,
|
Terminate,
|
||||||
|
Print,
|
||||||
|
PrintAll,
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
struct MenuState
|
struct MenuState
|
||||||
@ -67,7 +69,7 @@ private:
|
|||||||
|
|
||||||
static void centerTitle(WINDOW *pwin, const char *title);
|
static void centerTitle(WINDOW *pwin, const char *title);
|
||||||
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, std::string sModelFamily, std::string sSerial, std::string sCapacity, std::string sState, std::string sTime, std::string sSpeed, std::string sTemp, std::string sConnection, bool bSelected);
|
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, std::string sModelFamily, std::string sSerial, std::string sCapacity, std::string sState, std::string sTime, std::string sSpeed, std::string sTemp, std::string sConnection, bool bSelected);
|
||||||
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
|
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
|
||||||
@ -77,7 +79,7 @@ private:
|
|||||||
static WINDOW *createSmartWarning(int iXSize, int iYSize, int iXStart, int iYStart, std::string sPath, uint32_t u32PowerOnHours, uint32_t u32PowerCycles, uint32_t u32ErrorCount, uint32_t u32Temperature);
|
static WINDOW *createSmartWarning(int iXSize, int iYSize, int iXStart, int iYStart, std::string sPath, uint32_t u32PowerOnHours, uint32_t u32PowerCycles, uint32_t u32ErrorCount, uint32_t u32Temperature);
|
||||||
static WINDOW *createZeroChecksumWarning(int iXSize, int iYSize, int iXStart, int iYStart, std::string sPath, std::string sModelFamily, std::string sModelName, std::string sSerial, uint32_t u32Checksum);
|
static WINDOW *createZeroChecksumWarning(int iXSize, int iYSize, int iXStart, int iYStart, std::string sPath, std::string sModelFamily, std::string sModelName, std::string sSerial, uint32_t u32Checksum);
|
||||||
|
|
||||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
void displaySelectedDrive(Drive &drive, int stdscrX, int stdscrY);
|
||||||
std::string formatTimeDuration(time_t u32Duration);
|
std::string formatTimeDuration(time_t u32Duration);
|
||||||
std::string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
std::string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
||||||
static void vTruncateText(std::string *psText, uint16_t u16MaxLenght);
|
static void vTruncateText(std::string *psText, uint16_t u16MaxLenght);
|
||||||
|
|||||||
2
makefile
2
makefile
@ -18,7 +18,7 @@ DCOMPILE_FLAGS = -D DEBUG
|
|||||||
# Add additional include paths
|
# Add additional include paths
|
||||||
INCLUDES = include
|
INCLUDES = include
|
||||||
# General linker settings
|
# General linker settings
|
||||||
LINK_FLAGS = -Llib -lpthread -lncurses -ltfng
|
LINK_FLAGS = -Llib -lpthread -lncurses -ltfng -latomic
|
||||||
|
|
||||||
# Doc
|
# Doc
|
||||||
DOCDIR = doc
|
DOCDIR = doc
|
||||||
|
|||||||
@ -8,6 +8,94 @@
|
|||||||
#include "../include/reHDD.h"
|
#include "../include/reHDD.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// Copy constructor
|
||||||
|
Drive::Drive(const Drive &other)
|
||||||
|
: state(other.state.load()),
|
||||||
|
connectionType(other.connectionType.load()),
|
||||||
|
sShredSpeed(other.sShredSpeed.load()),
|
||||||
|
bWasShredded(other.bWasShredded),
|
||||||
|
bWasShredStarted(other.bWasShredStarted),
|
||||||
|
bWasChecked(other.bWasChecked),
|
||||||
|
bWasDeleted(other.bWasDeleted),
|
||||||
|
bIsOffline(other.bIsOffline),
|
||||||
|
u32DriveChecksumAfterShredding(other.u32DriveChecksumAfterShredding),
|
||||||
|
sPath(other.sPath),
|
||||||
|
u32Timestamp(other.u32Timestamp),
|
||||||
|
d32TaskPercentage(other.d32TaskPercentage),
|
||||||
|
u32TimestampTaskStart(other.u32TimestampTaskStart),
|
||||||
|
u32TaskDuration(other.u32TaskDuration),
|
||||||
|
sSmartData(other.sSmartData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy assignment operator
|
||||||
|
Drive &Drive::operator=(const Drive &other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
state = other.state.load();
|
||||||
|
connectionType = other.connectionType.load();
|
||||||
|
sShredSpeed = other.sShredSpeed.load();
|
||||||
|
bWasShredded = other.bWasShredded;
|
||||||
|
bWasShredStarted = other.bWasShredStarted;
|
||||||
|
bWasChecked = other.bWasChecked;
|
||||||
|
bWasDeleted = other.bWasDeleted;
|
||||||
|
bIsOffline = other.bIsOffline;
|
||||||
|
u32DriveChecksumAfterShredding = other.u32DriveChecksumAfterShredding;
|
||||||
|
sPath = other.sPath;
|
||||||
|
u32Timestamp = other.u32Timestamp;
|
||||||
|
d32TaskPercentage = other.d32TaskPercentage;
|
||||||
|
u32TimestampTaskStart = other.u32TimestampTaskStart;
|
||||||
|
u32TaskDuration = other.u32TaskDuration;
|
||||||
|
sSmartData = other.sSmartData;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move constructor
|
||||||
|
Drive::Drive(Drive &&other) noexcept
|
||||||
|
: state(other.state.load()),
|
||||||
|
connectionType(other.connectionType.load()),
|
||||||
|
sShredSpeed(other.sShredSpeed.load()),
|
||||||
|
bWasShredded(other.bWasShredded),
|
||||||
|
bWasShredStarted(other.bWasShredStarted),
|
||||||
|
bWasChecked(other.bWasChecked),
|
||||||
|
bWasDeleted(other.bWasDeleted),
|
||||||
|
bIsOffline(other.bIsOffline),
|
||||||
|
u32DriveChecksumAfterShredding(other.u32DriveChecksumAfterShredding),
|
||||||
|
sPath(std::move(other.sPath)),
|
||||||
|
u32Timestamp(other.u32Timestamp),
|
||||||
|
d32TaskPercentage(other.d32TaskPercentage),
|
||||||
|
u32TimestampTaskStart(other.u32TimestampTaskStart),
|
||||||
|
u32TaskDuration(other.u32TaskDuration),
|
||||||
|
sSmartData(std::move(other.sSmartData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move assignment operator
|
||||||
|
Drive &Drive::operator=(Drive &&other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
state = other.state.load();
|
||||||
|
connectionType = other.connectionType.load();
|
||||||
|
sShredSpeed = other.sShredSpeed.load();
|
||||||
|
bWasShredded = other.bWasShredded;
|
||||||
|
bWasShredStarted = other.bWasShredStarted;
|
||||||
|
bWasChecked = other.bWasChecked;
|
||||||
|
bWasDeleted = other.bWasDeleted;
|
||||||
|
bIsOffline = other.bIsOffline;
|
||||||
|
u32DriveChecksumAfterShredding = other.u32DriveChecksumAfterShredding;
|
||||||
|
sPath = std::move(other.sPath);
|
||||||
|
u32Timestamp = other.u32Timestamp;
|
||||||
|
d32TaskPercentage = other.d32TaskPercentage;
|
||||||
|
u32TimestampTaskStart = other.u32TimestampTaskStart;
|
||||||
|
u32TaskDuration = other.u32TaskDuration;
|
||||||
|
sSmartData = std::move(other.sSmartData);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
string Drive::getPath(void)
|
string Drive::getPath(void)
|
||||||
{
|
{
|
||||||
return sPath;
|
return sPath;
|
||||||
@ -205,6 +293,6 @@ void Drive::checkFrozenDrive(void)
|
|||||||
Logger::logThis()->warning("Drive Frozen: " + this->getModelName() + " " + this->getSerial());
|
Logger::logThis()->warning("Drive Frozen: " + this->getModelName() + " " + this->getSerial());
|
||||||
this->bWasDeleted = false;
|
this->bWasDeleted = false;
|
||||||
this->bWasShredded = false;
|
this->bWasShredded = false;
|
||||||
this->state = Drive::FROZEN;
|
this->state = Drive::TaskState::FROZEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "../include/reHDD.h"
|
#include "../include/reHDD.h"
|
||||||
|
|
||||||
|
|
||||||
bool Printer::instanceFlag = false;
|
bool Printer::instanceFlag = false;
|
||||||
Printer *Printer::single = NULL;
|
Printer *Printer::single = NULL;
|
||||||
|
|
||||||
@ -57,16 +56,16 @@ void Printer::print(Drive *drive)
|
|||||||
|
|
||||||
switch (drive->connectionType)
|
switch (drive->connectionType)
|
||||||
{
|
{
|
||||||
case Drive::USB:
|
case Drive::ConnectionType::USB:
|
||||||
strncpy(msgQueueData.driveData.caDriveConnectionType, "usb", STR_BUFFER_SIZE);
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "usb", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::SATA:
|
case Drive::ConnectionType::SATA:
|
||||||
strncpy(msgQueueData.driveData.caDriveConnectionType, "sata", STR_BUFFER_SIZE);
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "sata", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::NVME:
|
case Drive::ConnectionType::NVME:
|
||||||
strncpy(msgQueueData.driveData.caDriveConnectionType, "nvme", STR_BUFFER_SIZE);
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "nvme", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::UNKNOWN:
|
case Drive::ConnectionType::UNKNOWN:
|
||||||
default:
|
default:
|
||||||
strncpy(msgQueueData.driveData.caDriveConnectionType, "na", STR_BUFFER_SIZE);
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "na", STR_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
272
src/reHDD.cpp
272
src/reHDD.cpp
@ -133,7 +133,7 @@ void reHDD::ThreadCheckFrozenDrives()
|
|||||||
mxDrives.lock();
|
mxDrives.lock();
|
||||||
for (auto it = begin(listDrives); it != end(listDrives); ++it)
|
for (auto it = begin(listDrives); it != end(listDrives); ++it)
|
||||||
{
|
{
|
||||||
if (it->state == Drive::SHRED_ACTIVE)
|
if (it->state == Drive::TaskState::SHRED_ACTIVE)
|
||||||
{
|
{
|
||||||
it->checkFrozenDrive();
|
it->checkFrozenDrive();
|
||||||
}
|
}
|
||||||
@ -175,9 +175,9 @@ void reHDD::ThreadUserInput()
|
|||||||
|
|
||||||
if (tmpSelectedDrive != nullptr)
|
if (tmpSelectedDrive != nullptr)
|
||||||
{
|
{
|
||||||
if (tmpSelectedDrive->state == Drive::NONE)
|
if (tmpSelectedDrive->state == Drive::TaskState::NONE)
|
||||||
{
|
{
|
||||||
tmpSelectedDrive->state = Drive::DELETE_SELECTED;
|
tmpSelectedDrive->state = Drive::TaskState::DELETE_SELECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,9 +187,9 @@ void reHDD::ThreadUserInput()
|
|||||||
// cout << "Shred" << endl;
|
// cout << "Shred" << endl;
|
||||||
if (tmpSelectedDrive != nullptr)
|
if (tmpSelectedDrive != nullptr)
|
||||||
{
|
{
|
||||||
if (tmpSelectedDrive->state == Drive::NONE)
|
if (tmpSelectedDrive->state == Drive::TaskState::NONE)
|
||||||
{
|
{
|
||||||
tmpSelectedDrive->state = Drive::SHRED_SELECTED;
|
tmpSelectedDrive->state = Drive::TaskState::SHRED_SELECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
@ -216,34 +216,84 @@ 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)
|
||||||
{
|
{
|
||||||
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
||||||
Shred *pShredTask = new Shred(); // create new shred task
|
Shred *pShredInstance = new Shred(); // create new shred task
|
||||||
pShredTask->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
pShredInstance->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
||||||
delete pShredTask; // delete shred task
|
delete pShredInstance; // delete shred task
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +352,7 @@ void reHDD::filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDr
|
|||||||
{
|
{
|
||||||
// cout << "offline drive found: " << itOld->getPath() << endl;
|
// cout << "offline drive found: " << itOld->getPath() << endl;
|
||||||
Logger::logThis()->warning("Mark offline drive found: " + itOld->getPath());
|
Logger::logThis()->warning("Mark offline drive found: " + itOld->getPath());
|
||||||
itOld->state = Drive::NONE; // clear state --> shred task will terminate
|
itOld->state = Drive::TaskState::NONE; // clear state --> shred task will terminate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,26 +390,26 @@ void reHDD::searchDrives(std::list<Drive> *plistDrives)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Drive tmpDrive("/dev/" + devName);
|
Drive tmpDrive("/dev/" + devName);
|
||||||
tmpDrive.state = Drive::NONE;
|
tmpDrive.state = Drive::TaskState::NONE;
|
||||||
tmpDrive.bIsOffline = false;
|
tmpDrive.bIsOffline = false;
|
||||||
|
|
||||||
// Set connection type
|
// Set connection type
|
||||||
if (transport == "sata")
|
if (transport == "sata")
|
||||||
tmpDrive.connectionType = Drive::SATA;
|
tmpDrive.connectionType = Drive::ConnectionType::SATA;
|
||||||
else if (transport == "usb")
|
else if (transport == "usb")
|
||||||
tmpDrive.connectionType = Drive::USB;
|
tmpDrive.connectionType = Drive::ConnectionType::USB;
|
||||||
else if (transport == "nvme")
|
else if (transport == "nvme")
|
||||||
tmpDrive.connectionType = Drive::NVME;
|
tmpDrive.connectionType = Drive::ConnectionType::NVME;
|
||||||
else
|
else
|
||||||
tmpDrive.connectionType = Drive::UNKNOWN;
|
tmpDrive.connectionType = Drive::ConnectionType::UNKNOWN;
|
||||||
|
|
||||||
plistDrives->push_back(tmpDrive);
|
plistDrives->push_back(tmpDrive);
|
||||||
|
|
||||||
Logger::logThis()->info(
|
Logger::logThis()->info(
|
||||||
"Drive found: " + tmpDrive.getPath() +
|
"Drive found: " + tmpDrive.getPath() +
|
||||||
" (type: " +
|
" (type: " +
|
||||||
(tmpDrive.connectionType == Drive::USB ? "USB" : tmpDrive.connectionType == Drive::SATA ? "SATA"
|
(tmpDrive.connectionType == Drive::ConnectionType::USB ? "USB" : tmpDrive.connectionType == Drive::ConnectionType::SATA ? "SATA"
|
||||||
: tmpDrive.connectionType == Drive::NVME ? "NVME"
|
: tmpDrive.connectionType == Drive::ConnectionType::NVME ? "NVME"
|
||||||
: "UNKNOWN") +
|
: "UNKNOWN") +
|
||||||
")");
|
")");
|
||||||
}
|
}
|
||||||
@ -368,7 +418,7 @@ 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
|
||||||
*/
|
*/
|
||||||
@ -378,11 +428,17 @@ 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)
|
|
||||||
{
|
{
|
||||||
if (it->getPath().find(systemDrivePath) != std::string::npos) // compare found system drive and current drive
|
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
|
||||||
{
|
{
|
||||||
// system drive found --> ignore this drive
|
// system drive found --> ignore this drive
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
@ -390,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);
|
||||||
|
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)) // 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +598,7 @@ void reHDD::startShredAllDrives(list<Drive> *plistDrives)
|
|||||||
mxDrives.lock();
|
mxDrives.lock();
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->state == Drive::NONE)
|
if (it->state == Drive::TaskState::NONE)
|
||||||
{
|
{
|
||||||
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
|
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
@ -486,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -505,9 +624,9 @@ void reHDD::stopShredAllDrives(list<Drive> *plistDrives)
|
|||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (it->state == Drive::SHRED_ACTIVE || it->state == Drive::DELETE_ACTIVE)
|
if (it->state == Drive::TaskState::SHRED_ACTIVE || it->state == Drive::TaskState::DELETE_ACTIVE)
|
||||||
{
|
{
|
||||||
it->state = Drive::NONE;
|
it->state = Drive::TaskState::NONE;
|
||||||
Logger::logThis()->info("Abort-Shred-Signal for: " + it->getModelName() + "-" + it->getSerial());
|
Logger::logThis()->info("Abort-Shred-Signal for: " + it->getModelName() + "-" + it->getSerial());
|
||||||
// task for drive is running --> remove selection
|
// task for drive is running --> remove selection
|
||||||
}
|
}
|
||||||
@ -566,18 +685,20 @@ void reHDD::updateShredMetrics(list<Drive> *plistDrives)
|
|||||||
list<Drive>::iterator it;
|
list<Drive>::iterator it;
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->state == Drive::SHRED_ACTIVE)
|
if (it->state == Drive::TaskState::SHRED_ACTIVE)
|
||||||
{
|
{
|
||||||
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
|
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
|
||||||
// set metrics for calculating shred speed
|
// set metrics for calculating shred speed
|
||||||
std::chrono::time_point<std::chrono::system_clock> chronoCurrentTimestamp = std::chrono::system_clock::now();
|
std::chrono::time_point<std::chrono::system_clock> chronoCurrentTimestamp = std::chrono::system_clock::now();
|
||||||
time_t u32ShredTimeDelta = (chronoCurrentTimestamp - pTmpDrive->sShredSpeed.chronoShredTimestamp).count();
|
auto shredSpeed = pTmpDrive->sShredSpeed.load();
|
||||||
|
time_t u32ShredTimeDelta = (chronoCurrentTimestamp - shredSpeed.chronoShredTimestamp).count();
|
||||||
if (u32ShredTimeDelta > METRIC_THRESHOLD)
|
if (u32ShredTimeDelta > METRIC_THRESHOLD)
|
||||||
{
|
{
|
||||||
pTmpDrive->sShredSpeed.u32ShredTimeDelta = u32ShredTimeDelta;
|
shredSpeed.u32ShredTimeDelta = u32ShredTimeDelta;
|
||||||
pTmpDrive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();
|
shredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();
|
||||||
pTmpDrive->sShredSpeed.ulWrittenBytes = pTmpDrive->sShredSpeed.ulSpeedMetricBytesWritten;
|
shredSpeed.ulWrittenBytes = shredSpeed.ulSpeedMetricBytesWritten;
|
||||||
pTmpDrive->sShredSpeed.ulSpeedMetricBytesWritten = 0U;
|
shredSpeed.ulSpeedMetricBytesWritten = 0U;
|
||||||
|
pTmpDrive->sShredSpeed.store(shredSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -636,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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -675,9 +792,9 @@ void reHDD::handleAbort()
|
|||||||
Drive *tmpSelectedDrive = getSelectedDrive();
|
Drive *tmpSelectedDrive = getSelectedDrive();
|
||||||
if (tmpSelectedDrive != nullptr)
|
if (tmpSelectedDrive != nullptr)
|
||||||
{
|
{
|
||||||
if (tmpSelectedDrive->state == Drive::SHRED_ACTIVE || tmpSelectedDrive->state == Drive::DELETE_ACTIVE)
|
if (tmpSelectedDrive->state == Drive::TaskState::SHRED_ACTIVE || tmpSelectedDrive->state == Drive::TaskState::DELETE_ACTIVE)
|
||||||
{
|
{
|
||||||
tmpSelectedDrive->state = Drive::NONE;
|
tmpSelectedDrive->state = Drive::TaskState::NONE;
|
||||||
Logger::logThis()->info("Abort-Shred-Signal for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
Logger::logThis()->info("Abort-Shred-Signal for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial());
|
||||||
// task for drive is running --> remove selection
|
// task for drive is running --> remove selection
|
||||||
}
|
}
|
||||||
@ -707,14 +824,23 @@ bool reHDD::getSystemDrive(string &systemDrive)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger::logThis()->info(currentLine);
|
// Extract drive name from line (removing tree characters)
|
||||||
|
|
||||||
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
|
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces
|
// Find the actual drive name (after tree characters like └─, ├─)
|
||||||
// Logger::logThis()->info("Drive found: " + systemDrive);
|
size_t lastAlpha = 0;
|
||||||
|
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))
|
||||||
@ -737,5 +863,17 @@ 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 <= 500; i++)
|
for (int i = 0; i <= 100; i++)
|
||||||
{
|
{
|
||||||
if (drive->state != Drive::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);
|
||||||
@ -93,8 +93,10 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
tfng_prng_seedkey(ucKey);
|
tfng_prng_seedkey(ucKey);
|
||||||
|
|
||||||
this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr);
|
this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr);
|
||||||
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now(); // set inital timestamp for speed metric
|
Drive::ShredSpeed shredSpeed = drive->sShredSpeed.load();
|
||||||
drive->sShredSpeed.ulSpeedMetricBytesWritten = 0U; // uses to calculate speed metric
|
shredSpeed.chronoShredTimestamp = std::chrono::system_clock::now(); // set inital timestamp for speed metric
|
||||||
|
shredSpeed.ulSpeedMetricBytesWritten = 0U; // uses to calculate speed metric
|
||||||
|
drive->sShredSpeed.store(shredSpeed);
|
||||||
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial());
|
||||||
@ -140,14 +142,17 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto shredSpeed = drive->sShredSpeed.load();
|
||||||
|
shredSpeed.ulSpeedMetricBytesWritten += iByteShredded;
|
||||||
|
drive->sShredSpeed.store(shredSpeed);
|
||||||
|
|
||||||
ulDriveByteCounter += iByteShredded;
|
ulDriveByteCounter += iByteShredded;
|
||||||
ulDriveByteOverallCount += iByteShredded;
|
ulDriveByteOverallCount += iByteShredded;
|
||||||
d32Percent = this->calcProgress();
|
d32Percent = this->calcProgress();
|
||||||
drive->sShredSpeed.ulSpeedMetricBytesWritten += iByteShredded;
|
|
||||||
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("Shred-Task: ByteCount: " + to_string(ulDriveByteCounter) + " - iteration: " + to_string((uiShredIterationCounter + 1)) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: ByteCount: " + to_string(ulDriveByteCounter) + " - iteration: " + to_string((uiShredIterationCounter + 1)) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((d32Percent - d32TmpPercent) >= 0.01)
|
if ((d32Percent - d32TmpPercent) >= 0.01)
|
||||||
{
|
{
|
||||||
// set shred percantage
|
// set shred percantage
|
||||||
@ -157,7 +162,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
write(*ipSignalFd, "A", 1);
|
write(*ipSignalFd, "A", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drive->state != Drive::SHRED_ACTIVE)
|
if (drive->state != Drive::TaskState::SHRED_ACTIVE)
|
||||||
{
|
{
|
||||||
drive->setTaskPercentage(0);
|
drive->setTaskPercentage(0);
|
||||||
d32Percent = 0.00;
|
d32Percent = 0.00;
|
||||||
@ -184,29 +189,32 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
drive->bWasShredded = true;
|
drive->bWasShredded = true;
|
||||||
Logger::logThis()->info("Shred-Task finished - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
Logger::logThis()->info("Shred-Task finished - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
||||||
#ifdef ZERO_CHECK
|
#ifdef ZERO_CHECK
|
||||||
drive->state = Drive::CHECK_ACTIVE;
|
drive->state = Drive::TaskState::CHECK_ACTIVE;
|
||||||
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
|
|
||||||
if (drive->u32DriveChecksumAfterShredding != 0)
|
if (drive->u32DriveChecksumAfterShredding != 0)
|
||||||
{
|
{
|
||||||
|
drive->state = Drive::TaskState::CHECK_FAILED;
|
||||||
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());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
drive->state = Drive::TaskState::CHECK_SUCCESSFUL;
|
||||||
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
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((drive->state == Drive::SHRED_ACTIVE) || (drive->state == Drive::CHECK_ACTIVE))
|
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)
|
||||||
{
|
{
|
||||||
drive->state = Drive::NONE;
|
|
||||||
drive->setTaskPercentage(0.0);
|
|
||||||
Printer::getPrinter()->print(drive);
|
Printer::getPrinter()->print(drive);
|
||||||
|
}
|
||||||
|
drive->state = Drive::TaskState::NONE;
|
||||||
|
drive->setTaskPercentage(0.0);
|
||||||
Logger::logThis()->info("Finished shred/check for: " + drive->getModelName() + "-" + drive->getSerial());
|
Logger::logThis()->info("Finished shred/check for: " + drive->getModelName() + "-" + drive->getSerial());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -234,6 +242,7 @@ int Shred::iRewindDrive(fileDescriptor file)
|
|||||||
if (0 != lseek(file, 0L, SEEK_SET))
|
if (0 != lseek(file, 0L, SEEK_SET))
|
||||||
{
|
{
|
||||||
perror("unable to rewind drive");
|
perror("unable to rewind drive");
|
||||||
|
Logger::logThis()->info("Unable to rewind drive! - fileDescriptor: " + to_string(file));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -249,6 +258,7 @@ long Shred::getDriveSizeInBytes(fileDescriptor file)
|
|||||||
if (liDriveSizeTmp == -1)
|
if (liDriveSizeTmp == -1)
|
||||||
{
|
{
|
||||||
perror("unable to get drive size");
|
perror("unable to get drive size");
|
||||||
|
Logger::logThis()->info("Unable to get drive size! - fileDescriptor: " + to_string(file));
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +296,9 @@ unsigned int Shred::uiCalcChecksum(fileDescriptor file, Drive *drive, int *ipSig
|
|||||||
ulDriveByteCounter += iReadBytes;
|
ulDriveByteCounter += iReadBytes;
|
||||||
ulDriveByteOverallCount += iReadBytes;
|
ulDriveByteOverallCount += iReadBytes;
|
||||||
d32Percent = this->calcProgress();
|
d32Percent = this->calcProgress();
|
||||||
drive->sShredSpeed.ulSpeedMetricBytesWritten += iReadBytes;
|
auto shredSpeed = drive->sShredSpeed.load();
|
||||||
|
shredSpeed.ulSpeedMetricBytesWritten += iReadBytes;
|
||||||
|
drive->sShredSpeed.store(shredSpeed);
|
||||||
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("Shred-Task (Checksum): ByteCount: " + to_string(ulDriveByteCounter) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task (Checksum): ByteCount: " + to_string(ulDriveByteCounter) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||||
|
|||||||
70
src/tui.cpp
70
src/tui.cpp
@ -99,8 +99,8 @@ 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"
|
string sConnection = (it->connectionType == Drive::ConnectionType::USB ? "USB" : it->connectionType == Drive::ConnectionType::SATA ? "SATA"
|
||||||
: it->connectionType == Drive::NVME ? "NVME"
|
: it->connectionType == Drive::ConnectionType::NVME ? "NVME"
|
||||||
: "");
|
: "");
|
||||||
|
|
||||||
bool bSelectedEntry = false;
|
bool bSelectedEntry = false;
|
||||||
@ -122,30 +122,40 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
|
|||||||
|
|
||||||
switch (it->state)
|
switch (it->state)
|
||||||
{
|
{
|
||||||
case Drive::SHRED_ACTIVE:
|
case Drive::TaskState::SHRED_ACTIVE:
|
||||||
|
{
|
||||||
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
||||||
sState = "Shredding: " + stream.str() + "%";
|
sState = "Shredding: " + stream.str() + "%";
|
||||||
|
|
||||||
it->calculateTaskDuration();
|
it->calculateTaskDuration();
|
||||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||||
sSpeed = this->formatSpeed(it->sShredSpeed.u32ShredTimeDelta, it->sShredSpeed.ulWrittenBytes);
|
auto shredSpeed = it->sShredSpeed.load();
|
||||||
|
sSpeed = this->formatSpeed(shredSpeed.u32ShredTimeDelta, shredSpeed.ulWrittenBytes);
|
||||||
break;
|
break;
|
||||||
case Drive::CHECK_ACTIVE:
|
}
|
||||||
|
case Drive::TaskState::CHECK_ACTIVE:
|
||||||
|
{
|
||||||
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
||||||
sState = "Checking: " + stream.str() + "%";
|
sState = "Checking: " + stream.str() + "%";
|
||||||
it->calculateTaskDuration();
|
it->calculateTaskDuration();
|
||||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||||
sSpeed = this->formatSpeed(it->sShredSpeed.u32ShredTimeDelta, it->sShredSpeed.ulWrittenBytes);
|
auto shredSpeed = it->sShredSpeed.load();
|
||||||
|
sSpeed = this->formatSpeed(shredSpeed.u32ShredTimeDelta, shredSpeed.ulWrittenBytes);
|
||||||
break;
|
break;
|
||||||
case Drive::DELETE_ACTIVE:
|
}
|
||||||
|
case Drive::TaskState::DELETE_ACTIVE:
|
||||||
|
{
|
||||||
|
|
||||||
sState = "Deleting ...";
|
sState = "Deleting ...";
|
||||||
it->calculateTaskDuration();
|
it->calculateTaskDuration();
|
||||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||||
break;
|
break;
|
||||||
case Drive::NONE:
|
}
|
||||||
case Drive::SHRED_SELECTED:
|
case Drive::TaskState::NONE:
|
||||||
case Drive::DELETE_SELECTED:
|
case Drive::TaskState::SHRED_SELECTED:
|
||||||
|
case Drive::TaskState::DELETE_SELECTED:
|
||||||
|
case Drive::TaskState::CHECK_SUCCESSFUL:
|
||||||
|
{
|
||||||
if (it->bWasDeleted)
|
if (it->bWasDeleted)
|
||||||
{
|
{
|
||||||
sState = "DELETED"; // mark drive as deleted previously
|
sState = "DELETED"; // mark drive as deleted previously
|
||||||
@ -172,9 +182,9 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
|
|||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Drive::FROZEN:
|
}
|
||||||
|
case Drive::TaskState::FROZEN:
|
||||||
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
stream << fixed << setprecision(3) << (it->getTaskPercentage());
|
||||||
#ifdef FROZEN_ALERT
|
#ifdef FROZEN_ALERT
|
||||||
if (bSelectedEntry)
|
if (bSelectedEntry)
|
||||||
@ -249,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;
|
||||||
@ -290,7 +306,7 @@ WINDOW *TUI::createOverViewWindow(int iXSize, int iYSize)
|
|||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW *TUI::createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive drive)
|
WINDOW *TUI::createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive &drive)
|
||||||
{
|
{
|
||||||
WINDOW *newWindow;
|
WINDOW *newWindow;
|
||||||
newWindow = newwin(iYSize, iXSize, 1, iXStart);
|
newWindow = newwin(iYSize, iXSize, 1, iXStart);
|
||||||
@ -338,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";
|
||||||
@ -456,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;
|
||||||
@ -483,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)
|
||||||
{
|
{
|
||||||
@ -504,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;
|
||||||
@ -633,7 +653,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;
|
static bool dialogIsActive;
|
||||||
@ -646,27 +666,27 @@ void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
|||||||
// set menustate based on drive state
|
// set menustate based on drive state
|
||||||
switch (drive.state)
|
switch (drive.state)
|
||||||
{
|
{
|
||||||
case Drive::NONE: // no task running or selected for this drive
|
case Drive::TaskState::NONE: // no task running or selected for this drive
|
||||||
menustate.bShred = true;
|
menustate.bShred = true;
|
||||||
menustate.bDelete = true;
|
menustate.bDelete = true;
|
||||||
break;
|
break;
|
||||||
case Drive::DELETE_ACTIVE: // delete task running for this drive
|
case Drive::TaskState::DELETE_ACTIVE: // delete task running for this drive
|
||||||
menustate.bAbort = true;
|
menustate.bAbort = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Drive::SHRED_ACTIVE: // shred task running for this drive
|
case Drive::TaskState::SHRED_ACTIVE: // shred task running for this drive
|
||||||
menustate.bAbort = true;
|
menustate.bAbort = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Drive::CHECK_ACTIVE: // check task running for this drive
|
case Drive::TaskState::CHECK_ACTIVE: // check task running for this drive
|
||||||
menustate.bAbort = true;
|
menustate.bAbort = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Drive::DELETE_SELECTED: // delete task selected for this drive
|
case Drive::TaskState::DELETE_SELECTED: // delete task selected for this drive
|
||||||
menustate.bConfirmDelete = true;
|
menustate.bConfirmDelete = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Drive::SHRED_SELECTED: // shred task selected for this drive
|
case Drive::TaskState::SHRED_SELECTED: // shred task selected for this drive
|
||||||
menustate.bConfirmShred = true;
|
menustate.bConfirmShred = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user