diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 683061ce2..dd6a81871 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -2075,4 +2075,17 @@ function post_redirect($page, $params) { print "\n"; } +/* Locate disks that can be queried for S.M.A.R.T. data. */ +function get_smart_drive_list() { + $disk_list = explode(" ", get_single_sysctl("kern.disks")); + foreach ($disk_list as $id => $disk) { + // We only want certain kinds of disks for S.M.A.R.T. + if (preg_match("/^(ad|da|ada).*[0-9]{1,2}$/", $disk) === FALSE) { + unset($disk_list[$id]); + } + } + sort($disk_list); + return $disk_list; +} + ?> diff --git a/usr/local/www/diag_smart.php b/usr/local/www/diag_smart.php index 2cbc60bf1..a8bfd3ebb 100644 --- a/usr/local/www/diag_smart.php +++ b/usr/local/www/diag_smart.php @@ -276,8 +276,7 @@ switch($action) { // Default page, prints the forms to view info, test, etc... default: { - // Get all AD* and DA* (IDE and SCSI) devices currently installed and stores them in the $devs array - exec("ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'", $devs); + $devs = get_smart_drive_list(); ?> diff --git a/usr/local/www/widgets/widgets/smart_status.widget.php b/usr/local/www/widgets/widgets/smart_status.widget.php index 746e78d72..f02c53131 100644 --- a/usr/local/www/widgets/widgets/smart_status.widget.php +++ b/usr/local/www/widgets/widgets/smart_status.widget.php @@ -42,7 +42,7 @@ require_once("/usr/local/www/widgets/include/smart_status.inc"); 0) { foreach($devs as $dev) { ## for each found drive do