summaryrefslogtreecommitdiff
path: root/rc/bin/diskparts
blob: 3f2c6b72506e20804d27ace170d5e35cd62c5068 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/rc
rfork e

# set up any disk partitions
if (! test -e /dev/sdctl)
	bind -b '#S' /dev

# set up any /dev/sd partitions.
# note that really big disks (e.g., aoe devices) may have no mbr
# partition table because the mbr partition table can't cope with large
# block numbers, so we may have to examine the data file with prep if
# there's no plan9 file.  beware that `disk/prep -p data' on a disk with
# no plan 9 partition table will delete all extant partitions.
for(disk in /dev/sd*) {
	if(test -f $disk/data && test -f $disk/ctl)
		{ disk/fdisk -p $disk/data |
			grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
	if(test -f $disk/plan9)
		parts=($disk/plan9*)
	if not
		parts=($disk/data)
	for(part in $parts)
		if(test -f $part)
			 { disk/prep -p $part |
				grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
}

sysname=`{cat /dev/sysname}

# set up any fs(3) partitions
if (! test -e /dev/fs/ctl && test -e '#k/fs')
	bind -b '#k' /dev
if (~ $#sysname 1 && ! ~ $sysname '' &&
    test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
	awk '{print $0; fflush}' /cfg/$sysname/fsconfig >/dev/fs/ctl