summaryrefslogtreecommitdiffstats
path: root/src/util/padimg.pl
diff options
context:
space:
mode:
authorMichael Brown2009-04-16 06:59:44 +0200
committerMichael Brown2009-04-16 07:01:07 +0200
commit7aee624881ec3cf05d23cdeb9bccf2411a2081c1 (patch)
treed9136ff26b8466dee5fb39f70977747ec307347d /src/util/padimg.pl
parent[build] Pad .rom, .dsk, and .hd images to 512-byte boundaries (diff)
downloadipxe-7aee624881ec3cf05d23cdeb9bccf2411a2081c1.tar.gz
ipxe-7aee624881ec3cf05d23cdeb9bccf2411a2081c1.tar.xz
ipxe-7aee624881ec3cf05d23cdeb9bccf2411a2081c1.zip
[build] Reinstate the .pdsk padded-floppy image format
Some utilities that expect a floppy disk image (e.g. iLO?) may test for a file of the correct size. Reinstate the .pdsk image format in order to provide this if needed.
Diffstat (limited to 'src/util/padimg.pl')
-rwxr-xr-xsrc/util/padimg.pl7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/padimg.pl b/src/util/padimg.pl
index f3dcbbc3..71d0eee8 100755
--- a/src/util/padimg.pl
+++ b/src/util/padimg.pl
@@ -23,8 +23,8 @@ GetOptions ( { map { /^(\w+)/; $1 => $opts->{$_} } keys %$opts }, keys %$opts )
while ( my $filename = shift ) {
die "$filename is not a file\n" unless -f $filename;
my $oldsize = -s $filename;
- my $newsize = ( ( $oldsize + $blksize - 1 ) & ~( $blksize - 1 ) );
- my $padsize = ( $newsize - $oldsize );
+ my $padsize = ( ( -$oldsize ) % $blksize );
+ my $newsize = ( $oldsize + $padsize );
next unless $padsize;
if ( $verbosity >= 1 ) {
printf "Padding %s from %d to %d bytes with %d x 0x%02x\n",
@@ -40,5 +40,6 @@ while ( my $filename = shift ) {
truncate $filename, $newsize
or die "Could not resize $filename: $!\n";
}
- die "Failed to pad $filename\n" unless -s $filename == $newsize;
+ die "Failed to pad $filename\n"
+ unless ( ( ( -s $filename ) % $blksize ) == 0 );
}