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