From 744448b127802672eb7384a101bf523714e9cd0f Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 29 Jan 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-01-29 --- port/devcons.c | 2 +- port/devnonet.c | 5 ++++- port/devscc.c | 23 ++++++++++++++++++++++- port/devwren.c | 5 ++++- port/sysproc.c | 2 ++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/port/devcons.c b/port/devcons.c index 57499479b9d3d28bd473ab34c77b34c1b42d8567..a6a04fe29781810781f25888e67f5bd7df5c63b7 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -821,7 +821,7 @@ conswrite(Chan *c, void *va, long n, ulong offset) error(Eperm); strncpy(u->p->user, a+8, NAMELEN); u->p->user[NAMELEN-1] = '\0'; - memmove(u->p->pgrp->crypt->key, a+NAMELEN+DESKEYLEN, DESKEYLEN); + memmove(u->p->pgrp->crypt->key, a+8+NAMELEN, DESKEYLEN); break; case Qnull: diff --git a/port/devnonet.c b/port/devnonet.c index 341c9e5338665f073f4c0c1cf610c5448c0b476b..079e72666a73b1a5aa505961ce7ae55f33098fb2 100644 --- a/port/devnonet.c +++ b/port/devnonet.c @@ -376,7 +376,10 @@ nonetwrite(Chan *c, void *a, long n, ulong offset) * easier to do here than in nooput */ if(t == Sctlqid){ - strncpy(buf, a, sizeof buf); + if(n > sizeof buf - 1) + n = sizeof buf - 1; + strncpy(buf, a, n); + buf[n] = '\0'; m = getfields(buf, field, 5, ' '); if(strcmp(field[0], "connect")==0){ if(m < 2) diff --git a/port/devscc.c b/port/devscc.c index 70909c2d1e29d1201f185074ea4534033ec1b9a6..0abf51315a1c20b5e732d2b12f733d8bf710bad8 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -101,10 +101,16 @@ struct SCC Rendez r; /* kproc waiting for input */ Alarm *a; /* alarm for waking the kernel process */ int kstarted; /* kproc started */ + + /* idiot flow control */ + int xonoff; /* true if we obey this tradition */ + int blocked; /* abstinence */ }; int nscc; SCC *scc[8]; /* up to 4 8530's */ +#define CTLS 023 +#define CTLQ 021 void onepointseven(void) @@ -272,7 +278,7 @@ sccputs(IOQ *cq, char *s, int n) x = splhi(); lock(cq); puts(cq, s, n); - if(sp->printing == 0){ + if(sp->printing == 0 && sp->blocked==0){ ch = getc(cq); /*kprint("", ch);*/ if(ch >= 0){ @@ -303,6 +309,12 @@ sccintr0(SCC *sp, uchar x) while(*sp->ptr&RxReady){ onepointseven(); ch = *sp->data; + if (ch == CTLS && sp->xonoff) + sp->blocked = 1; + else if (ch == CTLQ && sp->xonoff) { + sp->blocked = 0; + sccputs(sp->oq, "", 0); + } if(cq->putc) (*cq->putc)(cq, ch); else @@ -310,6 +322,11 @@ sccintr0(SCC *sp, uchar x) } } if(x & TxPendB){ + if (sp->blocked) { + sccwrreg(sp, 0, ResTxPend); + sp->printing = 0; + return; + } cq = sp->oq; lock(cq); ch = getc(cq); @@ -503,6 +520,10 @@ sccoput(Queue *q, Block *bp) case 'w': /* obsolete */ break; + case 'X': + case 'x': + sp->xonoff = n; + break; } }else while((m = BLEN(bp)) > 0){ while ((n = canputc(cq)) == 0){ diff --git a/port/devwren.c b/port/devwren.c index ed0921e7469bcf739cb12cda8be9dc9b185f326d..2815e14f66e769e97c9ce111766606a114e2ed1f 100644 --- a/port/devwren.c +++ b/port/devwren.c @@ -185,7 +185,10 @@ wrenread(Chan *c, char *a, long n, ulong offset) long wrenwrite(Chan *c, char *a, long n, ulong offset) { - return wrenio(c, 1, a, n, offset); + n = wrenio(c, 1, a, n, offset); + if(n) + return n; + error("end of device"); } static long diff --git a/port/sysproc.c b/port/sysproc.c index 4f18acea231884b568667eefd36c06221e6b647c..0dae5f278f54af37212a58ead064441f7e74e5e3 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -478,6 +478,8 @@ sysforkpgrp(ulong *arg) if(mask & FPnamespc) pgrpcpy(pg, u->p->pgrp); + else + *pg->crypt = *u->p->pgrp->crypt; if(mask & FPenv) envcpy(eg, u->p->egrp);