2020-05-01 18:31:02 +02:00
/**
2020-05-02 22:06:47 +02:00
* @ file reHDD . h
* @ brief represent
* @ author hendrik schutter
* @ date 01.05 .2020
2020-05-01 18:31:02 +02:00
*/
2020-05-02 22:06:47 +02:00
# ifndef REHDD_H_
# define REHDD_H_
2020-09-15 13:39:45 +02:00
# define REHDD_VERSION "bV0.1.0"
2020-09-16 15:13:32 +02:00
# define DRYRUN
2020-08-04 19:51:34 +02:00
2020-09-11 17:18:53 +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
2020-09-15 13:39:45 +02:00
# define SHRED_ITERATIONS 3
2020-09-11 17:18:53 +02:00
# define FROZEN_TIMEOUT 5 //After this timeout (minutes) the drive will be marked as frozen
2020-08-26 00:12:39 +02:00
2020-09-07 17:23:15 +02:00
// Logger Settings
# define LOG_PATH ". / reHDD.log"
2020-09-08 13:01:09 +02:00
# define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
# define DEVICE_ID "generic"
# define SOFTWARE_VERSION "alpha"
# define HARDWARE_VERSION "generic"
# define LOG_LEVEL_HIGH //log everything, like drive scann 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-11 17:18:53 +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 ;
2020-05-01 18:31:02 +02:00
# include "drive.h"
2020-05-02 00:49:11 +02:00
# include "smart.h"
2020-08-26 00:12:39 +02:00
# include "shred/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-01 18:31:02 +02:00
2020-05-02 22:06:47 +02:00
template < typename T , typename I > T * iterator_to_pointer ( I i )
2020-05-02 17:15:55 +02:00
{
return ( & ( * i ) ) ;
}
2020-05-02 22:06:47 +02:00
class reHDD
2020-05-02 17:15:55 +02:00
{
2020-05-01 18:31:02 +02:00
protected :
public :
2020-05-02 22:06:47 +02:00
reHDD ( void ) ;
2020-09-07 17:23:15 +02:00
static void app_logic ( ) ;
2020-05-01 18:31:02 +02:00
private :
2020-09-16 15:13:32 +02:00
static void searchDrives ( list < Drive > * plistDrives ) ;
static void printDrives ( list < Drive > * plistDrives ) ;
static void filterIgnoredDrives ( list < Drive > * plistDrives ) ;
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 ( ) ;
2020-08-23 09:26:32 +02:00
static void ThreadShred ( ) ;
2020-09-11 17:18:53 +02:00
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 ( ) ;
2020-08-26 18:38:39 +02:00
static Drive * getSelectedDrive ( ) ;
2020-05-01 18:31:02 +02:00
} ;
2020-09-07 17:23:15 +02:00
# endif // REHDD_H_