code: 9ferno

Download patch

ref: 29611443bf92342bdbaa36d64ac0b89f7366e587
parent: e57fd0cf983e4eddd433d83eb0b216e3cb069ac4
author: 9ferno <gophone2015@gmail.com>
date: Fri Aug 27 13:16:16 EDT 2021

changed offset from int to big

--- a/appl/cmd/9win.b
+++ b/appl/cmd/9win.b
@@ -184,8 +184,8 @@
 				}
 			}
 			d := array of byte winname;
-			if(offset < len d)
-				d = d[offset:];
+			if(offset < big len d)
+				d = d[int offset:]; # TODO pontential bug truncating to int
 			else
 				d = nil;
 			rc <-= (d, nil);
--- a/appl/cmd/auth/factotum/factotum.b
+++ b/appl/cmd/auth/factotum/factotum.b
@@ -342,17 +342,17 @@
 		sys->fprint(sys->fildes(2), "factotum: warning: unable to make memory private: %r\n");
 }
 
-reads(str: string, off, nbytes: int): (array of byte, string)
+reads(str: string, off: big, nbytes: int): (array of byte, string)
 {
 	bstr := array of byte str;
 	slen := len bstr;
-	if(off < 0 || off >= slen)
+	if(off < big 0 || off >= big slen)
 		return (nil, nil);
-	if(off + nbytes > slen)
-		nbytes = slen - off;
+	if(off + big nbytes > big slen)
+		nbytes = slen - int off; # TODO potential bug truncating off to int from big
 	if(nbytes <= 0)
 		return (nil, nil);
-	return (bstr[off:off+nbytes], nil);
+	return (bstr[int off:int off+nbytes], nil); # TODO potential bug truncating off to int from big
 }
 
 readprotos(): string
@@ -566,7 +566,7 @@
 
 reply(rpc: ref Rpc, s: string)
 {
-	rpc.rc <-= reads(s, 0, rpc.nbytes);
+	rpc.rc <-= reads(s, big 0, rpc.nbytes);
 }
 
 puta(a: array of byte, n: int, v: array of byte): int
--- a/appl/cmd/getauthinfo.b
+++ b/appl/cmd/getauthinfo.b
@@ -146,12 +146,12 @@
 	(off, nbytes, nil, rc) := <-fileio.read =>
 		if(rc == nil)
 			break;
-		if(off > len infodata){
+		if(off > big len infodata){
 			rc <-= (nil, nil);
 		} else {
-			if(off + nbytes > len infodata)
-				nbytes = len infodata - off;
-			rc <-= (infodata[off:off+nbytes], nil);
+			if(off + big nbytes > big len infodata)
+				nbytes = len infodata - int off; # TODO potential bug truncating off to int from big
+			rc <-= (infodata[int off:int off+nbytes], nil); # TODO potential bug truncating to int from big
 		}
 
 	(off, data, nil, wc) := <-fileio.write =>
@@ -158,7 +158,7 @@
 		if(wc == nil)
 			break;
 
-		if(off != len infodata){
+		if(off != big len infodata){
 			wc <-= (0, "cannot be rewritten");
 		} else {
 			nid := array[len infodata+len data] of byte;
--- a/appl/cmd/lego/link.b
+++ b/appl/cmd/lego/link.b
@@ -71,9 +71,9 @@
 	buffer := array [256] of byte;
 	bix := 0;
 
-	rdblk := chan of (int, int, int, Sys->Rread);
+	rdblk := chan of (big, int, int, Sys->Rread);
 	readreq := rdblk;
-	wrblk := chan of (int, array of byte, int, Sys->Rwrite);
+	wrblk := chan of (big, array of byte, int, Sys->Rwrite);
 	writereq := f2c.write;
 	wrreply : Sys->Rwrite;
 	sendblk := chan of array of byte;
--- a/appl/cmd/mash/history.b
+++ b/appl/cmd/mash/history.b
@@ -24,7 +24,7 @@
 Reader: adt
 {
 	fid:	int;
-	offset:	int;
+	offset:	big;
 	hint:	int;
 	next:	cyclic ref Reader;
 };
@@ -104,32 +104,32 @@
 		}
 		prev = r;
 	}
-	o := 0;
+	o := big 0;
 	if (nhist > 0)
-		o = history[0].seek;
+		o = big history[0].seek;
 	return readers = ref Reader(fid, o, 0, readers);
 }
 
