reHDD/include/reHDD.h

106 lines
2.7 KiB
C
Raw Normal View History

/**
2020-05-02 22:06:47 +02:00
* @file reHDD.h
2020-09-21 21:56:26 +02:00
* @brief app logic header
2020-05-02 22:06:47 +02:00
* @author hendrik schutter
* @date 01.05.2020
*/
2020-05-02 22:06:47 +02:00
#ifndef REHDD_H_
#define REHDD_H_
2022-09-20 21:53:43 +02:00
#define REHDD_VERSION "bV0.3.0"
2020-09-15 13:39:45 +02:00
// Drive handling Settings
2020-08-07 16:17:45 +02:00
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
2020-08-31 09:40:31 +02:00
#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
2022-08-22 23:09:41 +02:00
#define METRIC_THRESHOLD 3L*1000L*1000L*1000L //calc shred speed with this minimum of time delta
2020-08-26 00:12:39 +02:00
2020-09-07 17:23:15 +02:00
// Logger Settings
#define LOG_PATH "./reHDD.log"
2022-01-26 15:44:32 +01:00
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2022"
#define DEVICE_ID "generic"
#define SOFTWARE_VERSION "alpha"
#define HARDWARE_VERSION "generic"
//#define LOG_LEVEL_HIGH //log everything, like drive scan thread
#ifndef LOG_LEVEL_HIGH
#define LOG_LEVEL_LOW //log only user actions and tasks
#endif
2020-09-07 17:23:15 +02:00
2020-09-21 21:56:26 +02:00
// Logic
2022-06-30 00:32:13 +02:00
//#define DRYRUN //don´t touch the drives
2020-09-21 21:56:26 +02:00
#define FROZEN_ALERT //show alert if drive is frozen
#define ZERO_CHECK_ALERT //check drive after shred if all bytes are zero, show alert if this fails
2020-09-21 21:56:26 +02:00
//IPC pipes
#define READ 0
#define WRITE 1
2020-05-02 22:06:47 +02:00
#include <iostream>
#include <string>
#include <fstream>
#include <tuple>
2020-09-16 15:13:32 +02:00
#include <list>
2020-05-03 17:17:20 +02:00
#include <time.h>
#include <chrono>
2020-08-03 22:40:07 +02:00
#include <curses.h>
2020-08-04 17:18:32 +02:00
#include <thread>
2020-08-03 22:40:07 +02:00
#include <unistd.h>
2020-08-04 11:59:45 +02:00
#include <mutex>
#include <sys/select.h>
2020-08-26 00:12:39 +02:00
#include <algorithm>
2020-08-04 22:35:29 +02:00
#include <cstring>
2020-08-07 13:17:52 +02:00
#include <sstream>
#include <iomanip>
2020-08-26 00:12:39 +02:00
#include <signal.h>
2020-08-04 11:59:45 +02:00
2020-05-02 22:06:47 +02:00
using namespace std;
#include "drive.h"
2020-05-02 00:49:11 +02:00
#include "smart.h"
#include "shred.h"
2020-08-23 11:04:10 +02:00
#include "delete.h"
2020-08-04 22:35:29 +02:00
#include "tui.h"
2020-09-07 17:23:15 +02:00
#include "logger/logger.h"
2020-08-04 22:35:29 +02:00
2020-09-07 17:23:15 +02:00
extern Logger* logging;
2020-05-02 22:06:47 +02:00
template <typename T, typename I> T* iterator_to_pointer(I i)
{
return (&(*i));
}
2020-05-02 22:06:47 +02:00
class reHDD
{
protected:
public:
2020-05-02 22:06:47 +02:00
reHDD(void);
2020-09-07 17:23:15 +02:00
static void app_logic();
private:
2020-09-16 15:13:32 +02:00
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);
2020-09-16 15:13:32 +02:00
static void filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNewDrives);
static void addSMARTData(list <Drive>* plistDrives);
2020-08-04 11:59:45 +02:00
static void ThreadScannDevices();
2020-08-07 12:07:29 +02:00
static void ThreadUserInput();
static void ThreadShred(Drive* const pDrive);
2020-09-21 16:50:33 +02:00
static void ThreadDelete();
static void ThreadCheckFrozenDrives();
2020-08-23 09:26:32 +02:00
static void handleArrowKey(TUI::UserInput userInput);
2020-08-09 21:41:28 +02:00
static void handleEnter();
static void handleESC();
static void handleAbort();
static Drive* getSelectedDrive();
};
2020-09-07 17:23:15 +02:00
#endif // REHDD_H_