summaryrefslogtreecommitdiffstats
path: root/src/util/makelilo.pl
diff options
context:
space:
mode:
authorMichael Brown2005-03-08 19:53:11 +0100
committerMichael Brown2005-03-08 19:53:11 +0100
commit3d6123e69ab879c72ff489afc5bf93ef0b7a94ce (patch)
tree9f3277569153a550fa8d81ebd61bd88f266eb8da /src/util/makelilo.pl
downloadipxe-3d6123e69ab879c72ff489afc5bf93ef0b7a94ce.tar.gz
ipxe-3d6123e69ab879c72ff489afc5bf93ef0b7a94ce.tar.xz
ipxe-3d6123e69ab879c72ff489afc5bf93ef0b7a94ce.zip
Initial revision
Diffstat (limited to 'src/util/makelilo.pl')
-rwxr-xr-xsrc/util/makelilo.pl40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util/makelilo.pl b/src/util/makelilo.pl
new file mode 100755
index 000000000..8f995bc46
--- /dev/null
+++ b/src/util/makelilo.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+use constant SYSSIZE_LOC => 500; # bytes from beginning of boot block
+use constant MINSIZE => 32768;
+
+use strict;
+
+use bytes;
+
+$#ARGV >= 1 or die "Usage: $0 liloprefix file ...\n";
+open(L, "$ARGV[0]") or die "$ARGV[0]: $!\n";
+undef($/);
+my $liloprefix = <L>;
+close(L);
+length($liloprefix) >= 512 or die "LILO prefix too short\n";
+shift(@ARGV);
+my $totalsize = 0;
+for my $file (@ARGV) {
+ next if (! -f $file or ! -r $file);
+ $totalsize += -s $file;
+}
+my $pad = 0;
+if ($totalsize < MINSIZE) {
+ $pad = MINSIZE - $totalsize;
+ $totalsize = MINSIZE;
+}
+print STDERR "LILO payload is $totalsize bytes\n";
+$totalsize += 16;
+$totalsize >>= 4;
+substr($liloprefix, SYSSIZE_LOC, 2) = pack('v', $totalsize);
+print $liloprefix;
+for my $file (@ARGV) {
+ next unless open(I, "$file");
+ undef($/);
+ my $data = <I>;
+ print $data;
+ close(I);
+}
+print "\x0" x $pad;
+exit(0);