acme: add -m option and avoid looking in the mirror
This commit is contained in:
parent
e63025d094
commit
cd5a73785d
6 changed files with 25 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -542,6 +542,7 @@ int erroutfd;
|
|||
int messagesize; /* negotiated in 9P version setup */
|
||||
int globalautoindent;
|
||||
int dodollarsigns;
|
||||
char* mtpt;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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*);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue