conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/rc
  2. # THIS FILE IS AUTOMATICALLY GENERATED
  3. # FROM /sys/src/cmd/fossil/conf.rc. DO NOT EDIT.
  4. # the venti configuration is stored at the 248kB offset in the first index
  5. # partition and extends for at most 8 kB.
  6. rfork e
  7. fn usage {
  8. echo 'usage: venti/conf [-w] /dev/sdC0/v.arenas' >[1=2]
  9. exit usage
  10. }
  11. wflag=no
  12. while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
  13. switch($1){
  14. case -w
  15. wflag=yes
  16. case *
  17. usage
  18. }
  19. shift
  20. }
  21. if(~ $1 --)
  22. shift
  23. if(~ $wflag no && ! ~ $#* 1)
  24. usage
  25. if(~ $wflag yes && ! ~ $#* 1 2)
  26. usage
  27. disk=$1
  28. if(! test -f $disk){
  29. echo 'unknown disk' $1 >[1=2]
  30. exit nodisk
  31. }
  32. fn sigexit {
  33. #rm -f /tmp/venticonf.$pid
  34. }
  35. if(~ $wflag yes){
  36. {echo venti config; cat $2} >/tmp/venticonf.$pid || exit oops
  37. if(! test -s /tmp/venticonf.$pid){
  38. echo 'config is empty; will not install' >[1=2]
  39. exit emptyconfig
  40. }
  41. if(test `{ls -l /tmp/venticonf.$pid | awk '{print $6}'} -gt 8192){
  42. echo 'config is too long; max is a little less than eight kilobytes' >[1=2]
  43. exit toolong
  44. }
  45. dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 \
  46. >/tmp/_venticonf.old || exit backup
  47. dd -quiet 1 -count 2 </dev/zero >> /tmp/venticonf.$pid || exit dd
  48. dd -quiet 1 -bs 1024 -count 8 -if /tmp/venticonf.$pid \
  49. -of $disk -trunc 0 -oseek 248 || exit dd2
  50. exit 0
  51. }
  52. dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 |
  53. aux/zerotrunc >/tmp/venticonf.$pid
  54. if(! cmp <{sed 1q /tmp/venticonf.$pid} <{echo venti config}){
  55. echo 'config has bad header' >[1=2]
  56. exit badconfig
  57. }
  58. sed 1d /tmp/venticonf.$pid
  59. exit 0