ref: 5fa804d69fe1c1db6954217bca19637656e579b4
parent: 7cd1b102ee03d676b050319eaaefe73309b9b01c
author: cinap_lenrek <cinap_lenrek@localhost>
date: Thu Jun 16 13:35:07 EDT 2011
boot(8): simplify
--- a/sys/src/9/boot/boot.c
+++ b/sys/src/9/boot/boot.c
@@ -35,7 +35,6 @@
readfile("#e/cputype", cputype, sizeof(cputype));
setenv("bootdisk", bootdisk, 0);
- setenv("cpuflag", cpuflag ? "1" : "0", 0);
/* setup the boot namespace */
bind("/boot", "/bin", MAFTER);
--- a/sys/src/9/boot/boot.h
+++ b/sys/src/9/boot/boot.h
@@ -3,9 +3,6 @@
};
extern char* bootdisk;
-extern char* rootdir;
-extern int (*cfs)(int);
-extern int cpuflag;
extern void fatal(char*);
extern int readfile(char*, char*, int);
@@ -12,4 +9,3 @@
extern void run(char*, ...);
extern void setenv(char*, char*, int);
extern int writefile(char*, char*, int);
-extern void boot(int, char **);
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -8,9 +8,9 @@
for(i in S f k æ t)
bind -a '#'^$i /dev >/dev/null >[2=1]
-for(i in init sysname user nvram rootdir cfs bootdisk bootargs \
- nobootprompt debugfactotum \
- fs fsaddr auth authaddr){
+# make variables settable by copying them from #ec
+for(i in init service sysname user nvram rootdir cfs bootdisk bootargs \
+ nobootprompt debugfactotum fs fsaddr auth authaddr){
a=$$i
$i=()
rm -f '#e'/$i '#ec'/$i /env/$i
@@ -75,7 +75,7 @@
# authentication agent
if(! test -f /srv/factotum){
x=(/boot/factotum -sfactotum)
- if(~ $cpuflag 1){
+ if(~ $service cpu){
x=($x -S)
if(~ -k $ff)
x=($x -k)
@@ -118,7 +118,7 @@
# compile init command
if(~ $#init 0){
init=/$cputype/init
- if(~ $cpuflag 1)
+ if(~ $service cpu)
init=($init -c)
if not
init=($init -t)
@@ -160,15 +160,24 @@
# bind in an ip interface
for(i in I l^(0 1 2 3))
bind -qa '#'$i /net
+# add partitions and binds
+configlocal
-configlocal # add partitions and binds
-
# boot(8) command line arguments
ff=()
aa=()
while(! ~ $#* 0){
if(~ $1 -*){
- if(! ~ $1 -u*){
+ if(~ $1 -u*){
+ if(~ $1 -u){
+ user=$2
+ shift
+ }
+ if not {
+ user=`{echo $1 | sed 's,^-u,,g'}
+ }
+ }
+ if not {
if(~ $1 -*f*)
ff=($ff -f)
if(~ $1 -*k*)
--- a/sys/src/9/boot/mkboot
+++ b/sys/src/9/boot/mkboot
@@ -15,21 +15,14 @@
---
awk '
- BEGIN { cpuflag = 0; bootprog = "boot"; bootdisk = "#S/sdC0/"; rootdir = "/root"; }
+ BEGIN { bootprog = "boot"; bootdisk = "/dev/sdC0/"; }
$0 ~ "^boot" && $2=="cpu"\
- { cpuflag = 1
- if(NF == 4 && $3 == "boot")
+ { if(NF == 4 && $3 == "boot")
bootdisk = $4
}
- $0 ~ "^boot" && $2=="rootdir" && NF==3\
- { rootdir = $3 }
- $0 ~ "^boot" && ($2=="bboot" || $2=="romboot" || $2=="dosboot")\
- { cpuflag = 1; bootprog = $2; }
$0 ~ "^boot" && $2=="boot" && NF==3\
{ bootdisk = $3 }
- END { print "int cpuflag = " cpuflag ";"
- print "char* rootdir = \"" rootdir "\";"
- print "char* bootdisk = \"" bootdisk "\";"
+ END { print "char* bootdisk = \"" bootdisk "\";"
print "extern void " bootprog "(int, char**);"
print "void"
print "main(int argc, char **argv)"
@@ -38,17 +31,3 @@
print "}"
}
' $1
-
-#
-# configure in a cache file system if a
-# /386/bin/root appears in the bootdir section.
-#
-../port/mkextract bootdir 0 $* | awk '
- BEGIN { cfs = 0 }
- $1 ~ "bin/cfs$" { cfs = 1 }
- END { if(cfs)
- print "int (*cfs)(int) = cache;"
- else
- print "int (*cfs)(int) = 0;"
- }
- '