]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/boot/local.rc
fix bugs and cleanup cryptsetup code
[plan9front.git] / sys / src / 9 / boot / local.rc
old mode 100644 (file)
new mode 100755 (executable)
index 7b5c85c..c999810
@@ -1,23 +1,75 @@
 #!/bin/rc
 
-fn configlocal{
-       disk=`{echo $methodarg | sed 's,(.*)!.*,\1,g'}
-       fstype=`{echo $disk | sed 's,.*/(.*)$,\1,g'}
-       disk=`{echo $disk | sed 's,(.*)/.*$,\1,'}
+fn showlocaldev {
+       echo $1'        ' $2
+       if(~ $#bootargs 0){
+               if(! ~ $#cdboot 0){
+                       if(~ $2 9660)
+                               bootargs=local!$1
+               }
+               if not {
+                       if(! ~ $2 '' dos)
+                               bootargs=local!$1
+               }
+       }
+}
+
+fn showlocaldevs{
+       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
+                       switch($i){
+                       case ctl raw log led
+                               ;
+                       case plan9 nvram swap
+                               echo $p
+                       case *
+                               showlocaldev $p `{fstype $p}
+                       }
+               }
+       }
+       for(d in /shr/sd*) if(test -d $d) {
+               echo $d':'
+               for(p in $d/*.^(iso paq)) if(test -f $p){
+                       t=`{fstype $p}
+                       ~ $#t 0 || showlocaldev $p $t
+               }
+       }
+}
 
+fn configlocal{
        diskparts
 }
 
+fn bootfs{
+       {$1 -s -f $*(2-) &} <[0=1] | echo 0 >/srv/boot
+}
+
 fn connectlocal{
-       rm -f /srv/boot
-       switch($fstype){
-       case kfs fs
-               must disk/kfs -n boot -f $disk^/$fstype 
-       case cwfs fscache fsworm w0 w1 w2 w3
-               must cwfs64x -n boot -f $disk^/$fstype 
-       case data
-               must 9660srv -f $disk^/$fstype boot
-       case *
-               fatal unknown partition $fstype
+       if(~ $#* 0){
+               echo local method needs an argument
+       }
+       if not {
+               if(test -f $1)
+                       t=`{fstype $1}
+               if not {
+                       t=$1; shift
+               }
+               switch($t){
+               case ''
+                       fatal unknown fstype $1
+               case 9660
+                       bootfs 9660srv $*
+               case dos
+                       bootfs dossrv $*
+               case *
+                       bootfs $t $*
+               }
        }
 }
+
+mlocal=(configlocal connectlocal)
+mt=(mlocal $mt)