diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-08-26 10:11:13 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-08-26 10:11:13 -0400 |
commit | df6e4b20cbd5681fa4810ceef15c52e6932bd7bb (patch) | |
tree | d9ec7b5c0c0017788ac6487d7b48d28767fd62d0 /pts-core/functions/pts-functions_system_parsing.php | |
parent | e8fdb2c711545b2b37a02425d6b8e9d0909cf3a1 (diff) | |
download | phoronix-test-suite-upstream-df6e4b20cbd5681fa4810ceef15c52e6932bd7bb.tar.gz phoronix-test-suite-upstream-df6e4b20cbd5681fa4810ceef15c52e6932bd7bb.tar.xz phoronix-test-suite-upstream-df6e4b20cbd5681fa4810ceef15c52e6932bd7bb.zip |
pts-core: Allow read_pci() to accept an array for fallback devices to
read
Diffstat (limited to 'pts-core/functions/pts-functions_system_parsing.php')
-rw-r--r-- | pts-core/functions/pts-functions_system_parsing.php | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php index d7b5d54..074713c 100644 --- a/pts-core/functions/pts-functions_system_parsing.php +++ b/pts-core/functions/pts-functions_system_parsing.php @@ -119,33 +119,34 @@ function read_sensors($attributes) function read_pci($desc, $clean_string = true) { // Read PCI bus information - $info = shell_exec("lspci 2>&1"); + $pci_info = shell_exec("lspci 2>&1"); + $info = "Unknown"; - if(($pos = strpos($info, $desc)) === FALSE) - { - $info = "Unknown"; - } - else + if(!is_array($desc)) + $desc = array($desc); + + for($i = 0; $i < count($desc) && $info == "Unknown"; $i++) { - $info = substr($info, $pos + strlen($desc)); - $EOL = strpos($info, "\n"); + if(($pos = strpos($pci_info, $desc[$i])) !== FALSE) + { + $sub_pci_info = substr($pci_info, $pos + strlen($desc[$i])); + $EOL = strpos($sub_pci_info, "\n"); - if(($temp = strpos($info, '/')) < $EOL && $temp > 0) - if(($temp = strpos($info, ' ', ($temp + 2))) < $EOL && $temp > 0) - $EOL = $temp; + if(($temp = strpos($sub_pci_info, '/')) < $EOL && $temp > 0) + if(($temp = strpos($sub_pci_info, ' ', ($temp + 2))) < $EOL && $temp > 0) + $EOL = $temp; - if(($temp = strpos($info, '(')) < $EOL && $temp > 0) - $EOL = $temp; + if(($temp = strpos($sub_pci_info, '(')) < $EOL && $temp > 0) + $EOL = $temp; - if(($temp = strpos($info, '[')) < $EOL && $temp > 0) - $EOL = $temp; + if(($temp = strpos($sub_pci_info, '[')) < $EOL && $temp > 0) + $EOL = $temp; - $info = trim(substr($info, 0, $EOL)); + $sub_pci_info = trim(substr($sub_pci_info, 0, $EOL)); - if(($strlen = strlen($info)) < 6 || $strlen > 96) - $info = "N/A"; - else if($clean_string) - $info = pts_clean_information_string($info); + if(($strlen = strlen($sub_pci_info)) >= 6 && $strlen < 96) + $info = pts_clean_information_string($sub_pci_info); + } } return $info; |