diff options
author | hpa <hpa> | 2004-12-09 06:27:12 +0000 |
---|---|---|
committer | hpa <hpa> | 2004-12-09 06:27:12 +0000 |
commit | 46898c5d701d3c9e31649da002346af7c53e7adf (patch) | |
tree | 8d829d7f0ac48d5856928401cb2cd516b9dac07b /checksumiso.pl | |
parent | 1ba37ec73d2ad7fc4b55622eb5e7cf0ef42f60ec (diff) | |
download | syslinux-46898c5d701d3c9e31649da002346af7c53e7adf.tar.gz |
Support non-mkisofs mastering programssyslinux-2.12-pre11
Diffstat (limited to 'checksumiso.pl')
-rwxr-xr-x | checksumiso.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/checksumiso.pl b/checksumiso.pl new file mode 100755 index 00000000..b5527428 --- /dev/null +++ b/checksumiso.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# +# Construct a checksum for isolinux*.bin, compatible +# with an mkisofs boot-info-table +# + +use bytes; +use integer; + +($file) = @ARGV; + +open(FILE, '+<', $file) or die "$0: Cannot open $file: $!\n"; +binmode FILE; + +if ( !seek(FILE,64,0) ) { + die "$0: Cannot seek past header\n"; +} + +$csum = 0; +$bytes = 64; +while ( ($n = read(FILE, $dw, 4)) > 0 ) { + $dw .= "\0\0\0\0"; # Pad to at least 32 bits + ($v) = unpack("V", $dw); + $csum = ($csum + $v) & 0xffffffff; + $bytes += $n; +} + +if ( !seek(FILE,16,0) ) { + die "$0: Cannot seek to header\n"; +} + +print FILE pack("VV", $bytes, $csum); + +close(FILE); + +exit 0; |