| plan 9 kernel history: overview | file list | diff list |
1990/0303/port/devmnt.c (diff list | history)
| 1990/0227/sys/src/9/port/devmnt.c:18,23 – 1990/0303/sys/src/9/port/devmnt.c:18,24 (short | long) | ||
| 1990/0227 | { Ref; /* for number of chans, incl. mntpt but not msg */ QLock; /* for access */ | |
| 1990/0303 | ulong mntid; /* serial # */ | |
| 1990/0227 | Chan *msg; /* for reading and writing messages */ Chan *mntpt; /* channel in user's name space */ }; | |
| 1990/0227/sys/src/9/port/devmnt.c:50,55 – 1990/0303/sys/src/9/port/devmnt.c:51,62 | ||
| 1990/0227 | Mnthdr *free; }mnthdralloc; | |
| 1990/0303 | struct { Lock; long id; }mntid; | |
| 1990/0227 | Mnt *mnt; void mntxmit(Mnt*, Mnthdr*); | |
| 1990/0227/sys/src/9/port/devmnt.c:119,137 – 1990/0303/sys/src/9/port/devmnt.c:126,142 | ||
| 1990/0227 | mntdev(int dev, int noerr) { Mnt *m; | |
| 1990/0303 | int i; | |
| 1990/0227 |
| |
| 1990/0303 | for(m=mnt,i=0; i<conf.nmntdev; i++,m++) /* use a hash table some day */ if(m->mntid == dev){ if(m->msg == 0) break; return m; } if(noerr) return 0; error(0, Eshutdown); | |
| 1990/0227 | } void | |
| 1990/0227/sys/src/9/port/devmnt.c:187,194 – 1990/0303/sys/src/9/port/devmnt.c:192,202 | ||
| 1990/0227 | Found: m->ref = 1; unlock(m); | |
| 1990/0303 | lock(&mntid); m->mntid = ++mntid.id; unlock(&mntid); | |
| 1990/0227 | c = devattach('M', spec); | |
| 1990/0303 | c->dev = m->mntid; | |
| 1990/0227 | m->mntpt = c; cm = bogus.chan; m->msg = cm; | |
| 1990/0227/sys/src/9/port/devmnt.c:205,210 – 1990/0303/sys/src/9/port/devmnt.c:213,220 | ||
| 1990/0227 | strcpy(mh->thdr.aname, spec); mntxmit(m, mh); c->qid = mh->rhdr.qid; | |
| 1990/0303 | c->mchan = m->msg; c->mqid = c->qid; | |
| 1990/0227 | mhfree(mh); poperror(); return c; | |
| 1990/0227/sys/src/9/port/devmnt.c:243,248 – 1990/0303/sys/src/9/port/devmnt.c:253,260 | ||
| 1990/0227 | nc->flag = c->flag; nc->offset = c->offset; nc->mnt = c->mnt; | |
| 1990/0303 | nc->mchan = c->mchan; nc->mqid = c->qid; | |
| 1990/0227 | if(new) poperror(); mhfree(mh); | |
| 1990/0303/sys/src/9/port/devmnt.c:554,559 – 1990/0306/sys/src/9/port/devmnt.c:554,560 (short | long) | ||
| 1990/0227 | ulong n; Mntbuf *mbr, *mbw; Chan *mntpt; | |
| 1990/0306 | int isbit; | |
| 1990/0227 | mbr = mballoc(); mbw = mballoc(); | |
| 1990/0303/sys/src/9/port/devmnt.c:568,577 – 1990/0306/sys/src/9/port/devmnt.c:569,583 | ||
| 1990/0227 | qunlock(m); error(0, Eshutdown); } | |
| 1990/0306 | isbit = 0; if(devchar[m->msg->type] == 'b') isbit = 1; if(!isbit) qlock(m->msg); | |
| 1990/0227 | if(waserror()){ qunlock(m); | |
| 1990/0306 | if(!isbit) qunlock(m->msg); | |
| 1990/0227 | nexterror(); } if((*devtab[m->msg->type].write)(m->msg, mbw->buf, n) != n){ | |
| 1990/0303/sys/src/9/port/devmnt.c:584,590 – 1990/0306/sys/src/9/port/devmnt.c:590,597 | ||
| 1990/0227 | */ n = (*devtab[m->msg->type].read)(m->msg, mbr->buf, BUFSIZE); qunlock(m); | |
| 1990/0306 | if(!isbit) qunlock(m->msg); | |
| 1990/0227 | poperror(); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0306/sys/src/9/port/devmnt.c:553,559 – 1990/03081/sys/src/9/port/devmnt.c:553,559 (short | long) | ||
| 1990/0227 | { ulong n; Mntbuf *mbr, *mbw; | |
| 1990/03081 | Chan *mntpt, *msg; | |
| 1990/0306 | int isbit; | |
| 1990/0227 | mbr = mballoc(); | |
| 1990/0306/sys/src/9/port/devmnt.c:564,586 – 1990/03081/sys/src/9/port/devmnt.c:564,601 | ||
| 1990/0227 | nexterror(); } n = convS2M(&mh->thdr, mbw->buf); | |
| 1990/0306 | isbit = 0; if(devchar[m->msg->type] == 'b') isbit = 1; | |
| 1990/03081 | /* * Avoid qlock for bit, to maximize parallelism */ if(isbit){ lock(&m->use); /* spin rather than sleep */ if((msg = m->msg) == 0){ unlock(&m->use); error(0, Eshutdown); } incref(msg); unlock(&m->use); }else{ qlock(m); if((msg = m->msg) == 0){ qunlock(m); error(0, Eshutdown); } qlock(msg); } | |
| 1990/0227 | if(waserror()){ | |
| 1990/0306 |
| |
| 1990/03081 | if(isbit) close(msg); else{ qunlock(m); qunlock(msg); } | |
| 1990/0227 | nexterror(); } | |
| 1990/03081 | if((*devtab[msg->type].write)(msg, mbw->buf, n) != n){ | |
| 1990/0227 | pprint("short write in mntxmit\n"); error(0, Egreg); } | |
| 1990/0306/sys/src/9/port/devmnt.c:588,597 – 1990/03081/sys/src/9/port/devmnt.c:603,615 | ||
| 1990/0227 | /* * Read response */ | |
| 1990/0306 |
| |
| 1990/03081 | n = (*devtab[msg->type].read)(msg, mbr->buf, BUFSIZE); if(isbit) close(msg); else{ qunlock(m); qunlock(msg); } | |
| 1990/0227 | poperror(); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/03081/sys/src/9/port/devmnt.c:382,387 – 1990/0310/sys/src/9/port/devmnt.c:382,388 (short | long) | ||
| 1990/0227 | if(c == m->mntpt) m->mntpt = 0; if(decref(m) == 0){ /* BUG: need to hang up all pending i/o */ | |
| 1990/0310 | print("close mount table %d\n", m->mntid); | |
| 1990/0227 | qlock(m); close(m->msg); m->msg = 0; | |
| 1990/0310/sys/src/9/port/devmnt.c:468,473 – 1990/0312/sys/src/9/port/devmnt.c:468,474 (short | long) | ||
| 1990/0227 | mhfree(mh); nexterror(); } | |
| 1990/0312 | decref(m); | |
| 1990/0227 | mh->thdr.type = Tremove; mh->thdr.fid = c->fid; mntxmit(m, mh); | |
| 1990/0312/sys/src/9/port/devmnt.c:17,23 – 1990/0322/sys/src/9/port/devmnt.c:17,23 (short | long) | ||
| 1990/0227 | struct Mnt { Ref; /* for number of chans, incl. mntpt but not msg */ | |
| 1990/0322 | QLock q; /* for access */ | |
| 1990/0303 | ulong mntid; /* serial # */ | |
| 1990/0227 | Chan *msg; /* for reading and writing messages */ Chan *mntpt; /* channel in user's name space */ | |
| 1990/0312/sys/src/9/port/devmnt.c:383,392 – 1990/0322/sys/src/9/port/devmnt.c:383,392 | ||
| 1990/0227 | m->mntpt = 0; if(decref(m) == 0){ /* BUG: need to hang up all pending i/o */ | |
| 1990/0310 | print("close mount table %d\n", m->mntid); | |
| 1990/0227 |
| |
| 1990/0322 | qlock(&m->q); | |
| 1990/0227 | close(m->msg); m->msg = 0; | |
| 1990/0322 | qunlock(&m->q); | |
| 1990/0227 | } poperror(); } | |
| 1990/0312/sys/src/9/port/devmnt.c:573,589 – 1990/0322/sys/src/9/port/devmnt.c:573,589 | ||
| 1990/03081 | * Avoid qlock for bit, to maximize parallelism */ if(isbit){ | |
| 1990/0322 | lock(&m->q); /* spin rather than sleep */ | |
| 1990/03081 | if((msg = m->msg) == 0){ | |
| 1990/0322 | unlock(&m->q); | |
| 1990/03081 | error(0, Eshutdown); } incref(msg); | |
| 1990/0322 | unlock(&m->q); | |
| 1990/03081 | }else{ | |
| 1990/0322 | qlock(&m->q); | |
| 1990/03081 | if((msg = m->msg) == 0){ | |
| 1990/0322 | qunlock(&m->q); | |
| 1990/03081 | error(0, Eshutdown); } qlock(msg); | |
| 1990/0312/sys/src/9/port/devmnt.c:592,598 – 1990/0322/sys/src/9/port/devmnt.c:592,598 | ||
| 1990/03081 | if(isbit) close(msg); else{ | |
| 1990/0322 | qunlock(&m->q); | |
| 1990/03081 | qunlock(msg); } | |
| 1990/0227 | nexterror(); | |
| 1990/0312/sys/src/9/port/devmnt.c:609,615 – 1990/0322/sys/src/9/port/devmnt.c:609,615 | ||
| 1990/03081 | if(isbit) close(msg); else{ | |
| 1990/0322 | qunlock(&m->q); | |
| 1990/03081 | qunlock(msg); } | |
| 1990/0227 | poperror(); | |
| 1990/0322/sys/src/9/port/devmnt.c:17,23 – 1990/0324/sys/src/9/port/devmnt.c:17,23 (short | long) | ||
| 1990/0227 | struct Mnt { Ref; /* for number of chans, incl. mntpt but not msg */ | |
| 1990/0322 |
| |
| 1990/0324 | QLock; /* for access */ | |
| 1990/0303 | ulong mntid; /* serial # */ | |
| 1990/0227 | Chan *msg; /* for reading and writing messages */ Chan *mntpt; /* channel in user's name space */ | |
| 1990/0322/sys/src/9/port/devmnt.c:383,392 – 1990/0324/sys/src/9/port/devmnt.c:383,392 | ||
| 1990/0227 | m->mntpt = 0; if(decref(m) == 0){ /* BUG: need to hang up all pending i/o */ | |
| 1990/0310 | print("close mount table %d\n", m->mntid); | |
| 1990/0322 |
| |
| 1990/0324 | qlock(m); | |
| 1990/0227 | close(m->msg); m->msg = 0; | |
| 1990/0322 |
| |
| 1990/0324 | qunlock(m); | |
| 1990/0227 | } poperror(); } | |
| 1990/0322/sys/src/9/port/devmnt.c:567,589 – 1990/0324/sys/src/9/port/devmnt.c:567,589 | ||
| 1990/0227 | } n = convS2M(&mh->thdr, mbw->buf); | |
| 1990/0306 | isbit = 0; | |
| 1990/0324 | if(devchar[m->msg->type] == '3') | |
| 1990/0306 | isbit = 1; | |
| 1990/03081 | /* * Avoid qlock for bit, to maximize parallelism */ if(isbit){ | |
| 1990/0322 |
| |
| 1990/0324 | lock(&m->use); /* spin rather than sleep */ | |
| 1990/03081 | if((msg = m->msg) == 0){ | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&m->use); | |
| 1990/03081 | error(0, Eshutdown); } incref(msg); | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&m->use); | |
| 1990/03081 | }else{ | |
| 1990/0322 |
| |
| 1990/0324 | qlock(m); | |
| 1990/03081 | if((msg = m->msg) == 0){ | |
| 1990/0322 |
| |
| 1990/0324 | qunlock(m); | |
| 1990/03081 | error(0, Eshutdown); } qlock(msg); | |
| 1990/0322/sys/src/9/port/devmnt.c:592,598 – 1990/0324/sys/src/9/port/devmnt.c:592,598 | ||
| 1990/03081 | if(isbit) close(msg); else{ | |
| 1990/0322 |
| |
| 1990/0324 | qunlock(m); | |
| 1990/03081 | qunlock(msg); } | |
| 1990/0227 | nexterror(); | |
| 1990/0322/sys/src/9/port/devmnt.c:609,615 – 1990/0324/sys/src/9/port/devmnt.c:609,615 | ||
| 1990/03081 | if(isbit) close(msg); else{ | |
| 1990/0322 |
| |
| 1990/0324 | qunlock(m); | |
| 1990/03081 | qunlock(msg); } | |
| 1990/0227 | poperror(); | |
| 1990/0324/sys/src/9/port/devmnt.c:382,388 – 1990/0409/sys/src/9/port/devmnt.c:382,387 (short | long) | ||
| 1990/0227 | if(c == m->mntpt) m->mntpt = 0; if(decref(m) == 0){ /* BUG: need to hang up all pending i/o */ | |
| 1990/0310 |
| |
| 1990/0324 | qlock(m); | |
| 1990/0227 | close(m->msg); m->msg = 0; | |
| 1990/0409/sys/src/9/port/devmnt.c:555,561 – 1990/0511/sys/src/9/port/devmnt.c:555,560 (short | long) | ||
| 1990/0227 | ulong n; Mntbuf *mbr, *mbw; | |
| 1990/03081 | Chan *mntpt, *msg; | |
| 1990/0306 |
| |
| 1990/0227 | mbr = mballoc(); mbw = mballoc(); | |
| 1990/0409/sys/src/9/port/devmnt.c:565,599 – 1990/0511/sys/src/9/port/devmnt.c:564,584 | ||
| 1990/0227 | nexterror(); } n = convS2M(&mh->thdr, mbw->buf); | |
| 1990/0306 |
| |
| 1990/0324 |
| |
| 1990/0306 |
| |
| 1990/03081 | /* | |
| 1990/0511 | * Bit3 does its own multiplexing. (Well, the file server does.) * The code is different enough that it's broken out separately here. | |
| 1990/03081 | */ | |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0511 | if(devchar[m->msg->type] != '3') goto Normal; lock(&m->use); /* spin rather than sleep */ if((msg = m->msg) == 0){ | |
| 1990/0324 | unlock(&m->use); | |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0511 | error(0, Eshutdown); | |
| 1990/03081 | } | |
| 1990/0511 | incref(msg); unlock(&m->use); | |
| 1990/0227 | if(waserror()){ | |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0511 | close(msg); | |
| 1990/0227 | nexterror(); } | |
| 1990/03081 | if((*devtab[msg->type].write)(msg, mbw->buf, n) != n){ | |
| 1990/0409/sys/src/9/port/devmnt.c:605,616 – 1990/0511/sys/src/9/port/devmnt.c:590,654 | ||
| 1990/0227 | * Read response */ | |
| 1990/03081 | n = (*devtab[msg->type].read)(msg, mbr->buf, BUFSIZE); | |
| 1990/0511 | close(msg); poperror(); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ pprint("format error in mntxmit\n"); error(0, Egreg); } /* * Various checks */ if(mh->rhdr.type != mh->thdr.type+1){ pprint("type mismatch %d %d\n", mh->rhdr.type, mh->thdr.type+1); error(0, Egreg); } if(mh->rhdr.fid != mh->thdr.fid){ pprint("fid mismatch %d %d type %d\n", mh->rhdr.fid, mh->thdr.fid, mh->rhdr.type); error(0, Egreg); } if(mh->rhdr.err){ mntpt = m->mntpt; /* unsafe, but Errors are unsafe anyway */ if(mntpt) error(mntpt, mh->rhdr.err); error(0, Eshutdown); } /* * Copy out on read */ if(mh->thdr.type == Tread) memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); mbfree(mbr); mbfree(mbw); poperror(); return; Normal: qlock(m); if((msg = m->msg) == 0){ | |
| 1990/0324 | qunlock(m); | |
| 1990/0511 | error(0, Eshutdown); } qlock(msg); if(waserror()){ qunlock(m); | |
| 1990/03081 | qunlock(msg); | |
| 1990/0511 | nexterror(); | |
| 1990/03081 | } | |
| 1990/0511 | if((*devtab[msg->type].write)(msg, mbw->buf, n) != n){ pprint("short write in mntxmit\n"); error(0, Egreg); } /* * Read response */ n = (*devtab[msg->type].read)(msg, mbr->buf, BUFSIZE); qunlock(m); qunlock(msg); | |
| 1990/0227 | poperror(); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0511/sys/src/9/port/devmnt.c:255,264 – 1990/0513/sys/src/9/port/devmnt.c:255,264 (short | long) | ||
| 1990/0227 | nc->mnt = c->mnt; | |
| 1990/0303 | nc->mchan = c->mchan; nc->mqid = c->qid; | |
| 1990/0227 |
| |
| 1990/0513 | if(new) poperror(); | |
| 1990/0227 | incref(m); return nc; } | |
| 1990/0513/sys/src/9/port/devmnt.c:9,28 – 1990/0604/sys/src/9/port/devmnt.c:9,37 (short | long) | ||
| 1990/0227 | #include "fcall.h" | |
| 1990/0604 | typedef struct Mnthdr Mnthdr; typedef struct MntQ MntQ; | |
| 1990/0227 | struct Mnt { Ref; /* for number of chans, incl. mntpt but not msg */ | |
| 1990/0324 |
| |
| 1990/0303 | ulong mntid; /* serial # */ | |
| 1990/0227 |
| |
| 1990/0604 | MntQ *q; | |
| 1990/0227 | }; | |
| 1990/0604 | struct MntQ { Ref; QLock; /* for access */ MntQ *next; /* for allocation */ Chan *msg; /* for reading and writing messages */ Proc *reader; /* process reading response */ Mnthdr *writer; /* queue of headers of written messages */ }; | |
| 1990/0227 | #define BUFSIZE (MAXFDATA+500) /* BUG */ typedef struct Mntbuf Mntbuf; struct Mntbuf | |
| 1990/0513/sys/src/9/port/devmnt.c:37,48 – 1990/0604/sys/src/9/port/devmnt.c:46,59 | ||
| 1990/0227 | Mntbuf *free; }mntbufalloc; | |
| 1990/0604 | struct Mnthdr | |
| 1990/0227 | { | |
| 1990/0604 | Mnthdr *next; /* in free list or writers list */ | |
| 1990/0227 | Fcall thdr; Fcall rhdr; | |
| 1990/0604 | Rendez r; Proc *p; Mntbuf *mbr; | |
| 1990/0227 | }; struct | |
| 1990/0513/sys/src/9/port/devmnt.c:54,59 – 1990/0604/sys/src/9/port/devmnt.c:65,77 | ||
| 1990/0303 | struct { Lock; | |
| 1990/0604 | MntQ *arena; MntQ *free; }mntqalloc; struct { Lock; | |
| 1990/0303 | long id; }mntid; | |
| 1990/0513/sys/src/9/port/devmnt.c:106,112 – 1990/0604/sys/src/9/port/devmnt.c:124,130 | ||
| 1990/0227 | unlock(&mnthdralloc); print("no mnthdrs\n"); if(u == 0) | |
| 1990/0604 | panic("mhalloc"); | |
| 1990/0227 | u->p->state = Wakeme; alarm(1000, wakeme, u->p); sched(); | |
| 1990/0513/sys/src/9/port/devmnt.c:122,127 – 1990/0604/sys/src/9/port/devmnt.c:140,184 | ||
| 1990/0227 | unlock(&mnthdralloc); } | |
| 1990/0604 | MntQ* mqalloc(void) { MntQ *q; lock(&mntqalloc); if(q = mntqalloc.free){ /* assign = */ mntqalloc.free = q->next; unlock(&mntqalloc); lock(q); q->ref = 1; q->writer = 0; q->reader = 0; unlock(q); return q; } unlock(&mntqalloc); panic("no mntqs\n"); /* there MUST be enough */ } void mqfree(MntQ *mq) { Chan *msg = 0; lock(mq); if(--mq->ref == 0){ msg = mq->msg; mq->msg = 0; lock(&mntqalloc); mq->next = mntqalloc.free; mntqalloc.free = mq; unlock(&mntqalloc); } unlock(mq); if(msg) /* after locks are down */ close(msg); } | |
| 1990/0227 | Mnt* mntdev(int dev, int noerr) { | |
| 1990/0513/sys/src/9/port/devmnt.c:130,136 – 1990/0604/sys/src/9/port/devmnt.c:187,193 | ||
| 1990/0227 | ||
| 1990/0303 | for(m=mnt,i=0; i<conf.nmntdev; i++,m++) /* use a hash table some day */ if(m->mntid == dev){ | |
| 1990/0604 | if(m->q == 0) | |
| 1990/0303 | break; return m; } | |
| 1990/0513/sys/src/9/port/devmnt.c:145,150 – 1990/0604/sys/src/9/port/devmnt.c:202,208 | ||
| 1990/0227 | int i; Mntbuf *mb; Mnthdr *mh; | |
| 1990/0604 | MntQ *mq; | |
| 1990/0227 | mnt = ialloc(conf.nmntdev*sizeof(Mnt), 0); | |
| 1990/0513/sys/src/9/port/devmnt.c:159,164 – 1990/0604/sys/src/9/port/devmnt.c:217,229 | ||
| 1990/0227 | mh[i].next = &mh[i+1]; mh[i].next = 0; mnthdralloc.free = mh; | |
| 1990/0604 | mq = ialloc(conf.nmntdev*sizeof(MntQ), 0); for(i=0; i<conf.nmntdev-1; i++) mq[i].next = &mq[i+1]; mq[i].next = 0; mntqalloc.arena = mq; mntqalloc.free = mq; | |
| 1990/0227 | } void | |
| 1990/0513/sys/src/9/port/devmnt.c:170,177 – 1990/0604/sys/src/9/port/devmnt.c:235,243 | ||
| 1990/0227 | mntattach(char *spec) { int i; | |
| 1990/0604 | Mnt *m, *mm; | |
| 1990/0227 | Mnthdr *mh; | |
| 1990/0604 | MntQ *q; | |
| 1990/0227 | Chan *c, *cm; struct bogus{ Chan *chan; | |
| 1990/0513/sys/src/9/port/devmnt.c:189,194 – 1990/0604/sys/src/9/port/devmnt.c:255,261 | ||
| 1990/0227 | unlock(m); } error(0, Enomntdev); | |
| 1990/0604 | ||
| 1990/0227 | Found: m->ref = 1; unlock(m); | |
| 1990/0513/sys/src/9/port/devmnt.c:199,209 – 1990/0604/sys/src/9/port/devmnt.c:266,296 | ||
| 1990/0303 | c->dev = m->mntid; | |
| 1990/0227 | m->mntpt = c; cm = bogus.chan; | |
| 1990/0604 | /* * Look for queue to same msg channel */ q = mntqalloc.arena; for(i=0; i<conf.nmntdev; i++,q++) if(q->msg==cm){ lock(q); if(q->ref && q->msg==cm){ m->q = q; q->ref++; unlock(q); goto out; } unlock(q); } m->q = mqalloc(); m->q->msg = cm; | |
| 1990/0227 | incref(cm); | |
| 1990/0604 | out: | |
| 1990/0227 | mh = mhalloc(); if(waserror()){ mhfree(mh); | |
| 1990/0604 | mqfree(q); | |
| 1990/0227 | close(c); nexterror(); } | |
| 1990/0513/sys/src/9/port/devmnt.c:213,219 – 1990/0604/sys/src/9/port/devmnt.c:300,306 | ||
| 1990/0227 | strcpy(mh->thdr.aname, spec); mntxmit(m, mh); c->qid = mh->rhdr.qid; | |
| 1990/0303 |
| |
| 1990/0604 | c->mchan = m->q->msg; | |
| 1990/0303 | c->mqid = c->qid; | |
| 1990/0227 | mhfree(mh); poperror(); | |
| 1990/0513/sys/src/9/port/devmnt.c:364,395 – 1990/0604/sys/src/9/port/devmnt.c:451,496 | ||
| 1990/0227 | } void | |
| 1990/0604 | mntclunk(Chan *c, int t) | |
| 1990/0227 | { Mnt *m; Mnthdr *mh; | |
| 1990/0604 | MntQ *q; int waserr; int ne = u->nerrlab; | |
| 1990/0227 | m = mntdev(c->dev, 0); mh = mhalloc(); | |
| 1990/0604 | mh->thdr.type = t; | |
| 1990/0227 | mh->thdr.fid = c->fid; | |
| 1990/0604 | waserr = 0; if(waserror()) /* gotta clean up as if there wasn't */ waserr = 1; else mntxmit(m, mh); | |
| 1990/0227 | mhfree(mh); if(c == m->mntpt) m->mntpt = 0; | |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/0604 | lock(m); if(--m->ref == 0){ /* BUG: need to hang up all pending i/o */ q = m->q; m->q = 0; m->mntid = 0; unlock(m); /* mqfree can take time */ mqfree(q); }else unlock(m); if(waserr) nexterror(); | |
| 1990/0227 | poperror(); } | |
| 1990/0604 | void mntclose(Chan *c) { mntclunk(c, Tclunk); } | |
| 1990/0227 | long mntreadwrite(Chan *c, void *vbuf, long n, int type) { | |
| 1990/0513/sys/src/9/port/devmnt.c:458,478 – 1990/0604/sys/src/9/port/devmnt.c:559,565 | ||
| 1990/0227 | void mntremove(Chan *c) { | |
| 1990/0312 |
| |
| 1990/0227 |
| |
| 1990/0604 | mntclunk(c, Tremove); | |
| 1990/0227 | } void | |
| 1990/0513/sys/src/9/port/devmnt.c:550,560 – 1990/0604/sys/src/9/port/devmnt.c:637,684 | ||
| 1990/0227 | } void | |
| 1990/0604 | mnterrdequeue(MntQ *q, Mnthdr *mh) /* queue is unlocked */ { Mnthdr *w; qlock(q); /* take self from queue if necessary */ if(q->reader == u->p){ /* advance a writer to reader */ w = q->writer; if(w){ q->reader = w->p; q->writer = w->next; wakeup(&w->r); }else{ q->reader = 0; q->writer = 0; } }else{ w = q->writer; if(w == mh) q->writer = w->next; else{ while(w){ if(w->next == mh){ w->next = mh->next; break; } w = w->next; } } } qunlock(q); } void | |
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { ulong n; Mntbuf *mbr, *mbw; | |
| 1990/03081 |
| |
| 1990/0604 | Mnthdr *w, *ow; Chan *mntpt; MntQ *q; int qlocked; | |
| 1990/0227 | mbr = mballoc(); mbw = mballoc(); | |
| 1990/0513/sys/src/9/port/devmnt.c:564,601 – 1990/0604/sys/src/9/port/devmnt.c:688,724 | ||
| 1990/0227 | nexterror(); } n = convS2M(&mh->thdr, mbw->buf); | |
| 1990/0604 | q = m->q; if(q == 0) error(0, Eshutdown); #ifdef BIT3 | |
| 1990/03081 | /* | |
| 1990/0511 | * Bit3 does its own multiplexing. (Well, the file server does.) * The code is different enough that it's broken out separately here. | |
| 1990/03081 | */ | |
| 1990/0511 |
| |
| 1990/0604 | if(devchar[q->msg->type] != '3') | |
| 1990/0511 | goto Normal; | |
| 1990/0324 |
| |
| 1990/0511 |
| |
| 1990/03081 |
| |
| 1990/0511 |
| |
| 1990/0604 | incref(q); | |
| 1990/0227 | if(waserror()){ | |
| 1990/0511 |
| |
| 1990/0604 | mqfree(q); | |
| 1990/0227 | nexterror(); } | |
| 1990/03081 |
| |
| 1990/0227 |
| |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); error(0, Eshortmsg); | |
| 1990/0227 | } /* * Read response */ | |
| 1990/03081 |
| |
| 1990/0511 |
| |
| 1990/0604 | n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE); mqfree(q); | |
| 1990/0511 | poperror(); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | print("format error in mntxmit\n"); error(0, Ebadmsg); | |
| 1990/0511 | } /* | |
| 1990/0513/sys/src/9/port/devmnt.c:602,613 – 1990/0604/sys/src/9/port/devmnt.c:725,736 | ||
| 1990/0511 | * Various checks */ if(mh->rhdr.type != mh->thdr.type+1){ | |
| 1990/0604 | print("type mismatch %d %d\n", mh->rhdr.type, mh->thdr.type+1); error(0, Ebadmsg); | |
| 1990/0511 | } if(mh->rhdr.fid != mh->thdr.fid){ | |
| 1990/0604 | print("fid mismatch %d %d type %d\n", mh->rhdr.fid, mh->thdr.fid, mh->rhdr.type); error(0, Ebadmsg); | |
| 1990/0511 | } if(mh->rhdr.err){ mntpt = m->mntpt; /* unsafe, but Errors are unsafe anyway */ | |
| 1990/0513/sys/src/9/port/devmnt.c:627,672 – 1990/0604/sys/src/9/port/devmnt.c:750,846 | ||
| 1990/0511 | return; Normal: | |
| 1990/0324 |
| |
| 1990/0511 |
| |
| 1990/0604 | #endif incref(q); qlock(q); qlocked = 1; | |
| 1990/0511 | if(waserror()){ | |
| 1990/03081 |
| |
| 1990/0604 | if(qlocked) qunlock(q); mqfree(q); | |
| 1990/0511 | nexterror(); | |
| 1990/03081 | } | |
| 1990/0511 |
| |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); error(0, Eshortmsg); | |
| 1990/0511 | } | |
| 1990/0227 |
| |
| 1990/0604 | if(q->reader == 0){ /* i will read */ q->reader = u->p; Read: qunlock(q); qlocked = 0; n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ print("format error in mntxmit\n"); mnterrdequeue(q, mh); error(0, Ebadmsg); } /* * Response might not be mine */ qlock(q); qlocked = 1; if(mh->rhdr.fid == mh->thdr.fid && mh->rhdr.type == mh->thdr.type+1){ /* it's mine */ q->reader = 0; if(w = q->writer){ /* advance a writer to reader */ q->reader = w->p; q->writer = w->next; wakeup(&w->r); } qunlock(q); qlocked = 0; goto Respond; } /* * Hand response to correct recipient */ if(q->writer == 0) print("response with empty queue\n"); for(ow=0,w=q->writer; w; ow=w,w=w->next) if(mh->rhdr.fid == w->thdr.fid && mh->rhdr.type == w->thdr.type+1){ Mntbuf *t; t = mbr; mbr = w->mbr; w->mbr = t; memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr); /* take recipient from queue */ if(ow == 0) q->writer = w->next; else ow->next = w->next; wakeup(&w->r); goto Read; } goto Read; }else{ mh->mbr = mbr; mh->p = u->p; /* put self in queue */ mh->next = q->writer; q->writer = mh; qunlock(q); qlocked = 0; if(waserror()){ /* interrupted sleep */ print("interrupted i/o\n"); mnterrdequeue(q, mh); nexterror(); } sleep(&mh->r, return0, 0); poperror(); qlock(q); qlocked = 1; if(q->reader == u->p) /* i got promoted */ goto Read; mbr = mh->mbr; /* pick up my buffer */ qunlock(q); qlocked = 0; goto Respond; | |
| 1990/0227 | } | |
| 1990/0604 | Respond: mqfree(q); poperror(); | |
| 1990/0227 | if(mh->rhdr.err){ mntpt = m->mntpt; /* unsafe, but Errors are unsafe anyway */ if(mntpt) | |
| 1990/0604/sys/src/9/port/devmnt.c:141,162 – 1990/0617/sys/src/9/port/devmnt.c:141,161 (short | long) | ||
| 1990/0227 | } | |
| 1990/0604 | MntQ* | |
| 1990/0617 | mqalloc(Chan *msg) /* mntqalloc is locked */ | |
| 1990/0604 | { MntQ *q; | |
| 1990/0617 | q->msg = msg; unlock(q); incref(msg); | |
| 1990/0604 | q->writer = 0; q->reader = 0; | |
| 1990/0604/sys/src/9/port/devmnt.c:167,172 – 1990/0617/sys/src/9/port/devmnt.c:166,172 | ||
| 1990/0604 | lock(mq); if(--mq->ref == 0){ | |
| 1990/0617 | print("mqfree %lux %lux\n", mq->reader, mq->writer); | |
| 1990/0604 | msg = mq->msg; mq->msg = 0; lock(&mntqalloc); | |
| 1990/0604/sys/src/9/port/devmnt.c:271,276 – 1990/0617/sys/src/9/port/devmnt.c:271,277 | ||
| 1990/0604 | * Look for queue to same msg channel */ q = mntqalloc.arena; | |
| 1990/0617 | lock(&mntqalloc); | |
| 1990/0604 | for(i=0; i<conf.nmntdev; i++,q++) if(q->msg==cm){ lock(q); | |
| 1990/0604/sys/src/9/port/devmnt.c:282,292 – 1990/0617/sys/src/9/port/devmnt.c:283,292 | ||
| 1990/0604 | } unlock(q); } | |
| 1990/0227 |
| |
| 1990/0617 | m->q = mqalloc(cm); | |
| 1990/0604 | out: | |
| 1990/0617 | unlock(&mntqalloc); | |
| 1990/0227 | mh = mhalloc(); if(waserror()){ mhfree(mh); | |
| 1990/0604/sys/src/9/port/devmnt.c:771,777 – 1990/0617/sys/src/9/port/devmnt.c:771,777 | ||
| 1990/0604 | qlocked = 0; n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE); if(convM2S(mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0617 | print("%lux %lux %lux %d format error in mntxmit %s\n", u->p, q->reader, q->writer, n, u->p->text); | |
| 1990/0604 | mnterrdequeue(q, mh); error(0, Ebadmsg); } | |
| 1990/0604/sys/src/9/port/devmnt.c:795,801 – 1990/0617/sys/src/9/port/devmnt.c:795,801 | ||
| 1990/0604 | /* * Hand response to correct recipient */ | |
| 1990/0617 | if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr.type, mh->rhdr.err, mh->rhdr.fid, mh->thdr.type, mh->thdr.fid); | |
| 1990/0604 | for(ow=0,w=q->writer; w; ow=w,w=w->next) if(mh->rhdr.fid == w->thdr.fid && mh->rhdr.type == w->thdr.type+1){ | |
| 1990/0604/sys/src/9/port/devmnt.c:822,828 – 1990/0617/sys/src/9/port/devmnt.c:822,828 | ||
| 1990/0604 | qunlock(q); qlocked = 0; if(waserror()){ /* interrupted sleep */ | |
| 1990/0617 | print("%lux interrupted i/o %d %d\n", u->p, mh->thdr.type, mh->thdr.fid); | |
| 1990/0604 | mnterrdequeue(q, mh); nexterror(); } | |
| 1990/0617/sys/src/9/port/devmnt.c:65,70 – 1990/0619/sys/src/9/port/devmnt.c:65,71 (short | long) | ||
| 1990/0303 | struct { Lock; | |
| 1990/0619 | QLock; | |
| 1990/0604 | MntQ *arena; MntQ *free; }mntqalloc; | |
| 1990/0617/sys/src/9/port/devmnt.c:141,147 – 1990/0619/sys/src/9/port/devmnt.c:142,148 | ||
| 1990/0227 | } | |
| 1990/0604 | MntQ* | |
| 1990/0617 |
| |
| 1990/0619 | mqalloc(Chan *msg) /* mntqalloc is qlocked */ | |
| 1990/0604 | { MntQ *q; | |
| 1990/0617/sys/src/9/port/devmnt.c:166,172 – 1990/0619/sys/src/9/port/devmnt.c:167,172 | ||
| 1990/0604 | lock(mq); if(--mq->ref == 0){ | |
| 1990/0617 |
| |
| 1990/0604 | msg = mq->msg; mq->msg = 0; lock(&mntqalloc); | |
| 1990/0617/sys/src/9/port/devmnt.c:271,277 – 1990/0619/sys/src/9/port/devmnt.c:271,277 | ||
| 1990/0604 | * Look for queue to same msg channel */ q = mntqalloc.arena; | |
| 1990/0617 |
| |
| 1990/0619 | qlock(&mntqalloc); | |
| 1990/0604 | for(i=0; i<conf.nmntdev; i++,q++) if(q->msg==cm){ lock(q); | |
| 1990/0617/sys/src/9/port/devmnt.c:286,292 – 1990/0619/sys/src/9/port/devmnt.c:286,292 | ||
| 1990/0617 | m->q = mqalloc(cm); | |
| 1990/0604 | out: | |
| 1990/0617 |
| |
| 1990/0619 | qunlock(&mntqalloc); | |
| 1990/0227 | mh = mhalloc(); if(waserror()){ mhfree(mh); | |
| 1990/0617/sys/src/9/port/devmnt.c:674,689 – 1990/0619/sys/src/9/port/devmnt.c:674,689 | ||
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { ulong n; | |
| 1990/0619 | Mntbuf *mbw; | |
| 1990/0604 | Mnthdr *w, *ow; Chan *mntpt; MntQ *q; int qlocked; | |
| 1990/0227 |
| |
| 1990/0619 | mh->mbr = mballoc(); | |
| 1990/0227 | mbw = mballoc(); if(waserror()){ | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); nexterror(); } | |
| 1990/0617/sys/src/9/port/devmnt.c:712,722 – 1990/0619/sys/src/9/port/devmnt.c:712,722 | ||
| 1990/0227 | /* * Read response */ | |
| 1990/0604 |
| |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/0604 | mqfree(q); | |
| 1990/0511 | poperror(); | |
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | print("format error in mntxmit\n"); error(0, Ebadmsg); | |
| 1990/0511 | } | |
| 1990/0617/sys/src/9/port/devmnt.c:744,750 – 1990/0619/sys/src/9/port/devmnt.c:744,750 | ||
| 1990/0511 | */ if(mh->thdr.type == Tread) memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0511 | mbfree(mbw); poperror(); return; | |
| 1990/0617/sys/src/9/port/devmnt.c:769,777 – 1990/0619/sys/src/9/port/devmnt.c:769,777 | ||
| 1990/0604 | Read: qunlock(q); qlocked = 0; | |
| 1990/0617 |
| |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ print("format error in mntxmit\n"); | |
| 1990/0604 | mnterrdequeue(q, mh); error(0, Ebadmsg); } | |
| 1990/0617/sys/src/9/port/devmnt.c:795,807 – 1990/0619/sys/src/9/port/devmnt.c:795,807 | ||
| 1990/0604 | /* * Hand response to correct recipient */ | |
| 1990/0617 |
| |
| 1990/0619 | if(q->writer==0) print("response with empty queue\n"); | |
| 1990/0604 | for(ow=0,w=q->writer; w; ow=w,w=w->next) if(mh->rhdr.fid == w->thdr.fid && mh->rhdr.type == w->thdr.type+1){ Mntbuf *t; | |
| 1990/0619 | t = mh->mbr; mh->mbr = w->mbr; | |
| 1990/0604 | w->mbr = t; memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr); /* take recipient from queue */ | |
| 1990/0617/sys/src/9/port/devmnt.c:814,820 – 1990/0619/sys/src/9/port/devmnt.c:814,819 | ||
| 1990/0604 | } goto Read; }else{ | |
| 1990/0617/sys/src/9/port/devmnt.c:822,828 – 1990/0619/sys/src/9/port/devmnt.c:821,827 | ||
| 1990/0604 | qunlock(q); qlocked = 0; if(waserror()){ /* interrupted sleep */ | |
| 1990/0617 |
| |
| 1990/0619 | print("interrupted i/o\n"); | |
| 1990/0604 | mnterrdequeue(q, mh); nexterror(); } | |
| 1990/0617/sys/src/9/port/devmnt.c:832,838 – 1990/0619/sys/src/9/port/devmnt.c:831,836 | ||
| 1990/0604 | qlocked = 1; if(q->reader == u->p) /* i got promoted */ goto Read; | |
| 1990/0617/sys/src/9/port/devmnt.c:852,858 – 1990/0619/sys/src/9/port/devmnt.c:850,856 | ||
| 1990/0227 | */ if(mh->thdr.type == Tread) memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); poperror(); } | |
| 1990/0619/sys/src/9/port/devmnt.c:771,777 – 1990/0623/sys/src/9/port/devmnt.c:771,776 (short | long) | ||
| 1990/0604 | qlocked = 0; | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | mnterrdequeue(q, mh); error(0, Ebadmsg); } | |
| 1990/0619/sys/src/9/port/devmnt.c:795,801 – 1990/0623/sys/src/9/port/devmnt.c:794,799 | ||
| 1990/0604 | /* * Hand response to correct recipient */ | |
| 1990/0619 |
| |
| 1990/0604 | for(ow=0,w=q->writer; w; ow=w,w=w->next) if(mh->rhdr.fid == w->thdr.fid && mh->rhdr.type == w->thdr.type+1){ | |
| 1990/0619/sys/src/9/port/devmnt.c:821,827 – 1990/0623/sys/src/9/port/devmnt.c:819,824 | ||
| 1990/0604 | qunlock(q); qlocked = 0; if(waserror()){ /* interrupted sleep */ | |
| 1990/0619 |
| |
| 1990/0604 | mnterrdequeue(q, mh); nexterror(); } | |
| 1990/0623/sys/src/9/port/devmnt.c:810,815 – 1990/0629/sys/src/9/port/devmnt.c:810,819 (short | long) | ||
| 1990/0604 | wakeup(&w->r); goto Read; } | |
| 1990/0629 | print("devmnt: undelivered response fid %d type %d\n", mh->rhdr.fid, mh->rhdr.type); print("reader pid %d fid %d type %d\n", u->p->pid, mh->thdr.fid, mh->thdr.type); for(w=q->writer; w; w=w->next)print("writer pid %d fid %d type %d\n",w->p->pid,w->thdr.fid,w->thdr.type); | |
| 1990/0604 | goto Read; }else{ mh->p = u->p; | |
| 1990/0629/sys/src/9/port/devmnt.c:769,775 – 1990/0703/sys/src/9/port/devmnt.c:769,780 (short | long) | ||
| 1990/0604 | Read: qunlock(q); qlocked = 0; | |
| 1990/0703 | if(waserror()){ mnterrdequeue(q, mh); nexterror(); } | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/0703 | poperror(); | |
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | mnterrdequeue(q, mh); error(0, Ebadmsg); | |
| 1990/0629/sys/src/9/port/devmnt.c:810,819 – 1990/0703/sys/src/9/port/devmnt.c:815,820 | ||
| 1990/0604 | wakeup(&w->r); goto Read; } | |
| 1990/0629 |
| |
| 1990/0604 | goto Read; }else{ mh->p = u->p; | |
| 1990/0629/sys/src/9/port/devmnt.c:849,856 – 1990/0703/sys/src/9/port/devmnt.c:850,860 | ||
| 1990/0227 | /* * Copy out on read */ | |
| 1990/0703 | if(mh->thdr.type == Tread){ if(mh->rhdr.count > mh->thdr.count) error(0, Ebadcnt); | |
| 1990/0227 | memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/0703 | } | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); poperror(); | |
| 1990/0703/sys/src/9/port/devmnt.c:54,59 – 1990/0717/sys/src/9/port/devmnt.c:54,60 (short | long) | ||
| 1990/0604 | Rendez r; Proc *p; Mntbuf *mbr; | |
| 1990/0717 | int readreply; /* true if we are reader or our reply has come */ | |
| 1990/0227 | }; struct | |
| 1990/0703/sys/src/9/port/devmnt.c:670,675 – 1990/0717/sys/src/9/port/devmnt.c:671,681 | ||
| 1990/0604 | qunlock(q); } | |
| 1990/0717 | int mntreadreply(void *a) { return ((Mnthdr *)a)->readreply; } | |
| 1990/0604 | void | |
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { | |
| 1990/0703/sys/src/9/port/devmnt.c:760,765 – 1990/0717/sys/src/9/port/devmnt.c:766,772 | ||
| 1990/0604 | mqfree(q); | |
| 1990/0511 | nexterror(); | |
| 1990/03081 | } | |
| 1990/0717 | mh->readreply = 0; | |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); error(0, Eshortmsg); | |
| 1990/0703/sys/src/9/port/devmnt.c:790,795 – 1990/0717/sys/src/9/port/devmnt.c:797,803 | ||
| 1990/0604 | if(w = q->writer){ /* advance a writer to reader */ q->reader = w->p; q->writer = w->next; | |
| 1990/0717 | w->readreply = 1; | |
| 1990/0604 | wakeup(&w->r); } qunlock(q); | |
| 1990/0703/sys/src/9/port/devmnt.c:812,817 – 1990/0717/sys/src/9/port/devmnt.c:820,826 | ||
| 1990/0604 | q->writer = w->next; else ow->next = w->next; | |
| 1990/0717 | w->readreply = 1; | |
| 1990/0604 | wakeup(&w->r); goto Read; } | |
| 1990/0703/sys/src/9/port/devmnt.c:827,833 – 1990/0717/sys/src/9/port/devmnt.c:836,842 | ||
| 1990/0604 | mnterrdequeue(q, mh); nexterror(); } | |
| 1990/0717 | sleep(&mh->r, mntreadreply, mh); | |
| 1990/0604 | poperror(); qlock(q); qlocked = 1; | |
| 1990/0703/sys/src/9/port/devmnt.c:858,861 – 1990/0717/sys/src/9/port/devmnt.c:867,889 | ||
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); poperror(); | |
| 1990/0717 | } mntdump() { int i; MntQ *q; Mnthdr *h; Proc *p; for(i=0; i<conf.nmntdev; i++){ q = &mntqalloc.arena[i]; if(!q->msg) continue; p = q->reader; print("q rdr %d wrtr ", p? p->pid : 0); for(h=q->writer; h; h=h->next) print("(%lux %lux %d)", h, &h->r, (p=h->p)? p->pid : 0); print("\n"); } | |
| 1990/0227 | } | |
| 1990/0717/sys/src/9/port/devmnt.c:291,297 – 1990/0725/sys/src/9/port/devmnt.c:291,296 (short | long) | ||
| 1990/0227 | mh = mhalloc(); if(waserror()){ mhfree(mh); | |
| 1990/0604 |
| |
| 1990/0227 | close(c); nexterror(); } | |
| 1990/0725/sys/src/9/port/devmnt.c:747,754 – 1990/1002/sys/src/9/port/devmnt.c:747,757 (short | long) | ||
| 1990/0511 | /* * Copy out on read */ | |
| 1990/1002 | if(mh->thdr.type == Tread){ if(mh->rhdr.count>497 && mh->rhdr.data[497]==011) print("*497==11 %lux\n", &mh->rhdr.data[497]); | |
| 1990/0511 | memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/1002 | } | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0511 | mbfree(mbw); poperror(); | |
| 1990/1002/sys/src/9/port/devmnt.c:747,757 – 1990/1004/sys/src/9/port/devmnt.c:747,754 (short | long) | ||
| 1990/0511 | /* * Copy out on read */ | |
| 1990/1002 |
| |
| 1990/1004 | if(mh->thdr.type == Tread) | |
| 1990/0511 | memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/1002 |
| |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0511 | mbfree(mbw); poperror(); | |
| 1990/1004/sys/src/9/port/devmnt.c:9,15 – 1990/11211/sys/src/9/port/devmnt.c:9,14 (short | long) | ||
| 1990/0227 | #include "fcall.h" | |
| 1990/0604 | typedef struct Mnthdr Mnthdr; typedef struct MntQ MntQ; | |
| 1990/1004/sys/src/9/port/devmnt.c:194,200 – 1990/11211/sys/src/9/port/devmnt.c:193,199 | ||
| 1990/0303 | } if(noerr) return 0; | |
| 1990/11211 | error(Eshutdown); | |
| 1990/0227 | } void | |
| 1990/1004/sys/src/9/port/devmnt.c:214,222 – 1990/11211/sys/src/9/port/devmnt.c:213,224 | ||
| 1990/0227 | mntbufalloc.free = mb; mh = ialloc(conf.nmnthdr*sizeof(Mnthdr), 0); | |
| 1990/11211 | for(i=0; i<conf.nmnthdr-1; i++){ | |
| 1990/0227 | mh[i].next = &mh[i+1]; | |
| 1990/11211 | mh[i].thdr.tag = i; } | |
| 1990/0227 | mh[i].next = 0; | |
| 1990/11211 | mh[i].thdr.tag = i; | |
| 1990/0227 | mnthdralloc.free = mh; | |
| 1990/0604 | mq = ialloc(conf.nmntdev*sizeof(MntQ), 0); | |
| 1990/1004/sys/src/9/port/devmnt.c:233,239 – 1990/11211/sys/src/9/port/devmnt.c:235,241 | ||
| 1990/0227 | } Chan* | |
| 1990/11211 | mntattach(char *crud) | |
| 1990/0227 | { int i; | |
| 1990/0604 | Mnt *m, *mm; | |
| 1990/1004/sys/src/9/port/devmnt.c:243,252 – 1990/11211/sys/src/9/port/devmnt.c:245,254 | ||
| 1990/0227 | struct bogus{ Chan *chan; char *spec; | |
| 1990/11211 | char *auth; | |
| 1990/0227 | }bogus; | |
| 1990/11211 | bogus = *((struct bogus *)crud); | |
| 1990/0227 | m = mnt; for(i=0; i<conf.nmntdev; i++,m++){ | |
| 1990/1004/sys/src/9/port/devmnt.c:255,261 – 1990/11211/sys/src/9/port/devmnt.c:257,263 | ||
| 1990/0227 | goto Found; unlock(m); } | |
| 1990/11211 | error(Enomntdev); | |
| 1990/0604 | ||
| 1990/0227 | Found: m->ref = 1; | |
| 1990/1004/sys/src/9/port/devmnt.c:263,269 – 1990/11211/sys/src/9/port/devmnt.c:265,271 | ||
| 1990/0303 | lock(&mntid); m->mntid = ++mntid.id; unlock(&mntid); | |
| 1990/0227 |
| |
| 1990/11211 | c = devattach('M', bogus.spec); | |
| 1990/0303 | c->dev = m->mntid; | |
| 1990/0227 | m->mntpt = c; cm = bogus.chan; | |
| 1990/1004/sys/src/9/port/devmnt.c:297,303 – 1990/11211/sys/src/9/port/devmnt.c:299,306 | ||
| 1990/0227 | mh->thdr.type = Tattach; mh->thdr.fid = c->fid; memcpy(mh->thdr.uname, u->p->pgrp->user, NAMELEN); | |
| 1990/11211 | strcpy(mh->thdr.aname, bogus.spec); strcpy(mh->thdr.auth, bogus.auth); | |
| 1990/0227 | mntxmit(m, mh); c->qid = mh->rhdr.qid; | |
| 1990/0604 | c->mchan = m->q->msg; | |
| 1990/1004/sys/src/9/port/devmnt.c:537,543 – 1990/11211/sys/src/9/port/devmnt.c:540,546 | ||
| 1990/0227 | uchar *b; n = mntreadwrite(c, buf, n, Tread); | |
| 1990/11211 | if(c->qid.path & CHDIR){ | |
| 1990/0227 | b = (uchar*)buf; for(i=n-DIRLEN; i>=0; i-=DIRLEN){ b[DIRLEN-4] = devchar[c->type]; | |
| 1990/1004/sys/src/9/port/devmnt.c:582,641 – 1990/11211/sys/src/9/port/devmnt.c:585,590 | ||
| 1990/0227 | poperror(); } | |
| 1990/0604 | mnterrdequeue(MntQ *q, Mnthdr *mh) /* queue is unlocked */ { | |
| 1990/1004/sys/src/9/port/devmnt.c:670,680 – 1990/11211/sys/src/9/port/devmnt.c:619,631 | ||
| 1990/0604 | qunlock(q); } | |
| 1990/11211 | ||
| 1990/0717 | int mntreadreply(void *a) { return ((Mnthdr *)a)->readreply; } | |
| 1990/11211 | ||
| 1990/0604 | void | |
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { | |
| 1990/1004/sys/src/9/port/devmnt.c:681,687 – 1990/11211/sys/src/9/port/devmnt.c:632,637 | ||
| 1990/0227 | ulong n; | |
| 1990/0619 | Mntbuf *mbw; | |
| 1990/0604 | Mnthdr *w, *ow; | |
| 1990/0227 | ||
| 1990/1004/sys/src/9/port/devmnt.c:695,701 – 1990/11211/sys/src/9/port/devmnt.c:645,651 | ||
| 1990/0227 | n = convS2M(&mh->thdr, mbw->buf); | |
| 1990/0604 | q = m->q; if(q == 0) | |
| 1990/11211 | error(Eshutdown); | |
| 1990/0604 | #ifdef BIT3 | |
| 1990/03081 | /* | |
| 1990/0511 | * Bit3 does its own multiplexing. (Well, the file server does.) | |
| 1990/1004/sys/src/9/port/devmnt.c:711,717 – 1990/11211/sys/src/9/port/devmnt.c:661,667 | ||
| 1990/0227 | } | |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); | |
| 1990/11211 | error(Eshortmsg); | |
| 1990/0227 | } /* | |
| 1990/1004/sys/src/9/port/devmnt.c:723,748 – 1990/11211/sys/src/9/port/devmnt.c:673,701 | ||
| 1990/0511 | ||
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | print("format error in mntxmit\n"); | |
| 1990/11211 | error(Ebadmsg); | |
| 1990/0511 | } /* * Various checks */ | |
| 1990/11211 | if(mh->rhdr.tag != mh->thdr.tag){ print("tag mismatch %d %d\n", mh->rhdr.tag, mh->thdr.tag); error(Ebadmsg); } if(mh->rhdr.type == Rerror){ if(m->mntpt) errors(mh->rhdr.ename); error(Eshutdown); } | |
| 1990/0511 | if(mh->rhdr.type != mh->thdr.type+1){ | |
| 1990/0604 | print("type mismatch %d %d\n", mh->rhdr.type, mh->thdr.type+1); | |
| 1990/11211 | error(Ebadmsg); | |
| 1990/0511 | } if(mh->rhdr.fid != mh->thdr.fid){ | |
| 1990/0604 | print("fid mismatch %d %d type %d\n", mh->rhdr.fid, mh->thdr.fid, mh->rhdr.type); | |
| 1990/11211 | error(Ebadmsg); | |
| 1990/0511 | } | |
| 1990/1004/sys/src/9/port/devmnt.c:768,774 – 1990/11211/sys/src/9/port/devmnt.c:721,727 | ||
| 1990/0717 | mh->readreply = 0; | |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); | |
| 1990/11211 | error(Eshortmsg); | |
| 1990/0511 | } | |
| 1990/0604 | if(q->reader == 0){ /* i will read */ q->reader = u->p; | |
| 1990/1004/sys/src/9/port/devmnt.c:783,789 – 1990/11211/sys/src/9/port/devmnt.c:736,742 | ||
| 1990/0703 | poperror(); | |
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | mnterrdequeue(q, mh); | |
| 1990/11211 | error(Ebadmsg); | |
| 1990/0604 | } /* * Response might not be mine | |
| 1990/1004/sys/src/9/port/devmnt.c:790,797 – 1990/11211/sys/src/9/port/devmnt.c:743,749 | ||
| 1990/0604 | */ qlock(q); qlocked = 1; | |
| 1990/11211 | if(mh->rhdr.tag == mh->thdr.tag){ /* it's mine */ | |
| 1990/0604 | q->reader = 0; if(w = q->writer){ /* advance a writer to reader */ q->reader = w->p; | |
| 1990/1004/sys/src/9/port/devmnt.c:807,814 – 1990/11211/sys/src/9/port/devmnt.c:759,765 | ||
| 1990/0604 | * Hand response to correct recipient */ for(ow=0,w=q->writer; w; ow=w,w=w->next) | |
| 1990/11211 | if(mh->rhdr.tag == w->thdr.tag){ | |
| 1990/0604 | Mntbuf *t; | |
| 1990/0619 | t = mh->mbr; mh->mbr = w->mbr; | |
| 1990/1004/sys/src/9/port/devmnt.c:849,859 – 1990/11211/sys/src/9/port/devmnt.c:800,809 | ||
| 1990/0604 | Respond: mqfree(q); poperror(); | |
| 1990/0227 |
| |
| 1990/11211 | if(mh->rhdr.type == Rerror){ if(m->mntpt) errors(mh->rhdr.ename); error(Eshutdown); | |
| 1990/0227 | } /* * Copy out on read | |
| 1990/1004/sys/src/9/port/devmnt.c:860,866 – 1990/11211/sys/src/9/port/devmnt.c:810,816 | ||
| 1990/0227 | */ | |
| 1990/0703 | if(mh->thdr.type == Tread){ if(mh->rhdr.count > mh->thdr.count) | |
| 1990/11211 | error(Ebadcnt); | |
| 1990/0227 | memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/0703 | } | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/11211/sys/src/9/port/devmnt.c:47,53 – 1990/1123/sys/src/9/port/devmnt.c:47,55 (short | long) | ||
| 1990/0227 | ||
| 1990/0604 | struct Mnthdr | |
| 1990/0227 | { | |
| 1990/0604 |
| |
| 1990/1123 | Mnthdr *next; /* in free list or writers list */ Mnthdr *prev; /* in writers list only */ int writing; /* flag: in writers list */ | |
| 1990/0227 | Fcall thdr; Fcall rhdr; | |
| 1990/0604 | Rendez r; | |
| 1990/11211/sys/src/9/port/devmnt.c:59,64 – 1990/1123/sys/src/9/port/devmnt.c:61,67 | ||
| 1990/0227 | struct { Lock; | |
| 1990/1123 | Mnthdr *arena; | |
| 1990/0227 | Mnthdr *free; }mnthdralloc; | |
| 1990/11211/sys/src/9/port/devmnt.c:219,224 – 1990/1123/sys/src/9/port/devmnt.c:222,228 | ||
| 1990/11211 | } | |
| 1990/0227 | mh[i].next = 0; | |
| 1990/11211 | mh[i].thdr.tag = i; | |
| 1990/1123 | mnthdralloc.arena = mh; | |
| 1990/0227 | mnthdralloc.free = mh; | |
| 1990/0604 | mq = ialloc(conf.nmntdev*sizeof(MntQ), 0); | |
| 1990/11211/sys/src/9/port/devmnt.c:586,593 – 1990/1123/sys/src/9/port/devmnt.c:590,612 | ||
| 1990/0227 | } void | |
| 1990/0604 |
| |
| 1990/1123 | mntwunlink(MntQ *q, Mnthdr *w) /* queue is locked and w is a writer */ | |
| 1990/0604 | { | |
| 1990/1123 | if(w->next) w->next->prev = w->prev; if(w->prev) w->prev->next = w->next; else{ q->writer = w->next; if(q->writer) q->writer->prev = 0; } w->writing = 0; } void mnterrdequeue(MntQ *q, Mnthdr *mh) /* queue is unlocked */ { | |
| 1990/0604 | Mnthdr *w; qlock(q); | |
| 1990/11211/sys/src/9/port/devmnt.c:597,621 – 1990/1123/sys/src/9/port/devmnt.c:616,629 | ||
| 1990/0604 | if(w){ q->reader = w->p; q->writer = w->next; | |
| 1990/1123 | q->writer->prev = 0; | |
| 1990/0604 | wakeup(&w->r); }else{ q->reader = 0; q->writer = 0; } | |
| 1990/1123 | }else mntwunlink(q, mh); | |
| 1990/0604 | qunlock(q); } | |
| 1990/11211/sys/src/9/port/devmnt.c:630,639 – 1990/1123/sys/src/9/port/devmnt.c:638,647 | ||
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { ulong n; | |
| 1990/0619 |
| |
| 1990/1123 | Mntbuf *mbw, *t; | |
| 1990/0604 | Mnthdr *w, *ow; MntQ *q; | |
| 1990/1123 | int qlocked, tag; | |
| 1990/0227 | ||
| 1990/0619 | mh->mbr = mballoc(); | |
| 1990/0227 | mbw = mballoc(); | |
| 1990/11211/sys/src/9/port/devmnt.c:743,753 – 1990/1123/sys/src/9/port/devmnt.c:751,764 | ||
| 1990/0604 | */ qlock(q); qlocked = 1; | |
| 1990/11211 |
| |
| 1990/1123 | tag = mh->rhdr.tag; if(tag == mh->thdr.tag){ /* it's mine */ | |
| 1990/0604 | q->reader = 0; if(w = q->writer){ /* advance a writer to reader */ q->reader = w->p; q->writer = w->next; | |
| 1990/1123 | if(q->writer) q->writer->prev = 0; | |
| 1990/0717 | w->readreply = 1; | |
| 1990/0604 | wakeup(&w->r); } | |
| 1990/11211/sys/src/9/port/devmnt.c:758,784 – 1990/1123/sys/src/9/port/devmnt.c:769,799 | ||
| 1990/0604 | /* * Hand response to correct recipient */ | |
| 1990/11211 |
| |
| 1990/0604 |
| |
| 1990/0619 |
| |
| 1990/0604 |
| |
| 1990/0717 |
| |
| 1990/0604 |
| |
| 1990/1123 | if(tag<0 || tag>=conf.nmnthdr){ print("unknown tag %d\n", tag); goto Read; } w = &mnthdralloc.arena[tag]; if(!w->writing){ print("reply not writing\n"); goto Read; } t = mh->mbr; mh->mbr = w->mbr; w->mbr = t; memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr); mntwunlink(q, w); w->readreply = 1; wakeup(&w->r); | |
| 1990/0604 | goto Read; }else{ mh->p = u->p; /* put self in queue */ mh->next = q->writer; | |
| 1990/1123 | mh->prev = 0; mh->writing = 1; if(q->writer) q->writer->prev = mh; | |
| 1990/0604 | q->writer = mh; qunlock(q); qlocked = 0; | |
| 1990/1123/sys/src/9/port/devmnt.c:49,55 – 1990/1124/sys/src/9/port/devmnt.c:49,56 (short | long) | ||
| 1990/0227 | { | |
| 1990/1123 | Mnthdr *next; /* in free list or writers list */ Mnthdr *prev; /* in writers list only */ | |
| 1990/1124 | short active; short flushing; /* a Tflush has been sent */ | |
| 1990/0227 | Fcall thdr; Fcall rhdr; | |
| 1990/0604 | Rendez r; | |
| 1990/1123/sys/src/9/port/devmnt.c:122,127 – 1990/1124/sys/src/9/port/devmnt.c:123,129 | ||
| 1990/0227 | lock(&mnthdralloc); if(mh = mnthdralloc.free){ /* assign = */ mnthdralloc.free = mh->next; | |
| 1990/1124 | mh->flushing = 0; | |
| 1990/0227 | unlock(&mnthdralloc); return mh; } | |
| 1990/1123/sys/src/9/port/devmnt.c:138,143 – 1990/1124/sys/src/9/port/devmnt.c:140,148 | ||
| 1990/0227 | void mhfree(Mnthdr *mh) { | |
| 1990/1124 | if(mh->flushing) return; mh->active = 0; | |
| 1990/0227 | lock(&mnthdralloc); mh->next = mnthdralloc.free; mnthdralloc.free = mh; | |
| 1990/1123/sys/src/9/port/devmnt.c:601,622 – 1990/1124/sys/src/9/port/devmnt.c:606,654 | ||
| 1990/1123 | if(q->writer) q->writer->prev = 0; } | |
| 1990/1124 | /* * m->q is unlocked. Send Tflush message to flush omh->tag. * Cut off all errors. Caller will free omh */ | |
| 1990/1123 | void | |
| 1990/1124 | mntflush(Mnt *m, Mnthdr *omh) /* queue is unlocked */ | |
| 1990/1123 | { | |
| 1990/1124 | Mnthdr *mh; if(omh->thdr.type == Tflush) return; mh = mhalloc(); if(waserror()){ omh->flushing = 0; mhfree(mh); return; /* no more errors please */ } mh->thdr.type = Tflush; mh->thdr.oldtag = omh->thdr.tag; mntxmit(m, mh); omh->flushing = 0; mhfree(mh); poperror(); } void mnterrdequeue(Mnt *m, Mnthdr *mh) /* queue is unlocked */ { | |
| 1990/0604 | Mnthdr *w; | |
| 1990/1124 | MntQ *q; | |
| 1990/0604 | ||
| 1990/1124 | mh->flushing = 1; q = m->q; | |
| 1990/0604 | qlock(q); /* take self from queue if necessary */ if(q->reader == u->p){ /* advance a writer to reader */ w = q->writer; if(w){ | |
| 1990/1124 | mntwunlink(q, w); | |
| 1990/0604 | q->reader = w->p; | |
| 1990/1123 |
| |
| 1990/0604 | wakeup(&w->r); }else{ q->reader = 0; | |
| 1990/1123/sys/src/9/port/devmnt.c:625,631 – 1990/1124/sys/src/9/port/devmnt.c:657,663 | ||
| 1990/1123 | }else mntwunlink(q, mh); | |
| 1990/0604 | qunlock(q); | |
| 1990/1124 | mntflush(m, mh); | |
| 1990/0604 | } | |
| 1990/11211 | ||
| 1990/0717 | int | |
| 1990/1123/sys/src/9/port/devmnt.c:641,651 – 1990/1124/sys/src/9/port/devmnt.c:673,683 | ||
| 1990/1123 | Mntbuf *mbw, *t; | |
| 1990/0604 | Mnthdr *w, *ow; MntQ *q; | |
| 1990/1123 |
| |
| 1990/1124 | int qlocked, tag, written; | |
| 1990/0227 | ||
| 1990/0619 | mh->mbr = mballoc(); | |
| 1990/0227 | mbw = mballoc(); | |
| 1990/1124 | if(waserror()){ /* 1 */ | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); nexterror(); | |
| 1990/1123/sys/src/9/port/devmnt.c:663,669 – 1990/1124/sys/src/9/port/devmnt.c:695,701 | ||
| 1990/0511 | goto Normal; | |
| 1990/0604 | incref(q); | |
| 1990/0227 |
| |
| 1990/1124 | if(waserror()){ /* 2 */ | |
| 1990/0604 | mqfree(q); | |
| 1990/0227 | nexterror(); } | |
| 1990/1123/sys/src/9/port/devmnt.c:677,683 – 1990/1124/sys/src/9/port/devmnt.c:709,715 | ||
| 1990/0227 | */ | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/0604 | mqfree(q); | |
| 1990/0511 |
| |
| 1990/1124 | poperror(); /* 2 */ | |
| 1990/0511 | ||
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 | print("format error in mntxmit\n"); | |
| 1990/1123/sys/src/9/port/devmnt.c:712,718 – 1990/1124/sys/src/9/port/devmnt.c:744,750 | ||
| 1990/0511 | memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0511 | mbfree(mbw); | |
| 1990/1124 | poperror(); /* 1 */ | |
| 1990/0511 | return; Normal: | |
| 1990/1123/sys/src/9/port/devmnt.c:720,726 – 1990/1124/sys/src/9/port/devmnt.c:752,758 | ||
| 1990/0604 | incref(q); qlock(q); qlocked = 1; | |
| 1990/0511 |
| |
| 1990/1124 | if(waserror()){ /* 2 */ | |
| 1990/0604 | if(qlocked) qunlock(q); mqfree(q); | |
| 1990/1123/sys/src/9/port/devmnt.c:727,732 – 1990/1124/sys/src/9/port/devmnt.c:759,765 | ||
| 1990/0511 | nexterror(); | |
| 1990/03081 | } | |
| 1990/0717 | mh->readreply = 0; | |
| 1990/1124 | mh->active = 1; | |
| 1990/0604 | if((*devtab[q->msg->type].write)(q->msg, mbw->buf, n) != n){ print("short write in mntxmit\n"); | |
| 1990/11211 | error(Eshortmsg); | |
| 1990/1123/sys/src/9/port/devmnt.c:736,749 – 1990/1124/sys/src/9/port/devmnt.c:769,783 | ||
| 1990/0604 | Read: qunlock(q); qlocked = 0; | |
| 1990/0703 |
| |
| 1990/1124 | if(waserror()){ /* 3 */ mnterrdequeue(m, mh); | |
| 1990/0703 | nexterror(); } | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/0703 |
| |
| 1990/1124 | poperror(); /* 3 */ | |
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/0604 |
| |
| 1990/1124 | print("bad reply message\n"); mnterrdequeue(m, mh); | |
| 1990/11211 | error(Ebadmsg); | |
| 1990/0604 | } /* | |
| 1990/1123/sys/src/9/port/devmnt.c:755,767 – 1990/1124/sys/src/9/port/devmnt.c:789,800 | ||
| 1990/1123 | if(tag == mh->thdr.tag){ /* it's mine */ | |
| 1990/0604 | q->reader = 0; if(w = q->writer){ /* advance a writer to reader */ | |
| 1990/1124 | mntwunlink(q, w); | |
| 1990/0604 | q->reader = w->p; | |
| 1990/1123 |
| |
| 1990/0717 | w->readreply = 1; | |
| 1990/0604 | wakeup(&w->r); } | |
| 1990/1124 | mh->active = 0; | |
| 1990/0604 | qunlock(q); qlocked = 0; goto Respond; | |
| 1990/1123/sys/src/9/port/devmnt.c:774,783 – 1990/1124/sys/src/9/port/devmnt.c:807,814 | ||
| 1990/1123 | goto Read; } w = &mnthdralloc.arena[tag]; | |
| 1990/1124 | if(w->flushing || !w->active) /* nothing to do; mntflush will clean up */ | |
| 1990/1123 | goto Read; | |
| 1990/1123/sys/src/9/port/devmnt.c:791,797 – 1990/1124/sys/src/9/port/devmnt.c:822,827 | ||
| 1990/0604 | /* put self in queue */ mh->next = q->writer; | |
| 1990/1123 | mh->prev = 0; | |
| 1990/0604 | q->writer = mh; | |
| 1990/1123/sys/src/9/port/devmnt.c:798,804 – 1990/1124/sys/src/9/port/devmnt.c:828,834 | ||
| 1990/0604 | qunlock(q); qlocked = 0; if(waserror()){ /* interrupted sleep */ | |
| 1990/1124 | mnterrdequeue(m, mh); | |
| 1990/0604 | nexterror(); } | |
| 1990/0717 | sleep(&mh->r, mntreadreply, mh); | |
| 1990/1123/sys/src/9/port/devmnt.c:807,812 – 1990/1124/sys/src/9/port/devmnt.c:837,843 | ||
| 1990/0604 | qlocked = 1; if(q->reader == u->p) /* i got promoted */ goto Read; | |
| 1990/1124 | mh->active = 0; | |
| 1990/0604 | qunlock(q); qlocked = 0; goto Respond; | |
| 1990/1123/sys/src/9/port/devmnt.c:814,824 – 1990/1124/sys/src/9/port/devmnt.c:845,858 | ||
| 1990/0227 | ||
| 1990/0604 | Respond: mqfree(q); | |
| 1990/1124 | poperror(); /* 2 */ | |
| 1990/11211 | if(mh->rhdr.type == Rerror){ if(m->mntpt) errors(mh->rhdr.ename); error(Eshutdown); | |
| 1990/1124 | }else if(mh->rhdr.type != mh->thdr.type+1){ print("bad type %d not %d in mntxmit\n", mh->rhdr.type, mh->thdr.type+1); error(Ebadmsg); | |
| 1990/0227 | } /* * Copy out on read | |
| 1990/1123/sys/src/9/port/devmnt.c:830,836 – 1990/1124/sys/src/9/port/devmnt.c:864,870 | ||
| 1990/0703 | } | |
| 1990/0619 | mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); | |
| 1990/1124 | poperror(); /* 1 */ | |
| 1990/0717 | } mntdump() | |
| 1990/1124/sys/src/9/port/devmnt.c:469,475 – 1990/1126/sys/src/9/port/devmnt.c:469,474 (short | long) | ||
| 1990/0227 | Mnthdr *mh; | |
| 1990/0604 | MntQ *q; int waserr; | |
| 1990/0227 | m = mntdev(c->dev, 0); mh = mhalloc(); | |
| 1990/1126/sys/src/9/port/devmnt.c:669,683 – 1990/1127/sys/src/9/port/devmnt.c:669,684 (short | long) | ||
| 1990/0227 | mntxmit(Mnt *m, Mnthdr *mh) { ulong n; | |
| 1990/1123 |
| |
| 1990/1127 | Mntbuf *mbw; | |
| 1990/0604 | Mnthdr *w, *ow; MntQ *q; | |
| 1990/1124 | int qlocked, tag, written; | |
| 1990/0227 | ||
| 1990/0619 |
| |
| 1990/1127 | mh->mbr = 0; | |
| 1990/0227 | mbw = mballoc(); | |
| 1990/1124 | if(waserror()){ /* 1 */ | |
| 1990/0619 |
| |
| 1990/1127 | if(mh->mbr) mbfree(mh->mbr); | |
| 1990/0227 | mbfree(mbw); nexterror(); } | |
| 1990/1126/sys/src/9/port/devmnt.c:706,711 – 1990/1127/sys/src/9/port/devmnt.c:707,713 | ||
| 1990/0227 | /* * Read response */ | |
| 1990/1127 | mh->mbr = mballoc(); | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/0604 | mqfree(q); | |
| 1990/1124 | poperror(); /* 2 */ | |
| 1990/1126/sys/src/9/port/devmnt.c:772,777 – 1990/1127/sys/src/9/port/devmnt.c:774,780 | ||
| 1990/1124 | mnterrdequeue(m, mh); | |
| 1990/0703 | nexterror(); } | |
| 1990/1127 | mh->mbr = mballoc(); | |
| 1990/0619 | n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); | |
| 1990/1124 | poperror(); /* 3 */ | |
| 1990/0619 | if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ | |
| 1990/1126/sys/src/9/port/devmnt.c:808,816 – 1990/1127/sys/src/9/port/devmnt.c:811,818 | ||
| 1990/1123 | w = &mnthdralloc.arena[tag]; | |
| 1990/1124 | if(w->flushing || !w->active) /* nothing to do; mntflush will clean up */ | |
| 1990/1123 | goto Read; | |
| 1990/1127 | w->mbr = mh->mbr; mh->mbr = 0; | |
| 1990/1123 | memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr); mntwunlink(q, w); w->readreply = 1; | |
| Too many diffs (26 > 25). Stopping. | ||