summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-04-30 20:17:33 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-04-30 20:17:33 +0000
commit15656fc79d5e348dddbde615a84e7288b580b35e (patch)
treec0bb74855eda3715454ec77d3ba6f78e07f215fb /sys/src
parent06db9d4d681e552e0d4803e76becace707a72f12 (diff)
boot(8): fix boot restarting
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/9/boot/bootrc84
-rw-r--r--sys/src/9/port/devsrv.c3
2 files changed, 50 insertions, 37 deletions
diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc
index d41b5eb96..9488d5f46 100644
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -1,8 +1,32 @@
-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 $*
@@ -32,18 +56,19 @@ fn ask {
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
- }
- if not {
- bootargs=$nobootprompt
- nobootprompt=()
+ ask bootargs ' is (tcp, local!device)' $bootargs
}
+ 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,12 +76,6 @@ fn getmethod{
mp=$$mt($i)
}
}
-}
-
-fn main{
- rm -f /srv/boot
-
- getmethod
switch($mn){
case local
@@ -81,16 +100,18 @@ fn main{
x=($x -p)
must $x
}
+ if not user=`{cat /dev/hostowner}
# connect method
$mp(2) $ma
- # mount root filesystem
- must mount -c /srv/boot /root
+ # mount and change root in new enviroment and namespace
+ rfork ne
- # start pager
- if(test -x /dev/swap)
- echo -n start >/dev/swap
+ # mount root filesystem
+ if(~ $#rootdir 0)
+ rootdir=/root
+ must mount -c /srv/boot $rootdir
# remove enviroment variables
rm -f /env/^$mt /env/? /env/?? '/env/fn#'*
@@ -107,26 +128,16 @@ fn main{
# 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
}
-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 @@ if(! ~ $#kbmap 0){
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
}
diff --git a/sys/src/9/port/devsrv.c b/sys/src/9/port/devsrv.c
index 161e77eed..0a8996750 100644
--- a/sys/src/9/port/devsrv.c
+++ b/sys/src/9/port/devsrv.c
@@ -205,12 +205,9 @@ srvremove(Chan *c)
/*
* 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);
/*
* No removing personal services.