shithub: riscv

Download patch

ref: a59aa24a94f84afd0fe52c28896d24de4becef54
parent: 9360415d569515e7e3b212e5ca3416e766e32bec
parent: 530ab11783fc11f57b8f44015d69bee93125e09f
author: spew <devnull@localhost>
date: Fri May 18 17:39:19 EDT 2018

merge

--- a/lib/keyboard
+++ b/lib/keyboard
@@ -165,6 +165,8 @@
 014D  _o          ō	latin small letter o macron
 014E  uO          Ŏ	latin capital letter o breve
 014F  uo          ŏ	latin small letter o breve
+0150  hO          Ő	latin capital letter o double acute
+0151  ho          ő     latin small letter o double acute
 0152  OE          Œ	latin capital letter o e
 0153  oe          œ	latin small letter o e
 0154  'R          Ŕ	latin capital letter r acute
@@ -426,6 +428,7 @@
 208C  b=          ₌	subscript equals sign
 208D  b(          ₍	subscript opening parenthesis
 208E  b)          ₎	subscript closing parenthesis
+208F  bN          ₏	subscript latin small letter n
 20AC  e$          €	euro symbol
 2102  CC          ℂ	double-struck capital c
 210A  $g          ℊ	script small g
@@ -548,6 +551,8 @@
 262D  SU          ☭	hammer and sickle
 2639  :(          ☹	sad face
 263A  :)          ☺	smiley face
+2640  fs          ♀	female sign
+2642  ms          ♂	male sign
 2654  wk          ♔	white chess king
 2655  wq          ♕	white chess queen
 2656  wr          ♖	white chess rook
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -507,7 +507,7 @@
 		return up->errstr;
 	}
 
-	if(mtu >= ifc->m->mintu && mtu <= ifc->m->maxtu)
+	if(mtu > 0 && mtu >= ifc->m->mintu && mtu <= ifc->m->maxtu)
 		ifc->maxtu = mtu;
 
 	/* ignore if this is already a local address for this ifc */
--- a/sys/src/boot/efi/pxe.c
+++ b/sys/src/boot/efi/pxe.c
@@ -118,8 +118,9 @@
 static
 EFI_PXE_BASE_CODE_PROTOCOL *pxe;
 
-static
-EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp;
+static uchar mymac[6];
+static uchar myip[16];
+static uchar serverip[16];
 
 typedef struct Tftp Tftp;
 struct Tftp
@@ -310,18 +311,103 @@
 	Tftp *t = (Tftp*)((uintptr)(buf+7)&~7);
 
 	memset(t, 0, sizeof(Tftp));
-
-	memmove(&t->dip, dhcp->BootpSiAddr, 4);
-	memmove(&t->sip, pxe->Mode->StationIp, 4);
-
+	memmove(&t->sip, myip, sizeof(myip));
+	memmove(&t->dip, serverip, sizeof(serverip));
 	if(tftpopen(t, name))
 		return nil;
 	return t;
 }
 
+static int
+parseipv6(uchar to[16], char *from)
+{
+	int i, dig, elipsis;
+	char *p;
+
+	elipsis = 0;
+	memset(to, 0, 16);
+	for(i = 0; i < 16; i += 2){
+		dig = 0;
+		for(p = from;; p++){
+			if(*p >= '0' && *p <= '9')
+				dig = (dig << 4) | (*p - '0');
+			else if(*p >= 'a' && *p <= 'f')
+				dig = (dig << 4) | (*p - 'a'+10);
+			else if(*p >= 'A' && *p <= 'F')
+				dig = (dig << 4) | (*p - 'A'+10);
+			else
+				break;
+			if(dig > 0xFFFF)
+				return -1;
+		}
+		to[i]   = dig>>8;
+		to[i+1] = dig;
+		if(*p == ':'){
+			if(*++p == ':'){	/* :: is elided zero short(s) */
+				if (elipsis)
+					return -1;	/* second :: */
+				elipsis = i+2;
+				p++;
+			}
+		} else if (p == from)
+			break;
+		from = p;		
+	}
+	if(i < 16){
+		memmove(&to[elipsis+16-i], &to[elipsis], i-elipsis);
+		memset(&to[elipsis], 0, 16-i);
+	}
+	return 0;
+}
+
+static void
+parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp)
+{
+	uchar *p, *e;
+	char *x;
+	int opt;
+	int len;
+
+	memset(mymac, 0, sizeof(mymac));
+	memset(serverip, 0, sizeof(serverip));
+
+	/* DHCPv4 */
+	if(pxe->Mode->UsingIpv6 == 0){
+		memmove(mymac, dhcp->BootpHwAddr, 6);
+		memmove(serverip, dhcp->BootpSiAddr, 4);
+		return;
+	}
+
+	/* DHCPv6 */
+	e = (uchar*)dhcp + sizeof(*dhcp);
+	p = (uchar*)dhcp + 4;
+	while(p+4 <= e){
+		opt = p[0]<<8 | p[1];
+		len = p[2]<<8 | p[3];
+		p += 4;
+		if(p + len > e)
+			break;
+		switch(opt){
+		case 1:	/* Client DUID */
+			memmove(mymac, p+len-6, 6);
+			break;
+		case 59: /* Boot File URL */
+			for(x = (char*)p; x < (char*)p+len; x++){
+				if(*x == '['){
+					parseipv6(serverip, x+1);
+					break;
+				}
+			}
+			break;
+		}
+		p += len;
+	}
+}
+
 int
 pxeinit(void **pf)
 {
+	EFI_PXE_BASE_CODE_DHCPV4_PACKET	*dhcp;
 	EFI_PXE_BASE_CODE_MODE *mode;
 	EFI_HANDLE *Handles;
 	UINTN Count;
@@ -328,7 +414,6 @@
 	int i;
 
 	pxe = nil;
-	dhcp = nil;
 	Count = 0;
 	Handles = nil;
 	if(eficall(ST->BootServices->LocateHandleBuffer,
@@ -341,7 +426,7 @@
 			Handles[i], &EFI_PXE_BASE_CODE_PROTOCOL_GUID, &pxe))
 			continue;
 		mode = pxe->Mode;
-		if(mode == nil || mode->UsingIpv6 || mode->Started == 0)
+		if(mode == nil || mode->Started == 0)
 			continue;
 		if(mode->DhcpAckReceived){
 			dhcp = (EFI_PXE_BASE_CODE_DHCPV4_PACKET*)mode->DhcpAck;
@@ -355,6 +440,9 @@
 	return -1;
 
 Found:
+	parsedhcp(dhcp);
+	memmove(myip, mode->StationIp, 16);
+
 	open = pxeopen;
 	read = pxeread;
 	close = pxeclose;
@@ -361,13 +449,11 @@
 
 	if(pf != nil){
 		char ini[24];
-		uchar *mac;
 
-		mac = dhcp->BootpHwAddr;
 		memmove(ini, "/cfg/pxe/", 9);
 		for(i=0; i<6; i++){
-			ini[9+i*2+0] = hex[mac[i] >> 4];
-			ini[9+i*2+1] = hex[mac[i] & 0xF];
+			ini[9+i*2+0] = hex[mymac[i] >> 4];
+			ini[9+i*2+1] = hex[mymac[i] & 0xF];
 		}
 		ini[9+12] = '\0';
 		if((*pf = pxeopen(ini)) == nil)
--- a/sys/src/cmd/audio/pcmconv/pcmconv.c
+++ b/sys/src/cmd/audio/pcmconv/pcmconv.c
@@ -355,7 +355,7 @@
 			else if(d < -1.0)
 				*dst++ = MININT;
 			else
-				*dst++ = d*((float)MAXINT);
+				*dst++ = d*((double)MAXINT);
 		}
 	}
 }
--- a/sys/src/cmd/ndb/cs.c
+++ b/sys/src/cmd/ndb/cs.c
@@ -1081,12 +1081,8 @@
 	Network *np;
 
 	if(background){
-		switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){
-		case 0:
-			break;
-		default:
+		if(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT) != 0)
 			return;
-		}
 		qlock(&netlock);
 	}
 
@@ -1627,6 +1623,43 @@
 
 }
 
+static int
+mountdns(void)
+{
+	static QLock mountlock;
+	static int mounted;
+	char buf[128], *p;
+	int fd;
+
+	if(mounted)
+		return 0;
+
+	qlock(&mountlock);
+	snprint(buf, sizeof(buf), "%s/dns", mntpt);
+	if(access(buf, AEXIST) == 0)
+		goto done;
+	if(strcmp(mntpt, "/net") == 0)
+		snprint(buf, sizeof(buf), "/srv/dns");
+	else {
+		snprint(buf, sizeof(buf), "/srv/dns%s", mntpt);
+		while((p = strchr(buf+8, '/')) != nil)
+			*p = '_';
+	}
+	if((fd = open(buf, ORDWR)) < 0){
+err:
+		qunlock(&mountlock);
+		return -1;	
+	}
+	if(mount(fd, -1, mntpt, MAFTER, "") < 0){
+		close(fd);
+		goto err;
+	}
+done:
+	mounted = 1;
+	qunlock(&mountlock);
+	return 0;
+}
+
 static Ndbtuple*
 dnsip6lookup(char *mntpt, char *buf, Ndbtuple *t)
 {
@@ -1659,6 +1692,11 @@
 	if(*isslave == 0){
 		qlock(&dblock);
 		werrstr("too much activity");
+		return nil;
+	}
+
+	if(mountdns() < 0){
+		qlock(&dblock);
 		return nil;
 	}
 
--- a/sys/src/cmd/sshfs.c
+++ b/sys/src/cmd/sshfs.c
@@ -1364,6 +1364,8 @@
 		sshfssrv.wstat = nil;
 		sshfssrv.remove = nil;
 	}
