Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 716ab5614f | |||
| e017aeca0b | |||
| 42a1567b32 |
@@ -1,92 +0,0 @@
|
||||
# reHDD Code Style - clang-format configuration
|
||||
# Based on analyzed codebase formatting
|
||||
|
||||
BasedOnStyle: LLVM
|
||||
|
||||
# Indentation
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
ContinuationIndentWidth: 4
|
||||
|
||||
# Braces
|
||||
BreakBeforeBraces: Allman
|
||||
# Allman style:
|
||||
# if (condition)
|
||||
# {
|
||||
# statement;
|
||||
# }
|
||||
|
||||
# Spacing
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
|
||||
# Alignment
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
|
||||
# Line breaks
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
|
||||
# Column limit
|
||||
ColumnLimit: 0
|
||||
# 0 = no limit (observed in the code)
|
||||
|
||||
# Breaking
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: false
|
||||
|
||||
# Pointers and references
|
||||
PointerAlignment: Left
|
||||
# Type *variable (not Type* variable)
|
||||
|
||||
# Include sorting
|
||||
SortIncludes: false
|
||||
# Keep includes in original order
|
||||
|
||||
# Comments
|
||||
ReflowComments: false
|
||||
# Don't reformat comments
|
||||
|
||||
# Access modifiers
|
||||
AccessModifierOffset: -4
|
||||
# public: is outdented
|
||||
|
||||
# Constructor initializers
|
||||
ConstructorInitializerIndentWidth: 6
|
||||
# Observed 6 spaces for initializer lists
|
||||
|
||||
# Other
|
||||
Cpp11BracedListStyle: true
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
PenaltyBreakBeforeFirstCallParameter: 100
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
+9
-9
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
static void initTUI();
|
||||
|
||||
void updateTUI(std::list<Drive>* plistDrives, uint8_t u8SelectedEntry);
|
||||
void updateTUI(std::list<Drive> *plistDrives, uint8_t u8SelectedEntry);
|
||||
|
||||
static enum UserInput readUserInput();
|
||||
|
||||
@@ -60,12 +60,12 @@ private:
|
||||
static std::string sRamUsage;
|
||||
static std::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);
|
||||
@@ -79,9 +79,9 @@ private:
|
||||
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, uint32_t u32ReallocatedSectors, uint32_t u32PendingSectors, uint32_t u32UncorrectableSectors);
|
||||
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);
|
||||
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);
|
||||
static void vTruncateText(std::string *psText, uint16_t u16MaxLenght);
|
||||
};
|
||||
#endif // TUI_H_
|
||||
|
||||
+15
-10
@@ -17,19 +17,19 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
const static char* randomsrc = (char*)"/dev/urandom";
|
||||
const static char *randomsrc = (char *)"/dev/urandom";
|
||||
|
||||
Shred::Shred()
|
||||
{
|
||||
#ifdef ADAPTIVE_CHUNK_SIZE
|
||||
// Allocate aligned buffers for maximum chunk size
|
||||
if (posix_memalign((void**)&caTfngData, 4096, CHUNK_SIZE_MAX) != 0)
|
||||
if (posix_memalign((void **)&caTfngData, 4096, CHUNK_SIZE_MAX) != 0)
|
||||
{
|
||||
Logger::logThis()->error("Failed to allocate aligned buffer for tfng data");
|
||||
caTfngData = nullptr;
|
||||
}
|
||||
|
||||
if (posix_memalign((void**)&caReadBuffer, 4096, CHUNK_SIZE_MAX) != 0)
|
||||
if (posix_memalign((void **)&caReadBuffer, 4096, CHUNK_SIZE_MAX) != 0)
|
||||
{
|
||||
Logger::logThis()->error("Failed to allocate aligned buffer for read buffer");
|
||||
caReadBuffer = nullptr;
|
||||
@@ -83,7 +83,7 @@ void Shred::startMeasurement()
|
||||
* \param file descriptor for signaling
|
||||
* \return 0 on success, -1 on error
|
||||
*/
|
||||
void Shred::evaluateThroughput(Drive* drive)
|
||||
void Shred::evaluateThroughput(Drive *drive)
|
||||
{
|
||||
auto measurementEndTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> elapsed = measurementEndTime - measurementStartTime;
|
||||
@@ -129,7 +129,7 @@ void Shred::evaluateThroughput(Drive* drive)
|
||||
* \param pointer to Drive instance
|
||||
* \return void
|
||||
*/
|
||||
void Shred::adjustChunkSize(Drive* drive)
|
||||
void Shred::adjustChunkSize(Drive *drive)
|
||||
{
|
||||
size_t oldChunkSize = currentChunkSize;
|
||||
|
||||
@@ -190,10 +190,10 @@ size_t Shred::getCurrentChunkSize() const
|
||||
* \param file descriptor for signaling
|
||||
* \return 0 on success, -1 on error
|
||||
*/
|
||||
int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
||||
{
|
||||
ostringstream address;
|
||||
address << (void const*)&(*drive);
|
||||
address << (void const *)&(*drive);
|
||||
Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
|
||||
|
||||
// Mark as started but NOT shredded yet
|
||||
@@ -229,7 +229,8 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
#endif
|
||||
|
||||
#ifndef DRYRUN
|
||||
const char* cpDrivePath = drive->getPath().c_str();
|
||||
string sDrivePath = drive->getPath();
|
||||
const char *cpDrivePath = sDrivePath.c_str();
|
||||
unsigned char ucKey[TFNG_KEY_SIZE];
|
||||
|
||||
#ifdef ADAPTIVE_CHUNK_SIZE
|
||||
@@ -454,8 +455,10 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
|
||||
if ((d32Percent - d32TmpPercent) >= 0.01)
|
||||
{
|
||||
// set shred percentage
|
||||
drive->setTaskPercentage(d32TmpPercent);
|
||||
d32TmpPercent = d32Percent;
|
||||
// signal process in shredding
|
||||
write(*ipSignalFd, "A", 1);
|
||||
}
|
||||
|
||||
@@ -562,7 +565,7 @@ double Shred::calcProgress()
|
||||
unsigned int uiMaxShredIteration = SHRED_ITERATIONS;
|
||||
|
||||
#ifdef ZERO_CHECK
|
||||
uiMaxShredIteration++;
|
||||
uiMaxShredIteration++; // increment because we will check after SHRED_ITERATIONS the drive for non-zero bytes
|
||||
#endif
|
||||
|
||||
if (this->ulDriveByteSize == 0)
|
||||
@@ -635,11 +638,13 @@ long Shred::getDriveSizeInBytes(fileDescriptor file)
|
||||
* \param signal file descriptor
|
||||
* \return checksum value (0 = all zeros)
|
||||
*/
|
||||
unsigned int Shred::uiCalcChecksum(fileDescriptor file, Drive* drive, int* ipSignalFd)
|
||||
unsigned int Shred::uiCalcChecksum(fileDescriptor file, Drive *drive, int *ipSignalFd)
|
||||
{
|
||||
unsigned int uiChecksum = 0;
|
||||
unsigned long ulDriveByteCounter = 0U;
|
||||
|
||||
Logger::logThis()->info("Check-Task: Starting checksum verification - Drive: " + drive->getSerial());
|
||||
|
||||
#ifdef ADAPTIVE_CHUNK_SIZE
|
||||
size_t checkChunkSize = CHUNK_SIZE_MAX;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user