From 04a33335c855e3550e395c67958c0734fa519bf7 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 12 Dec 2025 21:35:06 +0100 Subject: [PATCH 1/4] fix systemdrive and dummy shred pipe --- include/reHDD.h | 2 +- src/reHDD.cpp | 39 +++++++++++++++++++++++++++++++++------ src/shred.cpp | 2 +- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/reHDD.h b/include/reHDD.h index 059e199..01da1fd 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -31,7 +31,7 @@ #endif // Logic -// #define DRYRUN // don't touch the drives +#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 diff --git a/src/reHDD.cpp b/src/reHDD.cpp index 57cd30a..04c64d1 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -382,7 +382,13 @@ void reHDD::filterIgnoredDrives(list *plistDrives) list::iterator it; for (it = plistDrives->begin(); it != plistDrives->end(); ++it) { - if (it->getPath().find(systemDrivePath) != std::string::npos) // compare found system drive and current drive + string driveName = it->getPath(); + // Remove /dev/ prefix + if (driveName.find("/dev/") == 0) + { + driveName = driveName.substr(5); // Skip "/dev/" + } + if (systemDrivePath.find(driveName) != std::string::npos) // compare found system drive and current drive { // system drive found --> ignore this drive #ifdef LOG_LEVEL_HIGH @@ -709,14 +715,23 @@ bool reHDD::getSystemDrive(string &systemDrive) continue; } - // Logger::logThis()->info(currentLine); - + // Extract drive name from line (removing tree characters) if ((cLine[0U] != '|') && (cLine[0U] != '`')) { systemDrive = currentLine; - systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); // remove newline - systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces - // Logger::logThis()->info("Drive found: " + systemDrive); + + // Find the actual drive name (after tree characters like └─, ├─) + size_t lastAlpha = 0; + for (size_t i = 0; i < systemDrive.length(); i++) + { + if (isalpha(systemDrive[i])) + { + lastAlpha = i; + break; + } + } + + systemDrive = systemDrive.substr(lastAlpha); } if (currentLine.ends_with(" /boot/efi\n"s)) @@ -739,5 +754,17 @@ bool reHDD::getSystemDrive(string &systemDrive) } pclose(outputfileHwinfo); + // Remove mountpoint (everything after first space) + size_t spacePos = systemDrive.find(' '); + if (spacePos != std::string::npos) + { + systemDrive = systemDrive.substr(0, spacePos); + } + + // Remove all unwanted characters + systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); + systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '/'), systemDrive.end()); + systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\r'), systemDrive.end()); + return systemDriveFound; } diff --git a/src/shred.cpp b/src/shred.cpp index e825845..e152937 100644 --- a/src/shred.cpp +++ b/src/shred.cpp @@ -40,7 +40,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd) drive->bWasShredStarted = true; // Mark drive as partly shredded #ifdef DRYRUN - for (int i = 0; i <= 500; i++) + for (int i = 0; i <= 100; i++) { if (drive->state.load() != Drive::TaskState::SHRED_ACTIVE) { -- 2.50.1 From 7ce6986d921eecd330c4838e5ba652a3ab2f2300 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 12 Dec 2025 22:06:45 +0100 Subject: [PATCH 2/4] fix DRYRUN shred --- src/reHDD.cpp | 8 ++++---- src/shred.cpp | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/reHDD.cpp b/src/reHDD.cpp index 04c64d1..ea3757f 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -226,10 +226,10 @@ void reHDD::ThreadShred(Drive *const pDrive) { if (pDrive != nullptr) { - pDrive->setActionStartTimestamp(); // save timestamp at start of shredding - Shred *pShredTask = new Shred(); // create new shred task - pShredTask->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task - delete pShredTask; // delete shred task + pDrive->setActionStartTimestamp(); // save timestamp at start of shredding + Shred *pShredInstance = new Shred(); // create new shred task + pShredInstance->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task + delete pShredInstance; // delete shred task ui->updateTUI(&listDrives, u16SelectedEntry); } } diff --git a/src/shred.cpp b/src/shred.cpp index e152937..b2c6a0a 100644 --- a/src/shred.cpp +++ b/src/shred.cpp @@ -42,10 +42,6 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd) #ifdef DRYRUN for (int i = 0; i <= 100; i++) { - if (drive->state.load() != Drive::TaskState::SHRED_ACTIVE) - { - return 0; - } drive->setTaskPercentage(i + 0.05); write(*ipSignalFd, "A", 1); usleep(20000); @@ -204,9 +200,8 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd) Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial()); } #endif -#endif - cleanup(); +#endif if ((drive->state.load() == Drive::TaskState::SHRED_ACTIVE) || (drive->state.load() == Drive::TaskState::CHECK_SUCCESSFUL) || (drive->state == Drive::TaskState::CHECK_FAILED)) { -- 2.50.1 From 446944260bfb898b95e646ded9576f4f05a0da98 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 12 Dec 2025 22:11:02 +0100 Subject: [PATCH 3/4] update readme --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5ea5186..a72e989 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab ## Screenshot ![Screenshot of reHDD with multiple drives in different states](https://git.mosad.xyz/localhorst/reHDD/raw/commit/c40dfe2cbb8f86490b49caf82db70a10015f06f9/doc/screenshot.png "Screenshot") -## Debian Build Notes +## openSUSE Build Notes -* `apt-get install ncurses-dev git make g++` +* `zypper install ncurses-devel git make gcc-c++` * `git submodule init` * `git submodule update` * `make release` @@ -28,16 +28,8 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab Just install [reHDDPrinter](https://git.mosad.xyz/localhorst/reHDDPrinter). No further settings needed. -## Create Standalone with Debian 11 - -Instructions how to create a standalone machine that boots directly to reHDD. This is aimed for production use, like several drives a day shredding. -* Start reHDD after boot without login (as a tty1 shell) -* Start dmesg after boot without login (as a tty2 shell) -* Start htop after boot without login (as a tty3 shell) -* Upload reHDD log every 12h if wanted - ### Software requirements -* `apt-get install hwinfo smartmontools curl htop sudo` +* `zypper install hwinfo smartmontools curl htop sudo` ### Installation @@ -56,7 +48,7 @@ git submodule update If you want to upload the logs, edit `scripts/reHDDLogUploader.bash` with your nextcloud token -Add your system drive in `/root/reHDD/ignoreDrives.conf` like: +Add ignored drives in `/root/reHDD/ignoreDrives.conf` like: ```e102f49d``` Get the first 8 Bytes from your UUID via `blkid /dev/sdX` -- 2.50.1 From d0197d2ca60a6e7be0528b2ac36655fd9badde0a Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 12 Dec 2025 22:11:33 +0100 Subject: [PATCH 4/4] disable DRYRUN --- include/reHDD.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/reHDD.h b/include/reHDD.h index 01da1fd..059e199 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -31,7 +31,7 @@ #endif // Logic -#define DRYRUN // don't touch the drives +// #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 -- 2.50.1