aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-09-05 14:47:22 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-09-05 14:47:22 -0700
commit1587d4f8ead28ec79b4485db54147fa97fb86ef4 (patch)
tree4fedc0175bb59f70da56157c2b71a0be6cd248cf /core
parentac48d360b5b456f60ec87556bbf62646f5bcafbb (diff)
downloadsyslinux-elf-1587d4f8ead28ec79b4485db54147fa97fb86ef4.tar.gz
syslinux-elf-1587d4f8ead28ec79b4485db54147fa97fb86ef4.tar.xz
syslinux-elf-1587d4f8ead28ec79b4485db54147fa97fb86ef4.zip
checksumiso: pad isolinux.bin to a sector boundary
Always pad isolinux.bin to a full CD-ROM sector boundary. This avoids a lot of potential special cases. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core')
-rwxr-xr-xcore/checksumiso.pl21
1 files changed, 18 insertions, 3 deletions
diff --git a/core/checksumiso.pl b/core/checksumiso.pl
index b5527428..9b8c3ee5 100755
--- a/core/checksumiso.pl
+++ b/core/checksumiso.pl
@@ -9,11 +9,25 @@ use integer;
($file) = @ARGV;
-open(FILE, '+<', $file) or die "$0: Cannot open $file: $!\n";
+open(FILE, '+<', $file) or die "$0: cannot open $file: $!\n";
binmode FILE;
+@fstat = stat(FILE) or die "$0: stat $file: $!\n";
+if (!$fstat[7]) {
+ die "$0: $file: cannot query length\n";
+}
+
+# Pad file to a multiple of 2048 bytes
+$frac = $fstat[7] % 2048;
+if ($frac) {
+ seek(FILE,$fstat[7],0)
+ or die "$0: $file: cannot seek to end\n";
+ print FILE "\0" x (2048-$frac);
+}
+
+# Checksum the file post header
if ( !seek(FILE,64,0) ) {
- die "$0: Cannot seek past header\n";
+ die "$0: $file: cannot seek past header\n";
}
$csum = 0;
@@ -25,8 +39,9 @@ while ( ($n = read(FILE, $dw, 4)) > 0 ) {
$bytes += $n;
}
+# Update header
if ( !seek(FILE,16,0) ) {
- die "$0: Cannot seek to header\n";
+ die "$0: $file: cannot seek to header\n";
}
print FILE pack("VV", $bytes, $csum);