From c942f36e492d41969b96a2a3726760fcfb27e0a8 Mon Sep 17 00:00:00 2001
From: localhorst <localhorst@mosad.xyz>
Date: Wed, 26 Jan 2022 15:15:34 +0100
Subject: [PATCH] using lsblk for listing attached drives

---
 src/reHDD.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/reHDD.cpp b/src/reHDD.cpp
index 895745f..5cc7443 100644
--- a/src/reHDD.cpp
+++ b/src/reHDD.cpp
@@ -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);