diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-07 14:30:17 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-07 14:30:17 +0545 |
commit | 356ba464349df4aebbeaac8e9f241898d7cde8a6 (patch) | |
tree | 26d0b42b126f725a329be8a984eff27800bfc9a2 /src/usr/local/www/diag_nanobsd.php | |
parent | 24c16d618ea9f61a07b016808915706c9d2da7f5 (diff) | |
download | pfsense-356ba464349df4aebbeaac8e9f241898d7cde8a6.zip pfsense-356ba464349df4aebbeaac8e9f241898d7cde8a6.tar.gz |
diag_nanobsd clean up handling of RO<->RW switching
1) When the Save button has been used to save the Permanent Read/Write setting then display a success message so the user knows it worked.
2) Move the "This setting is only temporary..." setHelp to be with the Read/Write status area, where it is in 2.2.6. That text was under the Permanent Read/Write checkbox, where it was not true.
3) Always set the $btnlbl text used for the $robtn - there were ways to have the system in permanent read-write and then the button would not have a custom label, and so it would just say "Submit"
4) Only display the $robtn when it is relevant - if permanent RW is set and the running system is actually in RW then press a "Switch to Read-only" button actually does nothing anyhow, so there is no point displaying button.
Diffstat (limited to 'src/usr/local/www/diag_nanobsd.php')
-rw-r--r-- | src/usr/local/www/diag_nanobsd.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/usr/local/www/diag_nanobsd.php b/src/usr/local/www/diag_nanobsd.php index f2847d0..abefaff 100644 --- a/src/usr/local/www/diag_nanobsd.php +++ b/src/usr/local/www/diag_nanobsd.php @@ -122,8 +122,12 @@ if ($_POST['setrw']) { if (!DEBUG) { conf_mount_rw(); if (isset($_POST['nanobsd_force_rw'])) { + $savemsg = gettext("Permanent read/write has been set successfully."); + $class='alert-success'; $config['system']['nanobsd_force_rw'] = true; } else { + $savemsg = gettext('Permanent read/write has been cleared successfully.'); + $class='alert-success'; unset($config['system']['nanobsd_force_rw']); } @@ -158,8 +162,9 @@ $section->addInput(new Form_StaticText( $ACTIVE_SLICE . ' ' . $slicebtn )); +$refcount = refcount_read(1000); + if (is_writable("/")) { - $refcount = refcount_read(1000); /* refcount_read returns -1 when shared memory section does not exist */ /* refcount can be zero here when the user has set nanobsd_force_rw */ /* refcount 1 is normal, so only display the count for abnormal values */ @@ -169,30 +174,31 @@ if (is_writable("/")) { $refdisplay = " (Reference count " . $refcount . ")"; } $lbl = gettext("Read/Write") . $refdisplay; - if (!isset($config['system']['nanobsd_force_rw'])) { - $btnlbl = gettext("Switch to Read-Only"); - } + $btnlbl = gettext("Switch to Read-Only"); } else { $lbl = gettext("Read-Only"); - if (!isset($config['system']['nanobsd_force_rw'])) { - $btnlbl = gettext("Switch to Read/Write"); - } + $btnlbl = gettext("Switch to Read/Write"); } -$robtn = new Form_Button('changero', $btnlbl); -$robtn->removeClass('btn-primary')->addClass('btn-default btn-sm'); +// Only show the changero button if force read/write is off, or the file system is not in writable state, or there is an unusual refcount. +// If force read/write is on, and the file system is in writable state, and refcount is normal then the user has no reason to mess about. +if (!isset($config['system']['nanobsd_force_rw']) || !is_writable("/") || ($refcount > 1)) { + $robtn = new Form_Button('changero', $btnlbl); + $robtn->removeClass('btn-primary')->addClass('btn-default btn-sm'); + $lbl .= ' ' . $robtn; +} $section->addInput(new Form_StaticText( 'Read/Write status', - $lbl . ' ' . $robtn -)); + $lbl +))->setHelp('This setting is only temporary, and can be switched dynamically in the background.'); $section->addInput(new Form_Checkbox( 'nanobsd_force_rw', 'Permanent Read/Write', 'Keep media mounted read/write at all times. ', isset($config['system']['nanobsd_force_rw']) -))->setHelp('This setting is only temporary, and can be switched dynamically in the background.'); +)); $permbtn = new Form_Button('setrw', 'Save'); $permbtn->removeClass('btn-primary')->addClass('btn-default btn-sm'); |