X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=misc%2Ftest_vm%2Fscripts%2Fzerofile;fp=misc%2Ftest_vm%2Fscripts%2Fzerofile;h=52e744aa37dd66c90d6db637a49b14bfbfdc6328;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/misc/test_vm/scripts/zerofile b/misc/test_vm/scripts/zerofile new file mode 100755 index 0000000..52e744a --- /dev/null +++ b/misc/test_vm/scripts/zerofile @@ -0,0 +1,31 @@ +#! /usr/bin/perl + +# This script is used for creating a file full of zeroes, +# which we use to create the hard disk image used by bochs. + +use strict qw(refs vars); +use FileHandle; +use IO::Seekable; + +if ( scalar(@ARGV) != 2 ) { + print "Usage: zerofile \n"; + exit 1; +} + +my $outfile = shift @ARGV; +my $numsecs = shift @ARGV; + +my $buf = chr(0) x 1; + +my $fh = new FileHandle(">$outfile"); +(defined $fh) || die "Couldn't open $outfile: $!\n"; +binmode $fh; + +if ( !sysseek( $fh, ($numsecs * 512) - 1, SEEK_SET ) ) { + die "Couldn't seek in $outfile: $!\n"; +} +if ( !syswrite( $fh, $buf, 1 ) ) { + die "Couldn't write to $outfile: $!\n"; +} + +$fh->close();