forked from localhorst/reHDD
using now own shred impl with check if the complete drive is full of zeros after shredding
This commit is contained in:
54
include/shred.h
Normal file
54
include/shred.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file shred.h
|
||||
* @brief shred drive
|
||||
* @author hendrik schutter
|
||||
* @date 03.05.2020
|
||||
*/
|
||||
|
||||
#ifndef SHRED_H_
|
||||
#define SHRED_H_
|
||||
|
||||
#include "reHDD.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define CHUNK_SIZE 1024*1024*2 //amount of bytes that are overwritten at once
|
||||
#define SHRED_ITERATIONS 3 //overwrite the drive multiple times, last time with zeros
|
||||
|
||||
//#define DEMO_DRIVE_SIZE 1024*1024*256 // 256MB
|
||||
|
||||
typedef int fileDescriptor;
|
||||
|
||||
class Shred
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
Shred();
|
||||
~Shred();
|
||||
int shredDrive(Drive* drive, int* ipSignalFd);
|
||||
|
||||
private:
|
||||
fileDescriptor randomSrcFileDiscr;
|
||||
fileDescriptor driveFileDiscr;
|
||||
unsigned char caChunk[CHUNK_SIZE];
|
||||
unsigned long ulDriveByteSize;
|
||||
double d32Percent = 0.0;
|
||||
double d32TmpPercent = 0.0;
|
||||
|
||||
inline double calcProgress(unsigned long ulDriveByteIndex, unsigned int uiIteration);
|
||||
int iRewindDrive(fileDescriptor file);
|
||||
unsigned long getDriveSizeInBytes(fileDescriptor file);
|
||||
unsigned int uiCalcChecksum(fileDescriptor file);
|
||||
void cleanup();
|
||||
|
||||
};
|
||||
|
||||
#endif // SHRED_H_
|
Reference in New Issue
Block a user