X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FInitRD%2FGenerateInitRD.php;h=ab6eb600f0454af06001996fc214012156508654;hb=b1873b4cff47aae8ada8cc303ea01b475cc7ccc8;hp=d89d6e9cc153241d282ff134d87c415b050ddd6e;hpb=923a9dc473851ec2bb1c94021bbf139724e7e8a5;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/InitRD/GenerateInitRD.php b/Modules/Filesystems/InitRD/GenerateInitRD.php index d89d6e9c..ab6eb600 100644 --- a/Modules/Filesystems/InitRD/GenerateInitRD.php +++ b/Modules/Filesystems/InitRD/GenerateInitRD.php @@ -1,10 +1,21 @@ + + * Generated $lGenDate */ #include "initrd.h" - 3 ? $argv[3] : false); + +$gDependencies = array(); + $lines = file($argv[1]); $lDepth = 0; @@ -29,33 +40,45 @@ foreach($lines as $line) if(preg_match('/^File\s+"([^"]+)"\s+"([^"]+)"$/', $line, $matches)) { $lStack[$lDepth][1][] = array($matches[1], $matches[2]); + $gDependencies[] = $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 ); } function ProcessFolder($prefix, $items) { + global $gOutput; foreach($items as $i=>$item) { - if(is_array($item[1])) { - + 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; + +$fp = fopen($gOutputFile, "w"); +fputs($fp, $gOutput); +fclose($fp); + + +if($gDepFile !== false) +{ + $fp = fopen($gDepFile, "w"); + $line = $gOutputFile.":\t".implode(" ", $gDependencies); + fputs($fp, $line); + fclose($fp); +} + +?>