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));
setenv("bootdisk", bootdisk, 0);
setenv("cpuflag", cpuflag ? "1" : "0", 0);
/* setup the boot namespace */
bind("/boot", "/bin", MAFTER);

View file

@ -3,13 +3,9 @@ enum {
};
extern char* bootdisk;
extern char* rootdir;
extern int (*cfs)(int);
extern int cpuflag;
extern void fatal(char*);
extern int readfile(char*, char*, int);
extern void run(char*, ...);
extern void setenv(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)
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 @@ fn main{
# 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 @@ fn main{
# 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 @@ if(test -e '#u' && test -x /bin/usb/usbd){
# bind in an ip interface
for(i in I l^(0 1 2 3))
bind -qa '#'$i /net
configlocal # add partitions and binds
# add partitions and binds
configlocal
# 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*)

View file

@ -15,21 +15,14 @@ cat <<'---'
---
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 @@ awk '
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;"
}
'