rio: dont list files we dont serve when reading directory

front
cinap_lenrek 2012-05-08 23:53:46 +02:00
parent e614ab1d7f
commit 8791baf8b3
3 changed files with 19 additions and 8 deletions

View File

@ -322,6 +322,7 @@ Window **window;
Window *wkeyboard; /* window of simulated keyboard */
int nwindow;
int snarffd;
int gotscreen;
Window *input;
QLock all; /* BUG */
Filsys *filsys;

View File

@ -345,6 +345,18 @@ numeric(char *s)
return 1;
}
static
int
skipdir(char *name)
{
/* don't serve these if it's provided in the environment */
if(snarffd>=0 && strcmp(name, "snarf")==0)
return 1;
if(gotscreen && strcmp(name, "screen")==0)
return 1;
return 0;
}
static
Xfid*
filsyswalk(Filsys *fs, Xfid *x, Fid *f)
@ -430,13 +442,8 @@ filsyswalk(Filsys *fs, Xfid *x, Fid *f)
dir = dirtab;
goto Accept;
}
/* don't serve these if it's provided in the environment */
if(snarffd>=0 && strcmp(x->wname[i], "snarf")==0)
break;
if(strcmp(x->wname[i], "screen")==0 && access("/dev/screen", AEXIST)==0)
if(skipdir(x->wname[i]))
break;
id = WIN(f->qid);
d = dirtab;
d++; /* skip '.' */
@ -548,13 +555,15 @@ filsysread(Filsys *fs, Xfid *x, Fid *f)
case Qwsysdir:
d = dirtab;
d++; /* first entry is '.' */
for(i=0; d->name!=nil && i<e; i+=len){
for(i=0; d->name!=nil && i<e; d++){
if(skipdir(d->name))
continue;
len = dostat(fs, WIN(x->f->qid), d, b+n, x->count-n, clock);
if(len <= BIT16SZ)
break;
if(i >= o)
n += len;
d++;
i += len;
}
break;
case Qwsys:

View File

@ -184,6 +184,7 @@ threadmain(int argc, char *argv[])
}
snarffd = open("/dev/snarf", OREAD|OCEXEC);
gotscreen = access("/dev/screen", AEXIST)==0;
if(geninitdraw(nil, derror, nil, "rio", nil, Refnone) < 0){
fprint(2, "rio: can't open display: %r\n");