xref: /plan9-contrib/sys/src/9k/port/initcode.c (revision 9ef1f84b659abcb917c5c090acbce0772e494f21)
1 /*
2  * IMPORTANT!  DO NOT ADD LIBRARY CALLS TO THIS FILE.
3  * The entire text image must fit on one page
4  * (and there's no data segment, so any read/write data must be on the stack).
5  */
6 
7 #include <u.h>
8 #include <libc.h>
9 
10 char cons[] = "#c/cons";
11 char boot[] = "/boot/boot";
12 char dev[] = "/dev";
13 char c[] = "#c";
14 char e[] = "#e";
15 char ec[] = "#ec";
16 char s[] = "#s";
17 char srv[] = "/srv";
18 char env[] = "/env";
19 
20 void
startboot(char * argv0,char ** argv)21 startboot(char *argv0, char **argv)
22 {
23 	char buf[200];
24 
25 	USED(argv0);
26 	/*
27 	 * open the console here so that /boot/boot,
28 	 * which could be a shell script, can inherit the open fds.
29 	 */
30 	open(cons, OREAD);
31 	open(cons, OWRITE);
32 	open(cons, OWRITE);
33 	bind(c, dev, MAFTER);
34 	bind(ec, env, MAFTER);
35 	bind(e, env, MCREATE|MAFTER);
36 	bind(s, srv, MREPL|MCREATE);
37 	exec(boot, argv);
38 
39 	rerrstr(buf, sizeof buf);
40 	buf[sizeof buf - 1] = '\0';
41 	_exits(buf);
42 }
43