1
0

funcs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/rc
  2. # funcs - rc functions and definitions common to dump scripts
  3. fn backupinit {
  4. if (! ~ $backupinitdone yes) {
  5. disc=1
  6. tracks=0
  7. # tunable parameters
  8. set=set1
  9. fs=pie
  10. arenas=/dev/sde0/arena0 # on $fs
  11. rdev=/dev/sdE1 # on terminal with bd burner
  12. blocksize=8192
  13. arenasize=1073741824 # twice the venti default, on yoshimi & pie
  14. # trackbytes=$arenasize
  15. # discbytes=`{ls -l $rdev/data | awk '{print $6}'}
  16. # ntracks=`{ hoc -e 'int('$discbytes/$trackbytes')' }
  17. ntracks=45 # for BD dual-layer
  18. backupinitdone=yes
  19. backups=/sys/lib/backup
  20. path=(/bin $backups .)
  21. }
  22. }
  23. # assume we're in $backups/$set
  24. fn updprog {
  25. echo 'disc='$disc 'tracks='$tracks >ndisc && mv ndisc disc
  26. }
  27. # assumes $set is set
  28. fn dumpdone { # arena-part arena-name
  29. @ {
  30. cd $backups/$set
  31. progress=yes
  32. tracks = `{hoc -e $tracks+1}
  33. updprog
  34. if (~ $debug yes)
  35. echo $2 >>fake # pretend these are sealed
  36. echo $2 >>ondisc
  37. }
  38. }
  39. fn quitonfailure { # exit-status
  40. if (! ~ $1 '' 0 '|')
  41. exit $1
  42. }
  43. # caller sets arenabase first
  44. fn arenastart { # arena#
  45. bytes = `{ echo $arenabase' + ('$1' * '$arenasize')' | bc }
  46. blocks = `{ echo $bytes' / '$blocksize | bc }
  47. echo $blocks
  48. }
  49. backupinit