diff options
| author | charles forsyth <charles.forsyth@gmail.com> | 2015-06-13 16:34:09 +0100 |
|---|---|---|
| committer | charles forsyth <charles.forsyth@gmail.com> | 2015-06-13 16:34:09 +0100 |
| commit | 62d7827bc358c000db9ff48fe61bd28ac352a884 (patch) | |
| tree | 3369436e1f4ccfabd4bd5a58632d26934b868688 | |
| parent | 15cdcc9295cbd45a03f77559b9de402033858a41 (diff) | |
mkfiles/mkfile-Linux-386
| -rw-r--r-- | appl/charon/chutils.b | 6 | ||||
| -rw-r--r-- | appl/charon/chutils.m | 3 | ||||
| -rw-r--r-- | appl/charon/common.m | 1 | ||||
| -rw-r--r-- | appl/charon/cookiesrv.b | 2 | ||||
| -rw-r--r-- | appl/charon/ftp.b | 15 | ||||
| -rw-r--r-- | appl/charon/http.b | 11 | ||||
| -rw-r--r-- | appl/cmd/auth/logind.b | 4 | ||||
| -rw-r--r-- | appl/cmd/auth/passwd.b | 25 | ||||
| -rw-r--r-- | appl/cmd/ip/bootpd.b | 18 | ||||
| -rw-r--r-- | appl/cmd/ip/tftpd.b | 18 | ||||
| -rw-r--r-- | appl/cmd/listen.b | 12 | ||||
| -rw-r--r-- | appl/cmd/lockfs.b | 15 | ||||
| -rw-r--r-- | appl/cmd/styxlisten.b | 2 | ||||
| -rw-r--r-- | appl/lib/mpeg.b | 3 | ||||
| -rw-r--r-- | appl/lib/newns.b | 3 | ||||
| -rw-r--r-- | appl/lib/ninep.b | 15 | ||||
| -rw-r--r-- | appl/lib/pop3.b | 3 | ||||
| -rw-r--r-- | appl/lib/smtp.b | 5 | ||||
| -rw-r--r-- | emu/Linux/asm-arm.S | 17 | ||||
| -rw-r--r-- | module/9p.m | 1 | ||||
| -rw-r--r-- | utils/mkfile | 1 |
21 files changed, 91 insertions, 89 deletions
diff --git a/appl/charon/chutils.b b/appl/charon/chutils.b index 8d8bdf33..3f507108 100644 --- a/appl/charon/chutils.b +++ b/appl/charon/chutils.b @@ -201,6 +201,10 @@ init(ch: Charon, c: CharonUtils, argl: list of string, evc: chan of ref E->Event return Url->PATH; U->init(); + DI = load Dial Dial->PATH; + if(DI == nil) + return Dial->PATH; + T = load StringIntTab StringIntTab->PATH; if(T == nil) return StringIntTab->PATH; @@ -801,7 +805,7 @@ Netconn.new(id: int) : ref Netconn "", # host 0, # port "", # scheme - sys->Connection(nil, nil, ""), # conn + ref Dial->Connection(nil, nil, ""), # conn nil, # ssl context 0, # undetermined ssl version NCfree, # state diff --git a/appl/charon/chutils.m b/appl/charon/chutils.m index 15c3308f..8cff7163 100644 --- a/appl/charon/chutils.m +++ b/appl/charon/chutils.m @@ -13,6 +13,7 @@ CharonUtils: module J: Script; CH: Charon; CK: Cookiesrv; + DI: Dial; # HTTP methods HGet, HPost : con iota; @@ -234,7 +235,7 @@ CharonUtils: module host: string; # host name port: int; # port number scheme: string; # Url scheme ("http", "file", etc.) - conn: Sys->Connection; # fds, etc. + conn: ref Dial->Connection; # fds, etc. sslx: ref SSL3->Context; # ssl connection vers: int; # ssl version state: int; # NCfree, etc. diff --git a/appl/charon/common.m b/appl/charon/common.m index 714d6d6e..56a61782 100644 --- a/appl/charon/common.m +++ b/appl/charon/common.m @@ -8,6 +8,7 @@ include "keyring.m"; include "asn1.m"; include "pkcs.m"; include "x509.m"; +include "dial.m"; include "sslsession.m"; include "ssl3.m"; include "convcs.m"; diff --git a/appl/charon/cookiesrv.b b/appl/charon/cookiesrv.b index f50c1ce9..1670e63c 100644 --- a/appl/charon/cookiesrv.b +++ b/appl/charon/cookiesrv.b @@ -433,7 +433,7 @@ save() ix := getallcookies(doms, cka, 0); mergesort(cka, nil, SORT_TOUCHED); - for (i := 0; i < ncookies; i++) { + for (i := 0; i < ix; i++) { ck := cka[i]; if (ck.expire > now) sys->fprint(fd, "%s\n", cookie2str(cka[i])); diff --git a/appl/charon/ftp.b b/appl/charon/ftp.b index 4f564a71..20834235 100644 --- a/appl/charon/ftp.b +++ b/appl/charon/ftp.b @@ -8,6 +8,7 @@ sys: Sys; U: Url; Parsedurl: import U; S: String; +DI: Dial; CU: CharonUtils; Netconn, ByteSource, Header, config: import CU; @@ -27,6 +28,7 @@ init(c: CharonUtils) U = load Url Url->PATH; if (U != nil) U->init(); + DI = CU->DI; dbg = int (CU->config).dbg['n']; } @@ -35,14 +37,13 @@ connect(nc: ref Netconn, bs: ref ByteSource) port := nc.port; if(port == 0) port = FTPPORT; - addr := "tcp!" + nc.host + "!" + string port; + addr := DI->netmkaddr(nc.host, "net", string port); if(dbg) sys->print("ftp %d: dialing %s\n", nc.id, addr); err := ""; ctlfd : ref sys->FD = nil; - rv : int; - (rv, nc.conn) = sys->dial(addr, nil); - if(rv < 0) { + nc.conn = DI->dial(addr, nil); + if(nc.conn == nil) { syserr := sys->sprint("%r"); if(S->prefix("cs: dialup", syserr)) err = syserr[4:]; @@ -113,11 +114,11 @@ dialdata(nc: ref Netconn, ctlfd: ref sys->FD) : string if(paddr == "") return "passive mode protocol botch: " + msg; # dial data port - daddr := "tcp!" + paddr + "!" + pport; + daddr := DI->netmkaddr(paddr, "net", pport); if(dbg) sys->print("ftp %d: dialing data %s", nc.id, daddr); - (ok, dnet) := sys->dial(daddr, nil); - if(ok < 0) + dnet := DI->dial(daddr, nil); + if(dnet == nil) return "data dial error"; nc.conn.dfd = dnet.dfd; return ""; diff --git a/appl/charon/http.b b/appl/charon/http.b index d1208091..05d2396c 100644 --- a/appl/charon/http.b +++ b/appl/charon/http.b @@ -52,6 +52,7 @@ U: Url; S: String; C: Ctype; T: StringIntTab; +DI: Dial; CU: CharonUtils; Netconn, ByteSource, Header, config, Nameval : import CU; @@ -251,6 +252,7 @@ init(cu: CharonUtils) U = load Url Url->PATH; if (U != nil) U->init(); + DI = cu->DI; C = cu->C; T = load StringIntTab StringIntTab->PATH; # D = load Date CU->loadpath(Date->PATH); @@ -280,13 +282,12 @@ connect(nc: ref Netconn, bs: ref ByteSource) if(config.httpproxy.port != "") dialport = config.httpproxy.port; } - addr := "tcp!" + dialhost + "!" + dialport; + addr := DI->netmkaddr(dialhost, "net", dialport); err := ""; if(dbg) sys->print("http %d: dialing %s\n", nc.id, addr); - rv: int; - (rv, nc.conn) = sys->dial(addr, nil); - if(rv < 0) { + nc.conn = DI->dial(addr, nil); + if(nc.conn == nil) { syserr := sys->sprint("%r"); if(S->prefix("cs: dialup", syserr)) err = syserr[4:]; @@ -352,7 +353,7 @@ vers = 3; } } -constate(msg: string, conn: Sys->Connection) +constate(msg: string, conn: ref Dial->Connection) { fd := conn.dfd; fdfd := -1; diff --git a/appl/cmd/auth/logind.b b/appl/cmd/auth/logind.b index f9d14616..1bf17b15 100644 --- a/appl/cmd/auth/logind.b +++ b/appl/cmd/auth/logind.b @@ -13,6 +13,8 @@ include "keyring.m"; kr: Keyring; IPint: import kr; +include "dial.m"; + include "security.m"; ssl: SSL; @@ -62,7 +64,7 @@ init(nil: ref Draw->Context, nil: list of string) kill(tpid, "kill"); } -dologin(c: ref Sys->Connection): string +dologin(c: ref Dial->Connection): string { ivec: array of byte; diff --git a/appl/cmd/auth/passwd.b b/appl/cmd/auth/passwd.b index b001cb16..2c5306b6 100644 --- a/appl/cmd/auth/passwd.b +++ b/appl/cmd/auth/passwd.b @@ -8,6 +8,9 @@ include "draw.m"; include "keyring.m"; kr: Keyring; +include "dial.m"; + dial: Dial; + include "security.m"; auth: Auth; @@ -39,6 +42,9 @@ init(nil: ref Draw->Context, args: list of string) kr = load Keyring Keyring->PATH; if(kr == nil) noload(Keyring->PATH); + dial = load Dial Dial->PATH; + if(dial == nil) + noload(Dial->PATH); auth = load Auth Auth->PATH; if(auth == nil) noload(Auth->PATH); @@ -156,8 +162,8 @@ err(s: string) mountsrv(ai: ref Keyring->Authinfo): string { - (rc, c) := sys->dial(netmkaddr(signer, "net", "infkey"), nil); - if(rc < 0) + c := dial->dial(dial->netmkaddr(signer, "net", "infkey"), nil); + if(c == nil) err(sys->sprint("can't dial %s: %r", signer)); (fd, id_or_err) := auth->client("sha1/rc4_256", ai, c.dfd); if(fd == nil) @@ -220,21 +226,6 @@ putsecret(oldhash: array of byte, secret: array of byte): string return nil; } -netmkaddr(addr, net, svc: string): string -{ - if(net == nil) - net = "net"; - (n, nil) := sys->tokenize(addr, "!"); - if(n <= 1){ - if(svc== nil) - return sys->sprint("%s!%s", net, addr); - return sys->sprint("%s!%s!%s", net, addr, svc); - } - if(svc == nil || n > 2) - return addr; - return sys->sprint("%s!%s", addr, svc); -} - readline(io: ref Sys->FD, mode: string): (int, string) { r : int; diff --git a/appl/cmd/ip/bootpd.b b/appl/cmd/ip/bootpd.b index 71fea6f6..789c3e8a 100644 --- a/appl/cmd/ip/bootpd.b +++ b/appl/cmd/ip/bootpd.b @@ -18,6 +18,9 @@ include "attrdb.m"; attrdb: Attrdb; Attr, Db, Dbentry, Tuples: import attrdb; +include "dial.m"; + dial: Dial; + include "ip.m"; ip: IP; IPaddr, Udphdr: import ip; @@ -63,6 +66,9 @@ init(nil: ref Draw->Context, args: list of string) if(attrdb == nil) loadfail(Attrdb->PATH); attrdb->init(); + dial = load Dial Dial->PATH; + if(dial == nil) + loadfail(Dial->PATH); ip = load IP IP->PATH; if(ip == nil) loadfail(IP->PATH); @@ -120,8 +126,8 @@ init(nil: ref Draw->Context, args: list of string) addr = net+"/udp!*!499"; if(debug) sys->fprint(stderr, "bootpd: announcing %s\n", addr); - (ok, c) := sys->announce(addr); - if(ok < 0) + c := dial->announce(addr); + if(c == nil) error(sys->sprint("can't announce %s: %r", addr)); if(sys->fprint(c.cfd, "headers") < 0) error(sys->sprint("can't set headers mode: %r")); @@ -146,7 +152,7 @@ error(s: string) raise "fail:error"; } -server(c: Sys->Connection) +server(c: ref Sys->Connection) { buf := array[2048] of byte; badread := 0; @@ -298,12 +304,12 @@ send(hdr: ref Udphdr, msg: array of byte) lport := "67"; if(testing) lport = "499"; - (n, c) := sys->dial(replyaddr, lport); - if(n < 0) { + c := dial->dial(replyaddr, lport); + if(c == nil) { sys->fprint(stderr, "bootpd: can't dial %s for reply: %r\n", replyaddr); return; } - n = sys->write(c.dfd, msg, len msg); + n := sys->write(c.dfd, msg, len msg); if(n != len msg) sys->fprint(stderr, "bootpd: udp write error: %r\n"); } diff --git a/appl/cmd/ip/tftpd.b b/appl/cmd/ip/tftpd.b index c7edef4e..57d80cd5 100644 --- a/appl/cmd/ip/tftpd.b +++ b/appl/cmd/ip/tftpd.b @@ -8,6 +8,9 @@ include "draw.m"; include "arg.m"; +include "dial.m"; + dial: Dial; + include "ip.m"; ip: IP; IPaddr, Udphdr: import ip; @@ -34,7 +37,7 @@ port := 69; Udphdrsize: con IP->Udphdrlen; -tftpcon: Sys->Connection; +tftpcon: ref Sys->Connection; tftpreq: ref Sys->FD; dokill(pid: int, scope: string) @@ -152,6 +155,10 @@ init(nil: ref Draw->Context, args: list of string) sys->pctl(Sys->NEWPGRP|Sys->FORKFD|Sys->FORKNS, nil); stderr = sys->fildes(2); + dial = load Dial Dial->PATH; + if(dial == nil) + fatal("can't load Dial"); + arg := load Arg Arg->PATH; if(arg == nil) fatal("can't load Arg"); @@ -206,8 +213,8 @@ mainthing() raddr := sys->sprint("%s/udp!%s!%d", net, hdr.raddr.text(), hdr.rport); DBG(sys->sprint("raddr=%s", raddr)); - (err, cx) := sys->dial(raddr, nil); - if(err < 0) + cx := dial->dial(raddr, nil); + if(cx == nil) fatal("dialing "+raddr); # showbuf("bigbuf", bigbuf[0:dlen]); @@ -492,9 +499,8 @@ fatal(msg: string) openlisten() { name := net+"/udp!*!" + string port; - err := 0; - (err, tftpcon) = sys->announce(name); - if(err < 0) + tftpcon = dial->announce(name); + if(tftpcon == nil) fatal("can't announce "+name); if(sys->fprint(tftpcon.cfd, "headers") < 0) fatal("can't set header mode"); diff --git a/appl/cmd/listen.b b/appl/cmd/listen.b index 61c5ecf9..8ccaa15b 100644 --- a/appl/cmd/listen.b +++ b/appl/cmd/listen.b @@ -151,12 +151,12 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string, } sync <-= nil; - listench := chan of (int, ref Sys->Connection); - authch := chan of (string, ref Sys->Connection); + listench := chan of (int, ref Dial->Connection); + authch := chan of (string, ref Dial->Connection); spawn listener(listench, acon, addr); for (;;) { user := ""; - ccon: ref Sys->Connection; + ccon: ref Dial->Connection; alt { (lok, c) := <-listench => if (lok == -1){ @@ -187,7 +187,7 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string, } } -listener(listench: chan of (int, ref Sys->Connection), c: ref Sys->Connection, addr: string) +listener(listench: chan of (int, ref Dial->Connection), c: ref Dial->Connection, addr: string) { for (;;) { nc := dial->listen(c); @@ -210,8 +210,8 @@ listener(listench: chan of (int, ref Sys->Connection), c: ref Sys->Connection, a } } -authenticator(authch: chan of (string, ref Sys->Connection), - c: ref Sys->Connection, algs: list of string, addr: string) +authenticator(authch: chan of (string, ref Dial->Connection), + c: ref Dial->Connection, algs: list of string, addr: string) { err: string; (c.dfd, err) = auth->server(algs, serverkey, c.dfd, 0); diff --git a/appl/cmd/lockfs.b b/appl/cmd/lockfs.b index 766c6f64..26a9ccf4 100644 --- a/appl/cmd/lockfs.b +++ b/appl/cmd/lockfs.b @@ -735,21 +735,6 @@ doreq(greq: ref Ureq): (ref Sys->FD, string) return (fd, err); } -netmkaddr(addr, net, svc: string): string -{ - if(net == nil) - net = "net"; - (n, nil) := sys->tokenize(addr, "!"); - if(n <= 1){ - if(svc== nil) - return sys->sprint("%s!%s", net, addr); - return sys->sprint("%s!%s!%s", net, addr, svc); - } - if(svc == nil || n > 2) - return addr; - return sys->sprint("%s!%s", addr, svc); -} - user(): string { fd := sys->open("/dev/user", sys->OREAD); diff --git a/appl/cmd/styxlisten.b b/appl/cmd/styxlisten.b index ae9f7b45..22182e25 100644 --- a/appl/cmd/styxlisten.b +++ b/appl/cmd/styxlisten.b @@ -108,7 +108,7 @@ init(ctxt: ref Draw->Context, argv: list of string) spawn listener(c, popen(ctxt, cmd, lsync), authinfo, algs, lsync); } -listener(c: ref Sys->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int) +listener(c: ref Dial->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int) { lsync <-= sys->pctl(0, nil); for (;;) { diff --git a/appl/lib/mpeg.b b/appl/lib/mpeg.b index 100a8708..ed093edc 100644 --- a/appl/lib/mpeg.b +++ b/appl/lib/mpeg.b @@ -2,12 +2,13 @@ implement Mpeg; include "sys.m"; sys: Sys; -FD, Connection: import Sys; +FD: import Sys; include "draw.m"; draw: Draw; Display, Rect, Image: import draw; include "dial.m"; dial: Dial; +Connection: import dial; include "mpeg.m"; Chroma: con 16r05; diff --git a/appl/lib/newns.b b/appl/lib/newns.b index 534621a8..6a53cb75 100644 --- a/appl/lib/newns.b +++ b/appl/lib/newns.b @@ -15,7 +15,7 @@ implement Newns; # include "sys.m"; sys: Sys; - FD, FileIO, Connection: import Sys; + FD, FileIO: import Sys; stderr: ref FD; include "draw.m"; @@ -26,6 +26,7 @@ include "bufio.m"; include "dial.m"; dial: Dial; + Connection: import dial; include "newns.m"; diff --git a/appl/lib/ninep.b b/appl/lib/ninep.b index 91467f0b..90536d0b 100644 --- a/appl/lib/ninep.b +++ b/appl/lib/ninep.b @@ -847,6 +847,21 @@ Rmsg.read(fd: ref Sys->FD, msglim: int): ref Rmsg return m; } +Rmsg.write(m: self ref Rmsg, fd: ref Sys->FD, msize: int): int +{ + if(msize == 0) + m = ref Rmsg.Error(m.tag, "Tversion not seen"); + d := m.pack(); + if(msize != 0 && len d > msize){ + m = ref Rmsg.Error(m.tag, "9P reply didn't fit"); + d = m.pack(); + } + n := len d; + if(sys->write(fd, d, n) != n) + return -1; + return 0; +} + dir2text(d: Sys->Dir): string { return sys->sprint("Dir(\"%s\",\"%s\",\"%s\",%s,8r%uo,%d,%d,%bd,16r%ux,%d)", diff --git a/appl/lib/pop3.b b/appl/lib/pop3.b index ce297004..7cb749f3 100644 --- a/appl/lib/pop3.b +++ b/appl/lib/pop3.b @@ -9,8 +9,9 @@ include "dial.m"; dial: Dial; include "pop3.m"; -FD, Connection: import sys; +FD: import sys; Iobuf : import bufio; +Connection: import dial; ibuf, obuf : ref Bufio->Iobuf; conn : int = 0; diff --git a/appl/lib/smtp.b b/appl/lib/smtp.b index 8e118a31..13be21fa 100644 --- a/appl/lib/smtp.b +++ b/appl/lib/smtp.b @@ -8,8 +8,9 @@ include "dial.m"; dial: Dial; include "smtp.m"; -FD, Connection: import sys; -Iobuf : import bufio; +FD: import sys; +Iobuf: import bufio; +Connection: import dial; ibuf, obuf : ref Bufio->Iobuf; conn : int = 0; diff --git a/emu/Linux/asm-arm.S b/emu/Linux/asm-arm.S index 4d8cc01d..90a337ff 100644 --- a/emu/Linux/asm-arm.S +++ b/emu/Linux/asm-arm.S @@ -113,20 +113,3 @@ FPrestore: str r0, [fp, #-16] ldmea fp, {fp, sp, pc} .size FPrestore, .-FPrestore - -/* - * ulong _tas(ulong*); - */ - .align 2 - .global _tas - .type _tas, %function -_tas: - @ args = 0, pretend = 0, frame = 0 - @ frame_needed = 0, uses_anonymous_args = 0 - @ link register save eliminated. - @ lr needed for prologue - mov r3, #1 - mov r1, r0 - swp r0, r3, [r1] - mov pc, lr - .size _tas, .-_tas diff --git a/module/9p.m b/module/9p.m index 6201e638..8389aa6a 100644 --- a/module/9p.m +++ b/module/9p.m @@ -159,6 +159,7 @@ Ninep: module packedsize: fn(nil: self ref Rmsg): int; text: fn(nil: self ref Rmsg): string; mtype: fn(nil: self ref Rmsg): int; + write: fn(nil: self ref Rmsg, fd: ref Sys->FD, msize: int): int; }; init: fn(); diff --git a/utils/mkfile b/utils/mkfile index 389ab539..9b8b3126 100644 --- a/utils/mkfile +++ b/utils/mkfile @@ -56,6 +56,7 @@ NOTPLAN9=\ # Utils we build on Nt, for build environment compatibility. # NTONLY=\ + cat\ cp\ echo\ format\ |
