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