Something for the contrib directory

Heath Kehoe hakehoe at
Fri Nov 12 22:05:27 UTC 1999

Hi, all...

This is a small perl script I wrote to ease the creation of cnfs
buffers.  This was necessary because HP/UX doesn't have a /dev/zero,
so the example dd commands shown in the documentation won't work.
I figure we could just stick it in to the contrib directory...
(call it "mkbuf")

Usage is pretty easy, just say:
  mkbuf 2000000 buffer
to make a (slightly less than) 2G buffer.  The argument is the size
in K, which is the same as what you'll put in your cycbuff.conf.

If you've got largefiles support (but your perl doesn't) this might
still work:
  mkbuf 8000000 - > buffer

If your perl does do largefiles, you can just say:
  mkbuf 8000000 buffer



sub usage {
	print STDERR "Usage: $0 <size in KB> <filename>\n";
	exit 1;

usage if(@ARGV != 2);

$buf1k = "\0"x1024;
$buf1m = "$buf1k"x1024;

$kb = $ARGV[0] * 1;
&usage if($kb == 0);

if($ARGV[1] eq '-') {
	open(FILE, "|cat") or die;
} else {
	open(FILE, ">$ARGV[1]") or die;

for($i = 0; $i+1024 <= $kb; $i+=1024) {
	print FILE $buf1m or die;
if($i < $kb) {
	print FILE "$buf1k"x($kb-$i) or die;

close FILE;

More information about the inn-workers mailing list