From 4a8b32d910f43d31d2425e53c3b55c9976967e9c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 16 Jul 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-07-16 --- pc/ether589.c | 6 +++++- pc/etherelnk3.c | 8 ++++++-- pc/vgas3.c | 11 ++++++++++- port/chan.c | 10 +++++----- port/devdraw.c | 4 ++-- port/devsrv.c | 4 +++- port/lib.h | 3 ++- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/pc/ether589.c b/pc/ether589.c index 791f422b4d4224d133e662a735ee27a1ac9bc4f3..f04e3403656ae3048ba49fe628b0db1b93fd57b2 100644 --- a/pc/ether589.c +++ b/pc/ether589.c @@ -123,12 +123,15 @@ reset(Ether* ether) if(ioalloc(port, 0x10, 0, "3C589") < 0) return -1; - if((slot = pcmspecial(ether->type, ether)) < 0) + if((slot = pcmspecial(ether->type, ether)) < 0){ + iofree(port); return -1; + } /* try configuring as a 10BaseT */ if(configASIC(ether, port, xcvr10BaseT) < 0){ pcmspecialclose(slot); + iofree(port); return -1; } delay(100); @@ -143,6 +146,7 @@ reset(Ether* ether) COMMAND(port, GlobalReset, 0); if(configASIC(ether, port, xcvr10Base2) < 0){ pcmspecialclose(slot); + iofree(port); return -1; } print("#l%d: xcvr10Base2 %s\n", ether->ctlrno, ether->type); diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index 19af50acdc79af4e63fa7d12ab15b192a6fdbf2d..e40a2b20222a02ddeeb1d0c2f1d402ee3b3697f9 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -1312,7 +1312,7 @@ tcm509isa(void) * it fully. */ while(port = activate()){ - if(ioalloc(port, 0x20, 0, "tcm509isa") < 0){ + if(ioalloc(port, 0x10, 0, "tcm509isa") < 0){ print("tcm509isa:port %d in use\n", port); continue; } @@ -1436,8 +1436,12 @@ tcm5XXpcmcia(Ether* ether) for(i = 0; tcmpcmcia[i] != nil; i++){ if(!cistrcmp(ether->type, tcmpcmcia[i])){ - if(ioalloc(ether->port, 0x20, 0, "tcm5XXpcmcia") < 0) + /* + * No need for an ioalloc here, the 589 reset + * code deals with it. + if(ioalloc(ether->port, 0x10, 0, "tcm5XXpcmcia") < 0) return 0; + */ return ether->port; } } diff --git a/pc/vgas3.c b/pc/vgas3.c index a9d3bb164e64f6ee6b6e3407e5f683f78dc181aa..af7ffab39ef70d0b4a1adf844770d6bc980e35b2 100644 --- a/pc/vgas3.c +++ b/pc/vgas3.c @@ -64,12 +64,14 @@ s3page(VGAscr* scr, int page) static ulong s3linear(VGAscr* scr, int* size, int* align) { - ulong aperture, oaperture; + ulong aperture, oaperture, osize; int oapsize, wasupamem; Pcidev *p; + Physseg seg; oaperture = scr->aperture; oapsize = scr->apsize; + osize = *size; wasupamem = scr->isupamem; if(wasupamem) upafree(oaperture, oapsize); @@ -90,6 +92,13 @@ s3linear(VGAscr* scr, int* size, int* align) else scr->isupamem = 1; + memset(&seg, 0, sizeof(seg)); + seg.attr = SG_PHYSICAL; + seg.name = smalloc(NAMELEN); + snprint(seg.name, NAMELEN, "s3screen"); + seg.pa = aperture; + seg.size = osize; + addphysseg(&seg); return aperture; } diff --git a/port/chan.c b/port/chan.c index 3b030658e73c9dc9096470062c304567c30eff05..49d714d1458c34c6a97ee6364ec8de72c160adb6 100644 --- a/port/chan.c +++ b/port/chan.c @@ -643,7 +643,7 @@ saveregisters(void) * In place, rewrite name to compress multiple /, eliminate ., and process .. */ void -cleanname(Cname *n, int offset) +cleancname(Cname *n, int offset) { char *p, *q, *dotdot, *name; int rooted; @@ -669,7 +669,7 @@ cleanname(Cname *n, int offset) if(q > dotdot) { /* can backtrack */ while(--q > dotdot && *q != '/') ; - } else if(!rooted) { /* ``/..'' ≡ ``/'', but ``./../'' ≡ ``..'' */ + } else if(!rooted) { /* /.. is / but ./../ is .. */ if(q != name) *q++ = '/'; *q++ = '.'; @@ -685,7 +685,7 @@ cleanname(Cname *n, int offset) } if(q == name) /* empty string is really ``.'' */ *q++ = '.'; - *q = 0; + *q = '\0'; n->len = (q-name) + offset; } @@ -910,9 +910,9 @@ namec(char *name, int amode, int omode, ulong perm) /* peculiar workaround for #/ */ if(newname){ if(cname->s[0]=='#' && cname->s[1]=='/') - cleanname(cname, 2); + cleancname(cname, 1); else - cleanname(cname, 0); + cleancname(cname, 0); cnameclose(c->name); c->name = cname; }else diff --git a/port/devdraw.c b/port/devdraw.c index f5e4a0827d61ab4e09196c78a2cf865670d59b77..039ff0e1784da4dd74c66da5550742aea0b0cc5f 100644 --- a/port/devdraw.c +++ b/port/devdraw.c @@ -1,9 +1,9 @@ #include "u.h" -#include "../port/lib.h" +#include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" -#include "../port/error.h" +#include "error.h" #define Image IMAGE #include diff --git a/port/devsrv.c b/port/devsrv.c index 80b001c3feb7252bc59a5ec116d554380f749d13..aac2072100ba4f5ffa317885011d7dd11cf82240 100644 --- a/port/devsrv.c +++ b/port/devsrv.c @@ -114,7 +114,7 @@ srvopen(Chan *c, int omode) error(Eshutdown); if(omode&OTRUNC) - error(Eperm); + error("srv file already exists"); if(openmode(omode)!=sp->chan->mode && sp->chan->mode!=ORDWR) error(Eperm); @@ -270,6 +270,8 @@ srvwrite(Chan *c, void *va, long n, vlong) cclose(c1); nexterror(); } + if(c1->flag & (CCEXEC|CRCLOSE)) + error("posted fd has remove-on-close or close-on-exec"); sp = srvlookup(nil, c->qid.path); if(sp == 0) error(Enonexist); diff --git a/port/lib.h b/port/lib.h index 58349115330d8ed65b96e1ef19793e8133007a81..a904fc7614c153507f747c8d1d019c1420b4f0f9 100644 --- a/port/lib.h +++ b/port/lib.h @@ -66,7 +66,8 @@ extern int print(char*, ...); /* * one-of-a-kind */ -ulong getcallerpc(void*); +extern char* cleanname(char*); +extern ulong getcallerpc(void*); extern long strtol(char*, char**, int); extern ulong strtoul(char*, char**, int); extern vlong strtoll(char*, char**, int);