diff options
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | emu/port/devip.c | 26 | ||||
| -rw-r--r-- | emu/port/devmnt.c | 24 |
3 files changed, 24 insertions, 27 deletions
@@ -1,5 +1,6 @@ 20090930 emu/*/ipif*.c make "hangup" act as in native Inferno; also delete unused so_setsockopt + provide correct version of devmnt.c 20090928 update import(4) to remove the restriction to Plan 9 (can use Inferno's own factotum) (emu os)^/port/devmnt.c fix from plan 9 (don't access vanished data) diff --git a/emu/port/devip.c b/emu/port/devip.c index d68cf172..e70d7dc3 100644 --- a/emu/port/devip.c +++ b/emu/port/devip.c @@ -148,7 +148,7 @@ ip3gen(Chan *c, int i, Dir *dp) Conv *cv; char *p; - cv = ipfs[c->devno]->p[PROTO(c->qid)]->conv[CONV(c->qid)]; + cv = ipfs[c->dev]->p[PROTO(c->qid)]->conv[CONV(c->qid)]; if(cv->owner == nil) kstrdup(&cv->owner, eve); mkqid(&q, QID(PROTO(c->qid), CONV(c->qid), i), 0, QTFILE); @@ -207,7 +207,7 @@ ip1gen(Chan *c, int i, Dir *dp) Fs *f; extern ulong kerndate; - f = ipfs[c->devno]; + f = ipfs[c->dev]; prot = 0664; mkqid(&q, QID(0, 0, i), 0, QTFILE); @@ -219,7 +219,7 @@ ip1gen(Chan *c, int i, Dir *dp) break; case Qndb: p = "ndb"; - len = strlen(ipfs[c->devno]->ndb); + len = strlen(ipfs[c->dev]->ndb); break; /* case Qiproute: p = "iproute"; @@ -252,13 +252,13 @@ ipgen(Chan *c, char *name, Dirtab *tab, int x, int s, Dir *dp) USED(name); USED(tab); USED(x); - f = ipfs[c->devno]; + f = ipfs[c->dev]; switch(TYPE(c->qid)) { case Qtopdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#I%ud", c->devno); + sprint(up->genbuf, "#I%lud", c->dev); devdir(c, q, up->genbuf, 0, network, 0555, dp); return 1; } @@ -280,7 +280,7 @@ ipgen(Chan *c, char *name, Dirtab *tab, int x, int s, Dir *dp) case Qprotodir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#I%ud", c->devno); + sprint(up->genbuf, "#I%lud", c->dev); devdir(c, q, up->genbuf, 0, network, 0555, dp); return 1; } @@ -356,7 +356,7 @@ ipattach(char *spec) c = devattach('I', spec); mkqid(&c->qid, QID(0, 0, Qtopdir), 0, QTDIR); - c->devno = 0; + c->dev = 0; return c; } @@ -391,7 +391,7 @@ ipopen(Chan *c, int omode) perm = m2p[omode&3]; - f = ipfs[c->devno]; + f = ipfs[c->dev]; switch(TYPE(c->qid)) { default: @@ -526,7 +526,7 @@ ipclose(Chan *c) { Fs *f; - f = ipfs[c->devno]; + f = ipfs[c->dev]; switch(TYPE(c->qid)) { case Qdata: case Qctl: @@ -546,7 +546,7 @@ ipread(Chan *ch, void *a, long n, vlong off) Fs *f; ulong offset = off; - f = ipfs[ch->devno]; + f = ipfs[ch->dev]; p = a; switch(TYPE(ch->qid)) { @@ -816,7 +816,7 @@ ipwrite(Chan *ch, void *a, long n, vlong off) Cmdbuf *cb; Fs *f; - f = ipfs[ch->devno]; + f = ipfs[ch->dev]; switch(TYPE(ch->qid)) { default: @@ -932,7 +932,7 @@ ipwstat(Chan *c, uchar *dp, int n) Proto *p; Fs *f; - f = ipfs[c->devno]; + f = ipfs[c->dev]; switch(TYPE(c->qid)) { default: error(Eperm); @@ -1071,9 +1071,7 @@ Dev ipdevtab = { 'I', "ip", - devreset, ipinit, - devshutdown, ipattach, ipwalk, ipstat, diff --git a/emu/port/devmnt.c b/emu/port/devmnt.c index 16d5efd2..327ec67e 100644 --- a/emu/port/devmnt.c +++ b/emu/port/devmnt.c @@ -164,7 +164,7 @@ mntversion(Chan *c, char *version, int msize, int returnlen) c->offset += k; unlock(&c->l); - l = c->dev->write(c, msg, k, oo); + l = devtab[c->type]->write(c, msg, k, oo); if(l < k){ lock(&c->l); @@ -174,7 +174,7 @@ mntversion(Chan *c, char *version, int msize, int returnlen) } /* message sent; receive and decode reply */ - k = c->dev->read(c, msg, 8192+IOHDRSZ, c->offset); + k = devtab[c->type]->read(c, msg, 8192+IOHDRSZ, c->offset); if(k <= 0) error("EOF receiving fversion reply"); @@ -368,7 +368,7 @@ mntchan(void) c = devattach('M', 0); lock(&mntalloc.l); - c->devno = mntalloc.id++; + c->dev = mntalloc.id++; unlock(&mntalloc.l); if(c->mchan) @@ -405,8 +405,9 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) nc = devclone(c); /* * Until the other side accepts this fid, we can't mntclose it. - * nc->dev remains nil for now. + * Therefore set type to 0 for now; rootclose is known to be safe. */ + nc->type = 0; alloc = 1; } wq->clone = nc; @@ -439,8 +440,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) /* move new fid onto mnt device and update its qid */ if(wq->clone != nil){ if(wq->clone != c){ - devtabincref(c->dev); - wq->clone->dev = c->dev; + wq->clone->type = c->type; wq->clone->mchan = c->mchan; incref(&c->mchan->r); } @@ -794,7 +794,7 @@ mountio(Mnt *m, Mntrpc *r) n = convS2M(&r->request, r->rpc, m->msize); if(n < 0) panic("bad message type in mountio"); - if(m->c->dev->write(m->c, r->rpc, n, 0) != n) + if(devtab[m->c->type]->write(m->c, r->rpc, n, 0) != n) error(Emountrpc); /* r->stime = fastticks(nil); */ r->reqlen = n; @@ -830,7 +830,7 @@ doread(Mnt *m, int len) Block *b; while(qlen(m->q) < len){ - b = m->c->dev->bread(m->c, m->msize, 0); + b = devtab[m->c->type]->bread(m->c, m->msize, 0); if(b == nil) return -1; if(blocklen(b) == 0){ @@ -1151,7 +1151,7 @@ mntchk(Chan *c) /* * Was it closed and reused (was error(Eshutdown); now, it can't happen) */ - if(m->id == 0 || m->id >= c->devno) + if(m->id == 0 || m->id >= c->dev) panic("mntchk 3: can't happen"); return m; @@ -1167,11 +1167,11 @@ mntdirfix(uchar *dirbuf, Chan *c) { uint r; - r = c->dev->dc; + r = devtab[c->type]->dc; dirbuf += BIT16SZ; /* skip count */ PBIT16(dirbuf, r); dirbuf += BIT16SZ; - PBIT32(dirbuf, c->devno); + PBIT32(dirbuf, c->dev); } int @@ -1187,9 +1187,7 @@ Dev mntdevtab = { 'M', "mnt", - devreset, mntinit, - devshutdown, mntattach, mntwalk, mntstat, |
