filter drives only based on UUID
This commit is contained in:
parent
84e42a430b
commit
25d8ca6920
|
@ -322,29 +322,30 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
|
||||||
*/
|
*/
|
||||||
void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||||
{
|
{
|
||||||
string sDelimiter = ":";
|
//string sDelimiter = ":";
|
||||||
string sIgnoredDrivePath;
|
// string sIgnoredDrivePath;
|
||||||
string sIgnoredDriveUUID;
|
string sIgnoredDriveUUID;
|
||||||
|
|
||||||
list<tuple<string, string>> vtlIgnoredDevices; //store drives from ingnore file
|
list<tuple<string>> vtlIgnoredDevices; //store drives from ingnore file
|
||||||
|
|
||||||
ifstream input( "ignoreDrives.conf" ); //read ingnore file
|
ifstream input( "ignoreDrives.conf" ); //read ingnore file
|
||||||
|
|
||||||
for(string sLine; getline( input, sLine );)
|
for(string sLine; getline( input, sLine );)
|
||||||
{
|
{
|
||||||
if (string(sLine).find("/dev/sd") != string::npos)
|
// if (string(sLine).find("/dev/sd") != string::npos)
|
||||||
{
|
// {
|
||||||
size_t pos = 0;
|
//size_t pos = 0;
|
||||||
string token;
|
//string token;
|
||||||
while ((pos = sLine.find(sDelimiter)) != string::npos)
|
// while ((pos = sLine.find(sDelimiter)) != string::npos)
|
||||||
{
|
// {
|
||||||
token = sLine.substr(0, pos);
|
//token = sLine.substr(0, pos);
|
||||||
sIgnoredDrivePath = token;
|
//sIgnoredDrivePath = token;
|
||||||
sLine.erase(0, pos + sDelimiter.length());
|
//sLine.erase(0, pos + sDelimiter.length());
|
||||||
sIgnoredDriveUUID = sLine;
|
sIgnoredDriveUUID = sLine;
|
||||||
} //end while
|
// } //end while
|
||||||
vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ignore file to vector
|
Logger::logThis()->info("read uuid: " + sIgnoredDriveUUID);
|
||||||
}
|
vtlIgnoredDevices.emplace_back(sIgnoredDriveUUID); //add found path and uuid from ignore file to vector
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
//loop through found entries in ingnore file
|
//loop through found entries in ingnore file
|
||||||
for(auto row : vtlIgnoredDevices)
|
for(auto row : vtlIgnoredDevices)
|
||||||
|
@ -353,8 +354,8 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
string sUUID;
|
string sUUID;
|
||||||
if (!get<0>(row).compare(it->getPath())) //find same drive based on path
|
//if (!get<0>(row).compare(it->getPath())) //find same drive based on path
|
||||||
{
|
// {
|
||||||
char * cLine = NULL;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
string sCMD = "blkid ";
|
string sCMD = "blkid ";
|
||||||
|
@ -380,11 +381,11 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||||
pclose(outputfileBlkid);
|
pclose(outputfileBlkid);
|
||||||
//cout << "blkid uuid:" << sUUID << endl;
|
//cout << "blkid uuid:" << sUUID << endl;
|
||||||
|
|
||||||
if (get<1>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive
|
if (get<0>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive
|
||||||
{
|
{
|
||||||
cout << "[ERROR] different uuid found than in ignore file:" << it->getPath() << endl;
|
//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() + " uuid from drive: " + sUUID);
|
//Logger::logThis()->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
|
//exit(EXIT_FAILURE); // exit to prevent accidentally shred a system drive
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -395,7 +396,7 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||||
it = plistDrives->erase(it);
|
it = plistDrives->erase(it);
|
||||||
it--;
|
it--;
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue