Merge branch 'master' into feature/failed-state
This commit is contained in:
@ -14,7 +14,7 @@ class Drive
|
||||
{
|
||||
|
||||
public:
|
||||
enum TaskState
|
||||
enum class TaskState
|
||||
{
|
||||
NONE,
|
||||
SHRED_SELECTED,
|
||||
@ -25,23 +25,28 @@ public:
|
||||
DELETE_SELECTED,
|
||||
DELETE_ACTIVE,
|
||||
FROZEN
|
||||
} state;
|
||||
};
|
||||
|
||||
enum ConnectionType
|
||||
enum class ConnectionType
|
||||
{
|
||||
UNKNOWN,
|
||||
USB,
|
||||
SATA,
|
||||
NVME
|
||||
} connectionType;
|
||||
};
|
||||
|
||||
struct
|
||||
struct ShredSpeed
|
||||
{
|
||||
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 ulSpeedMetricBytesWritten;
|
||||
} sShredSpeed;
|
||||
};
|
||||
|
||||
std::atomic<TaskState> state;
|
||||
std::atomic<ConnectionType> connectionType;
|
||||
std::atomic<ShredSpeed> sShredSpeed;
|
||||
|
||||
bool bWasShredded = false; // all shred iterations done
|
||||
bool bWasShredStarted = false; // shred was atleast once started
|
||||
@ -49,9 +54,10 @@ public:
|
||||
bool bWasDeleted = false;
|
||||
bool bIsOffline = false;
|
||||
uint32_t u32DriveChecksumAfterShredding = 0U;
|
||||
uint16_t u16DriveIndex = 0U; // Index of TUI list
|
||||
|
||||
private:
|
||||
string sPath;
|
||||
std::string sPath;
|
||||
time_t u32Timestamp = 0U; // unix timestamp for detecting a frozen drive
|
||||
double d32TaskPercentage = 0U; // in percent for Shred (1 to 100)
|
||||
time_t u32TimestampTaskStart = 0U; // unix timestamp for duration of an action
|
||||
@ -59,9 +65,9 @@ private:
|
||||
|
||||
struct
|
||||
{
|
||||
string sModelFamily;
|
||||
string sModelName;
|
||||
string sSerial;
|
||||
std::string sModelFamily;
|
||||
std::string sModelName;
|
||||
std::string sSerial;
|
||||
uint64_t u64Capacity = 0U; // in byte
|
||||
uint32_t u32ErrorCount = 0U;
|
||||
uint32_t u32PowerOnHours = 0U; // in hours
|
||||
@ -74,15 +80,27 @@ private:
|
||||
|
||||
protected:
|
||||
public:
|
||||
Drive(string path)
|
||||
// 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)
|
||||
{
|
||||
this->sPath = path;
|
||||
}
|
||||
|
||||
string getPath(void);
|
||||
string getModelFamily(void);
|
||||
string getModelName(void);
|
||||
string getSerial(void);
|
||||
std::string getPath(void);
|
||||
std::string getModelFamily(void);
|
||||
std::string getModelName(void);
|
||||
std::string getSerial(void);
|
||||
uint64_t getCapacity(void); // in byte
|
||||
uint32_t getErrorCount(void);
|
||||
uint32_t getPowerOnHours(void); // in hours
|
||||
@ -90,20 +108,20 @@ public:
|
||||
uint32_t getTemperature(void); // in Fahrenheit, just kidding: degree Celsius
|
||||
void checkFrozenDrive(void);
|
||||
|
||||
void setDriveSMARTData(string modelFamily,
|
||||
string modelName,
|
||||
string serial,
|
||||
void setDriveSMARTData(std::string modelFamily,
|
||||
std::string modelName,
|
||||
std::string serial,
|
||||
uint64_t capacity,
|
||||
uint32_t errorCount,
|
||||
uint32_t powerOnHours,
|
||||
uint32_t powerCycles,
|
||||
uint32_t temperature);
|
||||
|
||||
string sCapacityToText();
|
||||
string sErrorCountToText();
|
||||
string sPowerOnHoursToText();
|
||||
string sPowerCyclesToText();
|
||||
string sTemperatureToText();
|
||||
std::string sCapacityToText();
|
||||
std::string sErrorCountToText();
|
||||
std::string sPowerOnHoursToText();
|
||||
std::string sPowerCyclesToText();
|
||||
std::string sTemperatureToText();
|
||||
|
||||
void setTaskPercentage(double d32TaskPercentage);
|
||||
double getTaskPercentage(void);
|
||||
|
||||
@ -16,6 +16,10 @@
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netpacket/packet.h>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@ -56,9 +56,7 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <signal.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <atomic>
|
||||
#include "drive.h"
|
||||
#include "smart.h"
|
||||
#include "shred.h"
|
||||
|
||||
@ -47,7 +47,7 @@ private:
|
||||
|
||||
inline double calcProgress();
|
||||
int iRewindDrive(fileDescriptor file);
|
||||
unsigned long getDriveSizeInBytes(fileDescriptor file);
|
||||
long getDriveSizeInBytes(fileDescriptor file);
|
||||
unsigned int uiCalcChecksum(fileDescriptor file, Drive *drive, int *ipSignalFd);
|
||||
void cleanup();
|
||||
};
|
||||
|
||||
@ -19,15 +19,15 @@ public:
|
||||
private:
|
||||
SMART(void);
|
||||
|
||||
static bool parseExitStatus(string sLine, uint8_t &status);
|
||||
static bool parseModelFamily(string sLine, string &modelFamily);
|
||||
static bool parseModelName(string sLine, string &modelName);
|
||||
static bool parseSerial(string sLine, string &serial);
|
||||
static bool parseCapacity(string sLine, uint64_t &capacity);
|
||||
static bool parseErrorCount(string sLine, uint32_t &errorCount);
|
||||
static bool parsePowerOnHours(string sLine, uint32_t &powerOnHours);
|
||||
static bool parsePowerCycles(string sLine, uint32_t &powerCycles);
|
||||
static bool parseTemperature(string sLine, uint32_t &temperature);
|
||||
static bool parseExitStatus(std::string sLine, uint8_t &status);
|
||||
static bool parseModelFamily(std::string sLine, std::string &modelFamily);
|
||||
static bool parseModelName(std::string sLine, std::string &modelName);
|
||||
static bool parseSerial(std::string sLine, std::string &serial);
|
||||
static bool parseCapacity(std::string sLine, uint64_t &capacity);
|
||||
static bool parseErrorCount(std::string sLine, uint32_t &errorCount);
|
||||
static bool parsePowerOnHours(std::string sLine, uint32_t &powerOnHours);
|
||||
static bool parsePowerCycles(std::string sLine, uint32_t &powerCycles);
|
||||
static bool parseTemperature(std::string sLine, uint32_t &temperature);
|
||||
};
|
||||
|
||||
#endif // SMART_H_
|
||||
@ -47,16 +47,16 @@ public:
|
||||
|
||||
static void initTUI();
|
||||
|
||||
void updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry);
|
||||
void updateTUI(std::list<Drive> *plistDrives, uint8_t u8SelectedEntry);
|
||||
|
||||
static enum UserInput readUserInput();
|
||||
|
||||
static void terminateTUI();
|
||||
|
||||
private:
|
||||
static string sCpuUsage;
|
||||
static string sRamUsage;
|
||||
static string sLocalTime;
|
||||
static std::string sCpuUsage;
|
||||
static std::string sRamUsage;
|
||||
static std::string sLocalTime;
|
||||
|
||||
WINDOW *overview;
|
||||
WINDOW *systemview;
|
||||
@ -67,19 +67,19 @@ private:
|
||||
|
||||
static void centerTitle(WINDOW *pwin, const char *title);
|
||||
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 *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, string sConnection, bool bSelected);
|
||||
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, 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 *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
||||
static WINDOW *createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial, string sProgress);
|
||||
static WINDOW *createSmartWarning(int iXSize, int iYSize, int iXStart, int iYStart, 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, string sPath, string sModelFamily, string sModelName, string sSerial, uint32_t u32Checksum);
|
||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, std::string selectedTask, std::string optionA, std::string optionB);
|
||||
static WINDOW *createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, std::string sPath, std::string sModelFamily, std::string sModelName, std::string sSerial, std::string sProgress);
|
||||
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);
|
||||
|
||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||
string formatTimeDuration(time_t u32Duration);
|
||||
string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
||||
static void vTruncateText(string *psText, uint16_t u16MaxLenght);
|
||||
void displaySelectedDrive(Drive &drive, int stdscrX, int stdscrY);
|
||||
std::string formatTimeDuration(time_t u32Duration);
|
||||
std::string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
||||
static void vTruncateText(std::string *psText, uint16_t u16MaxLenght);
|
||||
};
|
||||
#endif // TUI_H_
|
||||
|
||||
Reference in New Issue
Block a user