ref: 3b46053b231d314bf4b2d344404b3ac95b0e553b
parent: c8804a0b4e6dc5693d5fe5d107be4bb981f69291
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sat Apr 30 16:17:33 EDT 2011
boot(8): fix boot restarting
--- a/sys/lib/dist/pc/plan9.ini.cd
+++ b/sys/lib/dist/pc/plan9.ini.cd
@@ -1,8 +1,6 @@
# config for initial cd booting
-*nodumpstack=1
+*nomp=1
mouseport=ask
monitor=ask
vgasize=ask
-cdboot=yes
bootfile=/386/9pcf
-*nomp=1
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -1,9 +1,33 @@
-rfork e
+#!/bin/rc
-mt=()
-. /rc/lib/tcp.rc
-. /rc/lib/local.rc
+bind -q '#p' /proc
+bind -qa '#S' /dev
+bind -qa '#f' /dev
+bind -qa '#k' /dev
+bind -qa '#æ' /dev
+
+fn set {+ a=$$1
+ $1=()
+ rm -f '#e'/$1 '#ec'/$1 /env/$1
+ if(! ~ $#a 0)
+ $1=$a
+}
+
+# convert plan9.ini variables
+set init
+set user
+set nvram
+set rootdir
+set bootargs
+set nobootprompt
+set debugfactotum
+set fs
+set fsaddr
+set auth
+set authaddr
+
fn fatal {echo $*
exit $"*
@@ -32,18 +56,19 @@
ask $*
}
-fn getmethod{+mt=()
+. /rc/lib/tcp.rc
+. /rc/lib/local.rc
+
+fn main{mp=()
while(~ $#mp 0){ if(~ $#nobootprompt 0){echo
showlocaldevs
- ask bootargs ' are? (tcp, local!device)' $bootargs
+ ask bootargs ' is (tcp, local!device)' $bootargs
}
- if not {- bootargs=$nobootprompt
- nobootprompt=()
- }
+ if not bootargs=$nobootprompt
mn=`{echo $bootargs | awk -F! '{print $1}'} ma=`{echo $bootargs | awk -F! '{print $2}'} for(i in `{seq 1 $#mt}){@@ -51,13 +76,7 @@
mp=$$mt($i)
}
}
-}
-fn main{- rm -f /srv/boot
-
- getmethod
-
switch($mn){case local
islocal=1
@@ -81,17 +100,19 @@
x=($x -p)
must $x
}
+ if not user=`{cat /dev/hostowner}# connect method
$mp(2) $ma
+ # mount and change root in new enviroment and namespace
+ rfork ne
+
# mount root filesystem
- must mount -c /srv/boot /root
+ if(~ $#rootdir 0)
+ rootdir=/root
+ must mount -c /srv/boot $rootdir
- # start pager
- if(test -x /dev/swap)
- echo -n start >/dev/swap
-
# remove enviroment variables
rm -f /env/^$mt /env/? /env/?? '/env/fn#'*
@@ -107,8 +128,6 @@
# remove the remaining temporary root
/mnt/broot/$cputype/bin/unmount /mnt/broot
- rootdir=/root
-
if(~ $#init 0){init=/$cputype/init
if(~ $cpuflag 1)
@@ -115,18 +134,10 @@
init=($init -c)
if not
init=($init -t)
- # TODO handle mflag
}
exec $init
}
-bind -q '#p' /proc
-
-bind -qa '#S' /dev
-bind -qa '#f' /dev
-bind -qa '#k' /dev
-bind -qa '#æ' /dev
-
if(test -e '#u'){bind -a '#u' /dev
usb/usbd
@@ -140,7 +151,12 @@
configlocal # add partitions and binds
-while()@{- rfork ne
- main
+while(){+ @{main}+ sleep 1
+
+ # cleanup so it can be restarted
+ nobootprompt=()
+ user=()
+ rm -f /srv/boot /srv/slashn /srv/cs /srv/dns
}
--- a/sys/src/9/port/devsrv.c
+++ b/sys/src/9/port/devsrv.c
@@ -205,11 +205,8 @@
/*
* Only eve can remove system services.
- * No one can remove #s/boot.
*/
if(strcmp(sp->owner, eve) == 0 && !iseve())
- error(Eperm);
- if(strcmp(sp->name, "boot") == 0)
error(Eperm);
/*
--
⑨