git: 9front

Download patch

ref: 8dc5e9fd5d16500af1d4f4ba07cde4f23f7be254
parent: 4621691ae0af5cc5217bf07fc22a6b12d4fab1cf
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat May 11 14:43:03 EDT 2013

acme: apply nemos acmediskread patch (from sources)

pread does not guarantee that it would read all the data asked for.
But acme usage of disk assumes that. This issues as many reads as
needed to make acme work when read returns less data than it wanted.

--- a/sys/src/cmd/acme/disk.c
+++ b/sys/src/cmd/acme/disk.c
@@ -120,10 +120,20 @@
 void
 diskread(Disk *d, Block *b, Rune *r, uint n)
 {
+	int tot, nr;
+	char *p;
+
 	if(n > b->n)
 		error("internal error: diskread");
 
 	ntosize(b->n, nil);
-	if(pread(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
+	n *= sizeof(Rune);
+	p = (char*)r;
+	for(tot = 0; tot < n; tot += nr){
+		nr = pread(d->fd, p+tot, n-tot, b->addr+tot);
+		if(nr <= 0)
+			error("read error from temp file");
+	}
+	if(tot != n)
 		error("read error from temp file");
 }
--