using lsblk for listing attached drives
This commit is contained in:
parent
068413c15d
commit
c942f36e49
|
@ -294,7 +294,7 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
|
||||||
char * cLine = NULL;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
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)
|
if (outputfileHwinfo == NULL)
|
||||||
{
|
{
|
||||||
|
@ -304,13 +304,13 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
|
||||||
|
|
||||||
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
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->state = Drive::NONE;
|
||||||
tmpDrive->bIsOffline = false;
|
tmpDrive->bIsOffline = false;
|
||||||
plistDrives->push_back(*tmpDrive);
|
plistDrives->push_back(*tmpDrive);
|
||||||
Logger::logThis()->info("search drives: " + tmpDrive->getPath());
|
Logger::logThis()->info("drive found: " + tmpDrive->getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(outputfileHwinfo);
|
fclose(outputfileHwinfo);
|
||||||
|
|
Loading…
Reference in New Issue