boot(8): merge usb boot method into local

This commit is contained in:
cinap_lenrek 2011-05-02 01:21:55 +00:00
parent 8f7cdfa5e2
commit fa9a40027b
6 changed files with 65 additions and 52 deletions

View file

@ -1,9 +1,15 @@
#!/bin/rc
# set up any disk partitions
rfork e
if (! test -e /dev/sdctl)
bind -b '#S' /dev
# attach partfs to usb disks
for(disk in /dev/sdU*[0-9]){
pdev=`{echo $disk | sed 's,^/dev/(.*),\1p,'}
if(! test -d /dev/$pdev && test -f $disk/data)
disk/partfs -d $pdev $disk/data
}
# 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

View file

@ -1,10 +1,19 @@
#!/bin/rc
rfork e
m=`{dd -if $1 -bs 2048 -skip 16 >[2]/dev/null | xd -c | sed 1q | \
sed 's/.........(....................).*/\1/; s/ //g'}
if(~ $"m 01CD00101){
echo 9660
exit
}
fn fat {
m=`{dd -if $1 -bs 1 -count 3 -skip $2 >[2]/dev/null}
~ $"m FAT
}
if(fat $1 54 || fat $1 82){
echo dos
exit
}
dd -if $1 -count 1 >[2]/dev/null | \
awk '
/^kfs/{fs["kfs"]++}

View file

@ -59,7 +59,6 @@ fn ask {
mt=()
. /rc/lib/tcp.rc
. /rc/lib/local.rc
. /rc/lib/usb.rc
fn main{
mp=()
@ -147,7 +146,6 @@ if(! ~ $#kbmap 0){
for(i in I l`{seq 0 3})
bind -qa '#'$i /net
configusb # run partfs on usb disks
configlocal # add partitions and binds
while(){
@ -157,5 +155,5 @@ while(){
# cleanup so it can be restarted
nobootprompt=()
user=()
rm -f /srv/boot /srv/dosusb /srv/slashn /srv/cs /srv/dns
rm -f /srv/boot /srv/slashn /srv/cs /srv/dns
}

View file

@ -2,42 +2,67 @@
fn showlocaldevs{
echo local devices found:
for(c in /dev/sd*/ctl){
if(test -r $c){
d=`{echo $c | sed 's,/ctl,,g'}
echo $d':' `{sed 's/inquiry[ ]+//g; q' $c}
for(i in `{ls -p $d | grep -v -e 'ctl|raw'}){
for(d in /dev/sd*){
if(test -r $d/ctl){
q=`{sed 's,(inquiry|geometry),\
\1,g' $d/ctl | grep inquiry}
echo $d':' $q(2-)
for(i in `{ls -p $d}){
p=$d/$i
t=`{fstype $p}
if(~ $#bootargs 0 && ! ~ $t '')
bootargs=local!$p
echo $p $t
switch($i){
case ctl raw
;
case 9fat plan9 nvram
echo $p
case *
t=`{fstype $p}
if(~ $#bootargs 0 && ! ~ $t '')
bootargs=local!$p
echo $p $t
}
}
}
}
}
fn configlocal{
if(~ $pcload 1){
kern=`{echo $* | sed 's,.*!(.*)$,\1,g'}
if(~ $#kern 0 || ! ~ $#bootfile 0)
kern=`{echo $bootfile | sed 's,.*!(.*)$,\1,g'}
}
diskparts
}
fn bootfs{
{$1 -s -f $*(2-) &} <[0=1] | echo 0 >/srv/boot
}
fn connectlocal{
t=`{fstype $1}
if(~ $#t 0)
fatal unknown fstype $1
switch($t){
case 9660
t=9660srv
case kfs
t=disk/kfs
if(test -r $1)
t=`{fstype $1}
if not {
t=$1; shift
}
switch($t){
case ''
fatal unknown fstype $1
case 9660
bootfs 9660srv $*
case kfs
bootfs disk/kfs $*
case dos
if(! test -f /srv/dos)
dossrv
m=/mnt/dosboot
must mount /srv/dos $m $1
shift
if(~ $#* 0)
f=$m/9front.iso
if not
f=$m/$1
if(test -r $f)
connectlocal $f
if not
connectlocal $*
case *
bootfs $t $*
}
{$t -s -f $* &} <[0=1] | echo 0 >/srv/boot
}
mlocal=(configlocal connectlocal)

View file

@ -1,24 +0,0 @@
fn configusb{
for(c in /dev/sdU*[0-9]){
d=`{echo $c | sed 's,^/dev/(.*),\1p,g'}
if(! test -d /dev/$d)
disk/partfs -d $d $c/data
}
}
fn connectusb{
m=/mnt/dosusb
if(! test -r $1)
fatal device $1 does not exist
if(! test -r $1/dos)
fatal device $1 does not have a dos partition
mkdir -p $m
dossrv -r -f $1/dos dosusb
mount /srv/dosusb $m
if(! test -r $m/9front.iso)
fatal $m/9front.iso not found
{9660srv -s -f $m/9front.iso &} <[0=1] | echo 0 >/srv/boot
}
musb=(configusb connectusb)
mt=(musb $mt)

View file

@ -40,7 +40,6 @@ rc
rcmain
local.rc 555 sys sys ../boot/local.rc
tcp.rc 555 sys sys ../boot/tcp.rc
usb.rc 555 sys sys ../boot/usb.rc
bin
fstype
diskparts