When no disks are attached to a host, reading ahci_alpm_* files fail
with "Invalid argument" (but ahci_alpm_accounting can be written, so an
instance of ahci is created).
This case is now checked by reading ahci_alpm_accounting before writing to it:
if reading fails, the whole SCSI host is skipped.
---
src/devices/ahci.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 26f83a3..21f9d19 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -258,12 +258,20 @@ void create_all_ahcis(void)
while (1) {
class ahci *bl;
ofstream file;
+ ifstream check_file;
entry = readdir(dir);
if (!entry)
break;
if (entry->d_name[0] == '.')
continue;
sprintf(filename, "/sys/class/scsi_host/%s/ahci_alpm_accounting",
entry->d_name);
+
+ check_file.open(filename, ios::in);
+ check_file.get();
+ check_file.close();
+ if (check_file.bad())
+ continue;
+
file.open(filename, ios::in);
if (!file)
continue;
--
1.7.10.2
Show replies by thread