autoformat all sources
This commit is contained in:
@ -13,13 +13,11 @@
|
||||
class Delete
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
static void deleteDrive(Drive* drive);
|
||||
static void deleteDrive(Drive *drive);
|
||||
|
||||
private:
|
||||
Delete(void);
|
||||
|
||||
};
|
||||
|
||||
#endif // DELETE_H_
|
||||
#endif // DELETE_H_
|
||||
|
@ -14,14 +14,16 @@ class Drive
|
||||
{
|
||||
|
||||
public:
|
||||
enum TaskState {NONE,
|
||||
SHRED_SELECTED,
|
||||
SHRED_ACTIVE, //shred iterations active
|
||||
CHECK_ACTIVE, //optional checking active
|
||||
DELETE_SELECTED,
|
||||
DELETE_ACTIVE,
|
||||
FROZEN
|
||||
} state;
|
||||
enum TaskState
|
||||
{
|
||||
NONE,
|
||||
SHRED_SELECTED,
|
||||
SHRED_ACTIVE, // shred iterations active
|
||||
CHECK_ACTIVE, // optional checking active
|
||||
DELETE_SELECTED,
|
||||
DELETE_ACTIVE,
|
||||
FROZEN
|
||||
} state;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -31,36 +33,35 @@ public:
|
||||
unsigned long ulSpeedMetricBytesWritten;
|
||||
} sShredSpeed;
|
||||
|
||||
bool bWasShredded = false; //all shred iterations done
|
||||
bool bWasChecked = false; //all shred iterations and optional checking done
|
||||
bool bWasShredded = false; // all shred iterations done
|
||||
bool bWasChecked = false; // all shred iterations and optional checking done
|
||||
bool bWasDeleted = false;
|
||||
bool bIsOffline = false;
|
||||
uint32_t u32DriveChecksumAfterShredding = 0U;
|
||||
|
||||
private:
|
||||
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
|
||||
time_t u32TaskDuration = 0U; //time needed to complete the task
|
||||
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
|
||||
time_t u32TaskDuration = 0U; // time needed to complete the task
|
||||
|
||||
struct
|
||||
{
|
||||
string sModelFamily;
|
||||
string sModelName;
|
||||
string sSerial;
|
||||
uint64_t u64Capacity = 0U; //in byte
|
||||
uint64_t u64Capacity = 0U; // in byte
|
||||
uint32_t u32ErrorCount = 0U;
|
||||
uint32_t u32PowerOnHours = 0U; //in hours
|
||||
uint32_t u32PowerOnHours = 0U; // in hours
|
||||
uint32_t u32PowerCycles = 0U;
|
||||
uint32_t u32Temperature = 0U; //in Fahrenheit, just kidding: degree Celsius
|
||||
uint32_t u32Temperature = 0U; // in Fahrenheit, just kidding: degree Celsius
|
||||
} sSmartData;
|
||||
|
||||
private:
|
||||
void setTimestamp();
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
Drive(string path)
|
||||
{
|
||||
@ -71,21 +72,21 @@ public:
|
||||
string getModelFamily(void);
|
||||
string getModelName(void);
|
||||
string getSerial(void);
|
||||
uint64_t getCapacity(void); //in byte
|
||||
uint64_t getCapacity(void); // in byte
|
||||
uint32_t getErrorCount(void);
|
||||
uint32_t getPowerOnHours(void); //in hours
|
||||
uint32_t getPowerOnHours(void); // in hours
|
||||
uint32_t getPowerCycles(void);
|
||||
uint32_t getTemperature(void); //in Fahrenheit, just kidding: degree Celsius
|
||||
uint32_t getTemperature(void); // in Fahrenheit, just kidding: degree Celsius
|
||||
void checkFrozenDrive(void);
|
||||
|
||||
void setDriveSMARTData( string modelFamily,
|
||||
string modelName,
|
||||
string serial,
|
||||
uint64_t capacity,
|
||||
uint32_t errorCount,
|
||||
uint32_t powerOnHours,
|
||||
uint32_t powerCycles,
|
||||
uint32_t temperature);
|
||||
void setDriveSMARTData(string modelFamily,
|
||||
string modelName,
|
||||
string serial,
|
||||
uint64_t capacity,
|
||||
uint32_t errorCount,
|
||||
uint32_t powerOnHours,
|
||||
uint32_t powerCycles,
|
||||
uint32_t temperature);
|
||||
|
||||
string sCapacityToText();
|
||||
string sErrorCountToText();
|
||||
@ -101,7 +102,6 @@ public:
|
||||
|
||||
void calculateTaskDuration();
|
||||
time_t getTaskDuration();
|
||||
|
||||
};
|
||||
|
||||
#endif // DRIVE_H_
|
||||
#endif // DRIVE_H_
|
@ -28,26 +28,26 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MENU_LINE_SIZE 110 //Size of menu lines
|
||||
#define MENU_LINE_SIZE 110 // Size of menu lines
|
||||
|
||||
#ifndef LOG_PATH
|
||||
//#define LOG_PATH "./test.txt"
|
||||
// #define LOG_PATH "./test.txt"
|
||||
#endif
|
||||
|
||||
#ifndef DESCRIPTION
|
||||
#define DESCRIPTION "Software-Name - Copyright Company 2020" //use your values here
|
||||
#define DESCRIPTION "Software-Name - Copyright Company 2020" // use your values here
|
||||
#endif
|
||||
|
||||
#ifndef DEVICE_ID
|
||||
#define DEVICE_ID "Device-Name" //use your values here
|
||||
#define DEVICE_ID "Device-Name" // use your values here
|
||||
#endif
|
||||
|
||||
#ifndef SOFTWARE_VERSION
|
||||
#define SOFTWARE_VERSION "0.1.1.8" //use your values here
|
||||
#define SOFTWARE_VERSION "0.1.1.8" // use your values here
|
||||
#endif
|
||||
|
||||
#ifndef HARDWARE_VERSION
|
||||
#define HARDWARE_VERSION "7.77.9" //use your values here
|
||||
#define HARDWARE_VERSION "7.77.9" // use your values here
|
||||
#endif
|
||||
|
||||
class Logger
|
||||
@ -68,13 +68,12 @@ private:
|
||||
~Logger();
|
||||
|
||||
public:
|
||||
|
||||
void info(string s);
|
||||
void warning(string s);
|
||||
void error(string s);
|
||||
void newLine();
|
||||
|
||||
static Logger* logThis();
|
||||
static Logger *logThis();
|
||||
};
|
||||
|
||||
#endif // LOGGER_H_
|
||||
#endif // LOGGER_H_
|
@ -35,18 +35,16 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long msg_queue_type;
|
||||
long msg_queue_type;
|
||||
t_driveData driveData;
|
||||
} t_msgQueueData;
|
||||
|
||||
|
||||
class Printer
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
static Printer* getPrinter();
|
||||
void print(Drive* drive);
|
||||
static Printer *getPrinter();
|
||||
void print(Drive *drive);
|
||||
|
||||
private:
|
||||
static bool instanceFlag;
|
||||
@ -54,7 +52,5 @@ private:
|
||||
int msqid;
|
||||
Printer();
|
||||
~Printer();
|
||||
|
||||
|
||||
};
|
||||
#endif // PRINTER_H_
|
||||
#endif // PRINTER_H_
|
@ -11,31 +11,31 @@
|
||||
#define REHDD_VERSION "V1.1.1"
|
||||
|
||||
// Drive handling Settings
|
||||
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
||||
#define WORSE_POWERUP 10000 //mark drive if at this limit or beyond
|
||||
#define WORSE_TEMPERATURE 55 //mark drive if at this limit or beyond
|
||||
#define WORSE_HOURS 19200 // mark drive if at this limit or beyond
|
||||
#define WORSE_POWERUP 10000 // mark drive if at this limit or beyond
|
||||
#define WORSE_TEMPERATURE 55 // mark drive if at this limit or beyond
|
||||
#define SHRED_ITERATIONS 3U
|
||||
#define FROZEN_TIMEOUT 20 //After this timeout (minutes) the drive will be marked as frozen, if no progress
|
||||
#define METRIC_THRESHOLD 3L*1000L*1000L*1000L //calc shred speed with this minimum of time delta
|
||||
#define FROZEN_TIMEOUT 20 // After this timeout (minutes) the drive will be marked as frozen, if no progress
|
||||
#define METRIC_THRESHOLD 3L * 1000L * 1000L * 1000L // calc shred speed with this minimum of time delta
|
||||
|
||||
// Logger Settings
|
||||
#define LOG_PATH "./reHDD.log"
|
||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2024"
|
||||
#define DEVICE_ID "generic"
|
||||
#define SOFTWARE_VERSION REHDD_VERSION
|
||||
#define HARDWARE_VERSION "generic"
|
||||
#define DEVICE_ID "generic"
|
||||
#define SOFTWARE_VERSION REHDD_VERSION
|
||||
#define HARDWARE_VERSION "generic"
|
||||
|
||||
//#define LOG_LEVEL_HIGH //log everything, like drive scan thread
|
||||
// #define LOG_LEVEL_HIGH //log everything, like drive scan thread
|
||||
#ifndef LOG_LEVEL_HIGH
|
||||
#define LOG_LEVEL_LOW //log only user actions and tasks
|
||||
#define LOG_LEVEL_LOW // log only user actions and tasks
|
||||
#endif
|
||||
|
||||
// Logic
|
||||
//#define DRYRUN //don´t touch the drives
|
||||
#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 DRYRUN //don´t touch the drives
|
||||
#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
|
||||
|
||||
//IPC pipes
|
||||
// IPC pipes
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
@ -67,9 +67,10 @@ using namespace std;
|
||||
#include "printer.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
extern Logger* logging;
|
||||
extern Logger *logging;
|
||||
|
||||
template <typename T, typename I> T* iterator_to_pointer(I i)
|
||||
template <typename T, typename I>
|
||||
T *iterator_to_pointer(I i)
|
||||
{
|
||||
return (&(*i));
|
||||
}
|
||||
@ -77,31 +78,29 @@ template <typename T, typename I> T* iterator_to_pointer(I i)
|
||||
class reHDD
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
reHDD(void);
|
||||
static void app_logic();
|
||||
|
||||
private:
|
||||
|
||||
static void searchDrives(list <Drive>* plistDrives);
|
||||
static void printDrives(list <Drive>* plistDrives);
|
||||
static void startShredAllDrives(list <Drive>* plistDrives);
|
||||
static void updateShredMetrics(list <Drive>* plistDrives);
|
||||
static void filterIgnoredDrives(list <Drive>* plistDrives);
|
||||
static void filterInvalidDrives(list <Drive>* plistDrives);
|
||||
static void filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNewDrives);
|
||||
static void addSMARTData(list <Drive>* plistDrives);
|
||||
static void searchDrives(list<Drive> *plistDrives);
|
||||
static void printDrives(list<Drive> *plistDrives);
|
||||
static void startShredAllDrives(list<Drive> *plistDrives);
|
||||
static void updateShredMetrics(list<Drive> *plistDrives);
|
||||
static void filterIgnoredDrives(list<Drive> *plistDrives);
|
||||
static void filterInvalidDrives(list<Drive> *plistDrives);
|
||||
static void filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDrives);
|
||||
static void addSMARTData(list<Drive> *plistDrives);
|
||||
static void ThreadScanDevices();
|
||||
static void ThreadUserInput();
|
||||
static void ThreadShred(Drive* const pDrive);
|
||||
static void ThreadShred(Drive *const pDrive);
|
||||
static void ThreadDelete();
|
||||
static void ThreadCheckFrozenDrives();
|
||||
static void handleArrowKey(TUI::UserInput userInput);
|
||||
static void handleEnter();
|
||||
static void handleESC();
|
||||
static void handleAbort();
|
||||
static Drive* getSelectedDrive();
|
||||
static Drive *getSelectedDrive();
|
||||
};
|
||||
|
||||
#endif // REHDD_H_
|
||||
#endif // REHDD_H_
|
||||
|
@ -17,26 +17,23 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#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 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 DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
||||
//#define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
||||
//#define DEMO_DRIVE_SIZE 5*1024*1024*1024L // 5GB
|
||||
//#define DEMO_DRIVE_SIZE 1024*1024*1024*10L // 10GB
|
||||
// #define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
||||
// #define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
||||
// #define DEMO_DRIVE_SIZE 5*1024*1024*1024L // 5GB
|
||||
// #define DEMO_DRIVE_SIZE 1024*1024*1024*10L // 10GB
|
||||
|
||||
typedef int fileDescriptor;
|
||||
|
||||
class Shred
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
Shred();
|
||||
~Shred();
|
||||
int shredDrive(Drive* drive, int* ipSignalFd);
|
||||
int shredDrive(Drive *drive, int *ipSignalFd);
|
||||
|
||||
private:
|
||||
fileDescriptor randomSrcFileDiscr;
|
||||
@ -44,16 +41,15 @@ private:
|
||||
unsigned char caTfngData[TFNG_DATA_SIZE];
|
||||
unsigned char caReadBuffer[CHUNK_SIZE];
|
||||
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 d32TmpPercent = 0.0;
|
||||
|
||||
inline double calcProgress();
|
||||
int iRewindDrive(fileDescriptor file);
|
||||
unsigned long getDriveSizeInBytes(fileDescriptor file);
|
||||
unsigned int uiCalcChecksum(fileDescriptor file, Drive* drive, int* ipSignalFd);
|
||||
unsigned int uiCalcChecksum(fileDescriptor file, Drive *drive, int *ipSignalFd);
|
||||
void cleanup();
|
||||
|
||||
};
|
||||
|
||||
#endif // SHRED_H_
|
||||
#endif // SHRED_H_
|
||||
|
@ -13,9 +13,8 @@
|
||||
class SMART
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
static void readSMARTData(Drive* drive);
|
||||
static void readSMARTData(Drive *drive);
|
||||
|
||||
private:
|
||||
SMART(void);
|
||||
@ -30,14 +29,14 @@ private:
|
||||
static void parsePowerCycle(string sLine);
|
||||
static void parseTemperature(string sLine);
|
||||
|
||||
static string modelFamily;
|
||||
static string modelName;
|
||||
static string serial;
|
||||
static uint64_t capacity;
|
||||
static uint32_t errorCount;
|
||||
static uint32_t powerOnHours;
|
||||
static uint32_t powerCycle;
|
||||
static uint32_t temperature;
|
||||
static string modelFamily;
|
||||
static string modelName;
|
||||
static string serial;
|
||||
static uint64_t capacity;
|
||||
static uint32_t errorCount;
|
||||
static uint32_t powerOnHours;
|
||||
static uint32_t powerCycle;
|
||||
static uint32_t temperature;
|
||||
};
|
||||
|
||||
#endif // SMART_H_
|
||||
#endif // SMART_H_
|
@ -20,10 +20,19 @@
|
||||
class TUI
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
enum UserInput { UpKey, DownKey, Abort, Shred, ShredAll, Delete, Enter, ESC, Undefined};
|
||||
enum UserInput
|
||||
{
|
||||
UpKey,
|
||||
DownKey,
|
||||
Abort,
|
||||
Shred,
|
||||
ShredAll,
|
||||
Delete,
|
||||
Enter,
|
||||
ESC,
|
||||
Undefined
|
||||
};
|
||||
struct MenuState
|
||||
{
|
||||
bool bAbort;
|
||||
@ -37,7 +46,7 @@ public:
|
||||
|
||||
static void initTUI();
|
||||
|
||||
void updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry);
|
||||
void updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry);
|
||||
|
||||
static enum UserInput readUserInput();
|
||||
|
||||
@ -46,28 +55,28 @@ private:
|
||||
static string sRamUsage;
|
||||
static string sLocalTime;
|
||||
|
||||
WINDOW* overview;
|
||||
WINDOW* systemview;
|
||||
WINDOW* detailview;
|
||||
WINDOW* menuview;
|
||||
WINDOW* dialog;
|
||||
WINDOW* smartWarning;
|
||||
WINDOW *overview;
|
||||
WINDOW *systemview;
|
||||
WINDOW *detailview;
|
||||
WINDOW *menuview;
|
||||
WINDOW *dialog;
|
||||
WINDOW *smartWarning;
|
||||
|
||||
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 *overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart);
|
||||
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 *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, 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 *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);
|
||||
|
||||
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);
|
||||
static void vTruncateText(string *psText, uint16_t u16MaxLenght);
|
||||
};
|
||||
#endif // TUI_H_
|
||||
#endif // TUI_H_
|
Reference in New Issue
Block a user