summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ext2srv/xfssrv.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/ext2srv/xfssrv.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/ext2srv/xfssrv.c')
-rwxr-xr-xsys/src/cmd/ext2srv/xfssrv.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/sys/src/cmd/ext2srv/xfssrv.c b/sys/src/cmd/ext2srv/xfssrv.c
new file mode 100755
index 000000000..c8bafd9ce
--- /dev/null
+++ b/sys/src/cmd/ext2srv/xfssrv.c
@@ -0,0 +1,95 @@
+#include <u.h>
+#include <libc.h>
+#include <fcall.h>
+#include <thread.h>
+#include <9p.h>
+#include "dat.h"
+#include "fns.h"
+
+#include "errstr.h"
+
+int errno;
+int rdonly;
+char *srvfile;
+char *deffile;
+
+extern void iobuf_init(void);
+extern Srv ext2srv;
+
+void
+usage(void)
+{
+ fprint(2, "usage: %s [-v] [-s] [-r] [-p passwd] [-g group] [-f devicefile] [srvname]\n", argv0);
+ exits("usage");
+}
+
+/*void handler(void *v, char *sig)
+{
+ USED(v,sig);
+ syncbuf();
+ noted(NDFLT);
+}*/
+
+void
+main(int argc, char **argv)
+{
+ int stdio;
+
+ stdio = 0;
+ ARGBEGIN{
+ case 'D':
+ ++chatty9p;
+ break;
+ case 'v':
+ ++chatty;
+ break;
+ case 'f':
+ deffile = ARGF();
+ break;
+ case 'g':
+ gidfile(ARGF());
+ break;
+ case 'p':
+ uidfile(ARGF());
+ break;
+ case 's':
+ stdio = 1;
+ break;
+ case 'r':
+ rdonly = 1;
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ if(argc == 0)
+ srvfile = "ext2";
+ else if(argc == 1)
+ srvfile = argv[0];
+ else
+ usage();
+
+ iobuf_init();
+ /*notify(handler);*/
+
+ if(!chatty){
+ close(2);
+ open("#c/cons", OWRITE);
+ }
+ if(stdio){
+ srv(&ext2srv);
+ }else{
+ chat("%s %d: serving %s\n", argv0, getpid(), srvfile);
+ postmountsrv(&ext2srv, srvfile, 0, 0);
+ }
+ exits(0);
+}
+
+char *
+xerrstr(int e)
+{
+ if (e < 0 || e >= sizeof errmsg/sizeof errmsg[0])
+ return "no such error";
+ else
+ return errmsg[e];
+}