diff options
author | Russ Cox <rsc@swtch.com> | 2008-04-17 16:04:19 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-04-17 16:04:19 -0400 |
commit | cd5a73785d8f7533f1438a955daf23159d09a352 (patch) | |
tree | c9c9c688ca092d2639a41b30d448d7ff33f66d3f /src | |
parent | e63025d09486aea0f644578b5e05a093c130b7d2 (diff) | |
download | plan9port-cd5a73785d8f7533f1438a955daf23159d09a352.tar.gz plan9port-cd5a73785d8f7533f1438a955daf23159d09a352.tar.bz2 plan9port-cd5a73785d8f7533f1438a955daf23159d09a352.zip |
acme: add -m option and avoid looking in the mirror
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/acme/acme.c | 16 | ||||
-rw-r--r-- | src/cmd/acme/dat.h | 1 | ||||
-rw-r--r-- | src/cmd/acme/fns.h | 2 | ||||
-rw-r--r-- | src/cmd/acme/fsys.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/look.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/text.c | 4 |
6 files changed, 25 insertions, 2 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 87673cdb..07ce503a 100644 --- a/src/cmd/acme/acme.c +++ b/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 */ @@ -106,6 +107,11 @@ threadmain(int argc, char *argv[]) if(loadfile == nil) goto Usage; break; + case 'm': + mtpt = ARGF(); + if(mtpt == nil) + goto Usage; + break; case 'r': swapscrollbuttons = TRUE; break; @@ -1056,3 +1062,13 @@ acmegetsnarf(void) 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); +} diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h index a0d5cef3..93af258d 100644 --- a/src/cmd/acme/dat.h +++ b/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 { diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h index 34d561c5..c714175f 100644 --- a/src/cmd/acme/fns.h +++ b/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*); diff --git a/src/cmd/acme/fsys.c b/src/cmd/acme/fsys.c index 9a7dbd10..b5ed8d6c 100644 --- a/src/cmd/acme/fsys.c +++ b/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); diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 66c6c664..2ca2061d 100644 --- a/src/cmd/acme/look.c +++ b/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; diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index ddb3527a..f972b6ab 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -200,6 +200,10 @@ textload(Text *t, uint q0, char *file, int setqid) 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); if(fd < 0){ warning(nil, "can't open %s: %r\n", file); |