awd.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /*
  12. * like fprint but be sure to deliver as a single write.
  13. * (fprint uses a small write buffer.)
  14. */
  15. void
  16. xfprint(int fd, char *fmt, ...)
  17. {
  18. char *s;
  19. va_list arg;
  20. va_start(arg, fmt);
  21. s = vsmprint(fmt, arg);
  22. va_end(arg);
  23. if(s == nil)
  24. sysfatal("smprint: %r");
  25. write(fd, s, strlen(s));
  26. free(s);
  27. }
  28. void
  29. main(int argc, char **argv)
  30. {
  31. int fd;
  32. char dir[512];
  33. fd = open("/dev/acme/ctl", OWRITE);
  34. if(fd < 0)
  35. exits(0);
  36. getwd(dir, 512);
  37. if(dir[0]!=0 && dir[strlen(dir)-1]=='/')
  38. dir[strlen(dir)-1] = 0;
  39. xfprint(fd, "name %s/-%s\n", dir, argc > 1 ? argv[1] : "rc");
  40. xfprint(fd, "dumpdir %s\n", dir);
  41. exits(0);
  42. }