X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FInitRD%2FGenerateInitRD.php;h=03b7d81a3591fe0e07fb7f5b32b129e828c1ba6a;hb=c4af47e284ab94dc5e365b02f7d91e43f7880280;hp=d89d6e9cc153241d282ff134d87c415b050ddd6e;hpb=923a9dc473851ec2bb1c94021bbf139724e7e8a5;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/InitRD/GenerateInitRD.php b/Modules/Filesystems/InitRD/GenerateInitRD.php index d89d6e9c..03b7d81a 100644 --- a/Modules/Filesystems/InitRD/GenerateInitRD.php +++ b/Modules/Filesystems/InitRD/GenerateInitRD.php @@ -1,10 +1,24 @@ + + * Generated $lGenDate */ #include "initrd.h" - 3 ? $argv[3] : false); + +$gDependencies = array(); + $lines = file($argv[1]); $lDepth = 0; @@ -13,6 +27,7 @@ $lStack = array( array("",array()) ); foreach($lines as $line) { $line = trim($line); + // Directory if(preg_match('/^Dir\s+"([^"]+)"\s+{$/', $line, $matches)) { $new = array($matches[1], array()); @@ -20,47 +35,65 @@ foreach($lines as $line) $lDepth ++; continue; } + // End of a block if($line == "}") { $lDepth --; $lStack[$lDepth][1][] = array_pop($lStack); continue; } + // File if(preg_match('/^File\s+"([^"]+)"\s+"([^"]+)"$/', $line, $matches)) { $lStack[$lDepth][1][] = array($matches[1], $matches[2]); continue; } + echo "ERROR: $line\n"; + exit(0); } function hd($fp) +{ + //return "0x".str_pad( dechex(ord(fgetc($fp))), 8, "0", STR_PAD_LEFT ); + $val = unpack("I", fread($fp, 4)); + //print_r($val); exit -1; + return "0x".dechex($val[1]); +} + +function hd8($fp) { return "0x".str_pad( dechex(ord(fgetc($fp))), 2, "0", STR_PAD_LEFT ); } +$inode = 0; function ProcessFolder($prefix, $items) { + global $gOutput, $gDependencies; + global $ACESSDIR, $ARCH; + global $inode; foreach($items as $i=>$item) { - if(is_array($item[1])) { - + $inode ++; + if(is_array($item[1])) + { ProcessFolder("{$prefix}_{$i}", $item[1]); - echo "tInitRD_File {$prefix}_{$i}_entries[] = {\n"; + $gOutput .= "tInitRD_File {$prefix}_{$i}_entries[] = {\n"; foreach($item[1] as $j=>$child) { - if($j) echo ",\n"; - echo "\t{\"".addslashes($child[0])."\",&{$prefix}_{$i}_{$j}}"; + if($j) $gOutput .= ",\n"; + $gOutput .= "\t{\"".addslashes($child[0])."\",&{$prefix}_{$i}_{$j}}"; } - echo "\n};\n"; + $gOutput .= "\n};\n"; $size = count($item[1]); - echo <<$child) { - if($j) echo ",\n"; - echo "\t{\"".addslashes($child[0])."\",&gInitRD_Files_{$j}}"; + if($j) $gOutput .= ",\n"; + $gOutput .= "\t{\"".addslashes($child[0])."\",&gInitRD_Files_{$j}}"; } -echo "\n};\n"; -?> +$gOutput .= "\n};\n"; +$nRootFiles = count($lStack[0][1]); +$gOutput .= <<, + .Size = $nRootFiles, .ImplPtr = gInitRD_Root_Files, .ReadDir = InitRD_ReadDir, .FindDir = InitRD_FindDir }; +EOF; + +$gOutput .= <<$item) + { + $gOutput .= ",&{$prefix}_{$i}"; + if(is_array($item[1])) + { + PutNodePointers("{$prefix}_{$i}", $item[1]); + } + } +} + +PutNodePointers("gInitRD_Files", $lStack[0][1]); + +$gOutput .= <<