2011-03-30 12:46:40 +00:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <auth.h>
|
|
|
|
#include <fcall.h>
|
|
|
|
#include "../boot/boot.h"
|
|
|
|
|
|
|
|
char cputype[64];
|
|
|
|
char reply[256];
|
|
|
|
int printcol;
|
|
|
|
int mflag;
|
|
|
|
int fflag;
|
|
|
|
int kflag;
|
|
|
|
|
|
|
|
void
|
|
|
|
boot(int argc, char *argv[])
|
|
|
|
{
|
2011-04-16 20:42:16 +00:00
|
|
|
Waitmsg *w;
|
|
|
|
int pid, i;
|
2011-06-04 05:19:29 +00:00
|
|
|
char buf[32];
|
2011-03-30 12:46:40 +00:00
|
|
|
|
|
|
|
fmtinstall('r', errfmt);
|
|
|
|
|
|
|
|
bind("#c", "/dev", MBEFORE);
|
|
|
|
open("/dev/cons", OREAD);
|
|
|
|
open("/dev/cons", OWRITE);
|
|
|
|
open("/dev/cons", OWRITE);
|
|
|
|
/*
|
|
|
|
* init will reinitialize its namespace.
|
|
|
|
* #ec gets us plan9.ini settings (*var variables).
|
|
|
|
*/
|
|
|
|
bind("#ec", "/env", MREPL);
|
|
|
|
bind("#e", "/env", MBEFORE|MCREATE);
|
|
|
|
bind("#s", "/srv", MREPL|MCREATE);
|
2011-04-16 20:42:16 +00:00
|
|
|
|
|
|
|
if(Debug){
|
|
|
|
print("argc=%d\n", argc);
|
|
|
|
for(i = 0; i < argc; i++)
|
|
|
|
print("%lux %s ", (ulong)argv[i], argv[i]);
|
|
|
|
print("\n");
|
|
|
|
}
|
2011-03-30 12:46:40 +00:00
|
|
|
|
|
|
|
ARGBEGIN{
|
|
|
|
case 'k':
|
|
|
|
kflag = 1;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
mflag = 1;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
fflag = 1;
|
|
|
|
break;
|
|
|
|
}ARGEND
|
|
|
|
|
|
|
|
readfile("#e/cputype", cputype, sizeof(cputype));
|
2011-04-16 20:42:16 +00:00
|
|
|
setenv("bootdisk", bootdisk, 0);
|
2011-03-30 12:46:40 +00:00
|
|
|
|
2011-04-16 20:42:16 +00:00
|
|
|
/* setup the boot namespace */
|
2011-06-04 05:19:29 +00:00
|
|
|
run("/boot/paqfs", "-m" "/root", "/boot/bootfs.paq", nil);
|
|
|
|
bind("/root", "/", MAFTER);
|
|
|
|
snprint(buf, sizeof(buf), "/%s/bin", cputype);
|
|
|
|
bind(buf, "/bin", MAFTER);
|
2011-04-16 20:42:16 +00:00
|
|
|
bind("/rc/bin", "/bin", MAFTER);
|
|
|
|
bind("/boot", "/bin", MAFTER);
|
|
|
|
|
|
|
|
switch(pid = rfork(RFFDG|RFREND|RFPROC)){
|
2011-03-30 12:46:40 +00:00
|
|
|
case -1:
|
2011-04-16 20:42:16 +00:00
|
|
|
fatal("fork error");
|
2011-03-30 12:46:40 +00:00
|
|
|
case 0:
|
2011-04-16 20:42:16 +00:00
|
|
|
setenv("cpuflag", cpuflag ? "1" : "0", 0);
|
|
|
|
run("/bin/rc", "/rc/bin/bootrc", nil);
|
|
|
|
break;
|
2011-03-30 12:46:40 +00:00
|
|
|
default:
|
2011-04-16 20:42:16 +00:00
|
|
|
while((w = wait()) != nil)
|
|
|
|
if(w->pid == pid)
|
|
|
|
break;
|
|
|
|
if(w == nil){
|
|
|
|
free(w);
|
|
|
|
fatal("wait error");
|
|
|
|
}
|
|
|
|
free(w);
|
|
|
|
break;
|
2011-03-30 12:46:40 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 20:42:16 +00:00
|
|
|
for(;;)
|
|
|
|
;
|
2011-03-30 12:46:40 +00:00
|
|
|
}
|