From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Mon, 25 Sep 2006 20:49:45 -0400 From: "Russ Cox" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] venti backup example vs. 2GB In-Reply-To: <432bc0dde71c69a75de5f60bf55915ec@tombob.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <432bc0dde71c69a75de5f60bf55915ec@tombob.com> Topicbox-Message-UUID: c1803a54-ead1-11e9-9d60-3106f5b1d025 You can use %.0f to print the number from awk. Russ On 9/25/06, Robert Raschke wrote: > Hi, > > I've been using a backup script modelled on the example in > /sys/src/cmd/venti/backup.example and the other day it "just" stopped > working. On debugging I found that I have now reached the beginning > of the fifth 500MB arena. The script uses awk to calculate the > starting byte offset and that fails with a floating point error (!) > when we go beyond the 2G mark. > > I resorted to a fairly brutal use of bc(1) and that seems to work. > Here's what I use now (I flipped the 2nd and 3rd parameter to the x fn > to make printing from bc easier): > > #!/bin/rc > > rfork e > . bkup.info > fn x { > echo x $* > y=$1 > if(~ $#$y 0){ > $y=0 > } > echo venti/wrarena -h venti_backup_server -o $3 $2 $$y > end=`{venti/wrarena -h venti_backup_server -o $3 $2 $$y | grep '^end offset ' | sed 's/^end offset //'} > if(~ $#end 1 && ! ~ $$y $end){ > $y=$end > echo '#' `{date} >>bkup.info > whatis $y >>bkup.info > } > } > hget http://127.1:8000/index | > awk ' > /^index=/ { blockSize=0+substr($3, 11); } > /^arena=/ { arena=substr($1, 7); } > /^ arena=/ { > start=substr($5, 2, index($5, ",")-2); > printf("\"x \"; \"%s \"; \"%s \"; s=%s-%s; print s;", arena, $3, start, blockSize); > } > ' |bc -s |rc > > > Robby > >