find system drive
This commit is contained in:
parent
282c294ae7
commit
a665f8638e
@ -31,7 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Logic
|
// 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 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
|
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ private:
|
|||||||
static void handleESC();
|
static void handleESC();
|
||||||
static void handleAbort();
|
static void handleAbort();
|
||||||
static Drive *getSelectedDrive();
|
static Drive *getSelectedDrive();
|
||||||
|
static bool getSystemDrive(string &systemDrive);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REHDD_H_
|
#endif // REHDD_H_
|
||||||
|
@ -346,6 +346,12 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
{
|
{
|
||||||
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
|
||||||
ifstream input("ignoreDrives.conf"); // read ignore file
|
ifstream input("ignoreDrives.conf"); // read ignore file
|
||||||
|
string systemDrivePath;
|
||||||
|
|
||||||
|
if (getSystemDrive(systemDrivePath))
|
||||||
|
{
|
||||||
|
Logger::logThis()->info("Found system drive: " + systemDrivePath);
|
||||||
|
}
|
||||||
|
|
||||||
for (string sLine; getline(input, sLine);)
|
for (string sLine; getline(input, sLine);)
|
||||||
{
|
{
|
||||||
@ -605,3 +611,52 @@ void reHDD::handleAbort()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool reHDD::getSystemDrive(string &systemDrive)
|
||||||
|
{
|
||||||
|
Logger::logThis()->info("--> search system drive <--");
|
||||||
|
char *cLine = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
bool systemDriveFound = false;
|
||||||
|
|
||||||
|
FILE *outputfileHwinfo = popen("lsblk -e 11 -o NAME,MOUNTPOINT", "r");
|
||||||
|
|
||||||
|
if (outputfileHwinfo == NULL)
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Unable to scan attached drives for system drive");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
||||||
|
{
|
||||||
|
string currentLine = cLine;
|
||||||
|
|
||||||
|
if (currentLine.find("NAME") != std::string::npos)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logger::logThis()->info(currentLine);
|
||||||
|
|
||||||
|
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
||||||
|
{
|
||||||
|
systemDrive = currentLine;
|
||||||
|
// Logger::logThis()->info("Drive found: " + systemDrive);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.ends_with(" /boot/efi\n"s))
|
||||||
|
{
|
||||||
|
systemDriveFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.ends_with(" /\n"s))
|
||||||
|
{
|
||||||
|
systemDriveFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pclose(outputfileHwinfo);
|
||||||
|
|
||||||
|
return systemDriveFound;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user