From b5975aa598ae59da58013dd38bf32fd7baae32fd Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 3 Jul 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-07-03 --- gnot/clock.c | 5 ++++- gnot/devmnt.c | 10 +++++++++- gnot/errno.h | 1 + gnot/fns.h | 1 + gnot/stream.c | 26 ++++++++++++++++++++------ gnot/sysfile.c | 1 + port/devmnt.c | 14 +++++++++----- port/sysfile.c | 1 + power/errno.h | 1 + 9 files changed, 47 insertions(+), 13 deletions(-) diff --git a/gnot/clock.c b/gnot/clock.c index 8d9f8b6001924b93f08edb5fcfcc555de95bbad9..0877c0e92c3b0a60010ea15918aaef913782b4d3 100644 --- a/gnot/clock.c +++ b/gnot/clock.c @@ -121,7 +121,10 @@ clock(Ureg *ur) mouseclock(); if((ur->sr&SPL(7)) == 0){ spllo(); - if(p && p->state==Running) + if(p && p->state==Running){ checksched(); + if(u->nnote && (ur->sr&SUPER)==0) + notify(ur); + } } } diff --git a/gnot/devmnt.c b/gnot/devmnt.c index 4d9b2c6db0f23f838ce65c1cf9ff478b06d82ee6..84e44060446fae5211e5bc61169ebda75ef15913 100644 --- a/gnot/devmnt.c +++ b/gnot/devmnt.c @@ -769,7 +769,12 @@ mntxmit(Mnt *m, Mnthdr *mh) Read: qunlock(q); qlocked = 0; + if(waserror()){ + mnterrdequeue(q, mh); + nexterror(); + } n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); + poperror(); if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ mnterrdequeue(q, mh); error(0, Ebadmsg); @@ -845,8 +850,11 @@ mntxmit(Mnt *m, Mnthdr *mh) /* * Copy out on read */ - if(mh->thdr.type == Tread) + if(mh->thdr.type == Tread){ + if(mh->rhdr.count > mh->thdr.count) + error(0, Ebadcnt); memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); + } mbfree(mh->mbr); mbfree(mbw); poperror(); diff --git a/gnot/errno.h b/gnot/errno.h index 3b5738e2c513928e82e01adf22b6979ffe040709..f569775960d22f6307d687a57ff826844e296c87 100644 --- a/gnot/errno.h +++ b/gnot/errno.h @@ -52,6 +52,7 @@ enum{ Ebadbitmap, /* unallocated bitmap */ Eshortmsg, /* short message */ Ebadmsg, /* format error or mismatch in message */ + Ebadcnt, /* read count greater than requested */ Enofont, /* out of font descriptors */ Egreg, /* it's all greg's fault */ }; diff --git a/gnot/fns.h b/gnot/fns.h index 7fa826dd6081a01f2769ed7ea8570f0042893e9d..c26967ecd4ce11981bf0ecee0243691d301e8c39 100644 --- a/gnot/fns.h +++ b/gnot/fns.h @@ -91,6 +91,7 @@ Pgrp *newpgrp(void); Proc *newproc(void); void newqinfo(Qinfo*); char *nextelem(char*, char*); +void notify(Ureg*); void nullput(Queue*, Block*); int openmode(ulong); void pageinit(void); diff --git a/gnot/stream.c b/gnot/stream.c index 11afe3d19759d165e5afadf4f152897cfca860c0..940195d8ae6d0d42adab9b16a992eeb0bbccf1c2 100644 --- a/gnot/stream.c +++ b/gnot/stream.c @@ -64,6 +64,22 @@ Bclass bclass[Nclass]={ /* * Dump all block information of how many blocks are in which queues */ +void +dumpblocks(Queue *q, char c) +{ + Block *bp; + uchar *cp; + + lock(q); + for(bp = q->first; bp; bp = bp->next){ + print("%c%d%c", c, bp->wptr-bp->rptr, (bp->flags&S_DELIM)); + for(cp = bp->rptr; cpwptr && cprptr+10; cp++) + print(" %uo", *cp); + print("\n"); + } + unlock(q); +} + void dumpqueues(void) { @@ -76,14 +92,12 @@ dumpqueues(void) for(q = qlist; q < qlist + conf.nqueue; q++, q++){ if(!(q->flag & QINUSE)) continue; - for(count = 0, bp = q->first; bp; bp = bp->next) - count++; - print("%s %ux R c %d l %d f %ux r %ux", q->info->name, q, count, + print("%s %ux R n %d l %d f %ux r %ux", q->info->name, q, q->nb, q->len, q->flag, &(q->r)); - for(count = 0, bp = WR(q)->first; bp; bp = bp->next) - count++; - print(" W c %d l %d f %ux r %ux\n", count, WR(q)->len, WR(q)->flag, + print(" W n %d l %d f %ux r %ux\n", WR(q)->nb, WR(q)->len, WR(q)->flag, &(WR(q)->r)); + dumpblocks(q, 'R'); + dumpblocks(q, 'W'); } print("\n"); for(bcp=bclass; bcp<&bclass[Nclass]; bcp++){ diff --git a/gnot/sysfile.c b/gnot/sysfile.c index a3f1c6c8a535ee825be9a67316d69830e8662959..1a73b5306c5011f87441d479cb4b10e6de411d6a 100644 --- a/gnot/sysfile.c +++ b/gnot/sysfile.c @@ -457,6 +457,7 @@ sysremove(ulong *arg) validaddr(arg[0], 1, 0); c = namec((char*)arg[0], Aaccess, 0, 0); if(waserror()){ + c->type = 0; /* see below */ close(c); nexterror(); } diff --git a/port/devmnt.c b/port/devmnt.c index 04cc2a93b4878bd9ec3a77504a1a97d18fcc1b9b..84e44060446fae5211e5bc61169ebda75ef15913 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -769,7 +769,12 @@ mntxmit(Mnt *m, Mnthdr *mh) Read: qunlock(q); qlocked = 0; + if(waserror()){ + mnterrdequeue(q, mh); + nexterror(); + } n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE); + poperror(); if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ mnterrdequeue(q, mh); error(0, Ebadmsg); @@ -810,10 +815,6 @@ mntxmit(Mnt *m, Mnthdr *mh) wakeup(&w->r); goto Read; } -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); - goto Read; }else{ mh->p = u->p; @@ -849,8 +850,11 @@ for(w=q->writer; w; w=w->next)print("writer pid %d fid %d type %d\n",w->p->pid,w /* * Copy out on read */ - if(mh->thdr.type == Tread) + if(mh->thdr.type == Tread){ + if(mh->rhdr.count > mh->thdr.count) + error(0, Ebadcnt); memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count); + } mbfree(mh->mbr); mbfree(mbw); poperror(); diff --git a/port/sysfile.c b/port/sysfile.c index a3f1c6c8a535ee825be9a67316d69830e8662959..1a73b5306c5011f87441d479cb4b10e6de411d6a 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -457,6 +457,7 @@ sysremove(ulong *arg) validaddr(arg[0], 1, 0); c = namec((char*)arg[0], Aaccess, 0, 0); if(waserror()){ + c->type = 0; /* see below */ close(c); nexterror(); } diff --git a/power/errno.h b/power/errno.h index d7756a60cc444661fa6eb54ba9b7ab5b318adb2b..c0949503bf091c0f61e409bd74a91a78f282d071 100644 --- a/power/errno.h +++ b/power/errno.h @@ -49,4 +49,5 @@ enum{ Egreg, /* it's all greg's fault */ Eshortmsg, /* short message */ Ebadmsg, /* format error or mismatch in message */ + Ebadcnt, /* read count greater than requested */ };