diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-05-08 23:53:46 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-05-08 23:53:46 +0200 |
commit | 8791baf8b3a34e8bace2f6242153fbdf2812765c (patch) | |
tree | 25f843bb11720b432c6b035e51e816a0cafdd058 /sys/src/cmd/rio | |
parent | e614ab1d7f82b17b9a921280792ecbfb3a8d67d3 (diff) |
rio: dont list files we dont serve when reading directory
Diffstat (limited to 'sys/src/cmd/rio')
-rw-r--r-- | sys/src/cmd/rio/dat.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/rio/fsys.c | 25 | ||||
-rw-r--r-- | sys/src/cmd/rio/rio.c | 1 |
3 files changed, 19 insertions, 8 deletions
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h index 6db0a4cb4..3d4193d40 100644 --- a/sys/src/cmd/rio/dat.h +++ b/sys/src/cmd/rio/dat.h @@ -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; diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c index 673b53222..b141055d3 100644 --- a/sys/src/cmd/rio/fsys.c +++ b/sys/src/cmd/rio/fsys.c @@ -346,6 +346,18 @@ numeric(char *s) } 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: diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index 602fab43b..a3fff059e 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -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"); |