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. Reference: /n/sources/patch/applied/acme-disk-read Date: Sat May 11 17:22:55 CES 2013 Signed-off-by: nemo@lsub.org --- /sys/src/cmd/acme/disk.c Sat May 11 17:21:53 2013 +++ /sys/src/cmd/acme/disk.c Sat May 11 17:21:49 2013 @@ -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"); }