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{
|
fn usbinit{
|
||||||
if(test -f '#u'){
|
if(test -e '#u'){
|
||||||
bind -a '#u' /dev
|
bind -a '#u' /dev
|
||||||
# TODO: check access to /dev/usb
|
must usb/usbd
|
||||||
must usbd
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +47,6 @@ fn kbmap{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn readmethod{
|
fn readmethod{
|
||||||
resp=()
|
|
||||||
timeo=5
|
|
||||||
found=0
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo Storage devices
|
echo Storage devices
|
||||||
for(i in /dev/sd??){
|
for(i in /dev/sd??){
|
||||||
|
@ -60,13 +55,15 @@ fn readmethod{
|
||||||
partitions: `{cat $i/ctl | grep part | awk '{print $2}'}
|
partitions: `{cat $i/ctl | grep part | awk '{print $2}'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found=0
|
||||||
while(~ $found 0){
|
while(~ $found 0){
|
||||||
if(~ $#pcload 0)
|
timeo=5
|
||||||
echo -n 'root is from: '
|
resp=()
|
||||||
if not
|
|
||||||
echo -n 'kernel is at: '
|
|
||||||
|
|
||||||
while(~ $#resp 0){
|
while(~ $#resp 0){
|
||||||
|
if(~ $#pcload 0)
|
||||||
|
echo -n 'root is from: '
|
||||||
|
if not
|
||||||
|
echo -n 'kernel is at: '
|
||||||
resp=`{read}
|
resp=`{read}
|
||||||
if(! ~ $status ''){
|
if(! ~ $status ''){
|
||||||
bootconf # set configuration from file
|
bootconf # set configuration from file
|
||||||
|
@ -74,9 +71,11 @@ fn readmethod{
|
||||||
bootargs=$nobootprompt
|
bootargs=$nobootprompt
|
||||||
resp=$bootargs
|
resp=$bootargs
|
||||||
}
|
}
|
||||||
if(~ $resp !rc)
|
if(~ $resp !rc){
|
||||||
rc
|
rc -i
|
||||||
timeo=0
|
resp=()
|
||||||
|
}
|
||||||
|
timo=0
|
||||||
}
|
}
|
||||||
|
|
||||||
method=`{echo $resp | awk -F! '{print $1}'}
|
method=`{echo $resp | awk -F! '{print $1}'}
|
||||||
|
@ -86,10 +85,8 @@ fn readmethod{
|
||||||
if(~ $mtab($i) m^$method)
|
if(~ $mtab($i) m^$method)
|
||||||
found = $i
|
found = $i
|
||||||
}
|
}
|
||||||
|
|
||||||
if(~ $found 0){
|
if(~ $found 0){
|
||||||
echo method $method not found
|
echo method $method not found
|
||||||
resp=()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,25 +95,19 @@ fn readmethod{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authentication{
|
fn authentication{
|
||||||
# in pcload we only need to read the kernel
|
if(! test -f /srv/factotum){
|
||||||
if(~ $pcload 1)
|
# in pcload we only need to read the kernel
|
||||||
user=none
|
if(~ $pcload 1)
|
||||||
|
user=none
|
||||||
if(! test -x /boot/factotum){
|
x=(auth/factotum -sfactotum)
|
||||||
if(~ $#user 0)
|
|
||||||
user=glenda
|
|
||||||
echo -n $user > '#c'/hostowner
|
|
||||||
}
|
|
||||||
|
|
||||||
if not{
|
|
||||||
x=(/boot/factotum -u -sfactotum)
|
|
||||||
if(~ $cpuflag 1)
|
if(~ $cpuflag 1)
|
||||||
x=($x -S)
|
x=($x -kS)
|
||||||
|
if not
|
||||||
|
x=($x -u)
|
||||||
if(! ~ $#authaddr 0)
|
if(! ~ $#authaddr 0)
|
||||||
x=($x -a $authaddr)
|
x=($x -a $authaddr)
|
||||||
if(! ~ $#debugfactotum 0)
|
if(! ~ $#debugfactotum 0)
|
||||||
x=($x -p)
|
x=($x -p)
|
||||||
|
|
||||||
must $x
|
must $x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,58 +117,59 @@ fn swapproc{
|
||||||
echo -n start > '#c'/swap
|
echo -n start > '#c'/swap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main{
|
||||||
|
readmethod
|
||||||
|
$mp($config)
|
||||||
|
|
||||||
|
switch($method){
|
||||||
|
case local
|
||||||
|
islocal=1
|
||||||
|
case hybrid
|
||||||
|
ishybrid=1
|
||||||
|
}
|
||||||
|
|
||||||
|
# authentication agent
|
||||||
|
authentication
|
||||||
|
|
||||||
|
# connect to the root file system
|
||||||
|
$mp($connect)
|
||||||
|
|
||||||
|
mount -c /srv/boot /root
|
||||||
|
if(~ $pcload 1)
|
||||||
|
echo reboot /root/$kern >/dev/reboot
|
||||||
|
|
||||||
|
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 /
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
exec $init
|
||||||
|
}
|
||||||
|
|
||||||
usbinit # set up usb keyboard, mouse, and disk, if any
|
usbinit # set up usb keyboard, mouse, and disk, if any
|
||||||
|
configlocal # add partitions and binds
|
||||||
kbmap
|
kbmap
|
||||||
|
|
||||||
configlocal # add partitions and binds
|
while(){
|
||||||
|
@{rfork n; main}
|
||||||
readmethod
|
|
||||||
$mp($config)
|
|
||||||
|
|
||||||
switch($method){
|
|
||||||
case local
|
|
||||||
islocal=1
|
|
||||||
case hybrid
|
|
||||||
ishybrid=1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# authentication agent
|
|
||||||
authentication
|
|
||||||
|
|
||||||
# connect to the root file system
|
|
||||||
$mp($connect)
|
|
||||||
|
|
||||||
swapproc
|
|
||||||
|
|
||||||
mount -c '#s/boot' /root
|
|
||||||
|
|
||||||
# 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' /
|
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
$init
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,12 @@ fn configlocal{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connectlocal{
|
fn connectlocal{
|
||||||
|
rm -f /srv/boot
|
||||||
switch($fstype){
|
switch($fstype){
|
||||||
case fossil
|
|
||||||
connectlocalfossil
|
|
||||||
case fs
|
case fs
|
||||||
connectlocalkfs
|
connectlocalkfs
|
||||||
|
case fscache fsworm
|
||||||
|
must cwfs64x -n boot -f $disk^/$fstype
|
||||||
case data
|
case data
|
||||||
# test for cd/dvd
|
# test for cd/dvd
|
||||||
x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $disk^/ctl}
|
x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $disk^/ctl}
|
||||||
|
@ -50,23 +51,3 @@ fn connectlocal{
|
||||||
fatal unknown partition $fstype
|
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
|
bootdir
|
||||||
bootpccd.out boot
|
bootpccd.out boot
|
||||||
/386/bin/auth/factotum
|
|
||||||
/386/bin/bzfs
|
/386/bin/bzfs
|
||||||
/386/bin/echo
|
|
||||||
/386/bin/mntgen
|
/386/bin/mntgen
|
||||||
rootfs.bz2
|
rootfs.bz2
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
$cputype
|
$cputype
|
||||||
bin
|
bin
|
||||||
9660srv
|
9660srv
|
||||||
|
auth
|
||||||
|
factotum
|
||||||
awk
|
awk
|
||||||
bind
|
bind
|
||||||
bzfs
|
bzfs
|
||||||
|
@ -12,8 +14,7 @@ $cputype
|
||||||
prep
|
prep
|
||||||
dossrv
|
dossrv
|
||||||
echo
|
echo
|
||||||
fossil
|
cwfs64x
|
||||||
fossil
|
|
||||||
grep
|
grep
|
||||||
gunzip
|
gunzip
|
||||||
hoc
|
hoc
|
||||||
|
@ -30,6 +31,8 @@ $cputype
|
||||||
srv
|
srv
|
||||||
test
|
test
|
||||||
unmount
|
unmount
|
||||||
|
usb
|
||||||
|
usbd
|
||||||
xd
|
xd
|
||||||
rc
|
rc
|
||||||
lib
|
lib
|
||||||
|
|
|
@ -410,6 +410,9 @@ main(int argc, char **argv)
|
||||||
* processes to read the console
|
* processes to read the console
|
||||||
*/
|
*/
|
||||||
consserve();
|
consserve();
|
||||||
|
|
||||||
|
/* success */
|
||||||
|
exits(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue