ref: 3174ffc971c3f48a41e9717eae564c1019c82bf8
parent: 389d6a1054cbf6734499a81c7de2dbc8251fa65c
author: cinap_lenrek <[email protected]>
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");
}