+	if(mtpt == nil)
+		root = ".";
 	
 	if(pflag){
 		rdfd = 0;
--- a/sys/src/games/eui.c
+++ b/sys/src/games/eui.c
@@ -30,7 +30,8 @@
 	void(*fn)(void);
 	Kfn *n;
 };
-Kfn kfn, kkn;
+static Kfn kfn, kkn;
+static int ax0, ax1;
 
 void *
 emalloc(ulong sz)
@@ -152,7 +153,10 @@
 					k |= kp->k;
 			}
 		}
-		k &= ~(k << 1 & 0xa0 | k >> 1 & 0x50);
+		if((k & ax0) == ax0)
+			k &= ~ax0;
+		if((k & ax1) == ax1)
+			k &= ~ax1;
 		keys = k;
 	}
 }
@@ -291,6 +295,10 @@
 		;
 	kp->n = emalloc(sizeof *kp);
 	strncpy(kp->n->joyk, joyk, sizeof(kp->n->joyk)-1);
+	if(strcmp(joyk, "up") == 0 || strcmp(joyk, "down") == 0)
+		ax0 |= k;
+	if(strcmp(joyk, "left") == 0 || strcmp(joyk, "right") == 0)
+		ax1 |= k;
 	kp->n->r = r;
 	kp->n->k = k;
 }
@@ -310,7 +318,7 @@
 	if(dokey)
 		proccreate(kproc != nil ? kproc : keyproc, nil, mainstacksize);
 	if(kproc == nil)
-		proccreate(joyproc, nil, mainstacksize*2);
+		proccreate(joyproc, nil, mainstacksize);
 	bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
 	screeninit();
 }
--- a/sys/src/libndb/dnsquery.c
+++ b/sys/src/libndb/dnsquery.c
@@ -12,13 +12,12 @@
  *  search for a tuple that has the given 'attr=val' and also 'rattr=x'.
  *  copy 'x' into 'buf' and return the whole tuple.
  *
- *  return 0 if not found.
+ *  return nil if not found.
  */
 Ndbtuple*
 dnsquery(char *net, char *val, char *type)
 {
-	char rip[128];
-	char *p;
+	char buf[128];
 	Ndbtuple *t;
 	int fd;
 
@@ -28,37 +27,18 @@
 
 	if(net == nil)
 		net = "/net";
-	snprint(rip, sizeof(rip), "%s/dns", net);
-	fd = open(rip, ORDWR);
-	if(fd < 0){
-		if(strcmp(net, "/net") == 0)
-			snprint(rip, sizeof(rip), "/srv/dns");
-		else {
-			snprint(rip, sizeof(rip), "/srv/dns%s", net);
-			p = strrchr(rip, '/');
-			*p = '_';
-		}
-		fd = open(rip, ORDWR);
-		if(fd < 0)
-			return nil;
-		if(mount(fd, -1, net, MBEFORE, "") < 0){
-			close(fd);
-			return nil;
-		}
-		/* fd is now closed */
-		snprint(rip, sizeof(rip), "%s/dns", net);
-		fd = open(rip, ORDWR);
-		if(fd < 0)
-			return nil;
-	}
 
+	snprint(buf, sizeof(buf), "%s/dns", net);
+	if((fd = open(buf, ORDWR)) < 0)
+		return nil;
+
 	/* zero out the error string */
 	werrstr("");
 
 	/* if this is a reverse lookup, first lookup the domain name */
 	if(strcmp(type, "ptr") == 0){
-		mkptrname(val, rip, sizeof rip);
-		t = doquery(fd, rip, "ptr");
+		mkptrname(val, buf, sizeof buf);
+		t = doquery(fd, buf, "ptr");
 	} else
 		t = doquery(fd, val, type);