M gnot/dat.h => gnot/dat.h +1 -0
@@ 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 */
M port/chan.c => port/chan.c +2 -0
@@ 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;
M port/dev.c => port/dev.c +6 -2
@@ 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;
}
M port/devcons.c => port/devcons.c +1 -1
@@ 249,7 249,7 @@ echo(int c)
/*
* ^t hack BUG
*/
- if(c == 0x18)
+ if(c == 0x10)
panic("^p");
if(c == 0x14)
DEBUG();
M port/devkprof.c => port/devkprof.c +4 -4
@@ 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);
M port/devmnt.c => port/devmnt.c +19 -16
@@ 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; i<conf.nmntdev; i++,m++) /* use a hash table some day */
- if(m->mntid == 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);
M port/devsrv.c => port/devsrv.c +0 -1
@@ 73,7 73,6 @@ Chan *
srvclone(Chan *c, Chan *nc)
{
nc = devclone(c, nc);
- nc->aux = c->aux;
return nc;
}
M port/stream.c => port/stream.c +1 -1
@@ 52,7 52,7 @@ typedef struct {
Bclass bclass[Nclass]={
{ 0 },
{ 68 },
- { 260 },
+ { 268 },
{ 4096 },
};
M power/dat.h => power/dat.h +1 -0
@@ 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 */
M power/devbit3.c => power/devbit3.c +6 -0
@@ 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)
{