X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=misc%2Ftest_vm%2Fscripts%2Fpad;fp=misc%2Ftest_vm%2Fscripts%2Fpad;h=c1c5329a72807f7c19d6988f700ef6851c96355e;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/misc/test_vm/scripts/pad b/misc/test_vm/scripts/pad new file mode 100755 index 0000000..c1c5329 --- /dev/null +++ b/misc/test_vm/scripts/pad @@ -0,0 +1,30 @@ +#! /usr/bin/perl + +# Pad a file with zero bytes to make its length +# an even multiple of some value. + +# $Revision: 1.1 $ + +use strict qw(refs vars); +use FileHandle; + +if ( scalar(@ARGV) != 2 ) { + print STDERR "usage: pad \n"; + exit 1; +} + +my $filename = shift @ARGV; +my $multiple = shift @ARGV; + +my $size = (-s $filename); +die "Couldn't get size of $filename: $!" if ( !defined $size ); + +my $num_pad = ($multiple - ($size % $multiple)) % $multiple; + +my $buf = chr(0) x $num_pad; + +my $fh = new FileHandle(">>$filename"); +die "Couldn't open $filename: $!" if ( !defined $fh ); +binmode $fh; +syswrite $fh, $buf, $num_pad, 0; +$fh->close();