diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-05-18 17:58:18 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-05-18 17:58:18 -0400 |
commit | 7188fc6db5548d66b24859e7252a1a17e2dac7d4 (patch) | |
tree | a7df745ef91da739e0a4d10f109152646cf9bee9 /etc/inc | |
parent | 2c7d67ff55d4713b174d18c4e30368a908204824 (diff) | |
download | pfsense-7188fc6db5548d66b24859e7252a1a17e2dac7d4.zip pfsense-7188fc6db5548d66b24859e7252a1a17e2dac7d4.tar.gz |
Add missing functions and move check earlier since this only checks on bootup
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/system.inc | 39 |
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 |