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