summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrc/bin/diskparts8
-rwxr-xr-xrc/bin/fstype9
-rw-r--r--sys/src/9/boot/bootrc4
-rw-r--r--sys/src/9/boot/local.rc65
-rw-r--r--sys/src/9/boot/usb.rc24
-rw-r--r--sys/src/9/port/bootfs.proto1
6 files changed, 62 insertions, 49 deletions
diff --git a/rc/bin/diskparts b/rc/bin/diskparts
index 0088f5cc1..a7014ac44 100755
--- a/rc/bin/diskparts
+++ b/rc/bin/diskparts
@@ -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
diff --git a/rc/bin/fstype b/rc/bin/fstype
index c2fd65d9c..e2a46922a 100755
--- a/rc/bin/fstype
+++ b/rc/bin/fstype
@@ -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"]++}
diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc
index ccf864736..4590c4a38 100644
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -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
}
diff --git a/sys/src/9/boot/local.rc b/sys/src/9/boot/local.rc
index 1fd91e481..aeff20f97 100644
--- a/sys/src/9/boot/local.rc
+++ b/sys/src/9/boot/local.rc
@@ -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
+ if(test -r $1)
+ t=`{fstype $1}
+ if not {
+ t=$1; shift
+ }
switch($t){
+ case ''
+ fatal unknown fstype $1
case 9660
- t=9660srv
+ bootfs 9660srv $*
case kfs
- t=disk/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)
diff --git a/sys/src/9/boot/usb.rc b/sys/src/9/boot/usb.rc
deleted file mode 100644
index 659cdf817..000000000
--- a/sys/src/9/boot/usb.rc
+++ /dev/null
@@ -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)
diff --git a/sys/src/9/port/bootfs.proto b/sys/src/9/port/bootfs.proto
index 3e91924ab..62749e365 100644
--- a/sys/src/9/port/bootfs.proto
+++ b/sys/src/9/port/bootfs.proto
@@ -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