Merge pull request 'adopt newer debian' (#35) from develop into master

Reviewed-on: #35
This commit is contained in:
Hendrik Schutter 2022-01-26 16:41:56 +01:00
commit 8034ac496b
6 changed files with 27 additions and 24 deletions

3
.gitignore vendored
View File

@ -42,3 +42,6 @@
reHDD
reHDD.log
ignoreDrives.conf

View File

@ -8,7 +8,7 @@
#ifndef REHDD_H_
#define REHDD_H_
#define REHDD_VERSION "bV0.2.0"
#define REHDD_VERSION "bV0.2.1"
// Drive handling Settings
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
@ -18,7 +18,7 @@
// Logger Settings
#define LOG_PATH "./reHDD.log"
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2022"
#define DEVICE_ID "generic"
#define SOFTWARE_VERSION "alpha"
#define HARDWARE_VERSION "generic"

View File

@ -38,5 +38,5 @@ void Delete::deleteDrive(Drive* drive)
{
//wipefs running
}
fclose(deleteCmdOutput);
pclose(deleteCmdOutput);
}

View File

@ -48,17 +48,17 @@ uint32_t Drive::getPowerCycles(void)
string Drive::sCapacityToText()
{
if(getCapacity() <= (999*1000000000UL))
{
// Less or even 999 GB --> GB
return to_string(getCapacity() / 1000000000UL) + " GB";
}
else
{
// More 999 GB --> TB
return to_string(getCapacity() / 1000000000000UL) + " TB";
}
return "ERROR";
char acBuffer[16];
double dSize = (double) getCapacity();
uint16_t u16UnitIndex = 0;
const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
while (dSize >= 1000) { //using the marketing capacity
dSize /= 1000;
u16UnitIndex++;
}
sprintf(acBuffer, "%.*f %s", u16UnitIndex-3, dSize, units[u16UnitIndex]);
return acBuffer;
}
string Drive::sErrorCountToText()

View File

@ -289,30 +289,30 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
*/
void reHDD::searchDrives(list <Drive>* plistDrives)
{
// cout << "search drives ..." << endl;
Logger::logThis()->info("--> search drives <--");
char * cLine = NULL;
size_t len = 0;
FILE* outputfileHwinfo = popen("ls -1 /dev/sd*", "r");
FILE* outputfileHwinfo = popen("lsblk -I 8 -d -o NAME", "r");
if (outputfileHwinfo == NULL)
{
Logger::logThis()->error("Unable to scann attached drives");
Logger::logThis()->error("Unable to scan attached drives");
exit(EXIT_FAILURE);
}
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
{
if (string(cLine).length() == 9)
if (string(cLine).length() == 4)
{
Drive* tmpDrive = new Drive(string(cLine).substr(0, 8));
Drive* tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 3));
tmpDrive->state = Drive::NONE;
tmpDrive->bIsOffline = false;
plistDrives->push_back(*tmpDrive);
//Logger::logThis()->info("drive found: " + tmpDrive->getPath());
}
}
fclose(outputfileHwinfo);
pclose(outputfileHwinfo);
}
/**
@ -343,7 +343,7 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
sLine.erase(0, pos + sDelimiter.length());
sIgnoredDriveUUID = sLine;
} //end while
vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ingnore file to vector
vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ignore file to vector
}
}
//loop through found entries in ingnore file
@ -377,13 +377,13 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
//cout << "blkid uuid:" << sUUID << endl;
}
}
fclose(outputfileBlkid);
pclose(outputfileBlkid);
//cout << "blkid uuid:" << sUUID << endl;
if (get<1>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive
{
cout << "[ERROR] different uuid found than in ignore file:" << it->getPath() << endl;
Logger::logThis()->error("[ERROR] different uuid found than in ignore file: " + it->getPath());
Logger::logThis()->error("[ERROR] different uuid found than in ignore file: " + it->getPath() + " uuid from drive: " + sUUID);
exit(EXIT_FAILURE); // exit to prevent accidentally shred a system drive
}
else

View File

@ -51,7 +51,7 @@ void SMART::readSMARTData(Drive* drive)
SMART::parsePowerOnHours(sLine);
SMART::parsePowerCycle(sLine);
}
fclose(outputfileSmart);
pclose(outputfileSmart);
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle); //wirte data in drive
}