9boot: list known filesystem images on usb stick as boot filesystems

This commit is contained in:
cinap_lenrek 2011-08-16 04:09:15 +02:00
parent 9884f5f0ed
commit 828f63711b
3 changed files with 36 additions and 41 deletions

View file

@ -25,6 +25,7 @@ if(! bind -a '#u' /dev)
}
}
fn detach {
# handled /sys/src/9/boot/nusbrc
}
rc < '#σ/usb/usbevent' &
}

View file

@ -2,8 +2,7 @@
fn showlocaldevs{
echo local devices found:
for(d in /dev/sd*){
if(test -r $d/ctl){
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-)
@ -22,6 +21,16 @@ fn showlocaldevs{
}
}
}
for(d in /shr/sd*) if(test -d $d) {
echo $d':'
for(p in $d/*.^(iso kfs paq)) if(test -f $p){
t=`{fstype $p}
if(! ~ $t ''){
if(~ $#bootargs 0)
bootargs=local!$p
echo $p $t
}
}
}
}
@ -34,7 +43,7 @@ fn bootfs{
}
fn connectlocal{
if(test -r $1)
if(test -f $1)
t=`{fstype $1}
if not {
t=$1; shift
@ -44,22 +53,10 @@ fn connectlocal{
fatal unknown fstype $1
case 9660
bootfs 9660srv $*
case dos
bootfs dossrv $*
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 $*
}

View file

@ -17,18 +17,15 @@ if(! nusb/usbd)
@{
rfork ne
cd '#σ/usb'
for(dev in sdU^$1.*){
echo $dev...
for(dev in sdU^$1.*) if(test -d $dev) {
diskparts $dev
for(part in $dev/dos* $dev/9fat){
if(test -r $part) {
mkdir -m 0700 '#σc/'^$dev
for(part in $dev/dos* $dev/9fat) if(test -r $part) {
mkdir -m 0700 '#σc/'^$dev || exit
{dossrv -s -f $part &} <[0=1] |
echo 0 >'#σc/'^$dev/dos
exit
}
}
}
} &
}
}