summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--appl/cmd/9export.b16
-rw-r--r--appl/cmd/auth/aescbc.b16
-rw-r--r--appl/cmd/auxi/rstyxd.b8
-rw-r--r--appl/cmd/crypt.b4
-rw-r--r--appl/cmd/disk/prep/fdisk.b3
-rw-r--r--appl/cmd/disk/prep/pedit.b3
-rw-r--r--appl/cmd/disk/prep/prep.b3
-rw-r--r--appl/cmd/import.b18
-rw-r--r--appl/lib/auth9.b8
-rw-r--r--appl/lib/disks.b20
-rw-r--r--appl/lib/scsiio.b16
-rw-r--r--appl/wm/wm.b13
-rw-r--r--dis/9export.disbin3913 -> 3833 bytes
-rw-r--r--dis/auth/aescbc.disbin4790 -> 4715 bytes
-rw-r--r--dis/auxi/rstyxd.disbin1741 -> 1721 bytes
-rw-r--r--dis/crypt.disbin3901 -> 3836 bytes
-rw-r--r--dis/disk/fdisk.disbin12717 -> 12717 bytes
-rw-r--r--dis/disk/pedit.disbin7474 -> 7474 bytes
-rw-r--r--dis/disk/prep.disbin8119 -> 8119 bytes
-rw-r--r--dis/import.disbin4374 -> 4304 bytes
-rw-r--r--dis/lib/auth9.disbin4561 -> 4541 bytes
-rw-r--r--dis/lib/disks.disbin3904 -> 3808 bytes
-rw-r--r--dis/lib/scsiio.disbin4555 -> 4475 bytes
-rw-r--r--dis/lib/venti.disbin8873 -> 8873 bytes
-rw-r--r--dis/wm/wm.disbin11048 -> 11213 bytes
-rw-r--r--module/disks.m1
27 files changed, 32 insertions, 100 deletions
diff --git a/CHANGES b/CHANGES
index 496f060e..13ea86a5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
20070714
add Sys->readn, update sys-read(2)
copy two repairs from emu/port/inferno.c to os/port/inferno.c
+ remove readn implementation from several commands
+ print correct diagnostic in appl/cmd/crypt.b
+ prevent window titlebars from being dragged out of the main window in wm/wm.b
20070619
remembered to include /appl/cmd/trfs.b /dis/trfs.dis
20070614
diff --git a/appl/cmd/9export.b b/appl/cmd/9export.b
index 1c430d88..83a2ddb4 100644
--- a/appl/cmd/9export.b
+++ b/appl/cmd/9export.b
@@ -124,7 +124,7 @@ init(nil: ref Draw->Context, args: list of string)
key[12:] = secret[0:ns];
if(sys->write(fd, key[12:], 4) != 4)
fail("import", sys->sprint("can't write key to remote: %r"));
- if(readn(fd, key, 4) != 4)
+ if(sys->readn(fd, key, 4) != 4)
fail("import", sys->sprint("can't read remote key: %r"));
digest := array[Keyring->SHA1dlen] of byte;
kr->sha1(key, len key, digest, nil);
@@ -137,20 +137,6 @@ init(nil: ref Draw->Context, args: list of string)
fail("export", sys->sprint("can't export %s: %r", tree));
}
-readn(fd: ref Sys->FD, buf: array of byte, nb: int): int
-{
- for(nr := 0; nr < nb;){
- n := sys->read(fd, buf[nr:], nb-nr);
- if(n <= 0){
- if(nr == 0)
- return n;
- break;
- }
- nr += n;
- }
- return nr;
-}
-
S(a: array of byte): string
{
s := "";
diff --git a/appl/cmd/auth/aescbc.b b/appl/cmd/auth/aescbc.b
index c5b6e301..e168cd47 100644
--- a/appl/cmd/auth/aescbc.b
+++ b/appl/cmd/auth/aescbc.b
@@ -81,7 +81,7 @@ init(nil: ref Draw->Context, args: list of string)
fd := sys->open(keyfile, Sys->OREAD);
if(fd == nil)
error(sys->sprint("can't open %q: %r", keyfile), "keyfile");
- n := readn(fd, buf, len buf);
+ n := sys->readn(fd, buf, len buf);
while(n > 0 && buf[n-1] == byte '\n')
n--;
if(n <= 0)
@@ -175,20 +175,6 @@ eqbytes(a: array of byte, b: array of byte, n: int): int
return 1;
}
-readn(fd: ref Sys->FD, buf: array of byte, nb: int): int
-{
- for(nr := 0; nr < nb;){
- n := sys->read(fd, buf[nr:], nb-nr);
- if(n <= 0){
- if(nr == 0)
- return n;
- break;
- }
- nr += n;
- }
- return nr;
-}
-
Read(buf: array of byte, n: int)
{
if(bin.read(buf, n) != n){
diff --git a/appl/cmd/auxi/rstyxd.b b/appl/cmd/auxi/rstyxd.b
index 2f853ad5..aa0498dc 100644
--- a/appl/cmd/auxi/rstyxd.b
+++ b/appl/cmd/auxi/rstyxd.b
@@ -91,12 +91,8 @@ readargs(fd: ref Sys->FD): list of string
readn(fd: ref Sys->FD, nb: int): array of byte
{
buf:= array[nb] of byte;
- for(n:=0; n<nb;){
- m := sys->read(fd, buf[n:], nb-n);
- if(m <= 0)
- return nil;
- n += m;
- }
+ if(sys->readn(fd, buf, nb) != nb)
+ return nil;
return buf;
}
diff --git a/appl/cmd/crypt.b b/appl/cmd/crypt.b
index a478abfc..eec73bc9 100644
--- a/appl/cmd/crypt.b
+++ b/appl/cmd/crypt.b
@@ -153,11 +153,11 @@ cryptpipe(decrypt: int, alg: string, sk: array of byte): (string, array of ref S
(err, c) := ssl->connect(pfd[1]);
if (err != nil)
- return ("could not connect ssl: "+sys->sprint("%r"), nil, nil, nil);
+ return ("could not connect ssl: "+err, nil, nil, nil);
pfd[1] = nil;
err = ssl->secret(c, sk, sk);
if (err != nil)
- return ("could not write secret: "+sys->sprint("%r"), nil, nil, nil);
+ return ("could not write secret: "+err, nil, nil, nil);
if (alg != nil)
if (sys->fprint(c.cfd, "alg %s", alg) == -1)
diff --git a/appl/cmd/disk/prep/fdisk.b b/appl/cmd/disk/prep/fdisk.b
index 00ecbb36..b01045ff 100644
--- a/appl/cmd/disk/prep/fdisk.b
+++ b/appl/cmd/disk/prep/fdisk.b
@@ -14,7 +14,6 @@ include "disks.m";
Disk, PCpart: import disks;
NTentry, Toffset, TentrySize: import Disks;
Magic0, Magic1: import Disks;
- readn: import disks;
include "pedit.m";
pedit: Pedit;
@@ -299,7 +298,7 @@ diskread(disk: ref Disk, data: array of byte, ndata: int, sec: big, off: int)
a := sec*big disk.secsize + big off;
if(sys->seek(disk.fd, a, 0) != a)
sysfatal(sys->sprint("diskread seek %bud.%ud: %r", sec, off));
- if(readn(disk.fd, data, ndata) != ndata)
+ if(sys->readn(disk.fd, data, ndata) != ndata)
sysfatal(sys->sprint("diskread %ud at %bud.%ud: %r", ndata, sec, off));
}
diff --git a/appl/cmd/disk/prep/pedit.b b/appl/cmd/disk/prep/pedit.b
index f55bcaff..d9494cae 100644
--- a/appl/cmd/disk/prep/pedit.b
+++ b/appl/cmd/disk/prep/pedit.b
@@ -14,7 +14,6 @@ include "bufio.m";
include "disks.m";
disks: Disks;
Disk: import disks;
- readn: import disks;
include "draw.m";
include "calc.tab.m";
@@ -378,7 +377,7 @@ rdctlpart(edit: ref Edit)
edit.ctlpart = array[0] of ref Part;
sys->seek(disk.ctlfd, big 0, 0);
buf := array[4096] of byte;
- if(readn(disk.ctlfd, buf, len buf) <= 0)
+ if(sys->readn(disk.ctlfd, buf, len buf) <= 0)
return;
for(i := 0; i < len buf; i++)
if(buf[i] == byte 0)
diff --git a/appl/cmd/disk/prep/prep.b b/appl/cmd/disk/prep/prep.b
index fa4c60a1..02df806c 100644
--- a/appl/cmd/disk/prep/prep.b
+++ b/appl/cmd/disk/prep/prep.b
@@ -16,7 +16,6 @@ include "bufio.m";
include "disks.m";
disks: Disks;
Disk: import disks;
- readn: import disks;
include "pedit.m";
pedit: Pedit;
@@ -279,7 +278,7 @@ rdpart(edit: ref Edit)
{
disk := edit.disk;
sys->seek(disk.fd, big disk.secsize, 0);
- if(readn(disk.fd, osecbuf, disk.secsize) != disk.secsize)
+ if(sys->readn(disk.fd, osecbuf, disk.secsize) != disk.secsize)
return;
osecbuf[disk.secsize] = byte 0;
secbuf[0:] = osecbuf;
diff --git a/appl/cmd/import.b b/appl/cmd/import.b
index 657deb38..fb69d0ab 100644
--- a/appl/cmd/import.b
+++ b/appl/cmd/import.b
@@ -117,7 +117,7 @@ init(nil: ref Draw->Context, args: list of string)
key[4:] = ai.secret[0:ns];
if(sys->write(c.dfd, key, 4) != 4)
fail("import", sys->sprint("can't write key to remote: %r"));
- if(readn(c.dfd, key[12:], 4) != 4)
+ if(sys->readn(c.dfd, key[12:], 4) != 4)
fail("import", sys->sprint("can't read remote key: %r"));
digest := array[Keyring->SHA1dlen] of byte;
kr->sha1(key, len key, digest, nil);
@@ -135,20 +135,6 @@ init(nil: ref Draw->Context, args: list of string)
fail("mount failed", sys->sprint("import %s %s: mount failed: %r", addr, file));
}
-readn(fd: ref Sys->FD, buf: array of byte, nb: int): int
-{
- for(nr := 0; nr < nb;){
- n := sys->read(fd, buf[nr:], nb-nr);
- if(n <= 0){
- if(nr == 0)
- return n;
- break;
- }
- nr += n;
- }
- return nr;
-}
-
S(a: array of byte): string
{
s := "";
@@ -180,7 +166,7 @@ netmkaddr(addr, net, svc: string): string
{
if(net == nil)
net = "net";
- (n, l) := sys->tokenize(addr, "!");
+ (n, nil) := sys->tokenize(addr, "!");
if(n <= 1){
if(svc== nil)
return sys->sprint("%s!%s", net, addr);
diff --git a/appl/lib/auth9.b b/appl/lib/auth9.b
index 06accb53..d9f38c71 100644
--- a/appl/lib/auth9.b
+++ b/appl/lib/auth9.b
@@ -288,12 +288,8 @@ decrypt(key: array of byte, data: array of byte, n: int)
readn(fd: ref Sys->FD, nb: int): array of byte
{
buf:= array[nb] of byte;
- for(n:=0; n<nb;){
- m := sys->read(fd, buf[n:], nb-n);
- if(m <= 0)
- return nil;
- n += m;
- }
+ if(sys->readn(fd, buf, nb) != nb)
+ return nil;
return buf;
}
diff --git a/appl/lib/disks.b b/appl/lib/disks.b
index ac718af1..2918b2cc 100644
--- a/appl/lib/disks.b
+++ b/appl/lib/disks.b
@@ -72,14 +72,14 @@ partitiongeometry(d: ref Disk): int
rawfd := sys->open(d.prefix+"data", Sys->OREAD);
if(rawfd != nil
&& sys->seek(rawfd, big 0, 0) == big 0
- && readn(rawfd, buf, 512) == 512
+ && sys->readn(rawfd, buf, 512) == 512
&& int t[Omagic] == Magic0
&& int t[Omagic+1] == Magic1) {
rawfd = nil;
}else{
rawfd = nil;
if(sys->seek(d.fd, big 0, 0) < big 0
- || readn(d.fd, buf, 512) != 512
+ || sys->readn(d.fd, buf, 512) != 512
|| int t[Omagic] != Magic0
|| int t[Omagic+1] != Magic1)
return -1;
@@ -350,7 +350,7 @@ putle32(p: array of byte, i: big)
Disk.readn(d: self ref Disk, buf: array of byte, nb: int): int
{
- return readn(d.fd, buf, nb);
+ return sys->readn(d.fd, buf, nb);
}
chstext(p: array of byte): string
@@ -361,17 +361,3 @@ chstext(p: array of byte): string
s := (int p[1] & 16r3F);
return sys->sprint("%d/%d/%d", c, h, s);
}
-
-readn(fd: ref Sys->FD, buf: array of byte, nb: int): int
-{
- for(nr := 0; nr < nb;){
- n := sys->read(fd, buf[nr:], nb-nr);
- if(n <= 0){
- if(nr == 0)
- return n;
- break;
- }
- nr += n;
- }
- return nr;
-}
diff --git a/appl/lib/scsiio.b b/appl/lib/scsiio.b
index 152a22dd..3b4ce115 100644
--- a/appl/lib/scsiio.b
+++ b/appl/lib/scsiio.b
@@ -264,7 +264,7 @@ Scsi.open(dev: string): ref Scsi
return nil;
buf := array[512] of byte;
- n := readn(ctlfd, buf, len buf);
+ n := sys->readn(ctlfd, buf, len buf);
if(n < 8){
if(n >= 0)
sys->werrstr("error reading ctl file");
@@ -301,17 +301,3 @@ qunlock(s: ref Scsi)
{
<-s.lock;
}
-
-readn(fd: ref Sys->FD, buf: array of byte, nb: int): int
-{
- for(nr := 0; nr < nb;){
- n := sys->read(fd, buf[nr:], nb-nr);
- if(n <= 0){
- if(nr == 0)
- return n;
- break;
- }
- nr += n;
- }
- return nr;
-}
diff --git a/appl/wm/wm.b b/appl/wm/wm.b
index d8232b0b..d2dee3f8 100644
--- a/appl/wm/wm.b
+++ b/appl/wm/wm.b
@@ -402,9 +402,20 @@ dragwin(ptr: chan of ref Pointer, c: ref Client, w: ref Window, off: Point): str
if(buttons == 0)
return "too late";
p: ref Pointer;
+ scr := screen.image.r;
+ Margin: con 10;
do{
p = <-ptr;
- w.img.origin(w.img.r.min, p.xy.sub(off));
+ org := p.xy.sub(off);
+ if(org.y < scr.min.y)
+ org.y = scr.min.y;
+ else if(org.y > scr.max.y - Margin)
+ org.y = scr.max.y - Margin;
+ if(org.x < scr.min.x && org.x + w.r.dx() < scr.min.x + Margin)
+ org.x = scr.min.x + Margin - w.r.dx();
+ else if(org.x > scr.max.x - Margin)
+ org.x = scr.max.x - Margin;
+ w.img.origin(w.img.r.min, org);
} while (p.buttons != 0);
c.ptr <-= p;
buttons = 0;
diff --git a/dis/9export.dis b/dis/9export.dis
index 112f5672..a097dddc 100644
--- a/dis/9export.dis
+++ b/dis/9export.dis
Binary files differ
diff --git a/dis/auth/aescbc.dis b/dis/auth/aescbc.dis
index 19ec3c7b..a8f7de08 100644
--- a/dis/auth/aescbc.dis
+++ b/dis/auth/aescbc.dis
Binary files differ
diff --git a/dis/auxi/rstyxd.dis b/dis/auxi/rstyxd.dis
index c843b7cd..248e16a3 100644
--- a/dis/auxi/rstyxd.dis
+++ b/dis/auxi/rstyxd.dis
Binary files differ
diff --git a/dis/crypt.dis b/dis/crypt.dis
index 21e6174a..0c0a82db 100644
--- a/dis/crypt.dis
+++ b/dis/crypt.dis
Binary files differ
diff --git a/dis/disk/fdisk.dis b/dis/disk/fdisk.dis
index f3b99dee..fa73a70b 100644
--- a/dis/disk/fdisk.dis
+++ b/dis/disk/fdisk.dis
Binary files differ
diff --git a/dis/disk/pedit.dis b/dis/disk/pedit.dis
index 689cea87..4aabe861 100644
--- a/dis/disk/pedit.dis
+++ b/dis/disk/pedit.dis
Binary files differ
diff --git a/dis/disk/prep.dis b/dis/disk/prep.dis
index 1f88e854..164e1860 100644
--- a/dis/disk/prep.dis
+++ b/dis/disk/prep.dis
Binary files differ
diff --git a/dis/import.dis b/dis/import.dis
index 24b725f9..956d1e5a 100644
--- a/dis/import.dis
+++ b/dis/import.dis
Binary files differ
diff --git a/dis/lib/auth9.dis b/dis/lib/auth9.dis
index 9712dfc1..211c13f7 100644
--- a/dis/lib/auth9.dis
+++ b/dis/lib/auth9.dis
Binary files differ
diff --git a/dis/lib/disks.dis b/dis/lib/disks.dis
index de38f8fe..3e9c7f2b 100644
--- a/dis/lib/disks.dis
+++ b/dis/lib/disks.dis
Binary files differ
diff --git a/dis/lib/scsiio.dis b/dis/lib/scsiio.dis
index b6310ca4..28f365af 100644
--- a/dis/lib/scsiio.dis
+++ b/dis/lib/scsiio.dis
Binary files differ
diff --git a/dis/lib/venti.dis b/dis/lib/venti.dis
index 5d34c28d..262f79e3 100644
--- a/dis/lib/venti.dis
+++ b/dis/lib/venti.dis
Binary files differ
diff --git a/dis/wm/wm.dis b/dis/wm/wm.dis
index c49ab77d..3642c3e2 100644
--- a/dis/wm/wm.dis
+++ b/dis/wm/wm.dis
Binary files differ
diff --git a/module/disks.m b/module/disks.m
index 2063eef2..240b6676 100644
--- a/module/disks.m
+++ b/module/disks.m
@@ -30,7 +30,6 @@ Disks: module
};
init: fn();
- readn: fn(fd: ref Sys->FD, buf: array of byte, n: int): int;
# PC partition grot
PCpart: adt {