From 15656fc79d5e348dddbde615a84e7288b580b35e Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 30 Apr 2011 20:17:33 +0000 Subject: [PATCH] boot(8): fix boot restarting --- sys/lib/dist/pc/plan9.ini.cd | 4 +- sys/src/9/boot/bootrc | 84 +++++++++++++++++++++--------------- sys/src/9/port/devsrv.c | 3 -- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/sys/lib/dist/pc/plan9.ini.cd b/sys/lib/dist/pc/plan9.ini.cd index 0b908415a..0b36ebbe8 100644 --- 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 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.