main.c 1.5 KB

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