Annotation of /tags/mkinitrd-6_5_2/isolinux/checksumiso.pl
Parent Directory | Revision Log
Revision 1133 -
(hide annotations)
(download)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/checksumiso.pl
File MIME type: text/plain
File size: 999 byte(s)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/checksumiso.pl
File MIME type: text/plain
File size: 999 byte(s)
-updated to isolinux-3.86
1 | niro | 532 | #!/usr/bin/perl |
2 | # | ||
3 | # Construct a checksum for isolinux*.bin, compatible | ||
4 | # with an mkisofs boot-info-table | ||
5 | # | ||
6 | |||
7 | use bytes; | ||
8 | use integer; | ||
9 | |||
10 | ($file) = @ARGV; | ||
11 | |||
12 | niro | 1133 | open(FILE, '+<', $file) or die "$0: cannot open $file: $!\n"; |
13 | niro | 532 | binmode FILE; |
14 | |||
15 | niro | 1133 | @fstat = stat(FILE) or die "$0: stat $file: $!\n"; |
16 | if (!$fstat[7]) { | ||
17 | die "$0: $file: cannot query length\n"; | ||
18 | } | ||
19 | |||
20 | # Pad file to a multiple of 2048 bytes | ||
21 | $frac = $fstat[7] % 2048; | ||
22 | if ($frac) { | ||
23 | seek(FILE,$fstat[7],0) | ||
24 | or die "$0: $file: cannot seek to end\n"; | ||
25 | print FILE "\0" x (2048-$frac); | ||
26 | } | ||
27 | |||
28 | # Checksum the file post header | ||
29 | niro | 532 | if ( !seek(FILE,64,0) ) { |
30 | niro | 1133 | die "$0: $file: cannot seek past header\n"; |
31 | niro | 532 | } |
32 | |||
33 | $csum = 0; | ||
34 | $bytes = 64; | ||
35 | while ( ($n = read(FILE, $dw, 4)) > 0 ) { | ||
36 | $dw .= "\0\0\0\0"; # Pad to at least 32 bits | ||
37 | ($v) = unpack("V", $dw); | ||
38 | $csum = ($csum + $v) & 0xffffffff; | ||
39 | $bytes += $n; | ||
40 | } | ||
41 | |||
42 | niro | 1133 | # Update header |
43 | niro | 532 | if ( !seek(FILE,16,0) ) { |
44 | niro | 1133 | die "$0: $file: cannot seek to header\n"; |
45 | niro | 532 | } |
46 | |||
47 | print FILE pack("VV", $bytes, $csum); | ||
48 | |||
49 | close(FILE); | ||
50 | |||
51 | exit 0; |
Properties
Name | Value |
---|---|
svn:executable | * |