1
0
mirror of https://github.com/fspc/gbootroot.git synced 2025-02-24 09:23:23 -05:00

Worked out lots of issues with mem, even using POSIX, tested well for mtdram,

interface is almost there.
This commit is contained in:
freesource 2002-03-06 07:40:33 +00:00
parent 07694a9bf1
commit 7fcb2ca973

View File

@ -30,6 +30,7 @@ use Exporter;
@EXPORT = qw(start); @EXPORT = qw(start);
use strict; use strict;
use POSIX;
use BootRoot::Yard; use BootRoot::Yard;
use BootRoot::YardBox; use BootRoot::YardBox;
use BootRoot::Error; use BootRoot::Error;
@ -1676,10 +1677,10 @@ sub uml_box {
$mtd_size->show(); $mtd_size->show();
# Watch size if an actual file on open # Watch size if an actual file on open
if ( -f "$tmp/$entry_advanced[4]" ) { if ( -f "$tmp/$entry_advanced[4]" ) {
my $stat_size = (stat("$tmp/$entry_advanced[4]"))[12]/2; my $stat_size = (stat("$tmp/$entry_advanced[4]"))[12]/2;
my $blocks = ($stat_size + ( $stat_size * 0.30 ))/1024; my $blocks = ($stat_size + ( $stat_size * 0.30 ))/1024;
$blocks = sprintf("%.f",$blocks); $blocks = sprintf("%.f",$blocks);
$mtd_total_size = $blocks * 1024; $mtd_total_size = $blocks * 1024;
} }
$eab3->signal_connect( "changed", sub { $eab3->signal_connect( "changed", sub {
my $root_fs = (split(/ubd0=/,$entry_advanced[10]))[1]; my $root_fs = (split(/ubd0=/,$entry_advanced[10]))[1];
@ -1765,39 +1766,13 @@ sub uml_box {
} }
# MTD? # MTD?
if ( $mtd_check->get_active() ) { #########
# Check for the existence of root=/dev/ram0
for ( $entry_advanced[9],$entry_advanced[10] ) {
info(0,"$_");
}
}
unless ($pid = fork) {
unless (fork) {
if ($pid == 0) {
sys("$entry_advanced[8] $entry_advanced[5] $entry_advanced[9] $entry_advanced[10]");
Gtk->_exit($pid);
}
}
}
waitpid($pid,0);
}
else {
# MTD? .. testing location
if ( $mtd_check->get_active() ) { if ( $mtd_check->get_active() ) {
# Everything becomes an option for Initrd to parse # Everything becomes an option for Initrd to parse
# and is put on the options[9] line # and is put on the options[9] line
my ($initrd, $ram, $mem); my ($initrd, $ram, $mem, $root, $ramdisk_size);
for ( $entry_advanced[10],$entry_advanced[9] ) { for ( $entry_advanced[10],$entry_advanced[9] ) {
@ -1806,8 +1781,17 @@ sub uml_box {
if ( m,root=/dev/ram, ) { if ( m,root=/dev/ram, ) {
$ram = 1; $ram = 1;
} }
# Check for the existence of root=/dev/ram0
if ( m,ramdisk_size=, ) {
$ramdisk_size = 1;
}
# Check for the existence of root=
if ( m,root=, ) {
$root = 1;
}
# Check for the existence of initrd= # Check for the existence of initrd=
if ( m,initrd=, ) { if ( m,initrd=, ) {
m,(initrd=[/\d\w-]+),; m,(initrd=[/\d\w-]+),;
@ -1839,7 +1823,6 @@ sub uml_box {
} }
# Set a ram block if necessary # Set a ram block if necessary
if ( !$ram ) { if ( !$ram ) {
for ( $entry_advanced[10],$entry_advanced[9] ) { for ( $entry_advanced[10],$entry_advanced[9] ) {
if ( m,root=, ) { if ( m,root=, ) {
@ -1847,39 +1830,65 @@ sub uml_box {
} }
} }
} }
if ( !$root ) {
$entry_advanced[9] = "root=/dev/ram0 " . $entry_advanced[9];
}
# Decide what to do with initrd
if ( !$initrd ) {
$initrd = "initrd=Initrd";
}
else {
undef $initrd;
}
# Will use this format # Will use this format
# initrd=Initrd mem=? mtd=type,fs_type,size,erasure # initrd=Initrd mem=? mtd=type,fs_type,size,erasure
# Tell initrd whether it is mtdram or blkmtd, and # Tell initrd whether it is mtdram or blkmtd, and
if ( $mtd_radio_mtdram->get_active() ) { if ( $mtd_radio_mtdram->get_active() ) {
# ramdisk_size
if ( !$ramdisk_size ) {
$ramdisk_size = "ramdisk_size=$total_size";
}
else {
undef $ramdisk_size;
}
# default mem required by mtdram equaling total size # Memory needs to be figure out in 8192K blocks
# otherwise it fails, and it needs to be at least 16384
# for uml.
# mem
my $mem_size;
if ( $total_size < 16384 ) {
$mem_size = 16384;
}
else {
$mem_size = 8192 * ceil($mtd_total_size / 8192);
}
if ( !$mem ) { if ( !$mem ) {
$mem = "mem=$mem_size" . "K";
$mem = "mem=$total_size" . "K";
} }
else { else {
undef $mem; undef $mem;
} }
if ( !$initrd ) { $entry_advanced[9] = "$initrd $mem $ramdisk_size " .
"mtd=mtdram,$fs_type,$total_size,$erasure_size " .
$initrd = "initrd=Initrd"; $entry_advanced[9];
}
$entry_advanced[9] = "$initrd $mem " .
"mtd=mtdram,$fs_type,$total_size,$erasure_size " .
$entry_advanced[9];
} }
else {
if ( !$initrd ) { # blkmtd
else {
$initrd = "initrd=Initrd";
}
$entry_advanced[9] = "$initrd " . $entry_advanced[9] = "$initrd " .
"mtd=blkmtd,$fs_type,$total_size,$erasure_size " . "mtd=blkmtd,$fs_type,$total_size,$erasure_size " .
@ -1887,9 +1896,29 @@ sub uml_box {
} }
info(0,"$entry_advanced[9]\n$entry_advanced[10]\n"); #info(0,"$entry_advanced[9]\n$entry_advanced[10]\n");
} # mtd preparations } # mtd preparations
#############
unless ($pid = fork) {
unless (fork) {
if ($pid == 0) {
sys("$entry_advanced[8] $entry_advanced[5] $entry_advanced[9] $entry_advanced[10]");
Gtk->_exit($pid);
}
}
}
waitpid($pid,0);
}
else {
# MTD .. testing location
if (!$entry_advanced[8]) { if (!$entry_advanced[8]) {
error_window("gBootRoot Error: " . error_window("gBootRoot Error: " .