From 3e4f8fc4f431c48ee3132f3a3c9e6899b1656b04 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 28 Aug 2015 13:52:04 +0200 Subject: [PATCH 1/3] Bug #4569 - system_set_harddisk_standby() rewritte for current CAM-based ATA stack Resubmit of #1767 --- src/etc/inc/system.inc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 41e798eab8..94ef3684b9 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -2042,6 +2042,11 @@ function system_dmesg_save() { function system_set_harddisk_standby() { global $g, $config; + // Get only suitable candidates for standby; using get_smart_drive_list() + // from utils.inc to get the list of drives. + $harddisks = array(); + $harddisks = get_smart_drive_list(); + if (isset($config['system']['developerspew'])) { $mt = microtime(); echo "system_set_harddisk_standby() being called $mt\n"; @@ -2055,11 +2060,13 @@ function system_set_harddisk_standby() { $standby = $config['system']['harddiskstandby']; // Check for a numeric value if (is_numeric($standby)) { - // Sync the disk(s) - pfSense_sync(); - if (set_single_sysctl('hw.ata.standby', (int)$standby)) { - // Reinitialize ATA-drives - mwexec('/usr/local/sbin/atareinit'); + // Since get_smart_drive_list() only matches ad|da|ada; lets put the check below + // just in case of some weird pfSense platform installs. + if (count($harddisks) > 0) { + // Iterate disks and run the camcontrol command for each + foreach ($harddisks as $harddisk) { + mwexec("/sbin/camcontrol standby {$harddisk} -t {$standby}"); + } if (platform_booting()) { echo gettext("done.") . "\n"; } From a60c1700498cb18c5198247c82650cc99c29641d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 28 Aug 2015 14:03:48 +0200 Subject: [PATCH 2/3] Re-enable hard disk standby (Bug #4569) --- src/usr/local/www/system_advanced_misc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/local/www/system_advanced_misc.php b/src/usr/local/www/system_advanced_misc.php index 72f4833436..bd16f1dfd6 100644 --- a/src/usr/local/www/system_advanced_misc.php +++ b/src/usr/local/www/system_advanced_misc.php @@ -667,7 +667,7 @@ function tmpvar_checked(obj) {   - + From 0357ecfc68c734384ea890929085c04605204666 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 28 Aug 2015 14:22:03 +0200 Subject: [PATCH 3/3] Declare the harddisks variable only if needed --- src/etc/inc/system.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 94ef3684b9..f7987e1d1d 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -2042,10 +2042,6 @@ function system_dmesg_save() { function system_set_harddisk_standby() { global $g, $config; - // Get only suitable candidates for standby; using get_smart_drive_list() - // from utils.inc to get the list of drives. - $harddisks = array(); - $harddisks = get_smart_drive_list(); if (isset($config['system']['developerspew'])) { $mt = microtime(); @@ -2060,6 +2056,10 @@ function system_set_harddisk_standby() { $standby = $config['system']['harddiskstandby']; // Check for a numeric value if (is_numeric($standby)) { + // Get only suitable candidates for standby; using get_smart_drive_list() + // from utils.inc to get the list of drives. + $harddisks = get_smart_drive_list(); + // Since get_smart_drive_list() only matches ad|da|ada; lets put the check below // just in case of some weird pfSense platform installs. if (count($harddisks) > 0) {