From 4c74c8e3b69dbdee009d03d6c0dc8f98fb0bdfe0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 8 Dec 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-12-08 --- carrera/mem.h | 2 +- port/alloc.c | 6 ++++-- port/chan.c | 41 +++++++++++++++++++++++++++++++++++++++++ port/devproc.c | 8 +++++++- port/netif.c | 4 ++++ port/sysfile.c | 4 ++++ 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/carrera/mem.h b/carrera/mem.h index e4922d4f86dca52a6925ffd94701a3c10e181ca6..f3b3c42b7d978c27ca6aeb158b0d83fa0fb3e5fd 100644 --- a/carrera/mem.h +++ b/carrera/mem.h @@ -213,7 +213,7 @@ #define TSTKSIZ 100 #define KZERO KSEG0 /* base of kernel address space */ #define KTZERO (KZERO+0x12000) /* first address in kernel text */ -#define USTKSIZE (4*1024*1024) /* size of user stack */ +#define USTKSIZE (8*1024*1024) /* size of user stack */ #define globalmem(x) (((ulong)x)&KZERO) /* addresses valid in all contexts */ /* * Exception codes diff --git a/port/alloc.c b/port/alloc.c index f4d7f19e9c9156cbaa26f5d5e2d5af55d1e45aa1..4e2fac3be0a6790dfe5e7a9c069c95d1ca03728c 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -617,7 +617,9 @@ recur(Bhdr *t) } int -poolok(void) +poolok(int x) { - return recur(mainmem->root); + if(x & 1) + return recur(mainmem->root); + return recur(imagmem->root); } diff --git a/port/chan.c b/port/chan.c index 16e45e1df1182997cdd09e980c0d7c3e02d77c05..0d14f79b1dd21486c9ee778352fd9c6cd69c0b9a 100644 --- a/port/chan.c +++ b/port/chan.c @@ -104,6 +104,47 @@ newchan(void) return c; } +int +okchan1(Chan *c) +{ + if(c->type > 64) + return 0; + if((ulong)(c->next) & 3) + return 0; + if((ulong)(c->link) & 3) + return 0; + if((ulong)(c->path) & 3) + return 0; + if((ulong)(c->mnt) & 3) + return 0; + if((ulong)(c->xmnt) & 3) + return 0; + if((ulong)(c->mcp) & 3) + return 0; + if((ulong)(c->mchan) & 3) + return 0; + if((ulong)(c->session) & 3) + return 0; + return 1; +} + +void +okchan(char *msg, int n) +{ + int s; + Chan *c; + + return; + s = splhi(); + for(c = chanalloc.list; c; c = c->link) + if(!okchan1(c)){ + spllo(); + print("okchan: %s (%d=#%.8lux)\n", msg, n, n); + panic("okchan"); + } + splx(s); +} + void chanfree(Chan *c) { diff --git a/port/devproc.c b/port/devproc.c index 6da95711a946c6c8afe474c68e9a9206b879e859..7f714dbb3bdd0fc93d3d47eaac69335197518446 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -882,13 +882,19 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read) n = l; k = kmap(pg); + if(waserror()) { + s->steal--; + kunmap(k); + nexterror(); + } b = (char*)VA(k); b += offset&(BY2PG-1); if(read == 1) - memmove(a, b, n); + memmove(a, b, n); /* This can fault */ else memmove(b, a, n); kunmap(k); + poperror(); /* Ensure the process sees text page changes */ if(s->flushme) diff --git a/port/netif.c b/port/netif.c index 75e65aff7f256a5e078a3fd9b26f496737bf312c..0e49c9123d0c786401e9f1a875de0316c231afb6 100644 --- a/port/netif.c +++ b/port/netif.c @@ -171,6 +171,10 @@ netifread(Netif *nif, Chan *c, void *a, long n, ulong offset) switch(NETTYPE(c->qid.path)){ case Ndataqid: f = nif->f[NETID(c->qid.path)]; +okchan("before qread", 0); +j = qread(f->in, a, n); +okchan("after qread", j); +return j; return qread(f->in, a, n); case Nctlqid: return readnum(offset, a, n, NETID(c->qid.path), NUMSIZE); diff --git a/port/sysfile.c b/port/sysfile.c index afdd8f1ea4aeddc39c0873a5b6aa5f35798501cc..debe92ac10730db691478d3f611d7eedde4985f2 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -230,7 +230,9 @@ sysopen(ulong *arg) nexterror(); } validaddr(arg[0], 1, 0); +okchan("before open namec", 0); c = namec((char*)arg[0], Aopen, arg[1], 0); +okchan("after open namec", 0); fd = newfd(c); poperror(); return fd; @@ -515,7 +517,9 @@ sysfstat(ulong *arg) cclose(c); nexterror(); } +okchan("before stat routine", c->type); devtab[c->type]->stat(c, (char*)arg[1]); +okchan("after stat routine", c->type); poperror(); cclose(c); return 0;