diff options
| author | Charles.Forsyth <devnull@localhost> | 2008-01-24 15:40:38 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2008-01-24 15:40:38 +0000 |
| commit | ad01d857a3ec149074830330005eb4c786d3330c (patch) | |
| tree | a855490fd42296879f89d6cb57835ceb86ce2e19 | |
| parent | 9b29ac7ea714507a9c0690620c02c8ca5ab25f90 (diff) | |
20080124-1547
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | emu/port/devssl.c | 68 | ||||
| -rw-r--r-- | include/version.h | 2 | ||||
| -rw-r--r-- | os/port/devssl.c | 64 |
4 files changed, 66 insertions, 70 deletions
@@ -1,3 +1,5 @@ +20080124 + fix emu/port/devssl.c os/port/devssl.c not to keep the directory numbers(!) 20080122 update appl/lib/db.b: allow for split i/o on pipes or tcp/ip; eliminate lock process eliminate more unused identifier warnings (courtesy acme-sac) diff --git a/emu/port/devssl.c b/emu/port/devssl.c index 2132ab9f..c8c16fc3 100644 --- a/emu/port/devssl.c +++ b/emu/port/devssl.c @@ -78,7 +78,6 @@ Lock dslock; int dshiwat; int maxdstate = 20; Dstate** dstate; -char** dsname; enum{ Qtopdir = 1, /* top level directory */ @@ -111,7 +110,7 @@ static Block* digestb(Dstate*, Block*, int); static void checkdigestb(Dstate*, Block*); static Chan* buftochan(char*); static void sslhangup(Dstate*); -static Dstate* dsclone(Chan *c); +static void dsclone(Chan *c); static void dsnew(Chan *c, Dstate **); static int @@ -119,7 +118,7 @@ sslgen(Chan *c, char *dname, Dirtab *d, int nd, int s, Dir *dp) { Qid q; Dstate *ds; - char name[16], *p, *nm; + char *p, *nm; USED(dname); USED(nd); @@ -138,15 +137,12 @@ sslgen(Chan *c, char *dname, Dirtab *d, int nd, int s, Dir *dp) q.path = QID(s, Qconvdir); q.type = QTDIR; ds = dstate[s]; - if(ds != 0) + if(ds != 0) nm = ds->user; else nm = eve; - if(dsname[s] == nil){ - sprint(name, "%d", s); - kstrdup(&dsname[s], name); - } - devdir(c, q, dsname[s], 0, nm, DMDIR|0555, dp); + snprint(up->genbuf, sizeof(up->genbuf), "%d", s); + devdir(c, q, up->genbuf, 0, nm, DMDIR|0555, dp); return 1; } if(s > dshiwat) @@ -201,8 +197,6 @@ sslinit(void) { if((dstate = malloc(sizeof(Dstate*) * maxdstate)) == 0) panic("sslinit"); - if((dsname = malloc(sizeof(*dsname) * maxdstate)) == 0) - panic("sslinit"); alglistinit(); } @@ -259,9 +253,7 @@ sslopen(Chan *c, int omode) error(Eperm); break; case Qclonus: - s = dsclone(c); - if(s == 0) - error(Enodev); + dsclone(c); break; case Qctl: case Qdata: @@ -300,24 +292,32 @@ sslopen(Chan *c, int omode) } static int -sslwstat(Chan *c, uchar *dp, int n) +sslwstat(Chan *c, uchar *db, int n) { - Dir d; + Dir *dir; Dstate *s; + int m; - n = convM2D(dp, n, &d, nil); - if(n == 0) - error(Eshortstat); s = dstate[CONV(c->qid)]; if(s == 0) error(Ebadusefd); if(strcmp(s->user, up->env->user) != 0) error(Eperm); - if(!emptystr(d.uid)) - kstrdup(&s->user, d.uid); - if(d.mode != ~0UL) - s->perm = d.mode; - return n; + + dir = smalloc(sizeof(Dir)+n); + m = convM2D(db, n, &dir[0], (char*)&dir[1]); + if(m == 0){ + free(dir); + error(Eshortstat); + } + + if(!emptystr(dir->uid)) + kstrdup(&s->user, dir->uid); + if(dir->mode != ~0UL) + s->perm = dir->mode; + + free(dir); + return m; } static void @@ -1359,17 +1359,17 @@ sslhangup(Dstate *s) qunlock(&s->in.q); } -static Dstate* +static void dsclone(Chan *ch) { Dstate **pp, **ep, **np; int newmax; + lock(&dslock); if(waserror()) { unlock(&dslock); nexterror(); } - lock(&dslock); ep = &dstate[maxdstate]; for(pp = dstate; pp < ep; pp++) { if(*pp == 0) { @@ -1378,26 +1378,24 @@ dsclone(Chan *ch) } } if(pp >= ep) { - if(maxdstate >= Maxdstate) { - unlock(&dslock); - poperror(); - return 0; - } + if(maxdstate >= Maxdstate) + error(Enodev); newmax = 2 * maxdstate; if(newmax > Maxdstate) newmax = Maxdstate; + np = realloc(dstate, sizeof(Dstate*) * newmax); if(np == 0) error(Enomem); dstate = np; pp = &dstate[maxdstate]; memset(pp, 0, sizeof(Dstate*)*(newmax - maxdstate)); + maxdstate = newmax; dsnew(ch, pp); } - unlock(&dslock); poperror(); - return *pp; + unlock(&dslock); } static void @@ -1406,8 +1404,8 @@ dsnew(Chan *ch, Dstate **pp) Dstate *s; int t; - *pp = s = malloc(sizeof(*s)); - if(!s) + *pp = s = mallocz(sizeof(*s), 1); + if(s == nil) error(Enomem); if(pp - dstate >= dshiwat) dshiwat++; diff --git a/include/version.h b/include/version.h index f3fe4e7b..7fbfec41 100644 --- a/include/version.h +++ b/include/version.h @@ -1 +1 @@ -#define VERSION "Fourth Edition (20080122)" +#define VERSION "Fourth Edition (20080124)" diff --git a/os/port/devssl.c b/os/port/devssl.c index 23c3fec5..64938bac 100644 --- a/os/port/devssl.c +++ b/os/port/devssl.c @@ -76,7 +76,6 @@ Lock dslock; int dshiwat; int maxdstate = 20; Dstate** dstate; -char** dsname; enum { @@ -118,7 +117,7 @@ static Block* digestb(Dstate*, Block*, int); static void checkdigestb(Dstate*, Block*); static Chan* buftochan(char*); static void sslhangup(Dstate*); -static Dstate* dsclone(Chan *c); +static void dsclone(Chan *c); static void dsnew(Chan *c, Dstate **); static int @@ -126,7 +125,7 @@ sslgen(Chan *c, char*, Dirtab *d, int nd, int s, Dir *dp) { Qid q; Dstate *ds; - char name[16], *p, *nm; + char *p, *nm; USED(nd); USED(d); @@ -148,11 +147,8 @@ sslgen(Chan *c, char*, Dirtab *d, int nd, int s, Dir *dp) nm = ds->user; else nm = eve; - if(dsname[s] == nil){ - sprint(name, "%d", s); - kstrdup(&dsname[s], name); - } - devdir(c, q, dsname[s], 0, nm, DMDIR|0555, dp); + snprint(up->genbuf, sizeof(up->genbuf), "%d", s); + devdir(c, q, up->genbuf, 0, nm, DMDIR|0555, dp); return 1; } if(s > dshiwat) @@ -207,8 +203,6 @@ sslinit(void) { if((dstate = malloc(sizeof(Dstate*) * maxdstate)) == 0) panic("sslinit"); - if((dsname = malloc(sizeof(*dsname) * maxdstate)) == 0) - panic("sslinit"); alglistinit(); } @@ -265,9 +259,7 @@ sslopen(Chan *c, int omode) error(Eperm); break; case Qclonus: - s = dsclone(c); - if(s == 0) - error(Enodev); + dsclone(c); break; case Qctl: case Qdata: @@ -306,24 +298,32 @@ sslopen(Chan *c, int omode) } static int -sslwstat(Chan *c, uchar *dp, int n) +sslwstat(Chan *c, uchar *db, int n) { - Dir d; + Dir *dir; Dstate *s; + int m; - n = convM2D(dp, n, &d, nil); - if(n == 0) - error(Eshortstat); s = dstate[CONV(c->qid)]; if(s == 0) error(Ebadusefd); if(strcmp(s->user, up->env->user) != 0) error(Eperm); - if(!emptystr(d.uid)) - kstrdup(&s->user, d.uid); - if(d.mode != ~0UL) - s->perm = d.mode; - return n; + + dir = smalloc(sizeof(Dir)+n); + m = convM2D(db, n, &dir[0], (char*)&dir[1]); + if(m == 0){ + free(dir); + error(Eshortstat); + } + + if(!emptystr(dir->uid)) + kstrdup(&s->user, dir->uid); + if(dir->mode != ~0UL) + s->perm = dir->mode; + + free(dir); + return m; } static void @@ -1371,17 +1371,17 @@ sslhangup(Dstate *s) extern void rbcheck(char*); -static Dstate* +static void dsclone(Chan *ch) { Dstate **pp, **ep, **np; int newmax; + lock(&dslock); if(waserror()) { unlock(&dslock); nexterror(); } - lock(&dslock); ep = &dstate[maxdstate]; for(pp = dstate; pp < ep; pp++) { if(*pp == 0) { @@ -1390,11 +1390,8 @@ dsclone(Chan *ch) } } if(pp >= ep) { - if(maxdstate >= Maxdstate) { - unlock(&dslock); - poperror(); - return 0; - } + if(maxdstate >= Maxdstate) + error(Enodev); newmax = 2 * maxdstate; if(newmax > Maxdstate) newmax = Maxdstate; @@ -1407,9 +1404,8 @@ dsclone(Chan *ch) maxdstate = newmax; dsnew(ch, pp); } - unlock(&dslock); poperror(); - return *pp; + unlock(&dslock); } static void @@ -1418,8 +1414,8 @@ dsnew(Chan *ch, Dstate **pp) Dstate *s; int t; - *pp = s = malloc(sizeof(*s)); - if(!s) + *pp = s = mallocz(sizeof(*s), 1); + if(s == nil) error(Enomem); if(pp - dstate >= dshiwat) dshiwat++; |
