diff options
author | David du Colombier <0intro@gmail.com> | 2012-01-26 17:33:36 +0100 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2012-01-26 17:33:36 +0100 |
commit | 60d96f2e4385f0b4cee12add6dea545880a0e6a1 (patch) | |
tree | 8b75ff5ece7706d55d4d6696ef0093ba2cc49127 /src/cmd/venti | |
parent | 83b247a771a514792b972216e1ad32ae1f3fc316 (diff) | |
download | plan9port-60d96f2e4385f0b4cee12add6dea545880a0e6a1.tar.gz plan9port-60d96f2e4385f0b4cee12add6dea545880a0e6a1.tar.bz2 plan9port-60d96f2e4385f0b4cee12add6dea545880a0e6a1.zip |
venti: import venti/conf from plan 9
R=rsc
http://codereview.appspot.com/5572066
Diffstat (limited to 'src/cmd/venti')
-rwxr-xr-x | src/cmd/venti/srv/conf.rc | 67 | ||||
-rw-r--r-- | src/cmd/venti/srv/mkfile | 9 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/cmd/venti/srv/conf.rc b/src/cmd/venti/srv/conf.rc new file mode 100755 index 00000000..d5872103 --- /dev/null +++ b/src/cmd/venti/srv/conf.rc @@ -0,0 +1,67 @@ +#!/usr/local/plan9/bin/rc + +# the venti configuration is stored at the 248kB offset in the first index +# partition and extends for at most 8 kB. + +rfork e +fn usage { + echo 'usage: venti/conf [-w] /dev/sdC0/v.arenas' >[1=2] + exit usage +} + +wflag=no +while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){ + switch($1){ + case -w + wflag=yes + case * + usage + } + shift +} +if(~ $1 --) + shift + +if(~ $wflag no && ! ~ $#* 1) + usage +if(~ $wflag yes && ! ~ $#* 1 2) + usage + +disk=$1 +if(! 9 test -f $disk){ + echo 'unknown disk' $1 >[1=2] + exit nodisk +} + +fn sigexit { + #rm -f /tmp/venticonf.$pid +} + +if(~ $wflag yes){ + {echo venti config; cat $2} >/tmp/venticonf.$pid || exit oops + if(! 9 test -s /tmp/venticonf.$pid){ + echo 'config is empty; will not install' >[1=2] + exit emptyconfig + } + if(9 test `{9 ls -l /tmp/venticonf.$pid | awk '{print $6}'} -gt 8192){ + echo 'config is too long; max is a little less than eight kilobytes' >[1=2] + exit toolong + } + 9 dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 \ + >/tmp/_venticonf.old || exit backup + 9 dd -quiet 1 -count 2 </dev/zero >> /tmp/venticonf.$pid || exit dd + 9 dd -quiet 1 -bs 1024 -count 8 -if /tmp/venticonf.$pid \ + -of $disk -trunc 0 -oseek 248 || exit dd2 + exit 0 +} + +9 dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 | + zerotrunc >/tmp/venticonf.$pid + +if(! cmp <{sed 1q /tmp/venticonf.$pid} <{echo venti config}){ + echo 'config has bad header' >[1=2] + exit badconfig +} + +sed 1d /tmp/venticonf.$pid +exit '' diff --git a/src/cmd/venti/srv/mkfile b/src/cmd/venti/srv/mkfile index b11a461a..6a06e3e2 100644 --- a/src/cmd/venti/srv/mkfile +++ b/src/cmd/venti/srv/mkfile @@ -55,6 +55,7 @@ TARG=\ checkarenas\ checkindex\ clumpstats\ + conf\ findscore\ fixarenas\ fmtarenas\ @@ -88,3 +89,11 @@ $SLIB: $LIBOFILES acid:D: lumpcache.acid cat $prereq >$target +$O.conf:D: conf.rc + { + echo '#!/usr/local/plan9/bin/rc' + echo '# THIS FILE IS AUTOMATICALLY GENERATED' + echo '# FROM /usr/local/plan9/src/cmd/venti/srv/conf.rc. DO NOT EDIT.' + echo + sed 1d conf.rc + } >$target && chmod +x $target |