xfssrv.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <fcall.h>
  12. #include <thread.h>
  13. #include <9p.h>
  14. #include "dat.h"
  15. #include "fns.h"
  16. #include "errstr.h"
  17. int errno;
  18. int rdonly;
  19. char *srvfile;
  20. char *deffile;
  21. extern void iobuf_init(void);
  22. extern Srv ext2srv;
  23. void
  24. usage(void)
  25. {
  26. fprint(2, "usage: %s [-v] [-s] [-r] [-p passwd] [-g group] [-f devicefile] [srvname]\n", argv0);
  27. exits("usage");
  28. }
  29. /*void handler(void *v, char *sig)
  30. {
  31. USED(v,sig);
  32. syncbuf();
  33. noted(NDFLT);
  34. }*/
  35. void
  36. main(int argc, char **argv)
  37. {
  38. int stdio;
  39. stdio = 0;
  40. ARGBEGIN{
  41. case 'D':
  42. ++chatty9p;
  43. break;
  44. case 'v':
  45. ++chatty;
  46. break;
  47. case 'f':
  48. deffile = ARGF();
  49. break;
  50. case 'g':
  51. gidfile(ARGF());
  52. break;
  53. case 'p':
  54. uidfile(ARGF());
  55. break;
  56. case 's':
  57. stdio = 1;
  58. break;
  59. case 'r':
  60. rdonly = 1;
  61. break;
  62. default:
  63. usage();
  64. }ARGEND
  65. if(argc == 0)
  66. srvfile = "ext2";
  67. else if(argc == 1)
  68. srvfile = argv[0];
  69. else
  70. usage();
  71. iobuf_init();
  72. /*notify(handler);*/
  73. if(!chatty){
  74. close(2);
  75. open("#c/cons", OWRITE);
  76. }
  77. if(stdio){
  78. srv(&ext2srv);
  79. }else{
  80. chat("%s %d: serving %s\n", argv0, getpid(), srvfile);
  81. postmountsrv(&ext2srv, srvfile, 0, 0);
  82. }
  83. exits(0);
  84. }
  85. char *
  86. xerrstr(int e)
  87. {
  88. if (e < 0 || e >= sizeof errmsg/sizeof errmsg[0])
  89. return "no such error";
  90. else
  91. return errmsg[e];
  92. }