Search
j0ke.net Open Build Service
>
Projects
>
internetx
:
desktop
>
lshw
> lshw-scsi-scan.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File lshw-scsi-scan.patch of Package lshw
Index: packages/lshw/development/src/core/scsi.cc =================================================================== --- a/packages/lshw/development/src/core/scsi.cc +++ b/packages/lshw/development/src/core/scsi.cc @@ -30,5 +30,5 @@ __ID("@(#) $Id$"); -#define SG_X "/dev/sg%d" +#define SG_X "/dev/sg*" #define SG_MAJOR 21 @@ -654,8 +654,7 @@ -static bool scan_sg(int sg, -hwNode & n) -{ - char buffer[20]; +static void scan_sg(hwNode & n) +{ + int sg; int fd = -1; My_sg_scsi_id m_id; @@ -666,14 +665,22 @@ int emulated = 0; bool ghostdeventry = false; - - snprintf(buffer, sizeof(buffer), SG_X, sg); - - ghostdeventry = !exists(buffer); - - if(ghostdeventry) mknod(buffer, (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg)); - fd = open(buffer, OPEN_FLAG | O_NONBLOCK); - if(ghostdeventry) unlink(buffer); + size_t j; + glob_t entries; + + if(glob(SG_X, 0, NULL, &entries) == 0) + { + for(j=0; j < entries.gl_pathc; j++) + { + sg = strtol(strpbrk(entries.gl_pathv[j], "0123456789"), NULL, 10); + + ghostdeventry = !exists(entries.gl_pathv[j]); + + if(ghostdeventry) + mknod(entries.gl_pathv[j], (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg)); + fd = open(entries.gl_pathv[j], OPEN_FLAG | O_NONBLOCK); + if(ghostdeventry) + unlink(entries.gl_pathv[j]); if (fd < 0) - return false; + continue; memset(&m_id, 0, sizeof(m_id)); @@ -681,5 +688,5 @@ { close(fd); - return true; // we failed to get info but still hope we can continue + continue; // we failed to get info but still hope we can continue } @@ -774,9 +781,6 @@ parent = n.addChild(hwNode("scsi", hw::storage)); - if (!parent) - { - close(fd); - return true; - } + if (parent) + { if(parent->getBusInfo() == "") @@ -790,8 +794,10 @@ } parent->addChild(device); + } close(fd); - - return true; + } + globfree(&entries); + } } @@ -890,10 +896,7 @@ bool scan_scsi(hwNode & n) { - int i = 0; - scan_devices(); - while (scan_sg(i, n)) - i++; + scan_sg(n); scan_hosts(n);