diff options
author | spew <devnull@localhost> | 2018-05-18 21:39:19 -0400 |
---|---|---|
committer | spew <devnull@localhost> | 2018-05-18 21:39:19 -0400 |
commit | a59aa24a94f84afd0fe52c28896d24de4becef54 (patch) | |
tree | e81bbee815314f6daff9be017bcbd12b86914b59 | |
parent | 9360415d569515e7e3b212e5ca3416e766e32bec (diff) | |
parent | 530ab11783fc11f57b8f44015d69bee93125e09f (diff) | |
download | plan9front-a59aa24a94f84afd0fe52c28896d24de4becef54.tar.xz |
merge
-rw-r--r-- | lib/keyboard | 5 | ||||
-rw-r--r-- | sys/src/9/ip/ipifc.c | 2 | ||||
-rw-r--r-- | sys/src/boot/efi/pxe.c | 110 | ||||
-rw-r--r-- | sys/src/cmd/audio/pcmconv/pcmconv.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/ndb/cs.c | 48 | ||||
-rw-r--r-- | sys/src/cmd/sshfs.c | 2 | ||||
-rw-r--r-- | sys/src/games/eui.c | 14 | ||||
-rw-r--r-- | sys/src/libndb/dnsquery.c | 36 |
8 files changed, 169 insertions, 50 deletions
diff --git a/lib/keyboard b/lib/keyboard index 6630c76d3..53cd22f32 100644 --- 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 diff --git a/sys/src/9/ip/ipifc.c b/sys/src/9/ip/ipifc.c index d0d0557a9..44bc51cc0 100644 --- a/sys/src/9/ip/ipifc.c +++ b/sys/src/9/ip/ipifc.c @@ -507,7 +507,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) 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 */ diff --git a/sys/src/boot/efi/pxe.c b/sys/src/boot/efi/pxe.c index 5058a845f..c7953b5c3 100644 --- a/sys/src/boot/efi/pxe.c +++ b/sys/src/boot/efi/pxe.c @@ -118,8 +118,9 @@ EFI_GUID EFI_PXE_BASE_CODE_PROTOCOL_GUID = { 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,25 +311,109 @@ pxeopen(char *name) 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; int i; pxe = nil; - dhcp = nil; Count = 0; Handles = nil; if(eficall(ST->BootServices->LocateHandleBuffer, @@ -341,7 +426,7 @@ pxeinit(void **pf) 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,19 +440,20 @@ pxeinit(void **pf) return -1; Found: + parsedhcp(dhcp); + memmove(myip, mode->StationIp, 16); + open = pxeopen; read = pxeread; close = pxeclose; 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) diff --git a/sys/src/cmd/audio/pcmconv/pcmconv.c b/sys/src/cmd/audio/pcmconv/pcmconv.c index 3adda141a..dcd088f05 100644 --- a/sys/src/cmd/audio/pcmconv/pcmconv.c +++ b/sys/src/cmd/audio/pcmconv/pcmconv.c @@ -355,7 +355,7 @@ ficonv(int *dst, uchar *src, int bits, int skip, int count) else if(d < -1.0) *dst++ = MININT; else - *dst++ = d*((float)MAXINT); + *dst++ = d*((double)MAXINT); } } } diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c index 71e2d9e0b..4451f223f 100644 --- a/sys/src/cmd/ndb/cs.c +++ b/sys/src/cmd/ndb/cs.c @@ -1081,12 +1081,8 @@ netinit(int background) 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 @@ slave(char *host) } +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) { @@ -1662,6 +1695,11 @@ dnsiplookup(char *host, Ndbs *s, int v6) return nil; } + if(mountdns() < 0){ + qlock(&dblock); + return nil; + } + if(strcmp(ipattr(host), "ip") == 0) t = dnsquery(mntpt, host, "ptr"); else { diff --git a/sys/src/cmd/sshfs.c b/sys/src/cmd/sshfs.c index c25b4eba8..9a30191b5 100644 --- a/sys/src/cmd/sshfs.c +++ b/sys/src/cmd/sshfs.c @@ -1364,6 +1364,8 @@ threadmain(int argc, char **argv) sshfssrv.wstat = nil; sshfssrv.remove = nil; } + if(mtpt == nil) + root = "."; if(pflag){ rdfd = 0; diff --git a/sys/src/games/eui.c b/sys/src/games/eui.c index d462c76d8..5e5633904 100644 --- a/sys/src/games/eui.c +++ b/sys/src/games/eui.c @@ -30,7 +30,8 @@ struct Kfn{ void(*fn)(void); Kfn *n; }; -Kfn kfn, kkn; +static Kfn kfn, kkn; +static int ax0, ax1; void * emalloc(ulong sz) @@ -152,7 +153,10 @@ keyproc(void *) 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 @@ regkey(char *joyk, Rune r, int k) ; 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 @@ initemu(int dx, int dy, int bpp, ulong chan, int dokey, void(*kproc)(void*)) 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(); } diff --git a/sys/src/libndb/dnsquery.c b/sys/src/libndb/dnsquery.c index 634756b76..1bf1ff8b3 100644 --- a/sys/src/libndb/dnsquery.c +++ b/sys/src/libndb/dnsquery.c @@ -12,13 +12,12 @@ static Ndbtuple *doquery(int, char *dn, char *type); * 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 @@ dnsquery(char *net, char *val, char *type) 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); |