diff options
author | mischief <mischief@offblast.org> | 2015-08-25 02:07:46 -0700 |
---|---|---|
committer | mischief <mischief@offblast.org> | 2015-08-25 02:07:46 -0700 |
commit | 6b402b83cffc97015345dab1c27c35afe64bb3db (patch) | |
tree | b525f9443564682c46f8c36af6a4d238bd39a756 /sys/src/cmd | |
parent | dbe0a995f03f26ea2b6859d21df3bd67856d672d (diff) |
import E script from bell labs
Diffstat (limited to 'sys/src/cmd')
-rw-r--r-- | sys/src/cmd/auth/lib/okpasswd.c | 1 | ||||
-rw-r--r-- | sys/src/cmd/aux/consolefs.c | 158 | ||||
-rw-r--r-- | sys/src/cmd/cpu.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/gs/amd64.h | 4 | ||||
-rw-r--r-- | sys/src/cmd/ip/httpd/sendfd.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/ip/tftpd.c | 3 | ||||
-rw-r--r-- | sys/src/cmd/mk/run.c | 2 |
7 files changed, 87 insertions, 89 deletions
diff --git a/sys/src/cmd/auth/lib/okpasswd.c b/sys/src/cmd/auth/lib/okpasswd.c index b904db5aa..5512e559a 100644 --- a/sys/src/cmd/auth/lib/okpasswd.c +++ b/sys/src/cmd/auth/lib/okpasswd.c @@ -10,7 +10,6 @@ char *trivial[] = { "change me", "passwd", "no passwd", - "anonymous", 0 }; diff --git a/sys/src/cmd/aux/consolefs.c b/sys/src/cmd/aux/consolefs.c index ebc5e1230..0d4146bc6 100644 --- a/sys/src/cmd/aux/consolefs.c +++ b/sys/src/cmd/aux/consolefs.c @@ -5,6 +5,7 @@ #include <bio.h> #include <ndb.h> #include <thread.h> +#include <9p.h> /* * This fs presents a 1 level file system. It contains @@ -12,7 +13,7 @@ */ typedef struct Console Console; -typedef struct Fid Fid; +typedef struct Aux Aux; typedef struct Request Request; typedef struct Reqlist Reqlist; typedef struct Fs Fs; @@ -28,7 +29,7 @@ enum Bufsize= 32*1024, /* chars buffered per reader */ Maxcons= 64, /* maximum consoles */ - Nhash= 64, /* Fid hash buckets */ + Nhash= 64, /* Aux hash buckets */ }; #define TYPE(x) (((ulong)x.path) & 0xf) @@ -38,7 +39,7 @@ enum struct Request { Request *next; - Fid *fid; + Aux *fid; Fs *fs; Fcall f; uchar buf[1]; @@ -51,11 +52,11 @@ struct Reqlist Request *last; }; -struct Fid +struct Aux { Lock; - Fid *next; /* hash list */ - Fid *cnext; /* list of Fid's on a console */ + Aux *next; /* hash list */ + Aux *cnext; /* list of Aux's on a console */ int fid; int ref; @@ -93,7 +94,7 @@ struct Console int cfd; int sfd; - Fid *flist; /* open fids to broadcast to */ + Aux *flist; /* open fids to broadcast to */ }; struct Fs @@ -102,7 +103,7 @@ struct Fs int fd; /* to kernel mount point */ int messagesize; - Fid *hash[Nhash]; + Aux *hash[Nhash]; Console *cons[Maxcons]; int ncons; }; @@ -112,30 +113,30 @@ extern Fs* fsmount(char*); extern void fsreader(void*); extern void fsrun(void*); -extern Fid* fsgetfid(Fs*, int); -extern void fsputfid(Fs*, Fid*); +extern Aux* fsgetfid(Fs*, int); +extern void fsputfid(Fs*, Aux*); extern int fsdirgen(Fs*, Qid, int, Dir*, uchar*, int); extern void fsreply(Fs*, Request*, char*); -extern void fskick(Fs*, Fid*); +extern void fskick(Fs*, Aux*); extern int fsreopen(Fs*, Console*); -extern void fsversion(Fs*, Request*, Fid*); -extern void fsflush(Fs*, Request*, Fid*); -extern void fsauth(Fs*, Request*, Fid*); -extern void fsattach(Fs*, Request*, Fid*); -extern void fswalk(Fs*, Request*, Fid*); -extern void fsclwalk(Fs*, Request*, Fid*); -extern void fsopen(Fs*, Request*, Fid*); -extern void fscreate(Fs*, Request*, Fid*); -extern void fsread(Fs*, Request*, Fid*); -extern void fswrite(Fs*, Request*, Fid*); -extern void fsclunk(Fs*, Request*, Fid*); -extern void fsremove(Fs*, Request*, Fid*); -extern void fsstat(Fs*, Request*, Fid*); -extern void fswstat(Fs*, Request*, Fid*); - - -void (*fcall[])(Fs*, Request*, Fid*) = +extern void fsversion(Fs*, Request*, Aux*); +extern void fsflush(Fs*, Request*, Aux*); +extern void fsauth(Fs*, Request*, Aux*); +extern void fsattach(Fs*, Request*, Aux*); +extern void fswalk(Fs*, Request*, Aux*); +extern void fsclwalk(Fs*, Request*, Aux*); +extern void fsopen(Fs*, Request*, Aux*); +extern void fscreate(Fs*, Request*, Aux*); +extern void fsread(Fs*, Request*, Aux*); +extern void fswrite(Fs*, Request*, Aux*); +extern void fsclunk(Fs*, Request*, Aux*); +extern void fsremove(Fs*, Request*, Aux*); +extern void fsstat(Fs*, Request*, Aux*); +extern void fswstat(Fs*, Request*, Aux*); + + +void (*fcall[])(Fs*, Request*, Aux*) = { [Tflush] fsflush, [Tversion] fsversion, @@ -199,7 +200,7 @@ Ndb *db; * any request that can get queued for a delayed reply */ Request* -allocreq(Fs *fs, int bufsize) +alloccreq(Fs *fs, int bufsize) { Request *r; @@ -343,10 +344,10 @@ fsdirgen(Fs *fs, Qid parent, int i, Dir *d, uchar *buf, int nbuf) Fs* fsmount(char *mntpt) { + int pfd[2]; + Fs *fs; - int pfd[2], srv; - char buf[32]; - int n; + Dir d; static void *v[2]; fs = emalloc(sizeof(Fs)); @@ -359,21 +360,19 @@ fsmount(char *mntpt) v[1] = pfd; proccreate(fsrun, v, 16*1024); - /* Typically mounted before /srv exists */ - if(access("#s/consoles", AEXIST) < 0){ - srv = create("#s/consoles", OWRITE, 0666); - if(srv < 0) - fatal("post: %r"); + if(postfd("consoles", pfd[1]) < 0) + sysfatal("post: %r"); - n = sprint(buf, "%d", pfd[1]); - if(write(srv, buf, n) < 0) - fatal("write srv: %r"); + nulldir(&d); + d.mode = 0666; + dirwstat("/srv/consoles", &d); - close(srv); - } + if(mntpt){ + if(amount(pfd[1], mntpt, MBEFORE, "") == -1) + sysfatal("mount %s: %r", mntpt); + }else + close(pfd[1]); - mount(pfd[1], -1, mntpt, MBEFORE, ""); - close(pfd[1]); return fs; } @@ -516,7 +515,7 @@ console(Fs* fs, char *name, char *dev, int speed, int cronly, int ondemand) * the reader may miss data but always sees an in order sequence. */ void -fromconsole(Fid *f, char *p, int n) +fromconsole(Aux *f, char *p, int n) { char *rp, *wp, *ep; int pass; @@ -552,10 +551,10 @@ fromconsole(Fid *f, char *p, int n) * broadcast a list of members to all listeners */ void -bcastmembers(Fs *fs, Console *c, char *msg, Fid *f) +bcastmembers(Fs *fs, Console *c, char *msg, Aux *f) { int n; - Fid *fl; + Aux *fl; char buf[512]; sprint(buf, "[%s%s", msg, f->user); @@ -590,7 +589,7 @@ void fsreader(void *v) { int n; - Fid *fl; + Aux *fl; char buf[1024]; Fs *fs; Console *c; @@ -653,8 +652,6 @@ readdb(Fs *fs) } } -int dbmtime; - /* * a request processor (one per Fs) */ @@ -663,8 +660,7 @@ fsrun(void *v) { int n, t; Request *r; - Fid *f; - Dir *d; + Aux *f; void **a = v; Fs* fs; int *pfd; @@ -672,15 +668,12 @@ fsrun(void *v) fs = a[0]; pfd = a[1]; fs->fd = pfd[0]; + readdb(fs); notify(handler); for(;;){ - d = dirstat(consoledb); - if(d != nil && d->mtime != dbmtime){ - dbmtime = d->mtime; + if(ndbchanged(db)) readdb(fs); - } - free(d); - r = allocreq(fs, messagesize); + r = alloccreq(fs, messagesize); while((n = read9pmsg(fs->fd, r->buf, messagesize)) == 0) ; if(n < 0) @@ -705,10 +698,10 @@ fsrun(void *v) } } -Fid* +Aux* fsgetfid(Fs *fs, int fid) { - Fid *f, *nf; + Aux *f, *nf; lock(fs); for(f = fs->hash[fid%Nhash]; f; f = f->next){ @@ -719,7 +712,7 @@ fsgetfid(Fs *fs, int fid) } } - nf = emalloc(sizeof(Fid)); + nf = emalloc(sizeof(Aux)); nf->next = fs->hash[fid%Nhash]; fs->hash[fid%Nhash] = nf; nf->fid = fid; @@ -731,9 +724,9 @@ fsgetfid(Fs *fs, int fid) } void -fsputfid(Fs *fs, Fid *f) +fsputfid(Fs *fs, Aux *f) { - Fid **l, *nf; + Aux **l, *nf; lock(fs); if(--f->ref > 0){ @@ -751,13 +744,13 @@ fsputfid(Fs *fs, Fid *f) } void -fsauth(Fs *fs, Request *r, Fid*) +fsauth(Fs *fs, Request *r, Aux*) { fsreply(fs, r, "consolefs: authentication not required"); } void -fsversion(Fs *fs, Request *r, Fid*) +fsversion(Fs *fs, Request *r, Aux*) { if(r->f.msize < 256){ @@ -778,7 +771,7 @@ fsversion(Fs *fs, Request *r, Fid*) } void -fsflush(Fs *fs, Request *r, Fid *f) +fsflush(Fs *fs, Request *r, Aux *f) { Request *or; @@ -786,12 +779,15 @@ fsflush(Fs *fs, Request *r, Fid *f) if(or != nil){ fsputfid(fs, or->fid); free(or); + fsreply(fs, r, nil); + } else { + fsputfid(fs, f); + free(r); } - fsreply(fs, r, nil); } void -fsattach(Fs *fs, Request *r, Fid *f) +fsattach(Fs *fs, Request *r, Aux *f) { f->qid.type = QTDIR; f->qid.path = QID(0, Ttopdir); @@ -813,13 +809,13 @@ fsattach(Fs *fs, Request *r, Fid *f) } void -fswalk(Fs *fs, Request *r, Fid *f) +fswalk(Fs *fs, Request *r, Aux *f) { char *name; Dir d; int i, n, nqid, nwname; Qid qid, wqid[MAXWELEM]; - Fid *nf; + Aux *nf; char *err; if(f->attached == 0){ @@ -932,7 +928,7 @@ int m2p[] ={ void bcastmsg(Fs *fs, Console *c, char *msg, int n) { - Fid *fl; + Aux *fl; for(fl = c->flist; fl; fl = fl->cnext){ fromconsole(fl, msg, n); @@ -941,7 +937,7 @@ bcastmsg(Fs *fs, Console *c, char *msg, int n) } void -fsopen(Fs *fs, Request *r, Fid *f) +fsopen(Fs *fs, Request *r, Aux *f) { int mode; Console *c; @@ -1009,13 +1005,13 @@ fsopen(Fs *fs, Request *r, Fid *f) } void -fscreate(Fs *fs, Request *r, Fid*) +fscreate(Fs *fs, Request *r, Aux*) { fsreply(fs, r, Eperm); } void -fsread(Fs *fs, Request *r, Fid *f) +fsread(Fs *fs, Request *r, Aux *f) { uchar *p, *e; int i, m, off; @@ -1078,7 +1074,7 @@ fsread(Fs *fs, Request *r, Fid *f) } void -fswrite(Fs *fs, Request *r, Fid *f) +fswrite(Fs *fs, Request *r, Aux *f) { int i, eol = 0; @@ -1141,9 +1137,9 @@ fswrite(Fs *fs, Request *r, Fid *f) } void -fsclunk(Fs *fs, Request *r, Fid *f) +fsclunk(Fs *fs, Request *r, Aux *f) { - Fid **l, *fl; + Aux **l, *fl; Request *nr; if(f->open && TYPE(f->qid) == Qdata){ @@ -1170,13 +1166,13 @@ fsclunk(Fs *fs, Request *r, Fid *f) } void -fsremove(Fs *fs, Request *r, Fid*) +fsremove(Fs *fs, Request *r, Aux*) { fsreply(fs, r, Eperm); } void -fsstat(Fs *fs, Request *r, Fid *f) +fsstat(Fs *fs, Request *r, Aux *f) { int i, n; Qid q; @@ -1198,7 +1194,7 @@ fsstat(Fs *fs, Request *r, Fid *f) } void -fswstat(Fs *fs, Request *r, Fid*) +fswstat(Fs *fs, Request *r, Aux*) { fsreply(fs, r, Eperm); } @@ -1226,7 +1222,7 @@ fsreply(Fs *fs, Request *r, char *err) * called whenever input or a read request has been received */ void -fskick(Fs *fs, Fid *f) +fskick(Fs *fs, Aux *f) { Request *r; char *p, *rp, *wp, *ep; diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c index 1994aaf28..edcf8bd50 100644 --- a/sys/src/cmd/cpu.c +++ b/sys/src/cmd/cpu.c @@ -224,7 +224,7 @@ main(int argc, char **argv) if(system == nil) { p = getenv("cpu"); if(p == 0) - fatal("set $cpu"); + p = "$cpu"; system = p; } diff --git a/sys/src/cmd/gs/amd64.h b/sys/src/cmd/gs/amd64.h index ce16fed64..80ac5906c 100644 --- a/sys/src/cmd/gs/amd64.h +++ b/sys/src/cmd/gs/amd64.h @@ -33,13 +33,13 @@ /* ---------------- Cache sizes ---------------- */ -#define ARCH_CACHE1_SIZE 131072 +#define ARCH_CACHE1_SIZE 2097152 #define ARCH_CACHE2_SIZE 4194304 /* ---------------- Miscellaneous ---------------- */ #define ARCH_IS_BIG_ENDIAN 0 -#define ARCH_PTRS_ARE_SIGNED 0 +#define ARCH_PTRS_ARE_SIGNED 1 #define ARCH_FLOATS_ARE_IEEE 1 #define ARCH_ARITH_RSHIFT 2 #define ARCH_CAN_SHIFT_FULL_LONG 0 diff --git a/sys/src/cmd/ip/httpd/sendfd.c b/sys/src/cmd/ip/httpd/sendfd.c index b3ef1c13b..c1850ea75 100644 --- a/sys/src/cmd/ip/httpd/sendfd.c +++ b/sys/src/cmd/ip/httpd/sendfd.c @@ -240,10 +240,10 @@ static void printtype(Hio *hout, HContent *type, HContent *enc) { hprint(hout, "Content-Type: %s/%s", type->generic, type->specific); -/* + if(cistrcmp(type->generic, "text") == 0) hprint(hout, ";charset=utf-8"); -*/ + hprint(hout, "\r\n"); if(enc != nil) hprint(hout, "Content-Encoding: %s\r\n", enc->generic); @@ -351,6 +351,8 @@ checkreq(HConnect *c, HContent *type, HContent *enc, long mtime, char *etag) if(c->req.vermaj >= 1 && c->req.vermin >= 1 && !hcheckcontent(enc, c->head.okencode, "Content-Encoding", 0)) return notaccept(c, type, enc, "Content-Encoding"); + return 1; + /* * can use weak match only with get or head; * this always uses strong matches diff --git a/sys/src/cmd/ip/tftpd.c b/sys/src/cmd/ip/tftpd.c index e0569b959..4b4725f1f 100644 --- a/sys/src/cmd/ip/tftpd.c +++ b/sys/src/cmd/ip/tftpd.c @@ -54,6 +54,7 @@ enum */ Bandtblksz = Bandtmtu - 40 - 8, Bcavium = 1432, /* cavium's u-boot demands this size */ + Bci20 = 1468, /* ci20 u-boot */ }; typedef struct Opt Opt; @@ -329,7 +330,7 @@ options(int fd, char *buf, int bufsz, char *file, ushort oper, char *p, int dlen syslog(dbg, flog, "tftpd %d %s tsize is %,lld", pid, file, size); } else if (oper == Tftp_READ && cistrcmp(p, "blksize") == 0 && - blksize > Bandtblksz && blksize != Bcavium) { + blksize > Bandtblksz && blksize != Bcavium && blksize != Bci20) { *op->valp = blksize = Bandtblksz; olen = emitn(blksize, bp, ep); syslog(dbg, flog, "tftpd %d overriding blksize to %d", diff --git a/sys/src/cmd/mk/run.c b/sys/src/cmd/mk/run.c index c01b519fd..ecee9819a 100644 --- a/sys/src/cmd/mk/run.c +++ b/sys/src/cmd/mk/run.c @@ -163,7 +163,7 @@ again: /* rogue processes */ uarg = 1; } else { jobs = 0; - Exit(); + sysfatal("%s", buf); } } for(w = j->t; w; w = w->next){ |