Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/venti/mkventi

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/usr/local/plan9/bin/rc
# mkventi - prepare venti(7) file system

. 9.rc

fn usage {
	echo >[2=1] 'usage: mkventi [-f] [-a arenasize] [-b blocksize] venti.conf'
	exit usage
}

fn fmtisect  { venti/fmtisect -b $blocksize `{basename $1} $1 }
fn fmtarenas { venti/fmtarenas -a $arenasize -b $blocksize `{basename $1}^. $1 }
fn fmtbloom  { venti/fmtbloom $1 }
fn fmtfiles  {
	files=`{sed /^'#'/d $conf | awk '/'$1'/{print $2}'}
	if(! ~ $#files 0){
		count=''
		while(~ $count ''){
			echo -n $1' size (in blocks): '
			count=`{read}
		}
		for(f in $files){
			if(test -f $f)
				echo >[2=1] $f' exists; skipping'
			if not{
				dd -quiet 1 -if /dev/zero -of $f -bs $blocksize -count $count
				$2 $f && fmtindex=1
			}
		}
	}
}

arenasize=512m
blocksize=8k
fmtindex=0
while(~ $1 -*){
	switch($1){
	case -a
		if(~ $#* 1)
			usage
		arenasize=$2
		shift
	case -b
		if(~ $#* 1)
			usage
		blocksize=$2
		shift
	case -f
		fmtindex=1
	case *
		usage
	}
	shift
}
if(! ~ $#* 1)
	usage

conf=$1
fmtfiles isect fmtisect
fmtfiles arenas fmtarenas
fmtfiles bloom fmtbloom
if(~ $fmtindex 0)
	echo >[2=1] 'fmtindex: no changes; skipping'
if not
	venti/fmtindex $conf
exit ''

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.