initcode.c 823 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include <u.h>
  7. #include <libc.h>
  8. char cons[] = "#c/cons";
  9. char boot[] = "/boot/boot";
  10. char dev[] = "/dev";
  11. char c[] = "#c";
  12. char e[] = "#e";
  13. char ec[] = "#ec";
  14. char s[] = "#s";
  15. char srv[] = "/srv";
  16. char env[] = "/env";
  17. void
  18. startboot(char *argv0, char **argv)
  19. {
  20. char buf[200]; /* keep this fairly large to capture error details */
  21. /* in case boot is a shell script */
  22. open(cons, OREAD);
  23. open(cons, OWRITE);
  24. open(cons, OWRITE);
  25. bind(c, dev, MAFTER);
  26. bind(ec, env, MAFTER);
  27. bind(e, env, MCREATE|MAFTER);
  28. bind(s, srv, MREPL|MCREATE);
  29. exec(boot, argv);
  30. rerrstr(buf, sizeof buf);
  31. buf[sizeof buf - 1] = '\0';
  32. _exits(buf);
  33. }