-readhist(off, count, fid: int): (array of byte, string)
+readhist(off: big, count, fid: int): (array of byte, string)
 {
 	r := getfid(fid, 0);
 	off += r.offset;
-	if (nhist == 0 || off >= seek)
+	if (nhist == 0 || off >= big seek)
 		return (eof, nil);
 	i := r.hint;
 	if (i >= nhist)
 		i = nhist - 1;
 	s := history[i].seek;
-	if (off == s) {
+	if (off == big s) {
 		r.hint = i + 1;
 		return (history[i].text, nil);
 	}
-	if (off > s) {
+	if (off > big s) {
 		do {
 			if (++i == nhist)
 				break;
 			s = history[i].seek;
-		} while (off >= s);
+		} while (off >= big s);
 		i--;
 	} else {
 		do {
@@ -136,12 +136,12 @@
 			if (--i < 0)
 				return (eof, "data truncated");
 			s = history[i].seek;
-		} while (off < s);
+		} while (off < big s);
 	}
 	r.hint = i + 1;
 	b := history[i].text;
-	if (off != s)
-		b = b[off - s:];
+	if (off != big s)
+		b = b[int off - s:]; # TODO potential bug truncating big to int
 	return (b, nil);
 }
 
--- a/appl/cmd/ndb/cs.b
+++ b/appl/cmd/ndb/cs.b
@@ -322,7 +322,7 @@
 	donec <-= r;
 }
 
-reply(r: ref Reply, off: int, nbytes: int, rc: chan of (array of byte, string))
+reply(r: ref Reply, off: big, nbytes: int, rc: chan of (array of byte, string))
 {
 	if(r.err != nil){
 		rc <-= (nil, r.err);
@@ -333,7 +333,7 @@
 		addr = hd r.addrs;
 		r.addrs = tl r.addrs;
 	}
-	off = 0;	# this version ignores offset
+	off = big 0;	# this version ignores offset
 	rc <-= reads(addr, off, nbytes);
 }
 
@@ -340,17 +340,17 @@
 #
 # return the file2chan reply for a read of the given string
 #
-reads(str: string, off, nbytes: int): (array of byte, string)
+reads(str: string, off: big, nbytes: int): (array of byte, string)
 {
 	bstr := array of byte str;
 	slen := len bstr;
-	if(off < 0 || off >= slen)
+	if(off < big 0 || off >= big slen)
 		return (nil, nil);
-	if(off + nbytes > slen)
-		nbytes = slen - off;
+	if(off + big nbytes > big slen)
+		nbytes = slen - int off; # TODO potential bug truncating big to int
 	if(nbytes <= 0)
 		return (nil, nil);
-	return (bstr[off:off+nbytes], nil);
+	return (bstr[int off:int off+nbytes], nil); # TODO potential bug truncating big to int
 }
 
 lookcache(query: string, now: int): ref Cached
--- a/appl/cmd/ndb/dns.b
+++ b/appl/cmd/ndb/dns.b
@@ -280,7 +280,7 @@
 	donec <-= r;
 }
 
-reply(r: ref Reply, off: int, nbytes: int, rc: chan of (array of byte, string))
+reply(r: ref Reply, off: big, nbytes: int, rc: chan of (array of byte, string))
 {
 	if(r.err != nil || r.addrs == nil){
 		rc <-= (nil, r.err);
@@ -291,7 +291,7 @@
 		addr = hd r.addrs;
 		r.addrs = tl r.addrs;
 	}
-	off = 0;	# this version ignores offsets
+	off = big 0;	# this version ignores offsets
 #	rc <-= reads(r.query+" "+r.attr+" "+addr, off, nbytes);
 	rc <-= reads(addr, off, nbytes);
 }
