M gnot/clock.c => gnot/clock.c +4 -1
@@ 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);
+ }
}
}
M gnot/devmnt.c => gnot/devmnt.c +9 -1
@@ 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();
M gnot/errno.h => gnot/errno.h +1 -0
@@ 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 */
};
M gnot/fns.h => gnot/fns.h +1 -0
@@ 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);
M gnot/stream.c => gnot/stream.c +20 -6
@@ 65,6 65,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; cp<bp->wptr && cp<bp->rptr+10; cp++)
+ print(" %uo", *cp);
+ print("\n");
+ }
+ unlock(q);
+}
+
+void
dumpqueues(void)
{
Queue *q;
@@ 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++){
M gnot/sysfile.c => gnot/sysfile.c +1 -0
@@ 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();
}
M port/devmnt.c => port/devmnt.c +9 -5
@@ 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();
M port/sysfile.c => port/sysfile.c +1 -0
@@ 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();
}
M power/errno.h => power/errno.h +1 -0
@@ 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 */
};