using lsblk for listing attached drives

This commit is contained in:
Hendrik Schutter 2022-01-26 15:15:34 +01:00
parent 068413c15d
commit c942f36e49
1 changed files with 4 additions and 4 deletions

View File

@ -294,7 +294,7 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
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)
{
@ -304,13 +304,13 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
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("search drives: " + tmpDrive->getPath());
Logger::logThis()->info("drive found: " + tmpDrive->getPath());
}
}
fclose(outputfileHwinfo);