rio: dont list files we dont serve when reading directory
parent
e614ab1d7f
commit
8791baf8b3
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue