ref: 0087d42a6809902c10abf699d0bea50af64af436
parent: 9d24a107a5ba6a0a9154e335ecae231b94682139
author: cinap_lenrek <cinap_lenrek@localhost>
date: Mon Apr 18 01:58:04 EDT 2011
boot(8): add cwfs support to, restart if mount fails, usbd. cwfs: exit code
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -33,10 +33,9 @@
fn usbinit{
- if(test -f '#u'){
+ if(test -e '#u'){
bind -a '#u' /dev
- # TODO: check access to /dev/usb
- must usbd
+ must usb/usbd
}
}
@@ -48,10 +47,6 @@
}
fn readmethod{
- resp=()
- timeo=5
- found=0
-
echo
echo Storage devices
for(i in /dev/sd??){
@@ -60,13 +55,15 @@
partitions: `{cat $i/ctl | grep part | awk '{print $2}'}
}
+ found=0
while(~ $found 0){
- if(~ $#pcload 0)
- echo -n 'root is from: '
- if not
- echo -n 'kernel is at: '
-
+ timeo=5
+ resp=()
while(~ $#resp 0){
+ if(~ $#pcload 0)
+ echo -n 'root is from: '
+ if not
+ echo -n 'kernel is at: '
resp=`{read}
if(! ~ $status ''){
bootconf # set configuration from file
@@ -74,9 +71,11 @@
bootargs=$nobootprompt
resp=$bootargs
}
- if(~ $resp !rc)
- rc
- timeo=0
+ if(~ $resp !rc){
+ rc -i
+ resp=()
+ }
+ timo=0
}
method=`{echo $resp | awk -F! '{print $1}'}
@@ -86,10 +85,8 @@
if(~ $mtab($i) m^$method)
found = $i
}
-
if(~ $found 0){
echo method $method not found
- resp=()
}
}
@@ -98,25 +95,19 @@
}
fn authentication{
- # in pcload we only need to read the kernel
- if(~ $pcload 1)
- user=none
-
- if(! test -x /boot/factotum){
- if(~ $#user 0)
- user=glenda
- echo -n $user > '#c'/hostowner
- }
-
- if not{
- x=(/boot/factotum -u -sfactotum)
+ if(! test -f /srv/factotum){
+ # in pcload we only need to read the kernel
+ if(~ $pcload 1)
+ user=none
+ x=(auth/factotum -sfactotum)
if(~ $cpuflag 1)
- x=($x -S)
+ x=($x -kS)
+ if not
+ x=($x -u)
if(! ~ $#authaddr 0)
x=($x -a $authaddr)
if(! ~ $#debugfactotum 0)
x=($x -p)
-
must $x
}
}
@@ -126,58 +117,59 @@
echo -n start > '#c'/swap
}
-usbinit # set up usb keyboard, mouse, and disk, if any
-kbmap
+fn main{
+ readmethod
+ $mp($config)
-configlocal # add partitions and binds
+ switch($method){
+ case local
+ islocal=1
+ case hybrid
+ ishybrid=1
+ }
-readmethod
-$mp($config)
+ # authentication agent
+ authentication
-switch($method){
-case local
- islocal=1
-case hybrid
- ishybrid=1
-}
+ # connect to the root file system
+ $mp($connect)
-# authentication agent
-authentication
+ mount -c /srv/boot /root
+ if(~ $pcload 1)
+ echo reboot /root/$kern >/dev/reboot
-# connect to the root file system
-$mp($connect)
+ swapproc
-swapproc
+ # remove part of our temporary root
+ unmount /$cputype/bin /bin
+ /mnt/broot/$cputype/bin/unmount /rc/bin /bin
+ /mnt/broot/$cputype/bin/unmount /boot /bin
+ /mnt/broot/$cputype/bin/unmount /
-mount -c '#s/boot' /root
+ # create the name space, mount the root fs
+ /mnt/broot/$cputype/bin/bind / /
+ /mnt/broot/$cputype/bin/mount -ac '#s/boot' /
-# remove part of our temporary root
-unmount /$cputype/bin /bin
-/mnt/broot/$cputype/bin/unmount /rc/bin /bin
-/mnt/broot/$cputype/bin/unmount /boot /bin
-/mnt/broot/$cputype/bin/unmount /
+ # remove the remaining temporary root
+ /mnt/broot/$cputype/bin/unmount /mnt/broot
-if(~ $pcload 1)
- /boot/echo reboot /root/$kern >/dev/reboot
+ rootdir=/root
-# create the name space, mount the root fs
-/mnt/broot/$cputype/bin/bind / /
-/mnt/broot/$cputype/bin/mount -ac '#s/boot' /
-
-# remove the remaining temporary root
-/mnt/broot/$cputype/bin/unmount /mnt/broot
-
-rootdir=/root
-
-if(~ $#init 0){
- init=/$cputype/init
- if(~ $cpuflag 1)
- init=($init -c)
- if not
- init=($init -t)
- # TODO handle mflag
+ if(~ $#init 0){
+ init=/$cputype/init
+ if(~ $cpuflag 1)
+ init=($init -c)
+ if not
+ init=($init -t)
+ # TODO handle mflag
+ }
+ exec $init
}
-$init
+usbinit # set up usb keyboard, mouse, and disk, if any
+configlocal # add partitions and binds
+kbmap
-
+while(){
+ @{rfork n; main}
+}
--- a/sys/src/9/boot/local.rc
+++ b/sys/src/9/boot/local.rc
@@ -36,11 +36,12 @@
}
fn connectlocal{
+ rm -f /srv/boot
switch($fstype){
- case fossil
- connectlocalfossil
case fs
connectlocalkfs
+ case fscache fsworm
+ must cwfs64x -n boot -f $disk^/$fstype
case data
# test for cd/dvd
x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $disk^/ctl}
@@ -50,23 +51,3 @@
fatal unknown partition $fstype
}
}
-
-fn connectlocalfossil{
- if(! test -x /bin/fossil/fossil){
- echo no fossil
- exit nofossil
- }
-
- partition=$disk^/$fstype
-
- # settime(1, -1, nil)
-
- # make venti available
-
- # start fossil
- echo 'fossil('$partition')...'
- must fossil/fossil -f $partition -c 'srv -A boot' -c 'srv -p fscons'
-}
-
-
-
--- a/sys/src/9/pc/pccd
+++ b/sys/src/9/pc/pccd
@@ -125,8 +125,6 @@
bootdir
bootpccd.out boot
- /386/bin/auth/factotum
/386/bin/bzfs
- /386/bin/echo
/386/bin/mntgen
rootfs.bz2
--- a/sys/src/9/port/bootfs.proto
+++ b/sys/src/9/port/bootfs.proto
@@ -1,6 +1,8 @@
$cputype
bin
9660srv
+ auth
+ factotum
awk
bind
bzfs
@@ -12,8 +14,7 @@
prep
dossrv
echo
- fossil
- fossil
+ cwfs64x
grep
gunzip
hoc
@@ -30,6 +31,8 @@
srv
test
unmount
+ usb
+ usbd
xd
rc
lib
--- a/sys/src/cmd/cwfs/main.c
+++ b/sys/src/cmd/cwfs/main.c
@@ -410,6 +410,9 @@
* processes to read the console
*/
consserve();
+
+ /* success */
+ exits(nil);
}
/*