diff options
author | Jim P <jim@pingle.org> | 2012-11-14 20:20:44 -0800 |
---|---|---|
committer | Jim P <jim@pingle.org> | 2012-11-14 20:20:44 -0800 |
commit | 9f40c982756e59a1751a6eeeb843270b3aeedb3c (patch) | |
tree | bbf83bd0e8471504eb51d8d80720715dd6489976 | |
parent | dbbc7307d17d26df4130beea8bb667fdf6bf086e (diff) | |
parent | 41cc7a540236f73c34c10f4df3cb008e1abc3e8b (diff) | |
download | pfsense-9f40c982756e59a1751a6eeeb843270b3aeedb3c.zip pfsense-9f40c982756e59a1751a6eeeb843270b3aeedb3c.tar.gz |
Merge pull request #250 from phil-davis/master
Enhance reporting and changing read-write setting on nanoBSD
-rw-r--r-- | etc/inc/util.inc | 13 | ||||
-rwxr-xr-x | usr/local/www/diag_nanobsd.php | 12 |
2 files changed, 23 insertions, 2 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 94e8553..9961b4b 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -248,6 +248,19 @@ function refcount_unreference($reference) { return $shm_data; } +function refcount_read($reference) { + /* This function just reads the current value of the refcount for information. */ + /* There is no need for locking. */ + $shmid = @shmop_open($reference, "a", 0, 0); + if (!$shmid) { + log_error(gettext("Could not open shared memory for read {$reference}")); + return -1; + } + $shm_data = @shmop_read($shmid, 0, 10); + @shmop_close($shmid); + return $shm_data; +} + function is_module_loaded($module_name) { $running = `/sbin/kldstat | grep {$module_name} | /usr/bin/grep -v grep | /usr/bin/wc -l`; if (intval($running) >= 1) diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index 353f9ba..c88aa1b 100755 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -118,7 +118,9 @@ if ($_POST['changero']) { if ($_POST['setrw']) { if (isset($_POST['nanobsd_force_rw'])) { - conf_mount_rw(); + if (!is_writable("/")) { + conf_mount_rw(); + } $config['system']['nanobsd_force_rw'] = true; } else { unset($config['system']['nanobsd_force_rw']); @@ -181,7 +183,13 @@ if ($savemsg) <td valign="top" class="vncell"> <form action="diag_nanobsd.php" method="post" name="iform"> <?php if (is_writable("/")) { - echo gettext("Read/Write"); + $refcount = refcount_read(1000); + if ($refcount == 1) { + $refdisplay = ""; + } else { + $refdisplay = " (reference count " . $refcount . ")"; + } + echo gettext("Read/Write") . $refdisplay; if (!isset($config['system']['nanobsd_force_rw'])) echo "<br/><input type='submit' name='changero' value='" . gettext("Switch to Read-Only") . "'>"; } else { |