summaryrefslogtreecommitdiff
path: root/sys/src/cmd/acme
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-05-11 18:43:03 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-05-11 18:43:03 +0200
commit3174ffc971c3f48a41e9717eae564c1019c82bf8 (patch)
treea47246fdac65ed4c5b6c496a7a7ae5607e768909 /sys/src/cmd/acme
parent389d6a1054cbf6734499a81c7de2dbc8251fa65c (diff)
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.
Diffstat (limited to 'sys/src/cmd/acme')
-rw-r--r--sys/src/cmd/acme/disk.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/src/cmd/acme/disk.c b/sys/src/cmd/acme/disk.c
index 4c22d0a8c..9b76a5582 100644
--- a/sys/src/cmd/acme/disk.c
+++ b/sys/src/cmd/acme/disk.c
@@ -120,10 +120,20 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n)
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");
}