bootrc.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <u.h>
  10. #include <libc.h>
  11. #include <ip.h>
  12. #include "boot.h"
  13. void
  14. configrc(Method* m)
  15. {
  16. void configloopback(void);
  17. configloopback();
  18. bind("#S", "/dev", MAFTER);
  19. char *argv[] = {"rc", "-m", "/boot/rcmain", "-i", 0,};
  20. print("Step 1. Run an rc. Set things up.\n");
  21. switch(fork()){
  22. case -1:
  23. print("configrc: fork failed: %r\n");
  24. case 0:
  25. exec("/boot/rc", argv);
  26. fatal("can't exec rc");
  27. default:
  28. break;
  29. }
  30. while(waitpid() != -1)
  31. ;
  32. print("Step 2. Run an rc. Verify that things are as you want them.\n");
  33. switch(fork()){
  34. case -1:
  35. print("configrc: fork failed: %r\n");
  36. case 0:
  37. exec("/boot/rc", argv);
  38. fatal("can't exec rc");
  39. default:
  40. break;
  41. }
  42. while(waitpid() != -1)
  43. ;
  44. print("rc is done, continuing...\n");
  45. }
  46. int
  47. connectrc(void)
  48. {
  49. int fd;
  50. char buf[64];
  51. // Later, make this anything.
  52. snprint(buf, sizeof buf, "/srv/fossil");
  53. fd = open("#s/fossil", 2);
  54. if (fd < 0)
  55. werrstr("dial %s: %r", buf);
  56. return fd;
  57. }