boot(8): merge usb boot method into local
This commit is contained in:
parent
8f7cdfa5e2
commit
fa9a40027b
|
@ -1,9 +1,15 @@
|
||||||
#!/bin/rc
|
#!/bin/rc
|
||||||
# set up any disk partitions
|
# set up any disk partitions
|
||||||
rfork e
|
|
||||||
if (! test -e /dev/sdctl)
|
if (! test -e /dev/sdctl)
|
||||||
bind -b '#S' /dev
|
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.
|
# set up any /dev/sd partitions.
|
||||||
# note that really big disks (e.g., aoe devices) may have no mbr
|
# 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
|
# partition table because the mbr partition table can't cope with large
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
#!/bin/rc
|
#!/bin/rc
|
||||||
|
rfork e
|
||||||
m=`{dd -if $1 -bs 2048 -skip 16 >[2]/dev/null | xd -c | sed 1q | \
|
m=`{dd -if $1 -bs 2048 -skip 16 >[2]/dev/null | xd -c | sed 1q | \
|
||||||
sed 's/.........(....................).*/\1/; s/ //g'}
|
sed 's/.........(....................).*/\1/; s/ //g'}
|
||||||
if(~ $"m 01CD00101){
|
if(~ $"m 01CD00101){
|
||||||
echo 9660
|
echo 9660
|
||||||
exit
|
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 | \
|
dd -if $1 -count 1 >[2]/dev/null | \
|
||||||
awk '
|
awk '
|
||||||
/^kfs/{fs["kfs"]++}
|
/^kfs/{fs["kfs"]++}
|
||||||
|
|
|
@ -59,7 +59,6 @@ fn ask {
|
||||||
mt=()
|
mt=()
|
||||||
. /rc/lib/tcp.rc
|
. /rc/lib/tcp.rc
|
||||||
. /rc/lib/local.rc
|
. /rc/lib/local.rc
|
||||||
. /rc/lib/usb.rc
|
|
||||||
|
|
||||||
fn main{
|
fn main{
|
||||||
mp=()
|
mp=()
|
||||||
|
@ -147,7 +146,6 @@ if(! ~ $#kbmap 0){
|
||||||
for(i in I l`{seq 0 3})
|
for(i in I l`{seq 0 3})
|
||||||
bind -qa '#'$i /net
|
bind -qa '#'$i /net
|
||||||
|
|
||||||
configusb # run partfs on usb disks
|
|
||||||
configlocal # add partitions and binds
|
configlocal # add partitions and binds
|
||||||
|
|
||||||
while(){
|
while(){
|
||||||
|
@ -157,5 +155,5 @@ while(){
|
||||||
# cleanup so it can be restarted
|
# cleanup so it can be restarted
|
||||||
nobootprompt=()
|
nobootprompt=()
|
||||||
user=()
|
user=()
|
||||||
rm -f /srv/boot /srv/dosusb /srv/slashn /srv/cs /srv/dns
|
rm -f /srv/boot /srv/slashn /srv/cs /srv/dns
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,42 +2,67 @@
|
||||||
|
|
||||||
fn showlocaldevs{
|
fn showlocaldevs{
|
||||||
echo local devices found:
|
echo local devices found:
|
||||||
for(c in /dev/sd*/ctl){
|
for(d in /dev/sd*){
|
||||||
if(test -r $c){
|
if(test -r $d/ctl){
|
||||||
d=`{echo $c | sed 's,/ctl,,g'}
|
q=`{sed 's,(inquiry|geometry),\
|
||||||
echo $d':' `{sed 's/inquiry[ ]+//g; q' $c}
|
\1,g' $d/ctl | grep inquiry}
|
||||||
for(i in `{ls -p $d | grep -v -e 'ctl|raw'}){
|
echo $d':' $q(2-)
|
||||||
|
for(i in `{ls -p $d}){
|
||||||
p=$d/$i
|
p=$d/$i
|
||||||
t=`{fstype $p}
|
switch($i){
|
||||||
if(~ $#bootargs 0 && ! ~ $t '')
|
case ctl raw
|
||||||
bootargs=local!$p
|
;
|
||||||
echo $p $t
|
case 9fat plan9 nvram
|
||||||
|
echo $p
|
||||||
|
case *
|
||||||
|
t=`{fstype $p}
|
||||||
|
if(~ $#bootargs 0 && ! ~ $t '')
|
||||||
|
bootargs=local!$p
|
||||||
|
echo $p $t
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configlocal{
|
fn configlocal{
|
||||||
if(~ $pcload 1){
|
|
||||||
kern=`{echo $* | sed 's,.*!(.*)$,\1,g'}
|
|
||||||
if(~ $#kern 0 || ! ~ $#bootfile 0)
|
|
||||||
kern=`{echo $bootfile | sed 's,.*!(.*)$,\1,g'}
|
|
||||||
}
|
|
||||||
diskparts
|
diskparts
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bootfs{
|
||||||
|
{$1 -s -f $*(2-) &} <[0=1] | echo 0 >/srv/boot
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connectlocal{
|
fn connectlocal{
|
||||||
t=`{fstype $1}
|
if(test -r $1)
|
||||||
if(~ $#t 0)
|
t=`{fstype $1}
|
||||||
fatal unknown fstype $1
|
if not {
|
||||||
switch($t){
|
t=$1; shift
|
||||||
case 9660
|
}
|
||||||
t=9660srv
|
switch($t){
|
||||||
case kfs
|
case ''
|
||||||
t=disk/kfs
|
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)
|
mlocal=(configlocal connectlocal)
|
||||||
|
|
|
@ -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)
|
|
|
@ -40,7 +40,6 @@ rc
|
||||||
rcmain
|
rcmain
|
||||||
local.rc 555 sys sys ../boot/local.rc
|
local.rc 555 sys sys ../boot/local.rc
|
||||||
tcp.rc 555 sys sys ../boot/tcp.rc
|
tcp.rc 555 sys sys ../boot/tcp.rc
|
||||||
usb.rc 555 sys sys ../boot/usb.rc
|
|
||||||
bin
|
bin
|
||||||
fstype
|
fstype
|
||||||
diskparts
|
diskparts
|
||||||
|
|
Loading…
Reference in a new issue