plan9fox/sys/src/9/boot/local.rc

54 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/rc
cddevs=()
# fill cddevs with cd or dvd devices
fn findcds{
for(dev in /dev/sd*){
x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $dev/ctl >[2]/dev/null}
if(! ~ $#x 0)
cddevs=($cddevs $dev)
}
}
fn configlocal{
disk=`{echo $methodarg | sed 's,(.*)!.*,\1,g'}
fstype=`{echo $disk | sed 's,.*/(.*)$,\1,g'}
disk=`{echo $disk | sed 's,(.*)/.*$,\1,'}
if(~ $pcload 1){
kern=`{echo $methodarg | sed 's,.*!(.*)$,\1,g'}
# for now we only allow kernels in the same dev/part of $methodargs
if(~ $#kern 0 || ! ~ $#bootfile 0)
kern=`{echo $bootfile | sed 's,.*!(.*)$,\1,g'}
}
bind -a '#c' /dev >/dev/null >[2=1]
bind '#p' /proc >[2=1] >/dev/null >[2=1]
bind -a '#S' /dev >/dev/null >[2=1]
bind -a '#f' /dev >/dev/null >[2=1]
bind -a '#k' /dev >/dev/null >[2=1]
bind -a '#æ' /dev >/dev/null >[2=1]
diskparts
findcds
}
fn connectlocal{
rm -f /srv/boot
switch($fstype){
case fs
connectlocalkfs
case fscache fsworm
must cwfs64x -n boot -f $disk^/$fstype
case data
# test for cd/dvd
x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $disk^/ctl}
if(! ~ $#x 0)
must 9660srv -f $disk^/$fstype boot >/dev/null >[2=1]
case *
fatal unknown partition $fstype
}
}