boot(8): simplify

This commit is contained in:
cinap_lenrek 2011-06-16 17:35:07 +02:00
parent 7cd1b102ee
commit 5fa804d69f
4 changed files with 20 additions and 37 deletions

View file

@ -35,7 +35,6 @@ boot(int argc, char *argv[])
readfile("#e/cputype", cputype, sizeof(cputype)); readfile("#e/cputype", cputype, sizeof(cputype));
setenv("bootdisk", bootdisk, 0); setenv("bootdisk", bootdisk, 0);
setenv("cpuflag", cpuflag ? "1" : "0", 0);
/* setup the boot namespace */ /* setup the boot namespace */
bind("/boot", "/bin", MAFTER); bind("/boot", "/bin", MAFTER);

View file

@ -3,13 +3,9 @@ enum {
}; };
extern char* bootdisk; extern char* bootdisk;
extern char* rootdir;
extern int (*cfs)(int);
extern int cpuflag;
extern void fatal(char*); extern void fatal(char*);
extern int readfile(char*, char*, int); extern int readfile(char*, char*, int);
extern void run(char*, ...); extern void run(char*, ...);
extern void setenv(char*, char*, int); extern void setenv(char*, char*, int);
extern int writefile(char*, char*, int); extern int writefile(char*, char*, int);
extern void boot(int, char **);

View file

@ -8,9 +8,9 @@ bind -q '#p' /proc
for(i in S f k æ t) for(i in S f k æ t)
bind -a '#'^$i /dev >/dev/null >[2=1] bind -a '#'^$i /dev >/dev/null >[2=1]
for(i in init sysname user nvram rootdir cfs bootdisk bootargs \ # make variables settable by copying them from #ec
nobootprompt debugfactotum \ for(i in init service sysname user nvram rootdir cfs bootdisk bootargs \
fs fsaddr auth authaddr){ nobootprompt debugfactotum fs fsaddr auth authaddr){
a=$$i a=$$i
$i=() $i=()
rm -f '#e'/$i '#ec'/$i /env/$i rm -f '#e'/$i '#ec'/$i /env/$i
@ -75,7 +75,7 @@ fn main{
# authentication agent # authentication agent
if(! test -f /srv/factotum){ if(! test -f /srv/factotum){
x=(/boot/factotum -sfactotum) x=(/boot/factotum -sfactotum)
if(~ $cpuflag 1){ if(~ $service cpu){
x=($x -S) x=($x -S)
if(~ -k $ff) if(~ -k $ff)
x=($x -k) x=($x -k)
@ -118,7 +118,7 @@ fn main{
# compile init command # compile init command
if(~ $#init 0){ if(~ $#init 0){
init=/$cputype/init init=/$cputype/init
if(~ $cpuflag 1) if(~ $service cpu)
init=($init -c) init=($init -c)
if not if not
init=($init -t) init=($init -t)
@ -160,15 +160,24 @@ if(test -e '#u' && test -x /bin/usb/usbd){
# bind in an ip interface # bind in an ip interface
for(i in I l^(0 1 2 3)) for(i in I l^(0 1 2 3))
bind -qa '#'$i /net bind -qa '#'$i /net
# add partitions and binds
configlocal # add partitions and binds configlocal
# boot(8) command line arguments # boot(8) command line arguments
ff=() ff=()
aa=() aa=()
while(! ~ $#* 0){ while(! ~ $#* 0){
if(~ $1 -*){ 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*) if(~ $1 -*f*)
ff=($ff -f) ff=($ff -f)
if(~ $1 -*k*) if(~ $1 -*k*)

View file

@ -15,21 +15,14 @@ cat <<'---'
--- ---
awk ' awk '
BEGIN { cpuflag = 0; bootprog = "boot"; bootdisk = "#S/sdC0/"; rootdir = "/root"; } BEGIN { bootprog = "boot"; bootdisk = "/dev/sdC0/"; }
$0 ~ "^boot" && $2=="cpu"\ $0 ~ "^boot" && $2=="cpu"\
{ cpuflag = 1 { if(NF == 4 && $3 == "boot")
if(NF == 4 && $3 == "boot")
bootdisk = $4 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\ $0 ~ "^boot" && $2=="boot" && NF==3\
{ bootdisk = $3 } { bootdisk = $3 }
END { print "int cpuflag = " cpuflag ";" END { print "char* bootdisk = \"" bootdisk "\";"
print "char* rootdir = \"" rootdir "\";"
print "char* bootdisk = \"" bootdisk "\";"
print "extern void " bootprog "(int, char**);" print "extern void " bootprog "(int, char**);"
print "void" print "void"
print "main(int argc, char **argv)" print "main(int argc, char **argv)"
@ -38,17 +31,3 @@ awk '
print "}" print "}"
} }
' $1 ' $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;"
}
'