Browse Source

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

interface is almost there.
master
freesource 23 years ago
parent
commit
7fcb2ca973
  1. 131
      BootRoot/BootRoot.pm

131
BootRoot/BootRoot.pm

@ -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] ) {
@ -1807,6 +1782,15 @@ sub uml_box {
$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=, ) {
@ -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() ) {
# default mem required by mtdram equaling total size
if ( !$mem ) {
$mem = "mem=$total_size" . "K"; # ramdisk_size
if ( !$ramdisk_size ) {
$ramdisk_size = "ramdisk_size=$total_size";
} }
else { else {
undef $mem; undef $ramdisk_size;
} }
if ( !$initrd ) { # Memory needs to be figure out in 8192K blocks
# otherwise it fails, and it needs to be at least 16384
# for uml.
$initrd = "initrd=Initrd"; # mem
my $mem_size;
if ( $total_size < 16384 ) {
$mem_size = 16384;
}
else {
$mem_size = 8192 * ceil($mtd_total_size / 8192);
} }
$entry_advanced[9] = "$initrd $mem " . if ( !$mem ) {
"mtd=mtdram,$fs_type,$total_size,$erasure_size " . $mem = "mem=$mem_size" . "K";
$entry_advanced[9]; }
else {
undef $mem;
}
} $entry_advanced[9] = "$initrd $mem $ramdisk_size " .
else { "mtd=mtdram,$fs_type,$total_size,$erasure_size " .
$entry_advanced[9];
if ( !$initrd ) { }
$initrd = "initrd=Initrd"; # blkmtd
} else {
$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: " .

Loading…
Cancel
Save