diff options
| author | Burt P <pburt0@gmail.com> | 2018-03-25 17:11:33 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-04-24 07:50:00 -0700 | 
| commit | bf2447edb6237156b7523599c8837f74c9b069ef (patch) | |
| tree | 4f33394bce93491c34f13a36d1ae144836ed53cb /modules/devices | |
| parent | 5d9bba6e21aab22d54556c697a7f9db7da05e2cb (diff) | |
devices/storage: try `lsscsi -c` if /proc/scsi/scsi is not found
This is a hack to address #240. The storage scanner needs work.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices')
| -rw-r--r-- | modules/devices/storage.c | 14 | 
1 files changed, 12 insertions, 2 deletions
| diff --git a/modules/devices/storage.c b/modules/devices/storage.c index 0c393682..934ca238 100644 --- a/modules/devices/storage.c +++ b/modules/devices/storage.c @@ -45,7 +45,14 @@ __scan_scsi_devices(void)      scsi_storage_list = g_strdup(_("\n[SCSI Disks]\n")); -    if ((proc_scsi = fopen("/proc/scsi/scsi", "r"))) { +    int otype = 0; +    if (proc_scsi = fopen("/proc/scsi/scsi", "r")) { +        otype = 1; +    } else if (proc_scsi = popen("lsscsi -c", "r")) { +        otype = 2; +    } + +    if (otype) {          while (fgets(buffer, 256, proc_scsi)) {              buf = g_strstrip(buffer);              if (!strncmp(buf, "Host: scsi", 10)) { @@ -145,7 +152,10 @@ __scan_scsi_devices(void)                  scsi_controller = scsi_channel = scsi_id = scsi_lun = 0;              }          } -        fclose(proc_scsi); +        if (otype == 1) +            fclose(proc_scsi); +        else if (otype == 2) +            pclose(proc_scsi);      }      if (n) { | 
