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