diskparts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/rc
  2. # diskparts [/dev/sd?? ...] - set up any disk partitions
  3. rfork e
  4. if (! test -e /dev/sdctl)
  5. bind -b '#S' /dev
  6. if (~ $#* 0)
  7. *=`{ls -d /dev/sd* | uniq}
  8. bind -a /bin/disk /bin >[2]/dev/null # work with /boot too
  9. # set up any /dev/sd partitions.
  10. # note that really big disks (e.g., aoe devices) may have no mbr
  11. # partition table because the mbr partition table can't cope with large
  12. # block numbers, so we may have to examine the data file with prep if
  13. # there's no plan9 file. beware that `disk/prep -p data' on a disk with
  14. # no plan 9 partition table will delete all extant partitions.
  15. for(disk in /dev/sd?[0-9]) {
  16. if(test -f $disk/data && test -f $disk/ctl){
  17. disk/fdisk -p $disk/data >$disk/ctl >[2]/dev/null
  18. if(test -f $disk/plan9){
  19. for(part in $disk/plan9*)
  20. disk/prep -p $part >$disk/ctl >[2]/dev/null
  21. }
  22. if not{
  23. part=$disk/data
  24. if(! disk/prep -p $part>[2=1] | grep -s '^no plan 9')
  25. disk/prep -p $part >$disk/ctl >[2]/dev/null
  26. parts=($disk/data)
  27. }
  28. }
  29. }
  30. sysname=`{cat /dev/sysname}
  31. # set up any fs(3) partitions
  32. if (! test -e /dev/fs/ctl && test -e '#k/fs')
  33. bind -b '#k' /dev
  34. if (~ $#sysname 1 && ! ~ $sysname '' &&
  35. test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
  36. read -m /cfg/$sysname/fsconfig >/dev/fs/ctl