From b8250344f5f02851259ffde6fed8da40ddeaf0af Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 24 Oct 2013 18:01:52 -0200 Subject: [PATCH] Fix #3235 . diag_nanobsd.php: . Since conf_mount_ro() is always being called, always call conf_mount_rw to keep refcount correct . Do not show refcount_read() return when it's -1 . config.lib.inc . Increment and decrement refcount even if nanobsd_force_rw is set. This is necessary to avoid partition being mounted as RO when nanobsd_force_rw is disabled and any process requested it to be RW --- etc/inc/config.lib.inc | 10 +++++----- usr/local/www/diag_nanobsd.php | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index ddcfd9b669..0588252334 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -308,10 +308,7 @@ function conf_mount_rw() { if($g['platform'] == "cdrom" or $g['platform'] == "pfSense") return; - if (!isset($config['system']['nanobsd_force_rw']) && (refcount_reference(1000) > 1)) - return; - - if (isset($config['system']['nanobsd_force_rw']) && is_writable("/")) + if ((refcount_reference(1000) > 1) && is_writable("/")) return; $status = mwexec("/sbin/mount -u -w -o sync,noatime {$g['cf_path']}"); @@ -348,12 +345,15 @@ function conf_mount_ro() { /* Do not trust $g['platform'] since this can be clobbered during factory reset. */ $platform = trim(file_get_contents("/etc/platform")); /* do not umount on cdrom or pfSense platforms */ - if($platform == "cdrom" or $platform == "pfSense" or isset($config['system']['nanobsd_force_rw'])) + if($platform == "cdrom" or $platform == "pfSense") return; if (refcount_unreference(1000) > 0) return; + if(isset($config['system']['nanobsd_force_rw'])) + return; + if($g['booting']) return; diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index bab6d8da34..804b3b479b 100755 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -108,14 +108,11 @@ if ($_POST['changero']) { } if ($_POST['setrw']) { - if (isset($_POST['nanobsd_force_rw'])) { - if (!is_writable("/")) { - conf_mount_rw(); - } + conf_mount_rw(); + if (isset($_POST['nanobsd_force_rw'])) $config['system']['nanobsd_force_rw'] = true; - } else { + else unset($config['system']['nanobsd_force_rw']); - } write_config("Changed Permanent Read/Write Setting"); conf_mount_ro(); @@ -175,7 +172,8 @@ if ($savemsg)