@@ -299,17 +299,17 @@
 #
 # return the file2chan reply for a read of the given string
 #
-reads(str: string, off, nbytes: int): (array of byte, string)
+reads(str: string, off: big, nbytes: int): (array of byte, string)
 {
 	bstr := array of byte str;
 	slen := len bstr;
-	if(off < 0 || off >= slen)
+	if(off < big 0 || off >= big slen)
 		return (nil, nil);
-	if(off + nbytes > slen)
-		nbytes = slen - off;
+	if(off + big nbytes > big slen)
+		nbytes = slen - int off; # TODO potential bug truncating big to int
 	if(nbytes <= 0)
 		return (nil, nil);
-	return (bstr[off:off+nbytes], nil);
+	return (bstr[int off:int off+nbytes], nil); # TODO potential bug truncating big to int
 }
 
 sysname(): string
--- a/appl/cmd/plumber.b
+++ b/appl/cmd/plumber.b
@@ -237,7 +237,7 @@
 
 sender(input: ref Input, output: array of ref Output)
 {
-	outputc := array[len output] of chan of (int, int, int, Sys->Rread);
+	outputc := array[len output] of chan of (big, int, int, Sys->Rread);
 
 	for(;;){
 		alt{
--- a/appl/cmd/ramfile.b
+++ b/appl/cmd/ramfile.b
@@ -54,27 +54,27 @@
 	for (;;) alt {
 	(offset, count, nil, rc) := <-fio.read =>
 		if (rc != nil) {
-			if (offset > len data)
+			if (offset > big len data)
 				rc <-= (nil, nil);
 			else {
-				end := offset + count;
-				if (end > len data)
-					end = len data;
-				rc <-= (data[offset:end], nil);
+				end := big offset + big count;
+				if (end > big len data)
+					end = big len data;
+				rc <-= (data[int offset:int end], nil); # TODO potential bug truncating big to int
 			}
 		}
 	(offset, d, nil, wc) := <-fio.write =>
 		if (wc != nil) {
-			if (offset == 0)
+			if (offset == big 0)
 				data = array[0] of byte;
-			end := offset + len d;
-			if (end > len data) {
-				ndata := array[end] of byte;
+			end := offset + big len d;
+			if (end > big len data) {
+				ndata := array[int end] of byte; # TODO potential bug truncating big to int
 				ndata[0:] = data;
 				data = ndata;
 				ndata = nil;
 			}
-			data[offset:] = d;
+			data[int offset:] = d; # TODO potential bug truncating big to int
 			wc <-= (len d, nil);
 		}
 	}
--- a/appl/cmd/sh/file2chan.b
+++ b/appl/cmd/sh/file2chan.b
@@ -13,7 +13,8 @@
 
 Tag: adt {
 	tagid, blocked: int;
-	offset, fid: int;
+	offset: big;
+	fid: int;
 	pick {
 	Read =>
 		count: int;
@@ -137,7 +138,8 @@
 	ctxt = ctxt.copy(1);
 	sync <-= sys->pctl(0, nil);
 	for (;;) {
-		fid, offset, count: int;
+		fid, count: int;
+		offset: big;
 		rc: Sys->Rread;
 		wc: Sys->Rwrite;
 		d: array of byte;
@@ -177,7 +179,7 @@
 				deltag(t.tagid);
 			ctxt.setlocal("tag", nil);
 		} else if (ccmd != nil) {
-			t = ref Tag.Read(0, 0, -1, fid, -1, nil);
+			t = ref Tag.Read(0, 0, big -1, fid, -1, nil);
 			addtag(t);
 			ctxt.setlocal("tag", ref Listnode(nil, string t.tagid) :: nil);
 			ctxt.run(ccmd :: nil, 0);
@@ -203,10 +205,10 @@
 	arg := word(hd argv);
 	d := array of byte arg;
 	if (one) {
-		if (mt.offset >= len d)
+		if (mt.offset >= big len d)
 			d = nil;
 		else
-			d = d[mt.offset:];
+			d = d[int mt.offset:]; # TODO pontential bug truncating to int
 	}
 	if (len d > mt.count)
 		d = d[0:mt.count];
--- a/appl/collab/proxy.b
+++ b/appl/collab/proxy.b
@@ -82,17 +82,17 @@
 	}
 }
 
-reads(str: string, off, nbytes: int): (array of byte, string)
+reads(str: string, off: big, nbytes: int): (array of byte, string)
 {
 	bstr := array of byte str;
 	slen := len bstr;
-	if(off < 0 || off >= slen)
+	if(off < big 0 || off >= big slen)
 		return (nil, nil);
-	if(off + nbytes > slen)
-		nbytes = slen - off;
+	if(off + big nbytes > big slen)
+		nbytes = slen - int off; # TODO potential bug truncating big to int
 	if(nbytes <= 0)
 		return (nil, nil);
-	return (bstr[off:off+nbytes], nil);
+	return (bstr[int off:int off+nbytes], nil); # TODO potential bug truncating big to int
 }
 
 export(exportfd: ref Sys->FD, dir: string, done: chan of int)
--- a/appl/collab/servers/wbsrv.b
+++ b/appl/collab/servers/wbsrv.b
@@ -71,11 +71,11 @@
 			wb.readpixels(wb.r, data[len bithdr:]);
 			c.bitdata = data;
 		}
-		if (offset >= len c.bitdata) {
+		if (offset >= big len c.bitdata) {
 			rreply(r, (nil, nil));
 			continue;
 		}
-		rreply(r, (c.bitdata[offset:], nil));
+		rreply(r, (c.bitdata[int offset:], nil)); # TODO potential bug truncating big to int
 
 	(offset, data, fid, w) := <-bit.write =>
 		if (w != nil)
--- a/appl/demo/lego/clockface.b
+++ b/appl/demo/lego/clockface.b
@@ -104,7 +104,7 @@
 	(offset, count, fid, rc) := <- f2c.read =>
 		if (rc == nil)
 			continue;
-		if (offset != 0) {
+		if (offset != big 0) {
 			rc <-= (nil, nil);
 			continue;
 		}
@@ -113,7 +113,7 @@
 	(offset, data, fid, wc) := <- f2c.write =>
 		if (wc == nil)
 			continue;
-		if (offset != 0) {
+		if (offset != big 0) {
 			wc <-= (0, "bad offset");
 			continue;
 		}
--- a/appl/demo/lego/legolink.b
+++ b/appl/demo/lego/legolink.b
@@ -69,9 +69,9 @@
 	buffer := array [256] of byte;
 	bix := 0;
 
-	rdblk := chan of (int, int, int, Sys->Rread);
+	rdblk := chan of (big, int, int, Sys->Rread);
 	readreq := rdblk;
-	wrblk := chan of (int, array of byte, int, Sys->Rwrite);
+	wrblk := chan of (big, array of byte, int, Sys->Rwrite);
 	writereq := f2c.write;
 	wrreply : Sys->Rwrite;
 	sendblk := chan of array of byte;
--- a/appl/demo/whiteboard/wbsrv.b
+++ b/appl/demo/whiteboard/wbsrv.b
@@ -79,11 +79,11 @@
 			wb.readpixels(wb.r, data[len bithdr:]);
 			c.bitdata = data;
 		}
-		if (offset >= len c.bitdata) {
+		if (offset >= big len c.bitdata) {
 			rreply(r, (nil, nil));
 			continue;
 		}
-		rreply(r, (c.bitdata[offset:], nil));
+		rreply(r, (c.bitdata[int offset:], nil)); # TODO potential bug truncating big to int
 
 	(offset, data, fid, w) := <-bit.write =>
 		if (w != nil)
--- a/appl/grid/remotelogon.b
+++ b/appl/grid/remotelogon.b
@@ -314,15 +314,15 @@
 	(off, nbytes, fid, rc) := <-fileio.read =>
 		if(rc == nil)
 			break;
-		if(off > len infodata)
-			off = len infodata;
-		rc <-= (infodata[off:], nil);
+		if(off > big len infodata)
+			off = big len infodata;
+		rc <-= (infodata[int off:], nil); # TODO potential bug truncating big to int
 
 	(off, data, fid, wc) := <-fileio.write =>
 		if(wc == nil)
 			break;
 
-		if(off != len infodata){
+		if(off != big len infodata){
 			wc <-= (0, "cannot be rewritten");
 		} else {
 			nid := array[len infodata+len data] of byte;
--- a/appl/lib/devpointer.b
+++ b/appl/lib/devpointer.b
@@ -52,7 +52,7 @@
 srv(c: chan of ref Pointer, f: ref Sys->FileIO)
 {
 	ptrq := ref Ptrqueue;
-	dummy := chan of (int, int, int, Sys->Rread);
+	dummy := chan of (big, int, int, Sys->Rread);
 	sys = load Sys Sys->PATH;
 
 	for(;;){
--- a/appl/lib/usb/usbmass.b
+++ b/appl/lib/usb/usbmass.b
@@ -36,11 +36,11 @@
 	for(;;) alt{
 	(offset, count, nil, rc) := <-fileio.read =>
 		if (rc != nil) {
-			if (offset%blocksize || count%blocksize) {
+			if (int (offset%big blocksize) || count%blocksize) {
 				rc <- = (nil, "unaligned read");
 				continue;
 			}
-			offset /= blocksize;
+			offset /= big blocksize;
 			count /= blocksize;
 			buf := array [count * blocksize] of byte;
 			if (scsiread10(lun, offset, count, buf) < 0) {
@@ -53,11 +53,11 @@
 	(offset, data, nil, wc) := <-fileio.write =>
 		if(wc != nil){
 			count := len data;
-			if(offset%blocksize || count%blocksize){
+			if(int (offset%big blocksize) || count%blocksize){
 				wc <-= (0, "unaligned write");
 				continue;
 			}
-			offset /= blocksize;
+			offset /= big blocksize;
 			count /= blocksize;
 			if(scsiwrite10(lun, offset, count, data) < 0){
 				scsirequestsense(lun);
@@ -315,12 +315,12 @@
 	return 0;
 }
 
-scsiread10(lun: int, offset, count: int, buf: array of byte): int
+scsiread10(lun: int, offset: big, count: int, buf: array of byte): int
 {
 	cmd := array [10] of byte;
 	cmd[0] = byte 16r28;
 	cmd[1] = byte (lun << 5);
-	usb->bigput4(cmd[2:], offset);
+	usb->bigput4(cmd[2:], int offset); # TODO potential bug truncating big to int
 	cmd[6] = byte 0;
 	usb->bigput2(cmd[7:], count);
 	cmd[9] = byte 0;
@@ -330,12 +330,12 @@
 	return 0;
 }
 
-scsiwrite10(lun: int, offset, count: int, buf: array of byte): int
+scsiwrite10(lun: int, offset: big, count: int, buf: array of byte): int
 {
 	cmd := array [10] of byte;
 	cmd[0] = byte 16r2A;
 	cmd[1] = byte (lun << 5);
-	usb->bigput4(cmd[2:], offset);
+	usb->bigput4(cmd[2:], int offset); # TODO potential bug truncating big to int
 	cmd[6] = byte 0;
 	usb->bigput2(cmd[7:], count);
 	cmd[9] = byte 0;
--- a/appl/lib/zip.b
+++ b/appl/lib/zip.b
@@ -632,7 +632,7 @@
 	if(rfd == nil)
 		return;
 
-	prevoff := 0;
+	prevoff := big 0;
 	docrc := 1;
 	crc := ~0;
 	end := off+big n;
@@ -659,7 +659,7 @@
 				rc <-= (nil, sprint("crc mismatch, expected %bux, calculated %ux", hdrcrc, ~crc));
 				break Fio;
 			}
-			prevoff += nn;
+			prevoff += big nn;
 		}
 		rc <-= (buf[:nn], nil);
 	}
@@ -688,7 +688,7 @@
 	}
 
 	crc := ~0;
-	poff := 0;  # previous offset read
+	poff := big 0;  # previous offset read
 	buf := array[0] of byte;
 Fio:
 	for(;;) {
@@ -746,7 +746,7 @@
 			give = len buf;
 		r := buf[:give];
 		buf = buf[give:];
-		poff += give;
+		poff += big give;
 		rc <-= (r, nil);
 	}
 	kill(pid);
--- a/appl/wm/getauthinfo.b
+++ b/appl/wm/getauthinfo.b
@@ -259,12 +259,12 @@
 	(off, nbytes, fid, rc) := <-fileio.read =>
 		if(rc == nil)
 			break;
-		if(off > len infodata){
-			rc <-= (infodata[off:off], nil);
+		if(off > big len infodata){
+			rc <-= (infodata[int off:int off], nil); # TODO potential bug truncating big to int
 		} else {
-			if(off + nbytes > len infodata)
-				nbytes = len infodata - off;
-			rc <-= (infodata[off:off+nbytes], nil);
+			if(off + big nbytes > big len infodata)
+				nbytes = len infodata - int off; # TODO potential bug truncating big to int
+			rc <-= (infodata[int off:int off+nbytes], nil); # TODO potential bug truncating big to int
 		}
 
 	(off, data, fid, wc) := <-fileio.write =>
@@ -271,7 +271,7 @@
 		if(wc == nil)
 			break;
 
-		if(off != len infodata){
+		if(off != big len infodata){
 			wc <-= (0, "cannot be rewritten");
 		} else {
 			nid := array[len infodata+len data] of byte;
--- a/appl/wm/mash.b
+++ b/appl/wm/mash.b
@@ -44,7 +44,7 @@
 
 Rdreq: adt
 {
-	off:	int;
+	off:	big;
 	nbytes:	int;
 	fid:	int;
 	rc:	chan of (array of byte, string);
@@ -348,7 +348,7 @@
 	}
 }
 
-RPCread: type (int, int, int, chan of (array of byte, string));
+RPCread: type (big, int, int, chan of (array of byte, string));
 
 append(r: RPCread)
 {
--- a/appl/wm/remotelogon.b
+++ b/appl/wm/remotelogon.b
@@ -293,15 +293,15 @@
 	(off, nbytes, fid, rc) := <-fileio.read =>
 		if(rc == nil)
 			break;
-		if(off > len infodata)
-			off = len infodata;
-		rc <-= (infodata[off:], nil);
+		if(off > big len infodata)
+			off = big len infodata;
+		rc <-= (infodata[int off:], nil); # TODO potential bug truncating big to int
 
 	(off, data, fid, wc) := <-fileio.write =>
 		if(wc == nil)
 			break;
 
-		if(off != len infodata){
+		if(off != big len infodata){
 			wc <-= (0, "cannot be rewritten");
 		} else {
 			nid := array[len infodata+len data] of byte;
--- a/appl/wm/sh.b
+++ b/appl/wm/sh.b
@@ -47,7 +47,7 @@
 
 Rdreq: adt
 {
-	off:	int;
+	off:	big;
 	nbytes:	int;
 	fid:	int;
 	rc:	chan of (array of byte, string);
@@ -261,7 +261,7 @@
 		sys->print("newsh: shell cons creation failed\n");
 		return;
 	}
-	dummyfwrite := chan of (int, array of byte, int, Sys->Rwrite);
+	dummyfwrite := chan of (big, array of byte, int, Sys->Rwrite);
 	fwrite := file.write;
 
 	rdrpc: Rdreq;
@@ -591,7 +591,7 @@
 }
 
 
-RPCread: type (int, int, int, chan of (array of byte, string));
+RPCread: type (big, int, int, chan of (array of byte, string));
 
 append(r: RPCread)
 {
--- a/appl/wm/toolbar.b
+++ b/appl/wm/toolbar.b
@@ -154,7 +154,7 @@
 		if(snarfIO == nil)
 			fatal(sys->sprint("cannot make /chan/snarf: %r"));
 	}else
-		snarfIO = ref Sys->FileIO(chan of (int, int, int, Sys->Rread), chan of (int, array of byte, int, Sys->Rwrite));
+		snarfIO = ref Sys->FileIO(chan of (big, int, int, Sys->Rread), chan of (big, array of byte, int, Sys->Rwrite));
 	sync := chan of string;
 	spawn consoleproc(ctxt, sync);
 	if ((err := <-sync) != nil)
@@ -188,28 +188,28 @@
 	(off, data, nil, wc) := <-snarfIO.write =>
 		if(wc == nil)
 			break;
-		if (off == 0)			# write at zero truncates
+		if (off == big 0)			# write at zero truncates
 			snarf = data;
 		else {
-			if (off + len data > len snarf) {
-				nsnarf := array[off + len data] of byte;
+			if (off + big len data > big len snarf) {
+				nsnarf := array[int off + len data] of byte; # TODO potential bug truncating big to int
 				nsnarf[0:] = snarf;
 				snarf = nsnarf;
 			}
-			snarf[off:] = data;
+			snarf[int off:] = data; # TODO potential bug truncating big to int
 		}
 		wc <-= (len data, "");
 	(off, nbytes, nil, rc) := <-snarfIO.read =>
 		if(rc == nil)
 			break;
-		if (off >= len snarf) {
+		if (off >= big len snarf) {
 			rc <-= (nil, "");		# XXX alt
 			break;
 		}
-		e := off + nbytes;
-		if (e > len snarf)
-			e = len snarf;
-		rc <-= (snarf[off:e], "");	# XXX alt
+		e := off + big nbytes;
+		if (e > big len snarf)
+			e = big len snarf;
+		rc <-= (snarf[int off:int e], "");	# XXX alt # TODO potential bug truncating big to int
 	donesetup = <-setupfinished =>
 		;	
 	}
--- a/appl/wm/vt.b
+++ b/appl/wm/vt.b
@@ -924,7 +924,7 @@
 #############################################################################
 
 
-consinp(cs: chan of string, cr: chan of (int, int, int, Sys->Rread))
+consinp(cs: chan of string, cr: chan of (big, int, int, Sys->Rread))
 {
 	for(;;) {
 		alt {
--- a/appl/wm/wm.b
+++ b/appl/wm/wm.b
@@ -189,10 +189,10 @@
 		if(rc == nil)
 			break;
 		d := array of byte r2s(screen.image.r);
-		if(off > len d)
-			off = len d;
+		if(off > big len d)
+			off = big len d;
 		alt{
-		rc <-= (d[off:], nil) =>;
+		rc <-= (d[int off:], nil) =>; # TODO potential bug truncating big to int
 		* =>;
 		}
 	}
--- a/man/2/sys-file2chan
+++ b/man/2/sys-file2chan
@@ -10,8 +10,8 @@
 Rwrite: type chan of (int, string);
 FileIO: adt
 {
-    read:   chan of (int, int, int, Rread);
-    write:  chan of (int, array of byte, int, Rwrite);
+    read:   chan of (big, int, int, Rread);
+    write:  chan of (big, array of byte, int, Rwrite);
 };
 
 file2chan:  fn(dir, file: string): ref FileIO;
--- a/module/sys.m
+++ b/module/sys.m
@@ -64,8 +64,8 @@
 	Rwrite:	type chan of (int, string);
 	FileIO: adt
 	{
-		read:	chan of (int, int, int, Rread);
-		write:	chan of (int, array of byte, int, Rwrite);
+		read:	chan of (big, int, int, Rread);
+		write:	chan of (big, array of byte, int, Rwrite);
 	};
 
 	# Maximum read which will be completed atomically;