diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-05-18 18:03:02 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-05-18 18:03:02 -0400 |
commit | 31c9379c46455d7cf1bb9977ab30f7196cba2d10 (patch) | |
tree | ad5c1be64b517b98069f23487d340f54b66166b7 /etc/inc/system.inc | |
parent | fa83737d06c403f3d49c405052a1ec97fbf8146a (diff) | |
download | pfsense-31c9379c46455d7cf1bb9977ab30f7196cba2d10.zip pfsense-31c9379c46455d7cf1bb9977ab30f7196cba2d10.tar.gz |
Add back needed functions
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r-- | etc/inc/system.inc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index da34e66..c8d200f 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -1345,6 +1345,8 @@ function system_check_reset_button() { if(!$g['platform'] == "nanobsd") return 0; + $specplatform = system_identify_specific_platform(); + if ($specplatform['name'] != "wrap" && $specplatform['name'] != "alix") return 0; @@ -1371,4 +1373,82 @@ EOD; return 0; } +/* attempt to identify the specific platform (for embedded systems) + Returns an array with two elements: + name => platform string (e.g. 'wrap', 'alix' etc.) + descr => human-readable description (e.g. "PC Engines WRAP") +*/ +function system_identify_specific_platform() { + global $g; + + if ($g['platform'] == 'generic-pc') + return array('name' => 'generic-pc', 'descr' => "Generic PC"); + + if ($g['platform'] == 'generic-pc-cdrom') + return array('name' => 'generic-pc-cdrom', 'descr' => "Generic PC (CD-ROM)"); + + /* the rest of the code only deals with 'embedded' platforms */ + if ($g['platform'] != 'embedded') + return array('name' => $g['platform'], 'descr' => $g['platform']); + + $dmesg = system_get_dmesg_boot(); + + if (strpos($dmesg, "PC Engines WRAP") !== false) + return array('name' => 'wrap', 'descr' => 'PC Engines WRAP'); + + if (strpos($dmesg, "PC Engines ALIX") !== false) + return array('name' => 'alix', 'descr' => 'PC Engines ALIX'); + + if (preg_match("/Soekris net45../", $dmesg, $matches)) + return array('name' => 'net45xx', 'descr' => $matches[0]); + + if (preg_match("/Soekris net48../", $dmesg, $matches)) + return array('name' => 'net48xx', 'descr' => $matches[0]); + + if (preg_match("/Soekris net55../", $dmesg, $matches)) + return array('name' => 'net55xx', 'descr' => $matches[0]); + + /* unknown embedded 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 |