main.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include <ip.h>
  5. #include <plumb.h>
  6. #include <thread.h>
  7. #include <fcall.h>
  8. #include <9p.h>
  9. #include "dat.h"
  10. #include "fns.h"
  11. char *cookiefile;
  12. char *mtpt = "/mnt/web";
  13. char *service;
  14. Ctl globalctl =
  15. {
  16. 1, /* accept cookies */
  17. 1, /* send cookies */
  18. 10, /* redirect limit */
  19. "webfs/2.0 (plan 9)" /* user agent */
  20. };
  21. void
  22. usage(void)
  23. {
  24. fprint(2, "usage: webfs [-c cookies] [-m mtpt] [-s service]\n");
  25. threadexitsall("usage");
  26. }
  27. #include <pool.h>
  28. void
  29. threadmain(int argc, char **argv)
  30. {
  31. rfork(RFNOTEG);
  32. ARGBEGIN{
  33. case 'd':
  34. mainmem->flags |= POOL_PARANOIA|POOL_ANTAGONISM;
  35. break;
  36. case 'D':
  37. chatty9p++;
  38. break;
  39. case 'c':
  40. cookiefile = EARGF(usage());
  41. break;
  42. case 'm':
  43. mtpt = EARGF(usage());
  44. break;
  45. case 's':
  46. service = EARGF(usage());
  47. break;
  48. default:
  49. usage();
  50. }ARGEND
  51. quotefmtinstall();
  52. if(argc != 0)
  53. usage();
  54. plumbinit();
  55. globalctl.useragent = estrdup(globalctl.useragent);
  56. initcookies(cookiefile);
  57. initurl();
  58. initfs();
  59. threadpostmountsrv(&fs, service, mtpt, MREPL);
  60. threadexits(nil);
  61. }