ref: 6b402b83cffc97015345dab1c27c35afe64bb3db
parent: dbe0a995f03f26ea2b6859d21df3bd67856d672d
author: mischief <[email protected]>
date: Mon Aug 24 22:07:46 EDT 2015
import E script from bell labs
--- a/lib/namespace.httpd
+++ b/lib/namespace.httpd
@@ -1,39 +1,10 @@
-# we start with the namespace of the console...
+bind /cfg /usr/web/cfg
+bind /386 /usr/web/386
+bind /amd64 /usr/web/amd64
-# man2html expects man pages under /sys/man
-mount #s/boot /n/emelieother other
-bind /n/emelieother/plan9/sys/man /usr/web/sys/man
-#bind /n/emelieother/plan9/sys/doc /usr/web/sys/doc
-#bind /sys/man /usr/web/sys/man
-bind /sys/doc /usr/web/sys/doc
+bind /sys/src/9 /usr/web/sys/src/9
-# just so people will find something under plan9
-bind /usr/web/plan9dist /usr/web/plan9
-
-# users
-bind /usr/mike/www /usr/web/incoming/mike
-
-# netlib
-bind /netlib/pub /usr/web/netlib
-mount -b #s/netlib.depend.pub /usr/web/netlib.depend
-# don't need to bind to /usr/web/math etc. because of /sys/lib/http-rewrite
-
-# who what why when where
-mount /srv/alice /n/alice
-bind -b /n/alice/cm /usr/web/cm
-bind /usr/web/cm/who /usr/web/who
-bind -b /usr/web/cm/physics/who /usr/web/who
-bind -b /usr/web/cm/blrsv/who /usr/web/who
-bind -b /usr/web/cm/ss/who /usr/web/who
-bind -b /usr/web/cm/ms/who /usr/web/who
-bind -b /usr/web/cm/china/who /usr/web/who
-bind -b /usr/web/cm/cs/who /usr/web/who
-bind /usr/web/cm/ms/what/wavelet /usr/web/wavelet
-
-# formerly ftp.research.bell-labs.com
-bind -b /n/alice/usr/ftp /usr/web/dist
-
-# wiki (questions to rsc)
-mount -b #s/wiki.plan9 /usr/web/wiki/plan9
+mount #s/etcd /n/etcd
+bind /n/etcd/www /usr/web/etc
# httpd will bind /usr/web onto /
--- a/lib/vgadb
+++ b/lib/vgadb
@@ -435,6 +435,7 @@
ctlr=geode linear=1
ctlr
+ vid=0x8086 did=0x0126 # Intel 2nd Gen Core
vid=0x8086 did=0x0166 # Intel 3rd Gen Core
vid=0x8086 did=0x2a42 # Intel 4 Series Mobile
link=vga
@@ -1693,6 +1694,16 @@
shb=1728 ehb=1760 vt=1840
vrs=1053 vre=1059 vt=1080
hsync=+ vsync=-
+
+#
+# Lenovo T420 (LCD) LVDS
+#
+#t420=1366x768 # 60Hz
+# clock=69.3
+# shb=1398 ehb=1430 ht=1470
+# vrs=771 vre=776 vt=786
+# hsync=- vsync=-
+# lcd=1
#
# Lenovo X230 (LCD) LVDS
--- a/rc/bin/9fs
+++ b/rc/bin/9fs
@@ -71,6 +71,12 @@
vacfs -m /n/`{basename $1 .vac} `{cat $score}
case wiki
srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
+case ingenic
+ ftpfs -qKm /n/ingenic -a $user@$sysname ftp.ingenic.com
+case kernel
+ ftpfs -qKm /n/kernel -a $user@sysname ftp.kernel.org
+case qrstuv
+ srv -nqmC tcp!fs.9paste.net qrstuv
case *
switch($#*){
case 1
--- /dev/null
+++ b/rc/bin/E
@@ -1,0 +1,16 @@
+#!/bin/rc
+# E file - B file, wait until it changes, exit
+rfork e
+if (! ~ $#* 1) {
+ echo usage: $0 file >[1=2]
+ exit usage
+}
+if (! test -e $1) {
+ echo $0: $1: no such file >[1=2]
+ exit no-file
+}
+otm = `{mtime $1 | awk '{print $1}'}
+B $1
+while (~ $otm `{mtime $1 | awk '{print $1}'})
+ sleep 1
+exit ''
--- a/rc/bin/ape/egrep
+++ b/rc/bin/ape/egrep
@@ -1,2 +1,2 @@
#!/bin/rc
-exec /rc/bin/ape/grep $*
+exec /$objtype/bin/ape/grep -E $*
--- a/rc/bin/ape/fgrep
+++ b/rc/bin/ape/fgrep
@@ -1,2 +1,2 @@
#!/bin/rc
-exec /rc/bin/ape/grep $*
+exec /$objtype/bin/ape/grep -F $*
--- a/rc/bin/ape/ln
+++ b/rc/bin/ape/ln
@@ -20,4 +20,4 @@
exit 'usage'
}
-exec cp -gux $1 $2
+exec cp -R $1 $2
--- a/rc/bin/cpurc
+++ b/rc/bin/cpurc
@@ -55,18 +55,22 @@
}
}
-if(! test -e /net/dns)
+if(! test -e /net/dns){
+ echo dns...
ndb/dns -r
+}
+echo timesync...
if(! ps|grep -s timesync){
if(~ $#ntp 0)
. <{ndb/ipquery sys $sysname ntp | sed 's, +,\n,g'}
if(~ $#ntp 0)
ntp=pool.ntp.org
- aux/timesync -n $ntp
+ #aux/timesync -n $ntp
sleep 2
}
+echo listen...
if(~ $#auth 0){
auth=`{ndb/query sys $sysname auth}
. <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'}
@@ -89,6 +93,7 @@
if(test -f /dev/apm)
aux/apm
+echo cpustart...
if(test -e /cfg/$sysname/cpustart)
. /cfg/$sysname/cpustart
--- a/rc/bin/service/tcp17010
+++ b/rc/bin/service/tcp17010
@@ -1,3 +1,4 @@
#!/bin/rc
-netdir=`{echo $3 | sed 's;/[0-9]+$;!*!0;'}
-exec /bin/cpu -A $netdir -R
+#netdir=`{echo $3 | sed 's;/[0-9]+$;!*!0;'}
+#exec /bin/cpu -A $netdir -R
+exec /bin/cpu -R
--- a/rc/bin/sysupdate
+++ b/rc/bin/sysupdate
@@ -1,6 +1,6 @@
#!/bin/rc
rfork en
-source=https://code.9front.org/hg/plan9front
+
cd /
if(! test -d .hg)
bind -ac /dist/plan9front /
--- a/sys/include/libsec.h
+++ b/sys/include/libsec.h
@@ -403,6 +403,16 @@
int aes_xts_encrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len) ;
int aes_xts_decrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len);
+/*
+ * ECC
+ */
+
+/* ids for ecnamedcurve */
+enum
+{
+ Secp256r1 = 23,
+};
+
typedef struct ECpoint{
int inf;
mpint *x;
@@ -424,10 +434,15 @@
mpint *h;
} ECdomain;
+ECdomain* ecnamedcurve(int);
+void ecfreepoint(ECpoint*);
+void ecfreepriv(ECpriv*);
+void ecfreedomain(ECdomain*);
void ecassign(ECdomain *, ECpoint *old, ECpoint *new);
void ecadd(ECdomain *, ECpoint *a, ECpoint *b, ECpoint *s);
void ecmul(ECdomain *, ECpoint *a, mpint *k, ECpoint *s);
-ECpoint* strtoec(ECdomain *, char *, char **, ECpoint *);
+ECpoint* betoec(ECdomain*, uchar*, int, ECpoint*);
+ECpoint* strtoec(ECdomain *, char *, char **, ECpoint*);
ECpriv* ecgen(ECdomain *, ECpriv*);
int ecverify(ECdomain *, ECpoint *);
int ecpubverify(ECdomain *, ECpub *);
@@ -456,6 +471,9 @@
/* calculate shared key: k = pub ^ x % p */
mpint* dh_finish(DHstate *dh, mpint *pub);
+
+/* constant-time comparison similar to memcmp(2) */
+int constcmp(uchar *x, uchar *y, int len);
/* password-based key derivation function 2 (RFC 2898) */
void pbkdf2_hmac_sha1(uchar *p, ulong plen, uchar *s, ulong slen, ulong rounds, uchar *d, ulong dlen);
--- a/sys/lib/python/mercurial/store.py
+++ b/sys/lib/python/mercurial/store.py
@@ -246,7 +246,7 @@
'''fill the entries from the fncache file'''
self.entries = set()
try:
- fp = self.opener('fncache', mode='rb')
+ fp = self.opener('fncache', mode='r')
except IOError:
# skip nonexistent file
return
--- a/sys/lib/python/mercurial/util.py
+++ b/sys/lib/python/mercurial/util.py
@@ -763,7 +763,7 @@
return temp
try:
try:
- ifp = posixfile(name, "rb")
+ ifp = posixfile(name, "r")
except IOError, inst:
if inst.errno == errno.ENOENT:
return temp
--- a/sys/src/9/boot/boot.h
+++ b/sys/src/9/boot/boot.h
@@ -1,5 +1,5 @@
enum {
- Debug = 0,
+ Debug = 1,
};
extern void fatal(char*);
--- a/sys/src/9/boot/bootfs.proto
+++ b/sys/src/9/boot/bootfs.proto
@@ -30,6 +30,8 @@
ndb
dnsgetip
hjfs
+ p
+ ps
rc
rm
sed
@@ -36,6 +38,7 @@
sleep
srv
test
+ tlsclient
unmount
nusb
usbd
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -66,7 +66,7 @@
if(~ $#nobootprompt 0){
echo
showlocaldevs
- ask bootargs ' is (tcp, il, local!device)' $"bootargs
+ ask bootargs ' is (tcp, tcptls, il, local!device)' $"bootargs
}
if not bootargs=$nobootprompt
nobootprompt=()
--- a/sys/src/9/boot/net.rc
+++ b/sys/src/9/boot/net.rc
@@ -48,6 +48,12 @@
fs=$fs(1)
}
+fn connecttcptls{
+ while(! ~ $#fs 0 && ! srv -qe 'tlsclient -t <{echo $fsthumb} tcp!'^$fs(1)^!5564 boot)
+ fs=$fs(2-);
+ fs=$fs(1)
+}
+
fn connectil{
while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
fs=$fs(2-);
@@ -55,5 +61,7 @@
}
mtcp=(confignet connecttcp)
+mtcptls=(confignet connecttcptls)
mil=(confignet connectil)
-mt=(mtcp mil $mt)
+mt=(mtcp mtcptls mil $mt)
+
--- a/sys/src/9/pc/etheriwl.c
+++ b/sys/src/9/pc/etheriwl.c
@@ -2164,8 +2164,10 @@
if(ctlr->power)
poweroff(ctlr);
- if((csr32r(ctlr, Gpc) & RfKill) == 0)
+ if((csr32r(ctlr, Gpc) & RfKill) == 0){
+ print("#l%d: rfkill on, not resetting\n", edev->ctlrno);
break;
+ }
if(reset(ctlr) != nil)
break;
@@ -2447,6 +2449,7 @@
case 0x4238: /* Centrino Ultimate-N 6300 variant 2 */
case 0x08ae: /* Centrino Wireless-N 100 */
case 0x0083: /* Centrino Wireless-N 1000 */
+ case 0x0891: /* Centrino Wireless-N 2200 */
case 0x0887: /* Centrino Wireless-N 2230 */
case 0x0888: /* Centrino Wireless-N 2230 */
break;
--- a/sys/src/9/port/chan.c
+++ b/sys/src/9/port/chan.c
@@ -152,8 +152,10 @@
int i;
todinit(); /* avoid later reentry causing infinite recursion */
- for(i=0; devtab[i] != nil; i++)
+ for(i=0; devtab[i] != nil; i++){
+ //print("%c: %s: reset\n", devtab[i]->dc, devtab[i]->name);
devtab[i]->reset();
+ }
}
static void closeproc(void*);
--- a/sys/src/9/port/devssl.c
+++ b/sys/src/9/port/devssl.c
@@ -1439,7 +1439,7 @@
*p = n;
(*s->hf)(msgid, 4, digest, &ss);
- if(memcmp(digest, bin->rp, s->diglen) != 0)
+ if(constcmp(digest, bin->rp, s->diglen) != 0)
error("bad digest");
}
--- a/sys/src/9/port/devtls.c
+++ b/sys/src/9/port/devtls.c
@@ -825,7 +825,7 @@
(*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac);
if(unpad_len < in->sec->maclen)
rcvError(tr, EBadRecordMac, "short record mac");
- if(memcmp(hmac, p+len, in->sec->maclen) != 0)
+ if(constcmp(hmac, p+len, in->sec->maclen) != 0)
rcvError(tr, EBadRecordMac, "record mac mismatch");
b->rp = p;
b->wp = p+len;
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -173,6 +173,9 @@
up->state = Running;
up->mach = MACHP(m->machno);
m->proc = up;
+ //print("poolcheck sched %s\n", p->text);
+ //#include <pool.h>
+ //poolcheck(mainmem);
mmuswitch(up);
gotolabel(&up->sched);
}
--- a/sys/src/9/port/syscallfmt.c
+++ b/sys/src/9/port/syscallfmt.c
@@ -114,7 +114,7 @@
a = va_arg(list, char*);
fmtuserstring(&fmt, a, "");
argv = va_arg(list, char**);
- evenaddr(PTR2UINT(argv));
+ evenaddr((uintptr)argv);
for(;;){
validaddr((uintptr)argv, sizeof(char**), 0);
a = *(char **)argv;
--- a/sys/src/cmd/auth/lib/okpasswd.c
+++ b/sys/src/cmd/auth/lib/okpasswd.c
@@ -10,7 +10,6 @@
"change me",
"passwd",
"no passwd",
- "anonymous",
0
};
--- 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 @@
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 @@
struct Request
{
Request *next;
- Fid *fid;
+ Aux *fid;
Fs *fs;
Fcall f;
uchar buf[1];
@@ -51,11 +52,11 @@
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 @@
int cfd;
int sfd;
- Fid *flist; /* open fids to broadcast to */
+ Aux *flist; /* open fids to broadcast to */
};
struct Fs
@@ -102,7 +103,7 @@
int fd; /* to kernel mount point */
int messagesize;
- Fid *hash[Nhash];
+ Aux *hash[Nhash];
Console *cons[Maxcons];
int ncons;
};
@@ -112,30 +113,30 @@
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*);
+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*, Fid*) =
+void (*fcall[])(Fs*, Request*, Aux*) =
{
[Tflush] fsflush,
[Tversion] fsversion,
@@ -199,7 +200,7 @@
* 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 @@
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 @@
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 @@
* 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 @@
* 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 @@
fsreader(void *v)
{
int n;
- Fid *fl;
+ Aux *fl;
char buf[1024];
Fs *fs;
Console *c;
@@ -653,8 +652,6 @@
}
}
-int dbmtime;
-
/*
* a request processor (one per Fs)
*/
@@ -663,8 +660,7 @@
{
int n, t;
Request *r;
- Fid *f;
- Dir *d;
+ Aux *f;
void **a = v;
Fs* fs;
int *pfd;
@@ -672,15 +668,12 @@
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 @@
}
}
-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 @@
}
}
- 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 @@
}
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 @@
}
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 @@
}
void
-fsflush(Fs *fs, Request *r, Fid *f)
+fsflush(Fs *fs, Request *r, Aux *f)
{
Request *or;
@@ -786,12 +779,15 @@
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 @@
}
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 @@
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 @@
}
void
-fsopen(Fs *fs, Request *r, Fid *f)
+fsopen(Fs *fs, Request *r, Aux *f)
{
int mode;
Console *c;
@@ -1009,13 +1005,13 @@
}
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 @@
}
void
-fswrite(Fs *fs, Request *r, Fid *f)
+fswrite(Fs *fs, Request *r, Aux *f)
{
int i, eol = 0;
@@ -1141,9 +1137,9 @@
}
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 @@
}
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 @@
}
void
-fswstat(Fs *fs, Request *r, Fid*)
+fswstat(Fs *fs, Request *r, Aux*)
{
fsreply(fs, r, Eperm);
}
@@ -1226,7 +1222,7 @@
* 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;
--- a/sys/src/cmd/cpu.c
+++ b/sys/src/cmd/cpu.c
@@ -224,7 +224,7 @@
if(system == nil) {
p = getenv("cpu");
if(p == 0)
- fatal("set $cpu");
+ p = "$cpu";
system = p;
}
--- 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
--- a/sys/src/cmd/ip/httpd/sendfd.c
+++ b/sys/src/cmd/ip/httpd/sendfd.c
@@ -240,10 +240,10 @@
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);
@@ -350,6 +350,8 @@
return notaccept(c, type, enc, "Content-Type");
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;
--- a/sys/src/cmd/ip/tftpd.c
+++ b/sys/src/cmd/ip/tftpd.c
@@ -54,6 +54,7 @@
*/
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 @@
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",
--- a/sys/src/cmd/mk/run.c
+++ b/sys/src/cmd/mk/run.c
@@ -163,7 +163,7 @@
uarg = 1;
} else {
jobs = 0;
- Exit();
+ sysfatal("%s", buf);
}
}
for(w = j->t; w; w = w->next){
--- a/sys/src/libc/fmt/snprint.c
+++ b/sys/src/libc/fmt/snprint.c
@@ -12,4 +12,3 @@
va_end(args);
return n;
}
-
--- a/sys/src/libcontrol/control.c
+++ b/sys/src/libcontrol/control.c
@@ -164,7 +164,7 @@
Rune buf[2][20], *rp;
cs = v;
- threadsetname("controlsetthread 0x%p", cs);
+ threadsetname("controlsetthread %#p", cs);
alts[AKey].c = cs->kbdc;
alts[AKey].v = &rp;
@@ -324,6 +324,7 @@
vfprint(2, fmt, arg);
va_end(arg);
write(2, "\n", 1);
+ abort();
threadexitsall(buf);
}
@@ -376,6 +377,8 @@
t = strdup(s);
if(t == nil)
ctlerror("control strdup(%q) failed: %r", s);
+
+ setmalloctag(t, getcallerpc(&s));
return t;
}
--- a/sys/src/libdraw/newwindow.c
+++ b/sys/src/libdraw/newwindow.c
@@ -29,4 +29,3 @@
return mount(fd, -1, "/dev", MBEFORE, buf);
return bind("/mnt/wsys", "/dev", MBEFORE);
}
-
--- a/sys/src/libmach/vdb.c
+++ b/sys/src/libmach/vdb.c
@@ -836,7 +836,10 @@
break;
case 'm':
- bprint(i, "M(%s)", cop0regs[i->rd]);
+ if(i->function != 0)
+ bprint(i, "M(%s),%d", cop0regs[i->rd], i->function);
+ else
+ bprint(i, "M(%s)", cop0regs[i->rd]);
break;
case 'f':
--- /dev/null
+++ b/sys/src/libsec/port/const.c
@@ -1,0 +1,18 @@
+#include <u.h>
+
+/*
+ * returns 0 if the the len bytes in x are equal to len bytes in y,
+ * otherwise returns -1.
+ */
+int
+constcmp(uchar *x, uchar *y, int len)
+{
+ uint z;
+ int i;
+
+ for(z = 0, i = 0; i < len; i++) {
+ z |= x[i] ^ y[i];
+ }
+
+ return (1 & ((z - 1) >> 8)) - 1;
+}
--- a/sys/src/libsec/port/ecc.c
+++ b/sys/src/libsec/port/ecc.c
@@ -3,7 +3,77 @@
#include <libsec.h>
#include <ctype.h>
+ECdomain *
+ecnamedcurve(int id)
+{
+ ECdomain *dom;
+ dom = malloc(sizeof(ECdomain));
+ if(dom == nil)
+ return nil;
+
+ switch(id) {
+ default:
+ free(dom);
+ return nil;
+ case Secp256r1:
+ dom->p = strtomp("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", nil, 16, nil);
+ dom->a = strtomp("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", nil, 16, nil);
+ dom->b = strtomp("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", nil, 16, nil);
+ dom->G = strtoec(dom, "036B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", nil, nil);
+ dom->n = strtomp("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", nil, 16, nil);
+ dom->h = uitomp(1, nil);
+ break;
+ }
+
+ if(dom->p == nil || dom->a == nil || dom->b == nil || dom->G == nil || dom->n == nil || dom->h == nil) {
+ ecfreedomain(dom);
+ return nil;
+ }
+
+ return dom;
+}
+
void
+ecfreepoint(ECpoint *pt)
+{
+ if(pt != nil) {
+ mpfree(pt->x);
+ mpfree(pt->y);
+ }
+
+ free(pt);
+}
+
+void
+ecfreepriv(ECpriv *priv)
+{
+ if(priv != nil) {
+ mpfree(priv->x);
+ mpfree(priv->y);
+ mpfree(priv->d);
+ }
+
+ free(priv);
+}
+
+void
+ecfreedomain(ECdomain *dom)
+{
+ if(dom != nil) {
+ mpfree(dom->p);
+ mpfree(dom->a);
+ mpfree(dom->b);
+ if(dom->G != nil) {
+ ecfreepoint(dom->G);
+ }
+ mpfree(dom->n);
+ mpfree(dom->h);
+ }
+
+ free(dom);
+}
+
+void
ecassign(ECdomain *, ECpoint *a, ECpoint *b)
{
b->inf = a->inf;
@@ -329,7 +399,55 @@
return 1;
}
+// converts the bytes in buf to an ECpoint x y pair.
+// the domain is used to determine the number of bytes in x and y in the buffer.
ECpoint*
+betoec(ECdomain *dom, uchar *buf, int blen, ECpoint *ret)
+{
+ int allocd, bytelen;
+
+ allocd = 0;
+ bytelen = (mpsignif(dom->p)+7) >> 3;
+
+ // sanity check arguments
+ if(dom == nil || buf == nil)
+ return nil;
+
+ // check if input is too short for two mpints
+ if(blen != 1+2*bytelen)
+ return nil;
+
+ // check that point is in uncompressed format
+ if(buf[0] != 4)
+ return nil;
+
+ if(ret == nil) {
+ // allocate return pointer and mpints
+ allocd = 1;
+ ret = mallocz(sizeof(*ret), 1);
+ if(ret == nil)
+ return nil;
+ ret->x = mpnew(0);
+ ret->y = mpnew(0);
+ }
+
+ // uncompressed form
+ if(betomp(buf+1, bytelen, ret->x) == nil)
+ goto err;
+ if(betomp(buf+1+bytelen, bytelen, ret->y) == nil)
+ goto err;
+ if(!ecverify(dom, ret))
+ goto err;
+ return ret;
+
+err:
+ if(allocd){
+ ecfreepoint(ret);
+ }
+ return nil;
+}
+
+ECpoint*
strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *ret)
{
int allocd, o;
@@ -382,11 +500,8 @@
err:
if(rptr)
*rptr = s;
- if(allocd){
- mpfree(ret->x);
- mpfree(ret->y);
- free(ret);
- }
+ if(allocd)
+ ecfreepoint(ret);
return nil;
}
--- a/sys/src/libsec/port/mkfile
+++ b/sys/src/libsec/port/mkfile
@@ -22,6 +22,7 @@
ripemd.c\
dh.c\
pbkdf2.c\
+ const.c\
ALLOFILES=${CFILES:%.c=%.$O}
--- a/sys/src/libsec/port/thumb.c
+++ b/sys/src/libsec/port/thumb.c
@@ -38,7 +38,7 @@
return 0;
hd = tablehead(sum, table);
for(p = hd->next; p; p = p->next){
- if(memcmp(sum, p->sha1, SHA1dlen) == 0)
+ if(constcmp(sum, p->sha1, SHA1dlen) == 0)
return 1;
if(p == hd)
break;
--- a/sys/src/libsec/port/tlshand.c
+++ b/sys/src/libsec/port/tlshand.c
@@ -854,100 +854,58 @@
static Bytes*
tlsSecECDHEc(TlsSec *sec, uchar *srandom, int vers, int curve, Bytes *Ys)
{
- Namedcurve *nc, *enc;
Bytes *epm;
- ECdomain dom;
- ECpoint G, K, Y;
- ECpriv Q;
+ ECdomain *dom;
+ ECpoint K, *Y;
+ ECpriv *Q;
+ epm = nil;
+ Y = nil;
+ Q = nil;
+
if(Ys == nil)
return nil;
- enc = &namedcurves[nelem(namedcurves)];
- for(nc = namedcurves; nc != enc; nc++)
- if(nc->tlsid == curve)
- break;
-
- if(nc == enc)
- return nil;
-
memmove(sec->srandom, srandom, RandomSize);
if(setVers(sec, vers) < 0)
return nil;
-
- epm = nil;
- memset(&dom, 0, sizeof(dom));
- dom.p = strtomp(nc->p, nil, 16, nil);
- dom.a = strtomp(nc->a, nil, 16, nil);
- dom.b = strtomp(nc->b, nil, 16, nil);
- dom.n = strtomp(nc->n, nil, 16, nil);
- dom.h = strtomp(nc->h, nil, 16, nil);
+ dom = ecnamedcurve(curve);
+ if(dom == nil)
+ return nil;
- memset(&G, 0, sizeof(G));
- G.x = mpnew(0);
- G.y = mpnew(0);
- memset(&Q, 0, sizeof(Q));
- Q.x = mpnew(0);
- Q.y = mpnew(0);
- Q.d = mpnew(0);
-
memset(&K, 0, sizeof(K));
K.x = mpnew(0);
K.y = mpnew(0);
- memset(&Y, 0, sizeof(Y));
- Y.x = mpnew(0);
- Y.y = mpnew(0);
-
- if(dom.p == nil || dom.a == nil || dom.b == nil || dom.n == nil || dom.h == nil)
- goto Out;
- if(Q.x == nil || Q.y == nil || Q.d == nil)
- goto Out;
- if(G.x == nil || G.y == nil)
- goto Out;
if(K.x == nil || K.y == nil)
goto Out;
- if(Y.x == nil || Y.y == nil)
- goto Out;
- dom.G = strtoec(&dom, nc->G, nil, &G);
- if(dom.G == nil)
+ Y = betoec(dom, Ys->data, Ys->len, nil);
+ if(Y == nil)
goto Out;
- if(bytestoec(&dom, Ys, &Y) == nil)
+ Q = ecgen(dom, nil);
+ if(Q == nil)
goto Out;
- if(ecgen(&dom, &Q) == nil)
- goto Out;
-
- ecmul(&dom, &Y, Q.d, &K);
+ ecmul(dom, Y, Q->d, &K);
setMasterSecret(sec, mptobytes(K.x));
/* 0x04 = uncompressed public key */
- epm = ectobytes(0x04, &Q);
+ epm = ectobytes(0x04, Q);
Out:
- mpfree(Y.x);
- mpfree(Y.y);
+ ecfreepriv(Q);
+ ecfreepoint(Y);
+
mpfree(K.x);
mpfree(K.y);
- mpfree(Q.x);
- mpfree(Q.y);
- mpfree(Q.d);
+ ecfreedomain(dom);
- mpfree(G.x);
- mpfree(G.y);
-
- mpfree(dom.p);
- mpfree(dom.a);
- mpfree(dom.b);
- mpfree(dom.n);
- mpfree(dom.h);
-
return epm;
}
@@ -1957,7 +1915,7 @@
static int
finishedMatch(TlsConnection *c, Finished *f)
{
- return memcmp(f->verify, c->finished.verify, f->n) == 0;
+ return constcmp(f->verify, c->finished.verify, f->n) == 0;
}
// free memory associated with TlsConnection struct
--- a/sys/src/libsec/port/x509.c
+++ b/sys/src/libsec/port/x509.c
@@ -2212,7 +2212,7 @@
err = "bad digest length";
goto end;
}
- if(memcmp(digest->data, edigest, edigestlen) != 0)
+ if(constcmp(digest->data, edigest, edigestlen) != 0)
err = "digests did not match";
end:
--- a/sys/src/libthread/id.c
+++ b/sys/src/libthread/id.c
@@ -71,7 +71,7 @@
va_start(arg, fmt);
t->cmdname = vsmprint(fmt, arg);
va_end(arg);
- if(t->cmdname && p->nthreads == 1){
+ if(t->cmdname){
snprint(buf, sizeof buf, "#p/%lud/args", _tos->pid); //getpid());
if((fd = open(buf, OWRITE)) >= 0){
write(fd, t->cmdname, strlen(t->cmdname)+1);
--- a/sys/src/libthread/main.c
+++ b/sys/src/libthread/main.c
@@ -31,7 +31,7 @@
if(setjmp(_mainjmp))
_schedinit(p);
-//_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
+ //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND);
_systhreadinit();
_qlockinit(_threadrendezvous);
_sysfatal = _threadsysfatal;