prepdisk 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/rc
  2. # desc: subdivide plan 9 disk partition
  3. # prereq: partdisk
  4. fn autotype {
  5. if(~ $fstype fossil)
  6. echo -a 9fat -a nvram -a fossil -a swap
  7. if(~ $fstype fossil+venti)
  8. echo -a 9fat -a nvram -a arenas -a isect -a fossil -a swap # -a other
  9. }
  10. switch($1) {
  11. case checkready
  12. if(! test -f /dev/sd*/plan9*){
  13. prepdisk=notdone
  14. export prepdisk
  15. }
  16. case go
  17. echo 'The following Plan 9 disk partitions were found.'
  18. echo
  19. disks=(/dev/sd*/plan9*)
  20. for (i in $disks){
  21. echo $i
  22. echo q | disk/prep -r $i >[2]/dev/null
  23. echo
  24. }
  25. if(~ $#disks 1)
  26. default=(-d $disks)
  27. if not
  28. default=()
  29. prompt $default 'Plan 9 partition to subdivide' $disks
  30. disk=$rd
  31. echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
  32. echo 'If it is not yet subdivided, a sensible layout will be suggested;'
  33. echo 'you can probably just type ''w'' and then ''q''.'
  34. echo
  35. disk/prep `{autotype} $disk
  36. disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null
  37. case checkdone
  38. if(! test -f /dev/sd*/9fat)
  39. prepdisk=ready
  40. if(! ~ $prepdisk ready){
  41. prepdisk=done
  42. switch($fstype){
  43. case fossil
  44. if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
  45. prepdisk=ready
  46. case fossil+venti
  47. if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
  48. prepdisk=ready
  49. if(! test -f /dev/sd*/arenas && ! test -f /dev/fs/arenas*)
  50. prepdisk=ready
  51. if(! test -f /dev/sd*/isect && ! test -f /dev/fs/isect*)
  52. prepdisk=ready
  53. }
  54. }
  55. export prepdisk
  56. }