summaryrefslogtreecommitdiffstats
path: root/etc/inc/system.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2010-05-18 17:58:18 -0400
committerScott Ullrich <sullrich@pfsense.org>2010-05-18 17:58:18 -0400
commit7188fc6db5548d66b24859e7252a1a17e2dac7d4 (patch)
treea7df745ef91da739e0a4d10f109152646cf9bee9 /etc/inc/system.inc
parent2c7d67ff55d4713b174d18c4e30368a908204824 (diff)
downloadpfsense-7188fc6db5548d66b24859e7252a1a17e2dac7d4.zip
pfsense-7188fc6db5548d66b24859e7252a1a17e2dac7d4.tar.gz
Add missing functions and move check earlier since this only checks on bootup
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r--etc/inc/system.inc39
1 files changed, 39 insertions, 0 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 2123053..7756113 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -1408,4 +1408,43 @@ function system_identify_specific_platform() {
return array('name' => 'embedded', 'descr' => 'embedded (unknown)');
}
+function system_get_dmesg_boot() {
+ global $g;
+
+ if (!file_exists("{$g['varlog_path']}/dmesg.boot"))
+ system_dmesg_save();
+
+ return file_get_contents("{$g['varlog_path']}/dmesg.boot");
+}
+
+function system_dmesg_save() {
+ global $g;
+
+ if (file_exists("{$g['varlog_path']}/dmesg.boot"))
+ return 0; /* nothing to do */
+
+ exec("/sbin/dmesg", $dmesg);
+
+ /* find last copyright line (output from previous boots may be present) */
+ $lastcpline = 0;
+
+ for ($i = 0; $i < count($dmesg); $i++) {
+ if (strstr($dmesg[$i], "Copyright (c) 1992-"))
+ $lastcpline = $i;
+ }
+
+ $fd = fopen("{$g['varlog_path']}/dmesg.boot", "w");
+ if (!$fd) {
+ printf("Error: cannot open dmesg.boot in system_dmesg_save().\n");
+ return 1;
+ }
+
+ for ($i = $lastcpline; $i < count($dmesg); $i++)
+ fwrite($fd, $dmesg[$i] . "\n");
+
+ fclose($fd);
+
+ return 0;
+}
+
?> \ No newline at end of file
OpenPOWER on IntegriCloud