You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

makelilo.pl 872B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/perl -w
  2. use constant SYSSIZE_LOC => 500; # bytes from beginning of boot block
  3. use constant MINSIZE => 32768;
  4. use strict;
  5. use bytes;
  6. $#ARGV >= 1 or die "Usage: $0 liloprefix file ...\n";
  7. open(L, "$ARGV[0]") or die "$ARGV[0]: $!\n";
  8. undef($/);
  9. my $liloprefix = <L>;
  10. close(L);
  11. length($liloprefix) >= 512 or die "LILO prefix too short\n";
  12. shift(@ARGV);
  13. my $totalsize = 0;
  14. for my $file (@ARGV) {
  15. next if (! -f $file or ! -r $file);
  16. $totalsize += -s $file;
  17. }
  18. my $pad = 0;
  19. if ($totalsize < MINSIZE) {
  20. $pad = MINSIZE - $totalsize;
  21. $totalsize = MINSIZE;
  22. }
  23. print STDERR "LILO payload is $totalsize bytes\n";
  24. $totalsize += 16;
  25. $totalsize >>= 4;
  26. substr($liloprefix, SYSSIZE_LOC, 2) = pack('v', $totalsize);
  27. print $liloprefix;
  28. for my $file (@ARGV) {
  29. next unless open(I, "$file");
  30. undef($/);
  31. my $data = <I>;
  32. print $data;
  33. close(I);
  34. }
  35. print "\x0" x $pad;
  36. exit(0);