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 { fn detach {
# handled /sys/src/9/boot/nusbrc
} }
rc < '#σ/usb/usbevent' & rc < '#σ/usb/usbevent' &
} }

View file

@ -2,8 +2,7 @@
fn showlocaldevs{ fn showlocaldevs{
echo local devices found: echo local devices found:
for(d in /dev/sd*){ for(d in /dev/sd*) if(test -r $d/ctl){
if(test -r $d/ctl){
q=`{sed 's,(inquiry|geometry),\ q=`{sed 's,(inquiry|geometry),\
\1,g' $d/ctl | grep inquiry} \1,g' $d/ctl | grep inquiry}
echo $d':' $q(2-) 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{ fn connectlocal{
if(test -r $1) if(test -f $1)
t=`{fstype $1} t=`{fstype $1}
if not { if not {
t=$1; shift t=$1; shift
@ -44,22 +53,10 @@ fn connectlocal{
fatal unknown fstype $1 fatal unknown fstype $1
case 9660 case 9660
bootfs 9660srv $* bootfs 9660srv $*
case dos
bootfs dossrv $*
case kfs case kfs
bootfs 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 * case *
bootfs $t $* bootfs $t $*
} }

View file

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