commit cd5a73785d8f7533f1438a955daf23159d09a352 from: Russ Cox date: Thu Apr 17 20:04:19 2008 UTC acme: add -m option and avoid looking in the mirror commit - e63025d09486aea0f644578b5e05a093c130b7d2 commit + cd5a73785d8f7533f1438a955daf23159d09a352 blob - 87673cdb075735d448eef823b3bdd1b41fffecae blob + 07ce503a22184efb8e4b69555f2e8bcb3bf7223d --- src/cmd/acme/acme.c +++ src/cmd/acme/acme.c @@ -28,6 +28,7 @@ Reffont *reffonts[2]; int snarffd = -1; int mainpid; int swapscrollbuttons = FALSE; +char *mtpt; enum{ NSnarf = 1000 /* less than 1024, I/O buffer size */ @@ -104,6 +105,11 @@ threadmain(int argc, char *argv[]) case 'l': loadfile = ARGF(); if(loadfile == nil) + goto Usage; + break; + case 'm': + mtpt = ARGF(); + if(mtpt == nil) goto Usage; break; case 'r': @@ -1055,4 +1061,14 @@ acmegetsnarf(void) bufinsert(&snarfbuf, 0, r, nr); free(r); free(s); +} + +int +ismtpt(char *file) +{ + int n; + + /* This is not foolproof, but it will stop a lot of them. */ + n = strlen(mtpt); + return strncmp(file, mtpt, n) == 0 && ((n > 0 && mtpt[n-1] == '/') || file[n] == '/' || file[n] == 0); } blob - a0d5cef372aa85bddf12cc66646d9cfec62e48d3 blob + 93af258db9ac1bc1288059fad892cb0cfb7b96d0 --- src/cmd/acme/dat.h +++ src/cmd/acme/dat.h @@ -542,6 +542,7 @@ int erroutfd; int messagesize; /* negotiated in 9P version setup */ int globalautoindent; int dodollarsigns; +char* mtpt; enum { blob - 34d561c5cb32bd753a2be9c17afd793ebceef92b blob + c714175f12d5c9292a4170c1ee17801b5d594ecb --- src/cmd/acme/fns.h +++ src/cmd/acme/fns.h @@ -102,3 +102,5 @@ int abbrevenv(Rune**, uint*); #define runemalloc(a) (Rune*)emalloc((a)*sizeof(Rune)) #define runerealloc(a, b) (Rune*)erealloc((a), (b)*sizeof(Rune)) #define runemove(a, b, c) memmove((a), (b), (c)*sizeof(Rune)) + +int ismtpt(char*); blob - 9a7dbd10650a866adf7be5b4018edabf4fd423d3 blob + b5ed8d6ca19f21cf2623434a5a164794c4f88c6f --- src/cmd/acme/fsys.c +++ src/cmd/acme/fsys.c @@ -121,7 +121,7 @@ fsysinit(void) initfcall(); if(pipe(p) < 0) error("can't create pipe"); - if(post9pservice(p[0], "acme") < 0) + if(post9pservice(p[0], "acme", mtpt) < 0) error("can't post service"); sfd = p[1]; fmtinstall('F', fcallfmt); blob - 66c6c66403d388d2a71174c12cf07a2f15c36777 blob + 2ca2061deee3bdcf162378fca5bbaecc038a73f4 --- src/cmd/acme/look.c +++ src/cmd/acme/look.c @@ -620,7 +620,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) if(w != nil) goto Isfile; /* if it's the name of a file, it's a file */ - if(access(e->bname, 0) < 0){ + if(ismtpt(e->bname) || access(e->bname, 0) < 0){ free(e->bname); e->bname = nil; goto Isntfile; blob - ddb3527a2eaf801a23380d073623ac9ecb77d37f blob + f972b6abefde15d437d8b3ea04d616ccf7b597af --- src/cmd/acme/text.c +++ src/cmd/acme/text.c @@ -198,6 +198,10 @@ textload(Text *t, uint q0, char *file, int setqid) error("text.load"); if(t->w->isdir && t->file->nname==0){ warning(nil, "empty directory name"); + return 0; + } + if(ismtpt(file)){ + warning(nil, "will not open self mount point %s\n", file); return 0; } fd = open(file, OREAD);