boot(8): add cwfs support to, restart if mount fails, usbd. cwfs: exit code
This commit is contained in:
parent
9d24a107a5
commit
0087d42a68
5 changed files with 85 additions and 108 deletions
|
@ -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){
|
||||
timeo=5
|
||||
resp=()
|
||||
while(~ $#resp 0){
|
||||
if(~ $#pcload 0)
|
||||
echo -n 'root is from: '
|
||||
if not
|
||||
echo -n 'kernel is at: '
|
||||
|
||||
while(~ $#resp 0){
|
||||
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{
|
||||
if(! test -f /srv/factotum){
|
||||
# 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)
|
||||
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
|
||||
switch($method){
|
||||
case local
|
||||
islocal=1
|
||||
case hybrid
|
||||
case hybrid
|
||||
ishybrid=1
|
||||
}
|
||||
}
|
||||
|
||||
# authentication agent
|
||||
authentication
|
||||
# authentication agent
|
||||
authentication
|
||||
|
||||
# connect to the root file system
|
||||
$mp($connect)
|
||||
# connect to the root file system
|
||||
$mp($connect)
|
||||
|
||||
swapproc
|
||||
mount -c /srv/boot /root
|
||||
if(~ $pcload 1)
|
||||
echo reboot /root/$kern >/dev/reboot
|
||||
|
||||
mount -c '#s/boot' /root
|
||||
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 /
|
||||
# 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 /
|
||||
|
||||
if(~ $pcload 1)
|
||||
/boot/echo reboot /root/$kern >/dev/reboot
|
||||
# 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){
|
||||
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}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -410,6 +410,9 @@ main(int argc, char **argv)
|
|||
* processes to read the console
|
||||
*/
|
||||
consserve();
|
||||
|
||||
/* success */
|
||||
exits(nil);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue