From 5d85856073c8e5564edc680c395b340e7ee43f3b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 21 Apr 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-04-21 --- gnot/dat.h | 1 + port/chan.c | 2 ++ port/dev.c | 8 ++++++-- port/devcons.c | 2 +- port/devkprof.c | 8 ++++---- port/devmnt.c | 35 +++++++++++++++++++---------------- port/devsrv.c | 1 - port/stream.c | 2 +- power/dat.h | 1 + power/devbit3.c | 6 ++++++ 10 files changed, 41 insertions(+), 25 deletions(-) diff --git a/gnot/dat.h b/gnot/dat.h index 772dde1ded7579e0de602df9343f205c6b3c58a7..cc4e8284e3b14f6a7607f18d704c2470dbf6a77a 100644 --- a/gnot/dat.h +++ b/gnot/dat.h @@ -107,6 +107,7 @@ struct Chan Stream *stream; /* for stream channels */ void *aux; Qid pgrpid; /* for #p/notepg */ + int mntindex; /* for devmnt */ }; Chan *mchan; /* channel to mounted server */ Qid mqid; /* qid of root of mount point */ diff --git a/port/chan.c b/port/chan.c index 611725e17ddfdbe835cba35118e17894e9d0f6f9..ee34532104c4e030ce7ebb8bab497c22eaa9e23d 100644 --- a/port/chan.c +++ b/port/chan.c @@ -84,6 +84,8 @@ loop: c->offset = 0; c->mnt = 0; c->stream = 0; + c->aux = 0; + c->mntindex = 0; c->mchan = 0; c->mqid = (Qid){0, 0}; return c; diff --git a/port/dev.c b/port/dev.c index cdd1b32ddea9b4e0c33baeeffc264dacf191fb3a..51f0af94567ebd843c41f53aa359ae367c901992 100644 --- a/port/dev.c +++ b/port/dev.c @@ -71,12 +71,13 @@ devclone(Chan *c, Chan *nc) if(nc == 0) nc = newchan(); nc->type = c->type; + nc->dev = c->dev; nc->mode = c->mode; nc->qid = c->qid; nc->offset = c->offset; - nc->dev = c->dev; nc->flag = c->flag; nc->mnt = c->mnt; + nc->aux = c->aux; nc->mchan = c->mchan; nc->mqid = c->mqid; return nc; @@ -119,7 +120,10 @@ devclwalk(Chan *c, char *name) return 0; } nc = (*devtab[c->type].clone)(c, 0); - (*devtab[nc->type].walk)(nc, name); + if((*devtab[nc->type].walk)(nc, name) == 0){ + close(nc); + nc = 0; + } poperror(); return nc; } diff --git a/port/devcons.c b/port/devcons.c index 9f8cad8cf693f4b34eed72c688f1d11842446f66..0b79c2e2657a7dd663f37ce4ef65638ca1ca5737 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -249,7 +249,7 @@ echo(int c) /* * ^t hack BUG */ - if(c == 0x18) + if(c == 0x10) panic("^p"); if(c == 0x14) DEBUG(); diff --git a/port/devkprof.c b/port/devkprof.c index ae37d9ddd37882567802f3168457223be5fb458c..e86ec62beec9cbc7232f16edd05385534ee47592 100644 --- a/port/devkprof.c +++ b/port/devkprof.c @@ -24,10 +24,10 @@ enum{ Kprofmaxqid, }; Dirtab kproftab[Nkproftab]={ - "kpdata", Kprofdataqid, NBUF*sizeof timerbuf[0], 0600, - "kpstart", Kprofstartqid, 0, 0600, - "kpstartclr", Kprofstartclrqid, 0, 0600, - "kpstop", Kprofstopqid, 0, 0600, + "kpdata", {Kprofdataqid}, NBUF*sizeof timerbuf[0], 0600, + "kpstart", {Kprofstartqid}, 0, 0600, + "kpstartclr", {Kprofstartclrqid}, 0, 0600, + "kpstop", {Kprofstopqid}, 0, 0600, }; void kproftimer(ulong); diff --git a/port/devmnt.c b/port/devmnt.c index 8424228573397901ef7153e880763153484804b6..7d10653c5e6dcbb06d203ef1e94a07c72ebb6357 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -189,17 +189,14 @@ mqfree(MntQ *mq) } Mnt* -mntdev(int dev, int noerr) +mntdev(Chan *c, int noerr) { Mnt *m; int i; - for(m=mnt,i=0; imntid == dev){ - if(m->q == 0) - break; - return m; - } + m = &mnt[c->mntindex]; + if(m->mntid==c->dev && m->q!=0) + return m; if(noerr) return 0; error(Eshutdown); @@ -277,6 +274,7 @@ mntattach(char *crud) unlock(&mntid); c = devattach('M', bogus.spec); c->dev = m->mntid; + c->mntindex = m-mnt; m->mntpt = c; cm = bogus.chan; @@ -336,7 +334,7 @@ mntclone(Chan *c, Chan *nc) nexterror(); } } - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); @@ -353,6 +351,8 @@ mntclone(Chan *c, Chan *nc) nc->flag = c->flag; nc->offset = c->offset; nc->mnt = c->mnt; + nc->aux = c->aux; + nc->mntindex = c->mntindex; nc->mchan = c->mchan; nc->mqid = c->qid; mhfree(mh); @@ -371,7 +371,7 @@ mntwalk(Chan *c, char *name) int found; found = 1; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); mh->thdr.type = Twalk; mh->thdr.fid = c->fid; @@ -396,19 +396,22 @@ mntclwalk(Chan *c, char *name) Chan *nc; nc = newchan(); - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); mh->thdr.type = Tclwalk; mh->thdr.fid = c->fid; mh->thdr.newfid = nc->fid; strcpy(mh->thdr.name, name); if(waserror()){ /* BUG: can check type of error? */ + print("mntclwalk(%d %lux) failed\n", c->type, c->qid.path); freechan(nc); nc = 0; goto Out; } mntxmit(m, mh); nc->qid = mh->rhdr.qid; + print("mntclwalk(%d %lux)->%d %lux\n", c->type, c->qid.path, + nc->type, nc->qid.path); poperror(); Out: mhfree(mh); @@ -421,7 +424,7 @@ mntstat(Chan *c, char *dp) Mnt *m; Mnthdr *mh; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); @@ -445,7 +448,7 @@ mntopen(Chan *c, int omode) Mnt *m; Mnthdr *mh; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); @@ -470,7 +473,7 @@ mntcreate(Chan *c, char *name, int omode, ulong perm) Mnt *m; Mnthdr *mh; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); @@ -498,7 +501,7 @@ mntclunk(Chan *c, int t) MntQ *q; int waserr; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); mh->thdr.type = t; mh->thdr.fid = c->fid; @@ -540,7 +543,7 @@ mntreadwrite(Chan *c, void *vbuf, long n, int type, ulong offset) buf = vbuf; count = 0; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); @@ -606,7 +609,7 @@ mntwstat(Chan *c, char *dp) Mnt *m; Mnthdr *mh; - m = mntdev(c->dev, 0); + m = mntdev(c, 0); mh = mhalloc(); if(waserror()){ mhfree(mh); diff --git a/port/devsrv.c b/port/devsrv.c index 18d04658acfc3a7a6424e6fb074998fbea0cee7d..79797e2324407633462782181cda099542508321 100644 --- a/port/devsrv.c +++ b/port/devsrv.c @@ -73,7 +73,6 @@ Chan * srvclone(Chan *c, Chan *nc) { nc = devclone(c, nc); - nc->aux = c->aux; return nc; } diff --git a/port/stream.c b/port/stream.c index 360dc7a5fd608bc70b730a2ddef3a2e7c8a03564..d444a046dd347654d280303fcf8b2f5877cd4573 100644 --- a/port/stream.c +++ b/port/stream.c @@ -52,7 +52,7 @@ typedef struct { Bclass bclass[Nclass]={ { 0 }, { 68 }, - { 260 }, + { 268 }, { 4096 }, }; diff --git a/power/dat.h b/power/dat.h index 165e19b694792ab8ce664a44ec782625659231c7..c38ec1f6bbbf36a453018585e3aaf1ea2f9cc0ca 100644 --- a/power/dat.h +++ b/power/dat.h @@ -125,6 +125,7 @@ struct Chan Stream *stream; /* for stream channels */ void *aux; Qid pgrpid; /* for #p/notepg */ + int mntindex; /* for devmnt */ }; Chan *mchan; /* channel to mounted server */ Qid mqid; /* qid of root of mount point */ diff --git a/power/devbit3.c b/power/devbit3.c index b17cf5112ed1b830b2b3a6d980859e662251118f..2676a64e7719464715b54418f51380b5c981ce45 100644 --- a/power/devbit3.c +++ b/power/devbit3.c @@ -66,6 +66,12 @@ bit3clone(Chan *c, Chan *nc) return devclone(c, nc); } +Chan* +bit3clwalk(Chan *c, char *name) +{ + return devclwalk(c, name); +} + int bit3walk(Chan *c, char *name) {