initcode.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * IMPORTANT! DO NOT ADD LIBRARY CALLS TO THIS FILE.
  11. * The entire text image must fit on one page
  12. * (and there's no data segment, so any read/write data must be on the stack).
  13. */
  14. #include <u.h>
  15. #include <libc.h>
  16. char cons[] = "#c/cons";
  17. char boot[] = "/boot/boot";
  18. char dev[] = "/dev";
  19. char c[] = "#c";
  20. char e[] = "#e";
  21. char ec[] = "#ec";
  22. char s[] = "#s";
  23. char srv[] = "/srv";
  24. char env[] = "/env";
  25. void
  26. startboot(char *argv0, char **argv)
  27. {
  28. char buf[200];
  29. USED(argv0);
  30. /*
  31. * open the console here so that /boot/boot,
  32. * which could be a shell script, can inherit the open fds.
  33. */
  34. open(cons, OREAD);
  35. open(cons, OWRITE);
  36. open(cons, OWRITE);
  37. bind(c, dev, MAFTER);
  38. bind(ec, env, MAFTER);
  39. bind(e, env, MCREATE|MAFTER);
  40. bind(s, srv, MREPL|MCREATE);
  41. exec(boot, argv);
  42. rerrstr(buf, sizeof buf);
  43. buf[sizeof buf - 1] = '\0';
  44. _exits(buf);
  45. }