summaryrefslogtreecommitdiff
path: root/sys/src/9
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-04-18 05:58:04 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-04-18 05:58:04 +0000
commit0087d42a6809902c10abf699d0bea50af64af436 (patch)
treec5f71d1485f5fc3ac611b50bf35a30a029ba51de /sys/src/9
parent9d24a107a5ba6a0a9154e335ecae231b94682139 (diff)
boot(8): add cwfs support to, restart if mount fails, usbd. cwfs: exit code
Diffstat (limited to 'sys/src/9')
-rw-r--r--sys/src/9/boot/bootrc138
-rwxr-xr-xsys/src/9/boot/local.rc25
-rw-r--r--sys/src/9/pc/pccd2
-rw-r--r--sys/src/9/port/bootfs.proto7
4 files changed, 73 insertions, 99 deletions
diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc
index 0ae023aa0..dabc77aca 100644
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -33,10 +33,9 @@ fn must {
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 kbmap{
}
fn readmethod{
- resp=()
- timeo=5
- found=0
-
echo
echo Storage devices
for(i in /dev/sd??){
@@ -60,13 +55,15 @@ fn readmethod{
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 @@ fn readmethod{
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 @@ fn readmethod{
if(~ $mtab($i) m^$method)
found = $i
}
-
if(~ $found 0){
echo method $method not found
- resp=()
}
}
@@ -98,25 +95,19 @@ fn readmethod{
}
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 @@ fn swapproc{
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
-
-readmethod
-$mp($config)
-
-switch($method){
-case local
- islocal=1
-case hybrid
- ishybrid=1
-}
-
-# authentication agent
-authentication
+ switch($method){
+ case local
+ islocal=1
+ case hybrid
+ ishybrid=1
+ }
-# connect to the root file system
-$mp($connect)
+ # authentication agent
+ authentication
-swapproc
+ # connect to the root file system
+ $mp($connect)
-mount -c '#s/boot' /root
+ mount -c /srv/boot /root
+ if(~ $pcload 1)
+ echo reboot /root/$kern >/dev/reboot
-# 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 /
+ swapproc
-if(~ $pcload 1)
- /boot/echo reboot /root/$kern >/dev/reboot
+ # 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 /
-# create the name space, mount the root fs
-/mnt/broot/$cputype/bin/bind / /
-/mnt/broot/$cputype/bin/mount -ac '#s/boot' /
+ # 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
+ # remove the remaining temporary root
+ /mnt/broot/$cputype/bin/unmount /mnt/broot
-rootdir=/root
+ 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}
+}
diff --git a/sys/src/9/boot/local.rc b/sys/src/9/boot/local.rc
index 8e696f6fa..5ba6378c0 100755
--- a/sys/src/9/boot/local.rc
+++ b/sys/src/9/boot/local.rc
@@ -36,11 +36,12 @@ fn configlocal{
}
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 @@ fn connectlocal{
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'
-}
-
-
-
diff --git a/sys/src/9/pc/pccd b/sys/src/9/pc/pccd
index 76dc6afe9..619eda64a 100644
--- a/sys/src/9/pc/pccd
+++ b/sys/src/9/pc/pccd
@@ -125,8 +125,6 @@ boot boot #S/sdD0/data
bootdir
bootpccd.out boot
- /386/bin/auth/factotum
/386/bin/bzfs
- /386/bin/echo
/386/bin/mntgen
rootfs.bz2
diff --git a/sys/src/9/port/bootfs.proto b/sys/src/9/port/bootfs.proto
index 7c050fe08..ea8d4942c 100644
--- 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 @@ $cputype
prep
dossrv
echo
- fossil
- fossil
+ cwfs64x
grep
gunzip
hoc
@@ -30,6 +31,8 @@ $cputype
srv
test
unmount
+ usb
+ usbd
xd
rc
lib