xfssrv.c 1.3 KB

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